newLISP Fan Club

Forum => Anything else we might add? => Topic started by: gcanyon on September 27, 2006, 10:42:44 PM

Title: Is there a way to play sounds?
Post by: gcanyon on September 27, 2006, 10:42:44 PM
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
Title:
Post by: HPW on September 27, 2006, 11:28:45 PM
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.
Title:
Post by: pjot on September 27, 2006, 11:37:06 PM
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
Title:
Post by: cormullion on September 28, 2006, 12:51:15 AM
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:


(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'"))
Title:
Post by: Lutz on September 28, 2006, 05:09:09 AM
instead of (fork (exec "...")) have you tried (process "...") ? It also does not block, but returns immediately using less resources.



Lutz
Title:
Post by: cormullion on September 28, 2006, 09:14:35 AM
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...!