
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