Is there a way to play sounds?

For the Compleat Fan
Locked
gcanyon
Posts: 31
Joined: Mon Sep 18, 2006 7:58 am

Is there a way to play sounds?

Post by gcanyon »

I looked in the documentation and didn't see anything related to playing sounds, either resources or external files. Is there a way to do this?

thanks,

Geoff

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

Depends on what you understand for sound?
And what platform?

When you search on http://mini.net/tcl/ for 'sound' there are various option based on TCL/TK.
Other solution maybe possible on your target platform using DLL's via import.
Hans-Peter

pjot
Posts: 733
Joined: Thu Feb 26, 2004 10:19 pm
Location: The Hague, The Netherlands
Contact:

Post by pjot »

Hi gcanyon,

I created a demo with libMikMod. Please look here:

http://www.turtle.dds.nl/newlisp/

If you are running windows, you need the mikmod DLL as well (hosted at same site).


There is also a demo with SDL from camperman:

http://www.alh.net/newlisp/phpbb/viewtopic.php?t=1135

Regards
Peter

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

And on MacOS, it's a frequently asked question, since even AppleScript doesn't have a play sound command any more, I think.

But an easy solution is to install http://rainbowflight.googlepages.com/#qtplay, a free 64K binary that plays sound files. Then you can call it from newLISP depending on how you want to run it.

Use (exec ... ) to wait until sound finishes before continuing, or (fork (exec ... )) to start the sound without interrupting program flow.

For simultaneous play of more than one sound, use fork and exec more than once:

Code: Select all

(fork (exec "/Users/.../bin/qtplay '/Users/.../Library/Sounds/MystMenuClose.aiff'"))
(fork (exec "/Users/.../bin/qtplay '/Users/.../Library/Sounds/MystSliderTrackPress.aiff'"))
(fork (exec "/Users/.../bin/qtplay '/Users/.../Library/Sounds/MystWindowOpen.aiff'"))

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

instead of (fork (exec "...")) have you tried (process "...") ? It also does not block, but returns immediately using less resources.

Lutz

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

Yes, that makes sense!

I suppose I got the mistaken impression that 'process' was for interacting with processes and that 'exec' was for running single commands. If 'process' just runs a command without blocking and then exits it's certainly easier to type and remember than (fork (exec ...)). And if it's more economical with resources as well - even Greenpeace would approve...!

Locked