Static class to manage the speaker or speakers. It will return itself if it is tried to be instantiated. It can also use timbre.js, Band.js and jsfx.
- Source:
- To Do:
-
- Check whether the path used to play silent sounds as a workaround (through the internal "_playBlankFilesSilently" method) is right or not (now it uses the
CB_scriptPathvariable). - getCopy and filterProperties methods (similar to the ones from
CB_GraphicSpritesandCB_GraphicSpritesScene).
- Check whether the path used to play silent sounds as a workaround (through the internal "_playBlankFilesSilently" method) is right or not (now it uses the
Methods
-
<static> getAudioFileSpritesPool() → {CB_AudioFileSpritesPool|null}
-
Returns the current
CB_AudioFileSpritesPoolobject (if any).Returns:
Returns the current
CB_AudioFileSpritesPoolobject (if any) or null otherwise.- Type
- CB_AudioFileSpritesPool | null
-
<static> getBandJSObject() → {Object|null}
-
Returns a new Band.js object (if possible). Useful for managing music composition.
- Source:
- To Do:
-
- Band.js should have into account the CB_Speaker._volume
Returns:
Returns a new Band.js object (if possible) or null otherwise.
- Type
- Object | null
-
<static> getJsfxObject() → {Object|null}
-
Returns the jsfx object (if any). Useful for managing sound effects generation.
- Source:
- To Do:
-
- jsfx should have into account the CB_Speaker._volume
Returns:
Returns the current jsfx object (if any) or null otherwise.
- Type
- Object | null
-
<static> getTimbreJSObject() → {Object|null}
-
Returns the timbre.js object (if any). Useful for functional processing and synthesizing audio.
- Source:
- To Do:
-
- timbre.js should have into account the CB_Speaker._volume
Returns:
Returns the current timbre.js object (if any) or null otherwise.
- Type
- Object | null
-
<static> getVolume( [avoidSanitize]) → {number}
-
Tells the current volume.
Parameters:
Name Type Argument Default Description avoidSanitizeboolean <optional>
false If set to true, it will not call the
CB_Speaker.sanitizeVolumefunction internally before returning the volume.Returns:
Returns the current volume.
- Type
- number
-
<static> mute( [avoidApplyingVolume] [, onMute] [, audioFiles]) → {number}
-
Mutes the speaker. Calls the
CB_Speaker.setVolumefunction internally, with 0 (zero) as the "volume" parmeter, null as the "forceSetVolumeProperty" parameter and true for both "saveForUnmute" and "isMuteOrUnmute" parameters.Parameters:
Name Type Argument Default Description avoidApplyingVolumeboolean <optional>
false Used as a parameter to call the
CB_Speaker.setVolumefunction internally.onMutefunction <optional>
Used as as the "functionToExecute" parameter to call the
CB_Speaker.setVolumefunction internally.audioFilesarray <optional>
Used as a parameter to call the
CB_Speaker.setVolumefunction internally.- Source:
- To Do:
-
- Also affect BandJS, jsfx and timbre.js.
Returns:
Returns the result of the internal call to the
CB_Speaker.setVolumefunction.- Type
- number
-
<static> sanitizeVolume( [volume] [, useSpeakerVolumeIfNaN]) → {number}
-
Sanitizes the volume (it does not allow values greater than 100 or lower than 0).
Parameters:
Name Type Argument Default Description volumenumber <optional>
CB_Configuration.CrossBase.CB_Speaker_DEFAULT_VOLUME|CB_Speaker._volume The desired volume to be sanitized. If not given, it will use the current volume if the "useSpeakerVolumeIfNaN" parameter is set to true or the default volume otherwise.
useSpeakerVolumeIfNaNboolean <optional>
false If it is set to true and no valid volume is received in the "volume" parameter, it will use the current volume (
CB_Speaker._volume). Otherwise, if it is set to false and no valid volume is received in the "volume" parameter, it will use the default volume which is set in theCB_Configuration.CrossBase.CB_Speaker_DEFAULT_VOLUMEconstant.Returns:
Returns the volume sanitized (it does not allow values greater than 100 or lower than 0).
- Type
- number
-
<static> setAudioFileSpritesPool(audioFileSpritesPool) → {CB_AudioFileSpritesPool|null}
-
Sets the desired
CB_AudioFileSpritesPoolobject.Parameters:
Name Type Description audioFileSpritesPoolCB_AudioFileSpritesPool The desired
CB_AudioFileSpritesPoolobject to manage all audio files.Returns:
Returns the current
CB_AudioFileSpritesPoolobject after setting it (if any) or null otherwise.- Type
- CB_AudioFileSpritesPool | null
-
<static> setVolume( [volume] [, avoidApplyingVolume] [, forceSetVolumeProperty] [, functionToExecute] [, audioFiles] [, saveForUnmute] [, isMuteOrUnmute]) → {number}
-
Sets the given volume.
Parameters:
Name Type Argument Default Description volumenumber <optional>
CB_Speaker._volume The desired volume to be used (it will be sanitized internally by calling the
CB_Speaker.sanitizeVolumefunction with the volume as the unique parameter). If not given, it will use the current volume. If the "avoidApplyingVolume" is set to false and the "isMuteOrUnmute" parameter is false, it will also be used as a parameter to call theCB_AudioFileSpritesPool#setVolumeAllmethod of the internalCB_AudioFileSpritesPoolobject defined inCB_Speaker._audioFileSpritesPool(if any).avoidApplyingVolumeboolean <optional>
false If it is set to true, the volume will not be applied (by calling the
CB_Speaker._applyVolumeinternal function, which will also use the internalCB_AudioFileSpritesPoolobject defined inCB_Speaker._audioFileSpritesPool, if any) and just theCB_Speaker._volumeinternal property will be set.forceSetVolumePropertyboolean <optional>
false If the "avoidApplyingVolume" is set to false and the "isMuteOrUnmute" parameter is false, it will be used as a parameter to call the
CB_AudioFileSpritesPool#setVolumeAllmethod of the internalCB_AudioFileSpritesPoolobject defined inCB_Speaker._audioFileSpritesPool(if any).functionToExecutefunction <optional>
A callback function. If the "avoidApplyingVolume" is set to false and the "isMuteOrUnmute" parameter is false, it will be used as the "onSetVolume" parameter to call the
CB_AudioFileSpritesPool#setVolumeAllmethod of the internalCB_AudioFileSpritesPoolobject defined inCB_Speaker._audioFileSpritesPool(if any). If the "avoidApplyingVolume" is set to false and the "isMuteOrUnmute" parameter is true, it will be used as the "onMute" parameter to call theCB_AudioFileSpritesPool#muteAllmethod or as the "onUnmute" parameter to call theCB_AudioFileSpritesPool#unmuteAllmethod of the internalCB_AudioFileSpritesPoolobject defined inCB_Speaker._audioFileSpritesPool(if any).audioFilesarray <optional>
An array containing the CB_AudioFile objects that we want to affect (if not set and the "avoidApplyingVolume" is set to false, it will affect all the CB_AudioFile objects of the internal
CB_AudioFileSpritesPoolobject defined inCB_Speaker._audioFileSpritesPool, if any). If the "avoidApplyingVolume" is set to false and the "isMuteOrUnmute" parameter is false, it will be used as the "audioFiles" parameter to call theCB_AudioFileSpritesPool#setVolumeAllmethod of the internalCB_AudioFileSpritesPoolobject defined inCB_Speaker._audioFileSpritesPool(if any). If the "avoidApplyingVolume" is set to false and the "isMuteOrUnmute" parameter is true, it will be used as the "audioFiles" parameter to call theCB_AudioFileSpritesPool#muteAllmethod or as the "audioFiles" parameter to call theCB_AudioFileSpritesPool#unmuteAllmethod of the internalCB_AudioFileSpritesPoolobject defined inCB_Speaker._audioFileSpritesPool(if any).saveForUnmuteboolean <optional>
false If it is set to true, the given volume will be saved to be restored later when the
CB_Speaker.unmutemethod is called.isMuteOrUnmuteboolean <optional>
false If it is set to true and the volume given is zero, the action performed internally will be muting (by calling the
CB_AudioFileSpritesPool#muteAllmethod of the internalCB_AudioFileSpritesPoolobject defined inCB_Speaker._audioFileSpritesPool, if any). Otherwise, if it is set to true and the volume given is not zero, the action performed internally will be unmuting (by calling theCB_AudioFileSpritesPool#unmuteAllmethod of the internalCB_AudioFileSpritesPoolobject defined inCB_Speaker._audioFileSpritesPool, if any). If it is set to false, the action performed will be set the volume given (by calling theCB_AudioFileSpritesPool#setVolumeAllmethod of the internalCB_AudioFileSpritesPoolobject defined inCB_Speaker._audioFileSpritesPool, if any).- Source:
- To Do:
-
- Also affect BandJS, jsfx and timbre.js.
Returns:
Returns the current volume being used after setting it.
- Type
- number
-
<static> unmute( [avoidApplyingVolume] [, onUnmute] [, audioFiles] [, ignoreVolume]) → {number}
-
Restores the audio volume after muting it. If the current volume is 0 (zero, muted) or the "ignoreVolume" parameter is set to true, calls the
CB_Speaker.setVolumefunction internally, with the previously-saved volume before muting it as the "volume" parmeter, null as the "forceSetVolumeProperty" parameter, false for the "saveForUnmute" parameter and true for the "isMuteOrUnmute" parameter.Parameters:
Name Type Argument Default Description avoidApplyingVolumeboolean <optional>
false Used as a parameter to call the
CB_Speaker.setVolumefunction internally, if the "ignoreVolume" parameter is set to true.onUnmutefunction <optional>
Used as as the "functionToExecute" parameter to call the
CB_Speaker.setVolumefunction internally, if the "ignoreVolume" parameter is set to true.audioFilesarray <optional>
Used as a parameter to call the
CB_Speaker.setVolumefunction internally, if the "ignoreVolume" parameter is set to true.ignoreVolumeboolean <optional>
false If set to true, it will try to perform the muting action even when the current volume is not 0 (zero, muted).
- Source:
- To Do:
-
- Also affect BandJS, jsfx and timbre.js.
Returns:
Returns the current volume.
- Type
- number