Then the answer depends on how you are going about playing midi.
1. Is the api call for this playMidiFile :: FilePath -> IO (), where it waits until the file finishes before it returns?
You may have to spawn a thread (forkIO) before you play, save it's threadId in some sort of state and then attempt to kill it from the input thread when the time comes.
2. Does it play the file and return an id you can reference for later manipulation?
You can simply keep that reference in some sort of state and when the command comes to kill it, just use that reference.
3. Are you sending external system commands to a sound system like mplayer or alsa?
Just send the commands and let the system handle it.
On Tuesday, 29. January 2013 11:01:30 Miguel Negrao wrote:How to implement these functions is exactly my problem.
>
> main = forever readFromConsole
>
> readFromConsole = do
> in <- getLine
> processInput in
>
> processInput “start” = startMidi
> processInput “stop” = stopMidi
>
> where startMidi and stopMidi are functions.
--
Martin
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners