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_scriptPath
variable). - getCopy and filterProperties methods (similar to the ones from
CB_GraphicSprites
andCB_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_AudioFileSpritesPool
object (if any).Returns:
Returns the current
CB_AudioFileSpritesPool
object (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 avoidSanitize
boolean <optional>
false If set to true, it will not call the
CB_Speaker.sanitizeVolume
function 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.setVolume
function 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 avoidApplyingVolume
boolean <optional>
false Used as a parameter to call the
CB_Speaker.setVolume
function internally.onMute
function <optional>
Used as as the "functionToExecute" parameter to call the
CB_Speaker.setVolume
function internally.audioFiles
array <optional>
Used as a parameter to call the
CB_Speaker.setVolume
function internally.- Source:
- To Do:
-
- Also affect BandJS, jsfx and timbre.js.
Returns:
Returns the result of the internal call to the
CB_Speaker.setVolume
function.- 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 volume
number <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.
useSpeakerVolumeIfNaN
boolean <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_VOLUME
constant.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_AudioFileSpritesPool
object.Parameters:
Name Type Description audioFileSpritesPool
CB_AudioFileSpritesPool The desired
CB_AudioFileSpritesPool
object to manage all audio files.Returns:
Returns the current
CB_AudioFileSpritesPool
object 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 volume
number <optional>
CB_Speaker._volume The desired volume to be used (it will be sanitized internally by calling the
CB_Speaker.sanitizeVolume
function 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#setVolumeAll
method of the internalCB_AudioFileSpritesPool
object defined inCB_Speaker._audioFileSpritesPool
(if any).avoidApplyingVolume
boolean <optional>
false If it is set to true, the volume will not be applied (by calling the
CB_Speaker._applyVolume
internal function, which will also use the internalCB_AudioFileSpritesPool
object defined inCB_Speaker._audioFileSpritesPool
, if any) and just theCB_Speaker._volume
internal property will be set.forceSetVolumeProperty
boolean <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#setVolumeAll
method of the internalCB_AudioFileSpritesPool
object defined inCB_Speaker._audioFileSpritesPool
(if any).functionToExecute
function <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#setVolumeAll
method of the internalCB_AudioFileSpritesPool
object 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#muteAll
method or as the "onUnmute" parameter to call theCB_AudioFileSpritesPool#unmuteAll
method of the internalCB_AudioFileSpritesPool
object defined inCB_Speaker._audioFileSpritesPool
(if any).audioFiles
array <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_AudioFileSpritesPool
object 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#setVolumeAll
method of the internalCB_AudioFileSpritesPool
object 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#muteAll
method or as the "audioFiles" parameter to call theCB_AudioFileSpritesPool#unmuteAll
method of the internalCB_AudioFileSpritesPool
object defined inCB_Speaker._audioFileSpritesPool
(if any).saveForUnmute
boolean <optional>
false If it is set to true, the given volume will be saved to be restored later when the
CB_Speaker.unmute
method is called.isMuteOrUnmute
boolean <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#muteAll
method of the internalCB_AudioFileSpritesPool
object 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#unmuteAll
method of the internalCB_AudioFileSpritesPool
object 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#setVolumeAll
method of the internalCB_AudioFileSpritesPool
object 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.setVolume
function 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 avoidApplyingVolume
boolean <optional>
false Used as a parameter to call the
CB_Speaker.setVolume
function internally, if the "ignoreVolume" parameter is set to true.onUnmute
function <optional>
Used as as the "functionToExecute" parameter to call the
CB_Speaker.setVolume
function internally, if the "ignoreVolume" parameter is set to true.audioFiles
array <optional>
Used as a parameter to call the
CB_Speaker.setVolume
function internally, if the "ignoreVolume" parameter is set to true.ignoreVolume
boolean <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