midi-alsa 0.1.1 → 0.1.2
raw patch · 3 files changed
+55/−7 lines, 3 files
Files
- midi-alsa.cabal +3/−7
- src/Sound/MIDI/ALSA.hs +6/−0
- src/Sound/MIDI/ALSA/Check.hs +46/−0
midi-alsa.cabal view
@@ -1,5 +1,5 @@ Name: midi-alsa-Version: 0.1.1+Version: 0.1.2 License: BSD3 License-File: LICENSE Author: Henning Thielemann <haskell@henning-thielemann.de>@@ -19,12 +19,7 @@ Build-Type: Simple Source-Repository head type: darcs- location: http://code.haskell.org/~thielema/midi-alsa/--Source-Repository this- type: darcs- location: http://code.haskell.org/~thielema/midi-alsa/- tag: 0.1.1+ location: http://code.haskell.org/alsa/midi/ Flag splitBase description: Choose the new smaller, split-up base package.@@ -50,3 +45,4 @@ Hs-Source-Dirs: src Exposed-Modules: Sound.MIDI.ALSA+ Sound.MIDI.ALSA.Check
src/Sound/MIDI/ALSA.hs view
@@ -1,3 +1,9 @@+{-+ToDo:+ALSA events may contain values+for channel, pitch, velocity, controller, program that are out of bound.+In this case our conversions yield an error.+-} module Sound.MIDI.ALSA where import qualified Sound.MIDI.Message.Channel as ChannelMsg
+ src/Sound/MIDI/ALSA/Check.hs view
@@ -0,0 +1,46 @@+module Sound.MIDI.ALSA.Check where++import qualified Sound.MIDI.ALSA as MALSA++import qualified Sound.ALSA.Sequencer.Event as Event++import Sound.MIDI.Message.Channel (Channel, )+import Sound.MIDI.Message.Channel.Voice (Controller, )++import Data.Accessor.Basic ((^.), )+import Data.Maybe.HT (toMaybe, )+import Control.Monad (guard, )+++anyController ::+ Channel -> Event.T -> Maybe (Controller, Int)+anyController chan e = do+ -- let Event.TickTime n = Event.timestamp e+ Event.CtrlEv Event.Controller c <- Just $ Event.body e+ guard (c ^. MALSA.ctrlChannel == chan)+ MALSA.Controller cn cv <- Just $ c ^. MALSA.ctrlControllerMode+ return (cn, cv)++controller :: Channel -> Controller -> Event.T -> Maybe Int+controller chan ctrl e = do+ (c,n) <- anyController chan e+ guard (ctrl==c)+ return n++pitchBend :: Channel -> Event.T -> Maybe Int+pitchBend chan e =+ case Event.body e of+ Event.CtrlEv Event.PitchBend c ->+ toMaybe+ (c ^. MALSA.ctrlChannel == chan)+ (c ^. MALSA.ctrlValue)+ _ -> Nothing++channelPressure :: Channel -> Event.T -> Maybe Int+channelPressure chan e =+ case Event.body e of+ Event.CtrlEv Event.ChanPress c ->+ toMaybe+ (c ^. MALSA.ctrlChannel == chan)+ (c ^. MALSA.ctrlValue)+ _ -> Nothing