Skip to content

Commit

Permalink
add missing optional id parameter to 3D / Spatial audio methods
Browse files Browse the repository at this point in the history
  • Loading branch information
obiot committed Apr 19, 2024
1 parent 8337a1d commit 626673d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Update to eslint 9.0

### Added
- Audio: add missing optional id parameter to 3D / Spatial audio methods
- Core: add platform detection if running as a standalone web app

### Fixed
Expand Down
20 changes: 12 additions & 8 deletions src/audio/audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,14 +284,15 @@ export function rate(sound_name, ...args) {
* @memberof audio
* @param {string} sound_name - audio clip name - case sensitive
* @param {number} [pan] - the panning value - A value of -1.0 is all the way left and 1.0 is all the way right.
* @param {number} [id] - the sound instance ID. If none is passed, all sounds in group will be changed.
* @return {number} the current panning value
* @example
* me.audio.stereo("cling", -1);
*/
export function stereo(sound_name, pan) {
export function stereo(sound_name, pan, id) {
let sound = audioTracks[sound_name];
if (sound && typeof sound !== "undefined") {
return sound.stereo(pan);
return sound.stereo(pan, id);
} else {
throw new Error("audio clip " + sound_name + " does not exist");
}
Expand All @@ -304,12 +305,13 @@ export function stereo(sound_name, pan) {
* @param {Number} x - the x-position of the audio source.
* @param {Number} y - the y-position of the audio source.
* @param {Number} z - the z-position of the audio source.
* @param {number} [id] - the sound instance ID. If none is passed, all sounds in group will be changed.
* @return {Array} the current 3D spatial position: [x, y, z]
*/
export function position(sound_name, x, y, z) {
export function position(sound_name, x, y, z, id) {
let sound = audioTracks[sound_name];
if (sound && typeof sound !== "undefined") {
return sound.pos(x, y, z);
return sound.pos(x, y, z, id);
} else {
throw new Error("audio clip " + sound_name + " does not exist");
}
Expand All @@ -323,12 +325,13 @@ export function position(sound_name, x, y, z) {
* @param {Number} x - the x-orientation of the audio source.
* @param {Number} y - the y-orientation of the audio source.
* @param {Number} z - the z-orientation of the audio source.
* @param {number} [id] - the sound instance ID. If none is passed, all sounds in group will be changed.
* @return {Array} the current 3D spatial orientation: [x, y, z]
*/
export function orientation(sound_name, x, y, z) {
export function orientation(sound_name, x, y, z, id) {
let sound = audioTracks[sound_name];
if (sound && typeof sound !== "undefined") {
return sound.orientation(x, y, z);
return sound.orientation(x, y, z, id);
} else {
throw new Error("audio clip " + sound_name + " does not exist");
}
Expand All @@ -348,6 +351,7 @@ export function orientation(sound_name, x, y, z) {
* @param {string} [settings.refDistance=1] - A reference distance for reducing volume as source moves further from the listener. This is simply a variable of the distance model and has a different effect depending on which model is used and the scale of your coordinates. Generally, volume will be equal to 1 at this distance.
* @param {string} [settings.rolloffFactor=1] - How quickly the volume reduces as source moves from listener. This is simply a variable of the distance model and can be in the range of `[0, 1]` with `linear` and `[0, ∞]` with `inverse` and `exponential`.
* @param {string} [settings.panningModel="HRTF"] - Determines which spatialization algorithm is used to position audio. Can be `HRTF` or `equalpower`.
* @param {number} [id] - the sound instance ID. If none is passed, all sounds in group will be changed.
* @return {Object} current panner attributes.
* @example
* me.audio.panner("cling", {
Expand All @@ -357,10 +361,10 @@ export function orientation(sound_name, x, y, z) {
* distanceModel: 'exponential'
* });
*/
export function panner(sound_name, attributes) {
export function panner(sound_name, attributes, id) {
let sound = audioTracks[sound_name];
if (sound && typeof sound !== "undefined") {
return sound.pannerAttr(attributes);
return sound.pannerAttr(attributes, id);
} else {
throw new Error("audio clip " + sound_name + " does not exist");
}
Expand Down

0 comments on commit 626673d

Please sign in to comment.