updated description for detune setting and added a check to see if it's available, webkit implementation does not support it

This commit is contained in:
Pavle Goloskokovic 2017-11-20 14:54:33 +01:00
parent d20b7abba6
commit cafa91005f
2 changed files with 5 additions and 1 deletions

View file

@ -65,6 +65,9 @@ var BaseSound = new Class({
* Represents detuning of sound in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29).
* The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent).
*
* Standards based Web Audio implementation only.
* Webkit Web Audio implementation and HTML5 Audio don't support this.
*
* @property {number} detune
*/
this.detune = 0;

View file

@ -108,6 +108,7 @@ var WebAudioSound = new Class({
this.source.buffer = this.audioBuffer;
this.source.connect(this.muteNode);
this.applyConfig();
// TODO add onended event handler to reset sound state
this.source.start(0, offset, duration);
},
/**
@ -177,7 +178,7 @@ Object.defineProperty(WebAudioSound.prototype, 'detune', {
},
set: function (value) {
this.currentConfig.detune = value;
if (this.source) {
if (this.source && this.source.detune) {
this.source.detune.value =
Math.max(-1200, Math.min(value + this.manager.detune, 1200));
}