Playground.js is a framework for your javascript based games. It gives you out-of-box access to essentials like mouse, keyboard, sound and well designed architecture that you can expand to your needs.
Below is a draft usage of a new sound engine I am working on.
It will most likely come as a standalone library and plugin to integrate with playground's loader flow
API and features by example:
Setup / channels
/* audio engine */
this.audio = new SoundOnDemand();
/* separate audio channels */
this.audio.channel("sound");
this.audio.channel("music");
this.audio.channel("enviro").reverb(0.5);
/* as you can see you can push your gui bleeps through a clean channel, but if a player is in a cave his footsteps could go through reverbed enviro channel */
/* set master volume */
this.audio.volume(0.5);
/* set channel volume */
this.audio.channel("music").volume(0.5);
/* enqueue sound to be played in next frame or when ready
con: 1/60 delay
pro: ondemand loading
*/
this.audio.channel("sound").play("explosion").rate(0.8).volume(1.0);
/* the new engine will load sounds on demand - and play them ASAP -
of course manual preloading is still possible */
Other features
Dynamics compression
Equalizer
Automatic sound disposal (free memory if sound has not been used for certain time)
Panning
Being lazy?
It take more time to write app.audio.channel("sound").play(...) but there is nothing to stop you from saving a channel this.sound = this.audio.channel("sound")
Variable names reasoning:
I took app.audio because I am pretty sure you will want to use app.sound for a channel shorthand
I took channel because it's not Amiga 500 (or AudioElement) and we don't need numeric channels anymore hence I consider this keyword free.
Technically
It is an abstraction over WebAudioAPI - still pretty universal - bundled with sane defaults
If you need a sound system tightly coupled with your game engine - featuring audio emitters, spatial description of these sources (velocity, position) - you should not try to write it on top of this abstraction - but instead start from scratch with WebAudioAPI.
EDIT: The work is done - see http://playgroundjs.com/libs
Below is a draft usage of a new sound engine I am working on.
It will most likely come as a standalone library and plugin to integrate with playground's loader flow
API and features by example:
Setup / channels
Other features
Being lazy?
It take more time to write
app.audio.channel("sound").play(...)
but there is nothing to stop you from saving a channelthis.sound = this.audio.channel("sound")
Variable names reasoning:
app.audio
because I am pretty sure you will want to useapp.sound
for a channel shorthandchannel
because it's not Amiga 500 (or AudioElement) and we don't need numeric channels anymore hence I consider this keyword free.Technically