[Haskell-cafe] example of PortMidi use
Michael Mossey
mpm at alumni.caltech.edu
Wed Oct 14 13:44:03 EDT 2009
Can someone give me an example of Sound.PortMidi use? I'm having trouble.
This program has bugs---makes sound only intermittently, and seems to have
set up some kind of loop that is sending midi messages continuously even
after terminating the program:
import Sound.PortMidi
import Foreign.C
msgs = [ (0::CULong,PMMsg 0x9c 0x40 0x40)
, (500, PMMsg 0x8c 0x40 0x40)
, (1000, PMMsg 0x9c 0x41 0x40)
, (1500, PMMsg 0x8c 0x41 0x40) ]
main = do
let deviceId = 12
initialize >>= print
getDeviceInfo deviceId >>= print
startTime <- time
let evts = map (\(t,msg) -> PMEvent msg (t+startTime)) msgs
result <- openOutput deviceId 10
case result of
Right err -> putStrLn ("After open: " ++ show err)
Left stream ->
do result <- writeEvents stream evts
putStrLn ("After write: " ++ show result)
close stream
return ()
terminate >>= print
More information about the Haskell-Cafe
mailing list