Class Index | File Index

Classes


Class activeSound

activeSound
Defined in: activeSound.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Class that assists in working with audio waveforms that are currently being streamed to the audio manager.
Field Summary
Field Attributes Field Name and Description
 
The output channel of the sound sample.
 
The panning of the sample playback.
 
Sets whether the sample should be repeated once all samples have been exhausted.
 
Whether this activeSound still refers to a valid sound.
 
The volume of the sample.
Method Summary
Method Attributes Method Name and Description
 
Requests that the sound manager temporary halt the playback of this sound.
 
Requests that the sound manager continue playing this sample.
 
seek(seconds)
Requests that the sound manager change its playback position of the active sound to a new location.
 
stop()
Requests that the sound manager halt playing this sound.
Class Detail
activeSound()
Class that assists in working with audio waveforms that are currently being streamed to the audio manager.

Once an audio asset (audioBlock) is requested to be played through sandboxe.sound.playAudio, activeSound objects allow you to interact with the playing waveform to allow for more dynamic behavior. Since activeSounds reflect a temporary object on the audio engine, activeSounds are not directly instantiable.

Example:
 // Once we play a sound, we get the activeSound reference.
 var sound = sandboxe.sound.playAudio(myAudioAsset);

 // Since we want to interact with the sound over time, lets 
 // make an entity and insert its behavior into its step function.
 var fader = sandboxe.entity.create();

 fader.onStep = function() {
     // We're going to make the sound fade out over time by setting its volume
     sound.volume *= .99;
     
     // if the volume is too low, halt the sound and remove the object
     if (sound.volume < .1) {
         sandboxe.console.info('Sound halted!\n');        
         sound.stop();
         fader.remove();
     }

     // If the sound stopped natrually before the volume was low enough, 
     // just remove the object and report it.
     if (!sound.valid) {
         fader.remove();
         sandboxe.console.info('Sound ended on its own!\n');
     }
 }

 sandboxe.engine.setRoot(fader);
Field Detail
channel
The output channel of the sound sample. Changing this requests a new output channel for the buffer. The default is the channel that the sound was played on.

panning
The panning of the sample playback. The default is 0.5, meaning evenly split between the 2 output channels. 0.0 is leftmost, 1.0 is rightmost.

repeat
Sets whether the sample should be repeated once all samples have been exhausted. This reference to the active sound will be valid until repeat is over.

valid
Whether this activeSound still refers to a valid sound. Writing over this value has no effect.

volume
The volume of the sample. 0.0 will result in a silent playback 1.0 is the default.
Method Detail
pause()
Requests that the sound manager temporary halt the playback of this sound. If the process is acknowledged, the sample will be suspended until resume() is called.

resume()
Requests that the sound manager continue playing this sample.

seek(seconds)
Requests that the sound manager change its playback position of the active sound to a new location.
Parameters:
{Number} seconds
Seconds of progress within the sample to seek.

stop()
Requests that the sound manager halt playing this sound.

Documentation generated by JsDoc Toolkit 2.4.0 on Sun Feb 03 2019 18:30:56 GMT-0500 (EST)