Skip to content

Instantly share code, notes, and snippets.

@evanrinehart
Created September 2, 2019 19:00
Show Gist options
  • Save evanrinehart/05dfd2c1929afdb8105df136701b8799 to your computer and use it in GitHub Desktop.
Save evanrinehart/05dfd2c1929afdb8105df136701b8799 to your computer and use it in GitHub Desktop.
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