Skip to content

Commit

Permalink
Update mixer.ts
Browse files Browse the repository at this point in the history
ConnorChristie#5 (comment)

Unfortunately it seems this repo is no longer maintained. I was able to fork the repo (to our company repo) - you will be able to fix the CPU issue by doing the following here: https://github.com/ConnorChristie/Audio-Mixer/blob/master/src/mixer.ts#L82

Replace this bit:

clearImmediate(this._timer)
this._timer = setImmediate(this._read.bind(this));
with

clearTimeout(this._timer)
this._timer = setTimeout(this._read.bind(this), 0);
I dont know what kind of impact it would have in terms of realtime processing. But for our use-case it works and all 2000 unit tests are still passing after this change. But CPU basically went down to 0 :)
  • Loading branch information
karyeet authored Dec 22, 2022
1 parent 9ab1fed commit fe6a86c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/mixer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class Mixer extends Readable {
this.push(mixedBuffer);
} else if(this.needReadable) {
clearImmediate(this._timer)
this._timer = setImmediate(this._read.bind(this));
this._timer = setTimeout(this._read.bind(this), 0);
}

this.clearBuffers();
Expand Down

0 comments on commit fe6a86c

Please sign in to comment.