Skip to content

Commit

Permalink
Volume slider event
Browse files Browse the repository at this point in the history
  • Loading branch information
AshimeeAlt committed Oct 4, 2024
1 parent 5cf159b commit 9a12548
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/engine/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,14 @@ class Runtime extends EventEmitter {
return 'PROJECT_STOP_ALL';
}

/**
* Event name for when the volume is changed
* @const {string}
*/
static get VOLUME_CHANGE () {
return 'VOLUME_CHANGE';
}

/**
* Event name for target being stopped by a stop for target call.
* Used by blocks that need to stop individual targets.
Expand Down Expand Up @@ -2232,6 +2240,19 @@ class Runtime extends EventEmitter {
this.emit(Runtime.PROJECT_PAUSE, status);
}

/*
* Sets the volume on the audio engine for the project
* @param {number} volume The volume (in a 0.00 - 1.00 range)
* @returns {boolean} Whether or not the volume was actually set succesfully
* this function also emits an event for the GUI
*/
setVolume(volume) {

Check failure on line 2249 in src/engine/runtime.js

View workflow job for this annotation

GitHub Actions / build

Missing space before function parentheses
// It is safe to assume the engine is setup
this.audioEngine.inputNode.gain.value = volume;
this.emit(Runtime.VOLUME_CHANGE, volume);
return true;
}

/**
* Create a thread and push it to the list of threads.
* @param {!string} id ID of block that starts the stack.
Expand Down

0 comments on commit 9a12548

Please sign in to comment.