On Sat, 21 Nov 2015, Paolino wrote: > Hello Henning, this program crashes with resource temporarily unavailable, as > soon as I attach it to a midi consumer. > > I couldn't find an example on how to fix it.
I can reproduce the problem, but I have no idea what your program should do if it would work. 'top' reports 100% CPU usage. It looks suspicious to me that you send a Queue event to all subscribers. I assume that you must send it to Addr.systemTimer, which is what Queue.control does for you. Btw. the identifiers in the alsa-seq package are intended for qualified imports, as it is demonstrated in the 'examples' directory. Without qualification a program becomes pretty incomprehensible. examples/beat.hs also shows how to send a QueueStart event. > import Prelude hiding (show) > > import Sound.ALSA.Sequencer.Address > import Sound.ALSA.Sequencer.Client > import Sound.ALSA.Sequencer.Port > import Sound.ALSA.Sequencer.Event hiding (time) > import Sound.ALSA.Sequencer.Connect > import Sound.ALSA.Sequencer.Queue > import Sound.ALSA.Sequencer > import Sound.ALSA.Exception > import Sound.OSC > > import Control.Concurrent > > > midiOutTime :: String -- ^ client name > -> Time > -> IO ThreadId > midiOutTime name t = do > t0 <- time > let n = fromIntegral . floor $ t0 / t > forkIO $ (`catch` \e -> putStrLn $ "midi_exception: " ++ show e) $ do > withDefault Block $ \h -> do > setName (h :: Sound.ALSA.Sequencer.T OutputMode) $ name ++ " > time_out" > c <- getId h > withSimple h "ctrl_in" (caps [capRead, capSubsRead]) > typeMidiGeneric $ \p -> > let loop n = do > sleepThreadUntil $ n * t > void $ outputDirect h $ forConnection > (toSubscribers (Sound.ALSA.Sequencer.Address.Cons c p)) > $ QueueEv QueueClock Sound.ALSA.Sequencer.Queue.direct > loop $ n + 1 > in loop 1 > > main = do > midiOutTime "timeout" $ 0.125/6 > getLine -- Read the whole topic here: Haskell Art: http://lurk.org/r/topic/37rzIJHSGeocyr5n7PvG88 To leave Haskell Art, email haskell-...@group.lurk.org with the following email subject: unsubscribe