Controlling "sfplay~" with Javascript to play audio files
Hi everybody,
I'm pretty new to MaxMSP, and I've got some troubles to run sfplay~ with Javascript.
In order to play an audio file with sfplay~, you usually put a message button with delivers the message "open sound.wav", and then a toogle box sending "1" to play the file and "0" to stop the file.
So there's my js code (I just want to play the sound.wav) :
function play_sound(){
outlet(0,"open sound.wav"); // This line isn't understood by sfplay~
outlet(0,1); // This line is understood by sfplay~
}
If you put the js outlet into a "print", you've got the attempted result.
However, this error appears : "sfplay~ - no open file" which means that sfplay~ understand the second line but not the first (if you previously load the audio file with a msg box, the sound plays well).
How sfplay~ can understand my first line?
Thanks for your help (I hope i'm clear enough)
Romain
Ok, after some research I found the answer. It's a common problem : spaces have to be replaced by commas in the outlet function.
So like this :
outlet(0,"open","sound.wav");
And it works !