mirror of
https://github.com/scratchfoundation/scratch-audio.git
synced 2025-01-03 11:35:49 -05:00
Add public getter/setter for buffers
This commit is contained in:
parent
0555407406
commit
062f39244b
1 changed files with 18 additions and 0 deletions
18
src/index.js
18
src/index.js
|
@ -225,6 +225,24 @@ class AudioEngine {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the audio buffer as held in memory for a given sound id.
|
||||
* @param {!string} soundId - the id of the sound buffer to get
|
||||
* @return {AudioBuffer} the buffer corresponding to the given sound id.
|
||||
*/
|
||||
getSoundBuffer (soundId, newBuffer) {
|
||||
return this.audioBuffers[soundId] = newBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the in-memory audio buffer to a new one by soundId.
|
||||
* @param {!string} soundId - the id of the sound buffer to update.
|
||||
* @param {AudioBuffer} newBuffer - the new buffer to swap in.
|
||||
*/
|
||||
updateSoundBuffer (soundId, newBuffer) {
|
||||
this.audioBuffers[soundId] = newBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* An older version of the AudioEngine had this function to load all sounds
|
||||
* This is a stub to provide a warning when it is called
|
||||
|
|
Loading…
Reference in a new issue