Skip to content

Commit f389176

Browse files
Added setRate method to BaseSound class that contains logic for applying rate and detune settings to sound so it can be reused in both Web Audio and HTML5 Audio implementations
1 parent c253e01 commit f389176

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

v3/src/sound/BaseSound.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,16 @@ var BaseSound = new Class({
260260
},
261261
update: NOOP,
262262
destroy: function () {
263+
},
264+
/**
265+
* @private
266+
*/
267+
setRate: function () {
268+
var cent = 1.0005777895065548; // Math.pow(2, 1/1200);
269+
var totalDetune = Math.max(-1200, Math.min(this.currentConfig.detune + this.manager.detune, 1200));
270+
var detuneRate = Math.pow(cent, totalDetune);
271+
var totalRate = this.currentConfig.rate * this.manager.rate * detuneRate;
272+
return totalRate;
263273
}
264274
});
265275
module.exports = BaseSound;

0 commit comments

Comments
 (0)