Namespace sandboxe.sound
Defined in: docbase.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Sound and general audio utility namespace
Sound within the engine is output into separate channels, each of which
are assembled into a waveform sent to the system.
|
Method Attributes | Method Name and Description |
---|---|
<static> |
sandboxe.sound.channelAddEffect(effectHandler, channel)
Adds an effect to the audio channel.
|
<static> |
sandboxe.sound.channelKeepAwake(channel, enable)
Sets whether to keep the channel awake.
|
<static> |
sandboxe.sound.channelReset(channel)
Removes all effects from a channel.
|
<static> |
sandboxe.sound.channelSetPanning(channel, volume)
Sets the panning for the channel.
|
<static> |
sandboxe.sound.channelSetVolume(channel, volume)
Sets the volume for the channel.
|
<static> |
sandboxe.sound.isPlaying(asset)
Returns whether the given sound file is playing.
|
<static> |
sandboxe.sound.playAudio(asset, channel, volume, panning)
Plays the given audio asset.
|
Namespace Detail
sandboxe.sound
Sound and general audio utility namespace
Sound within the engine is output into separate channels, each of which
are assembled into a waveform sent to the system. Each channel has its
own volume, panning, and custom effect control, allowing for advanced audio control
(i.e. independent volume for sound effects and background music.)
Method Detail
<static>
sandboxe.sound.channelAddEffect(effectHandler, channel)
Adds an effect to the audio channel. **WARNING:** currently, effect functors are very resource intensive and
may not perform well enough for most applications.
Channel effects provide a mechnism to provide custom behavior to the raw audio that
passes through a sound channel. See audioBuffer
- Parameters:
- {Function} effectHandler
- The function to provde the custom effect. Its input is an audioBuffer
- {Number} channel
- The channel to add this effect to.
<static>
sandboxe.sound.channelKeepAwake(channel, enable)
Sets whether to keep the channel awake.
By default, channels will only be active if there are samples playing through it
This is normally fine, execpt this means effects will stop once no samples are
being processed through a channel. For something like reverberation, this
would cut off meaningful information from being output. Keeping the channel
awake sacrifices performance for making more quality effects.
- Parameters:
- {Number} channel
- Channel to set the volume
- {Boolean} enable
- Whether to keep the channel awake. By default, no channels are kept awake.
<static>
sandboxe.sound.channelReset(channel)
Removes all effects from a channel.
- Parameters:
- {Number} channel
- Channel to reset.
<static>
sandboxe.sound.channelSetPanning(channel, volume)
Sets the panning for the channel. As with all other
panning input contexts, 0.f is all the way to the left, and 1.f is all the way to the left.
- Parameters:
- {Number} channel
- Channel to set the volume
- {Number} volume
- Volume to set. Default is .5
<static>
sandboxe.sound.channelSetVolume(channel, volume)
Sets the volume for the channel.
- Parameters:
- {Number} channel
- Channel to set the volume
- {Number} volume
- Volume to set. Default is 1.0.
<static>
{boolean}
sandboxe.sound.isPlaying(asset)
Returns whether the given sound file is playing.
- Parameters:
- {asset} asset
- The loaded sound file
- Returns:
- {boolean}
<static>
{activeSound}
sandboxe.sound.playAudio(asset, channel, volume, panning)
Plays the given audio asset.
- Parameters:
- {asset} asset
- The loaded sound asset.
- {Number} channel
- The channel to send the audio to. Default is 0. (optional)
- {Number} volume
- The volume multiplier to play the audio at. Default is 1.0. (optional)
- {Number} panning
- The panning multiplier to play the audio with. 0 -> left audio device, 1-> right audio device. Default is .5. (optional)
- Returns:
- {activeSound}