Created
September 2, 2019 19:00
-
-
Save evanrinehart/05dfd2c1929afdb8105df136701b8799 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import qualified Sound.JACK.MIDI as MIDI | |
import Sound.JACK (NFrames(NFrames), ) | |
import qualified Sound.MIDI.Message as Msg | |
import qualified Sound.MIDI.Message.Channel as Ch | |
import Data.IORef | |
mutableValue :: IO (IORef Int) | |
mutableValue = newIORef (0 :: Int) | |
startMidiListener :: IO () | |
startMidiListener = MIDI.main (makeMidiEventHandler counter) | |
makeMidiEventHandler :: IORef Int -> NFrames -> (NFrames, Msg.T) -> IO (NFrames, Msg.T) | |
makeMidiEventHandler counter (NFrames cycleStart) (tf@(NFrames t), e) = do | |
putStrLn message | |
modifyIORef counter (+ 1) | |
incr <- readIORef counter | |
putStrLn (show incr) | |
return (tf, e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment