Skip to content

Commit 372983a

Browse files
defined rate property on WebAudioSoundManager prototype
and _rate field to actually hold that value
1 parent 716a1d4 commit 372983a

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

v3/src/sound/WebAudioSoundManager.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ var WebAudioSoundManager = new Class({
3131
* @property {AudioNode} destination
3232
*/
3333
this.destination = this.masterMuteNode;
34+
/**
35+
* Property that actually holds the value of global playback rate.
36+
*
37+
* @property {number} _rate
38+
* @private
39+
*/
40+
this._rate = 1;
3441
BaseSoundManager.call(this, game);
3542
},
3643
createAudioContext: function (game) {
@@ -70,4 +77,21 @@ Object.defineProperty(WebAudioSoundManager.prototype, 'volume', {
7077
this.masterVolumeNode.gain.value = value;
7178
}
7279
});
80+
/**
81+
* Global playback rate.
82+
* @property {number} rate
83+
*/
84+
Object.defineProperty(WebAudioSoundManager.prototype, 'rate', {
85+
get: function () {
86+
return this._rate;
87+
},
88+
set: function (value) {
89+
this._rate = value;
90+
this.sounds.forEach(function (sound) {
91+
// invoke sound's rate setter method to update
92+
// value based on new global rate value
93+
sound.rate = sound.rate;
94+
}, this);
95+
}
96+
});
7397
module.exports = WebAudioSoundManager;

0 commit comments

Comments
 (0)