Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/beatbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export class Beatbox extends EventEmitter {
source.connect(this._audioContext!.destination);
}

this.emit("source", { source, time });
source.start(time);

const clear = () => {
Expand Down Expand Up @@ -373,8 +374,9 @@ export class Beatbox extends EventEmitter {
if (instr && (instr.volume == null || instr.volume > 0)) {
let time = this._referenceTime! + (this._position - this._upbeat) * this._strokeLength / 1000;

if(this._lastInstrumentStrokes[instr.key])
this._lastInstrumentStrokes[instr.key].stop(time);
// We avoid the sound to stop before it is required to sound again. We let it end by itself
// if(this._lastInstrumentStrokes[instr.key])
// this._lastInstrumentStrokes[instr.key].stop(time);

const sound = this._scheduleSound(instr, time);
this._lastInstrumentStrokes[instr.key] = sound;
Expand Down