adding onstop to noise

This commit is contained in:
Yotam Mann 2019-08-11 11:42:17 -04:00
parent 18facc5576
commit 07cdf6840e

View file

@ -109,9 +109,13 @@ export class Noise extends Source<NoiseOptions> {
*/ */
protected _start(time?: Time): void { protected _start(time?: Time): void {
const buffer = _noiseBuffers[this._type]; const buffer = _noiseBuffers[this._type];
this._source = new ToneBufferSource(buffer).connect(this.output); this._source = new ToneBufferSource({
this._source.loop = true; buffer,
this._source.playbackRate.value = this._playbackRate; context: this.context,
loop: true,
onended: () => this.onstop(this),
playbackRate: this._playbackRate,
}).connect(this.output);
this._source.start(this.toSeconds(time), Math.random() * (buffer.duration - 0.001)); this._source.start(this.toSeconds(time), Math.random() * (buffer.duration - 0.001));
} }