[plt-scheme] Music player :o)

From: Eli Barzilay (eli at barzilay.org)
Date: Mon Apr 9 21:58:36 EDT 2007

On Apr  9, Laurent wrote:
> 
> However that doesn't perform. The thread is not associated with the
> sound.  Is it possible with MrEd to stop and put in pause the
> reading of an audio file?

No.  MrEd has three different mechanisms for playing sounds: on
Windows and OSX it uses standard functions, and on Unix it starts an
external process.  In all cases, suspending the thread is irrelevant
for the sound that the OS is playing.

I don't think that there's a good way of doing a music player in a
portable way -- your best bet would be to interface some player.  I'd
start on linux and look for something portable.  Another option is to
use Jon's Allegro library -- I think it has enough support to be able
to play mp3 files etc.

If you're on Linux, you can play with the sound device directly --
have Scheme push the bytes down the device, so suspending the Scheme
thread will suspend the sound (after a delay since there's some
buffering).  If you're on Windows, I have a quick hack that I did
recently that interfaces the MCI thing, which is more advanced that
what MrEd does (you can start playing a sound, then send a command to
pause it etc) -- and the same interface works also for playing several
formats as well as some movie formats.  On OSX, you'll probably want
to read about some QuickTime interface.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!


Posted on the users mailing list.