-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sound API #15
Comments
So I added the "finished" event in my quick implementation, and using that event I implemented a Playlist class, fully in JavaScript 😃. It uses fs to read all files from a folder, and plays the first. When it is finished, it loads the second and plays that. I think we should have this event. |
Something I added in the AudioBass plugin in TurboSphere, the ability to specify the number of repeats for a Sound and SoundEffect. |
Thanks! I found that functionality in AVFoundation too (the framework I use for audio). I will add it.
|
Another thing is that the separation of Sound and SoundEffect objects is more than just semantic. I'm not sure if this was the original intent, but working on TurboSphere they represent two different ways to play a sound. This also is why, in TurboSphere, Sounds cannot be played more than once, while SoundEffects can. Similarly, you can only post raw PCM or encoded data to a Sound to generate it on the fly. Re the playlist, have you seen the playlist portion of RadLib? I haven't looked at it too closely, but seeing it in action in Hold The Line, it looks perfectly functional. I would rather consider this kind of event more as a callback, rather than a true asynchronous event. |
The distinction between Sound and SoundEffect you give sounds valid (pun intended). We can put restrictions on the capabilities of both classes and enforce those. What else? RE Playlist: I can't find the 'playlist portion' in RadLib. Link? RE Callbacks: I am not sure whether to put 'finished' on the event queue or call the function directly. I think keeping it all alike, so using only the event queue, might simplify things for users. But if you have a valid argument to directly call all the listeners... |
I wrote the Sound API in the sound module (sound.js). It is almost an exact copy of the Sphere 1.5 API but has a couple of differences:
playing
property.path
property.The same is true for SoundEffect.
Now I think about adding an event for both: 'finished'. Especially useful for Sound, to play the next song of a playlist.
For better background music playlist stuff, we might want to add some other technique: something that calls a function to ask for the next song, when it thinks it needs it: just before the ending. and it then crossfades. Maybe some playlist module? Is this useful, or wished?
What about a
exports.currentPlaying
function/property that returns an array of all current playing sounds? It is just an array, so thesound.play()
can addthis
to the array, and on stop or pause, it can remove itself from the array.After that, I would like approval on the module 😄
The text was updated successfully, but these errors were encountered: