Class in reactor_managers.js

AudioManager

74 functions in 6 groups · hide internal

The Database: everything Core loads at boot.

Familiar territory. AudioManager keeps the RPG Maker MZ API, so existing MZ knowledge, tutorials and plugin code apply. Reactor's additions are marked with descriptions below.

Quick Reference

Setup & Creation 3

loadStaticSe() Loads the static se.
makeEmptyAudioObject() Makes the empty audio object.
createBuffer() Creates the buffer.

Getting Information 2

resolveSeVariant() The SE to actually play.
_pickBgmSequencePoolEntry() The next pool entry: in order, dealt from a shuffled bag, or drawn at random.

Checks (True / False) 4

isCurrentBgm() Whether it is current bgm.
isCurrentBgs() Whether it is current bgs.
isMissingLocalSe() A missing one-shot sound must not stop the battle or start a new failed request for every hit.
isStaticSe() Whether it is static se.

Actions 27

playBgm() Plays the bgm.
stopBgm() Stops the bgm.
fadeOutBgm() Fade out bgm.
fadeInBgm() Fade in bgm.
playBgs() Plays the bgs.
stopBgs() Stops the bgs.
fadeOutBgs() Fade out bgs.
fadeInBgs() Fade in bgs.
playMe() Plays the me.
fadeOutMe() Fade out me.
stopMe() Stops the me.
playSe() Plays the se.
stopSe() Stops the se.
playStaticSe() Plays the static se.
stopAll() Stops the all.
saveBgm() Saves the bgm.
saveBgs() Saves the bgs.
resumePendingBgmSequence() Plays the sequence that was waiting for its map, once that map is the one loaded.
playBgmSequence() Plays the bgm sequence.
stopBgmSequence() Stops the bgm sequence.
_startBgmSequenceTrack() Starts one non-looping track for the sequence; onEnd runs when it plays out.
_destroyBgmSequenceBuffer() Destroy bgm sequence buffer.
_startBgmSequenceEntry() Starts the bgm sequence entry.
_startBgmSequencePalette() Starts the bgm sequence palette.
_startBgmSequenceLayer() Starts the bgm sequence layer.
_endBgmSequencePalette() Ends the bgm sequence palette.
_fadeOutBgmSequence() Fade out bgm sequence.

Updating & Drawing 9

updateBgmParameters() Updates the bgm parameters each frame.
updateCurrentBgm() Updates the current bgm each frame.
updateBgsParameters() Updates the bgs parameters each frame.
updateCurrentBgs() Updates the current bgs each frame.
updateMeParameters() Updates the me parameters each frame.
updateSeParameters() Updates the se parameters each frame.
updateBufferParameters() Updates the buffer parameters each frame.
updateBgmSequence() The per-frame step: silences end, palette layers restart, palettes fade and move on.
_refreshBgmSequenceVolumes() Re-derives every live layer's volume after the BGM volume option changes.

Other 29

replayBgm() Replay bgm.
replayBgs() Replay bgs.
seVariantPool() Every take a slot or timing can play: the SE itself, then its variants, with anything unnamed dropped.
rollSePitch() A pitch inside range, or null when the range is absent or unusable.
cleanupSe() Cleanup se.
audioFileExt() Audio file ext.
checkErrors() Check errors.
skipsMissingAudio() System.json rrSkipMissingAudio (2000/2003 imports): a sound or track the game names but never shipped (often…
throwLoadError() Throw load error.
mapBgmObject() The BGM object a map plays: its fallback track, marked with the sequence when it has one.
mapHasBgmSequence() Map has bgm sequence.
librarySequenceKey() The key a library entry travels under in a BGM object.
librarySequenceId() The library id a key names, or 0 when the key is a map id.
librarySequenceData() A library entry's sequence, or null when id names nothing playable.
battleMusicBgm() The battle music a troop or a map keeps in battleBgm, the same audio object Change Battle BGM stores.
troopBattleBgm() The battle music the troop about to fight names, or null.
mapBattleBgm() The battle music the current map names, or null; a battle test has no map.
_bgmSequenceDataFor() The sequence a key names: a library entry, or the current map's for its id (null while that map is not loaded…
_bgmSequenceTrackAudio() Bgm sequence track audio.
_bgmSequenceBuffers() Bgm sequence buffers.
_retireBgmSequenceBuffer() Releases a buffer the sequence has finished with.
_sweepBgmSequenceRetiring() Sweep bgm sequence retiring.
_nextBgmSequenceEntry() The entry that would play next, skipping any the sequence has used up -- the same walk the advance makes, wit…
_bgmSequenceFadeIn() Seconds the entry wants to swell in over; 0 for one that names none.
_pruneBgmSequenceBuffers() Prune bgm sequence buffers.
_advanceBgmSequence() Advance bgm sequence.
_bgmSequenceLayerIsEnding() Whether a layer's track is close enough to its end to hand over now.
_advanceIfPaletteSpent() Moves a single-shot palette on once every layer has had its one turn.
_duckBgmSequence() Duck bgm sequence.

Setup & Creation

loadStaticSe

static source
AudioManager.loadStaticSe(se)

Loads the static se. (Same as the RPG Maker MZ method of this name.)

makeEmptyAudioObject

static source
AudioManager.makeEmptyAudioObject()

Makes the empty audio object. (Same as the RPG Maker MZ method of this name.)

createBuffer

static source
AudioManager.createBuffer(folder, name)

Creates the buffer. (Same as the RPG Maker MZ method of this name.)

Getting Information

resolveSeVariant

static source
AudioManager.resolveSeVariant(se)

The SE to actually play.

Details

The SE to actually play. Resolution sits here rather than in SoundManager so that every SE the engine plays gets it -- animation sound timings, the Play SE event command, UI and 3D effect sounds -- and not only the system sound slots, which are the only thing SoundManager is reached by.

Returns se itself when neither key is set, so the common path allocates nothing. Otherwise it returns a fresh object: the pool entries are live $dataSystem/$dataAnimations objects, and writing a rolled pitch back into one would persist it on the editor's next save.

_pickBgmSequencePoolEntry

static internal source
AudioManager._pickBgmSequencePoolEntry(layer)

The next pool entry: in order, dealt from a shuffled bag, or drawn at random.

Checks (True / False)

isCurrentBgm

static source
AudioManager.isCurrentBgm(bgm)

Whether it is current bgm. (Same as the RPG Maker MZ method of this name.)

isCurrentBgs

static source
AudioManager.isCurrentBgs(bgs)

Whether it is current bgs. (Same as the RPG Maker MZ method of this name.)

isMissingLocalSe

static source
AudioManager.isMissingLocalSe(name)

A missing one-shot sound must not stop the battle or start a new failed request for every hit.

Details

A missing one-shot sound must not stop the battle or start a new failed request for every hit. Web/remote audio retains the normal loading path.

isStaticSe

static source
AudioManager.isStaticSe(se)

Whether it is static se. (Same as the RPG Maker MZ method of this name.)

Actions

playBgm

static source
AudioManager.playBgm(bgm, pos)

Plays the bgm. (Same as the RPG Maker MZ method of this name.)

stopBgm

static source
AudioManager.stopBgm()

Stops the bgm. (Same as the RPG Maker MZ method of this name.)

fadeOutBgm

static source
AudioManager.fadeOutBgm(duration)

Fade out bgm. (Same as the RPG Maker MZ method of this name.)

fadeInBgm

static source
AudioManager.fadeInBgm(duration)

Fade in bgm. (Same as the RPG Maker MZ method of this name.)

playBgs

static source
AudioManager.playBgs(bgs, pos)

Plays the bgs. (Same as the RPG Maker MZ method of this name.)

stopBgs

static source
AudioManager.stopBgs()

Stops the bgs. (Same as the RPG Maker MZ method of this name.)

fadeOutBgs

static source
AudioManager.fadeOutBgs(duration)

Fade out bgs. (Same as the RPG Maker MZ method of this name.)

fadeInBgs

static source
AudioManager.fadeInBgs(duration)

Fade in bgs. (Same as the RPG Maker MZ method of this name.)

playMe

static source
AudioManager.playMe(me)

Plays the me. (Same as the RPG Maker MZ method of this name.)

fadeOutMe

static source
AudioManager.fadeOutMe(duration)

Fade out me. (Same as the RPG Maker MZ method of this name.)

stopMe

static source
AudioManager.stopMe()

Stops the me. (Same as the RPG Maker MZ method of this name.)

playSe

static source
AudioManager.playSe(se)

Plays the se. (Same as the RPG Maker MZ method of this name.)

stopSe

static source
AudioManager.stopSe()

Stops the se. (Same as the RPG Maker MZ method of this name.)

playStaticSe

static source
AudioManager.playStaticSe(se)

Plays the static se. (Same as the RPG Maker MZ method of this name.)

stopAll

static source
AudioManager.stopAll()

Stops the all. (Same as the RPG Maker MZ method of this name.)

saveBgm

static source
AudioManager.saveBgm()

Saves the bgm. (Same as the RPG Maker MZ method of this name.)

saveBgs

static source
AudioManager.saveBgs()

Saves the bgs. (Same as the RPG Maker MZ method of this name.)

resumePendingBgmSequence

static source
AudioManager.resumePendingBgmSequence()

Plays the sequence that was waiting for its map, once that map is the one loaded.

Details

Plays the sequence that was waiting for its map, once that map is the one loaded. A save being loaded asks for its music before the map is read and makes no transfer, so the map's autoplay never repeats the request.

playBgmSequence

static source
AudioManager.playBgmSequence(bgm)

Plays the bgm sequence. (Same as the RPG Maker MZ method of this name.)

stopBgmSequence

static source
AudioManager.stopBgmSequence()

Stops the bgm sequence. (Same as the RPG Maker MZ method of this name.)

_startBgmSequenceTrack

static internal source
AudioManager._startBgmSequenceTrack(state, audio, onEnd, fadeIn)

Starts one non-looping track for the sequence; onEnd runs when it plays out.

_destroyBgmSequenceBuffer

static internal source
AudioManager._destroyBgmSequenceBuffer(buffer)

Destroy bgm sequence buffer. (Same as the RPG Maker MZ method of this name.)

_startBgmSequenceEntry

static internal source
AudioManager._startBgmSequenceEntry(state, entry)

Starts the bgm sequence entry. (Same as the RPG Maker MZ method of this name.)

_startBgmSequencePalette

static internal source
AudioManager._startBgmSequencePalette(state, entry, now)

Starts the bgm sequence palette. (Same as the RPG Maker MZ method of this name.)

_startBgmSequenceLayer

static internal source
AudioManager._startBgmSequenceLayer(state, layer)

Starts the bgm sequence layer. (Same as the RPG Maker MZ method of this name.)

_endBgmSequencePalette

static internal source
AudioManager._endBgmSequencePalette(state, fadeOut)

Ends the bgm sequence palette. (Same as the RPG Maker MZ method of this name.)

_fadeOutBgmSequence

static internal source
AudioManager._fadeOutBgmSequence(duration)

Fade out bgm sequence. (Same as the RPG Maker MZ method of this name.)

Updating & Drawing

updateBgmParameters

static source
AudioManager.updateBgmParameters(bgm)

Updates the bgm parameters each frame. (Same as the RPG Maker MZ method of this name.)

updateCurrentBgm

static source
AudioManager.updateCurrentBgm(bgm, pos)

Updates the current bgm each frame. (Same as the RPG Maker MZ method of this name.)

updateBgsParameters

static source
AudioManager.updateBgsParameters(bgs)

Updates the bgs parameters each frame. (Same as the RPG Maker MZ method of this name.)

updateCurrentBgs

static source
AudioManager.updateCurrentBgs(bgs, pos)

Updates the current bgs each frame. (Same as the RPG Maker MZ method of this name.)

updateMeParameters

static source
AudioManager.updateMeParameters(me)

Updates the me parameters each frame. (Same as the RPG Maker MZ method of this name.)

updateSeParameters

static source
AudioManager.updateSeParameters(buffer, se)

Updates the se parameters each frame. (Same as the RPG Maker MZ method of this name.)

updateBufferParameters

static source
AudioManager.updateBufferParameters(buffer, configVolume, audio)

Updates the buffer parameters each frame. (Same as the RPG Maker MZ method of this name.)

updateBgmSequence

static source
AudioManager.updateBgmSequence()

The per-frame step: silences end, palette layers restart, palettes fade and move on.

_refreshBgmSequenceVolumes

static internal source
AudioManager._refreshBgmSequenceVolumes()

Re-derives every live layer's volume after the BGM volume option changes.

Other

replayBgm

static source
AudioManager.replayBgm(bgm)

Replay bgm. (Same as the RPG Maker MZ method of this name.)

replayBgs

static source
AudioManager.replayBgs(bgs)

Replay bgs. (Same as the RPG Maker MZ method of this name.)

seVariantPool

static source
AudioManager.seVariantPool(se)

Every take a slot or timing can play: the SE itself, then its variants, with anything unnamed dropped.

rollSePitch

static source
AudioManager.rollSePitch(range)

A pitch inside range, or null when the range is absent or unusable.

Details

A pitch inside range, or null when the range is absent or unusable. The editor writes '' for a cleared control, which is not a zero -- Number('') is 0 and would clamp to a silent-sounding 50 rather than meaning "no range". Clamped to 50-150 because pitch is playback rate downstream.

cleanupSe

static source
AudioManager.cleanupSe()

Cleanup se. (Same as the RPG Maker MZ method of this name.)

audioFileExt

static source
AudioManager.audioFileExt()

Audio file ext. (Same as the RPG Maker MZ method of this name.)

checkErrors

static source
AudioManager.checkErrors()

Check errors. (Same as the RPG Maker MZ method of this name.)

skipsMissingAudio

static source
AudioManager.skipsMissingAudio()

System.json rrSkipMissingAudio (2000/2003 imports): a sound or track the game names but never shipped (often a standard RTP file such as Save2) stays silent, as the old players do, instead of stopping the game on a load error.

throwLoadError

static source
AudioManager.throwLoadError(webAudio)

Throw load error. (Same as the RPG Maker MZ method of this name.)

mapBgmObject

static source
AudioManager.mapBgmObject(map, mapId)

The BGM object a map plays: its fallback track, marked with the sequence when it has one.

mapHasBgmSequence

static source
AudioManager.mapHasBgmSequence(map)

Map has bgm sequence. (Same as the RPG Maker MZ method of this name.)

librarySequenceKey

static source
AudioManager.librarySequenceKey(id)

The key a library entry travels under in a BGM object.

librarySequenceId

static source
AudioManager.librarySequenceId(key)

The library id a key names, or 0 when the key is a map id.

librarySequenceData

static source
AudioManager.librarySequenceData(id)

A library entry's sequence, or null when id names nothing playable.

battleMusicBgm

static source
AudioManager.battleMusicBgm(audio)

The battle music a troop or a map keeps in battleBgm, the same audio object Change Battle BGM stores.

Details

The battle music a troop or a map keeps in battleBgm, the same audio object Change Battle BGM stores. Its track plays; a sequence naming a playable library entry plays that entry instead, with the track -- or the System track, when none is set -- as the fallback. Null when it names neither.

troopBattleBgm

static source
AudioManager.troopBattleBgm()

The battle music the troop about to fight names, or null.

mapBattleBgm

static source
AudioManager.mapBattleBgm()

The battle music the current map names, or null; a battle test has no map.

_bgmSequenceDataFor

static internal source
AudioManager._bgmSequenceDataFor(key)

The sequence a key names: a library entry, or the current map's for its id (null while that map is not loaded).

_bgmSequenceTrackAudio

static internal source
AudioManager._bgmSequenceTrackAudio(entry)

Bgm sequence track audio. (Same as the RPG Maker MZ method of this name.)

_bgmSequenceBuffers

static internal source
AudioManager._bgmSequenceBuffers()

Bgm sequence buffers. (Same as the RPG Maker MZ method of this name.)

_retireBgmSequenceBuffer

static internal source
AudioManager._retireBgmSequenceBuffer(state, buffer, fade)

Releases a buffer the sequence has finished with.

Details

Releases a buffer the sequence has finished with. Given a fade it keeps playing, ramping down, until the sweep in updateBgmSequence destroys it -- which is what lets the next entry start over the top of this one.

_sweepBgmSequenceRetiring

static internal source
AudioManager._sweepBgmSequenceRetiring(state, now)

Sweep bgm sequence retiring. (Same as the RPG Maker MZ method of this name.)

_nextBgmSequenceEntry

static internal source
AudioManager._nextBgmSequenceEntry(state)

The entry that would play next, skipping any the sequence has used up -- the same walk the advance makes, without moving.

Details

The entry that would play next, skipping any the sequence has used up -- the same walk the advance makes, without moving. Asking the raw next entry would read an intro's fade to decide a hand-over the intro is not going to take.

_bgmSequenceFadeIn

static internal source
AudioManager._bgmSequenceFadeIn(entry)

Seconds the entry wants to swell in over; 0 for one that names none.

_pruneBgmSequenceBuffers

static internal source
AudioManager._pruneBgmSequenceBuffers(state)

Prune bgm sequence buffers. (Same as the RPG Maker MZ method of this name.)

_advanceBgmSequence

static internal source
AudioManager._advanceBgmSequence(fadeOut)

Advance bgm sequence. (Same as the RPG Maker MZ method of this name.)

_bgmSequenceLayerIsEnding

static internal source
AudioManager._bgmSequenceLayerIsEnding(layer, palette)

Whether a layer's track is close enough to its end to hand over now.

Details

Whether a layer's track is close enough to its end to hand over now. Measured from the buffer's own clock rather than from when playback was asked for, so a slow decode delays the hand-over with the track instead of cutting it short.

_advanceIfPaletteSpent

static internal source
AudioManager._advanceIfPaletteSpent(state)

Moves a single-shot palette on once every layer has had its one turn.

_duckBgmSequence

static internal source
AudioManager._duckBgmSequence(factor)

Duck bgm sequence. (Same as the RPG Maker MZ method of this name.)