mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 16:48:00 +00:00
no longer throws error when no buffer is set
just doesn’t play instead
This commit is contained in:
parent
438abe481a
commit
9a74728858
1 changed files with 58 additions and 57 deletions
|
@ -121,10 +121,7 @@ define(["Tone/core/Tone", "Tone/core/Buffer", "Tone/source/Source"], function (T
|
|||
throw new Error("Tone.BufferSource: can only be started once.");
|
||||
}
|
||||
|
||||
if (!this.buffer){
|
||||
throw new Error("Tone.BufferSource: no buffer set.");
|
||||
}
|
||||
|
||||
if (this.buffer){
|
||||
time = this.toSeconds(time);
|
||||
//if it's a loop the default offset is the loopstart point
|
||||
if (this.loop){
|
||||
|
@ -163,6 +160,7 @@ define(["Tone/core/Tone", "Tone/core/Buffer", "Tone/source/Source"], function (T
|
|||
duration = this.toSeconds(duration);
|
||||
this.stop(time + duration + fadeInTime, fadeInTime);
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
@ -175,9 +173,7 @@ define(["Tone/core/Tone", "Tone/core/Buffer", "Tone/source/Source"], function (T
|
|||
* @return {Tone.BufferSource} this
|
||||
*/
|
||||
Tone.BufferSource.prototype.stop = function(time, fadeOutTime){
|
||||
if (!this.buffer){
|
||||
throw new Error("Tone.BufferSource: no buffer set.");
|
||||
}
|
||||
if (this.buffer){
|
||||
|
||||
time = this.toSeconds(time);
|
||||
|
||||
|
@ -200,6 +196,7 @@ define(["Tone/core/Tone", "Tone/core/Buffer", "Tone/source/Source"], function (T
|
|||
this._gainNode.gain.setValueAtTime(0, time);
|
||||
}
|
||||
this._source.stop(time);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
@ -252,7 +249,11 @@ define(["Tone/core/Tone", "Tone/core/Buffer", "Tone/source/Source"], function (T
|
|||
*/
|
||||
Object.defineProperty(Tone.BufferSource.prototype, "buffer", {
|
||||
get : function(){
|
||||
if (this._source){
|
||||
return this._source.buffer;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
set : function(buffer){
|
||||
if (buffer instanceof Tone.Buffer){
|
||||
|
|
Loading…
Reference in a new issue