Hello, I'm fairly new to Haskell. Trying to get PortMidi to work. The
following program doesn't work properly---plays sound only intermittently,
and seems to have created some kind of infinite loop of midi messages that
continued even after the program terminated.
More generally, I'm wondering if there is a "sleep" function in Haskell, or
in general some way to control the timing of MIDI messages.
Thanks,
Mike
import Sound.PortMidi
import Control.Monad
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
_______________________________________________
haskell-art mailing list
[email protected]
http://lists.lurk.org/mailman/listinfo/haskell-art