TooTallNate / node-speaker

Output PCM audio data to the speakers
648 stars 143 forks source link

Hardcoded 0.5 seconds of lag in ALSA backend #13

Open danopia opened 10 years ago

danopia commented 10 years ago

Hey, I'm using this module in a node-backed music/dj server (developing on linux) and it's been treating me pretty well so far. The only issue that I've had is that mpg123's alsa output driver contains a hardcoded #DEFINE forcing half a second of lag. I swapped this number out for 0.05 in my local copy of the module and achieved stable output with almost no noticeable control lag.

Is is possible for this #DEFINE to be made a dynamic setting, or will I need to fork node-speaker and change it in the fork?

I have not checked if any other backends have such a buffer hardcoded.

TooTallNate commented 10 years ago

So it would be great if this backend buffer was configurable. The coreaudio backend has a similar #DEFINE for FIFO_DURATION (0.5f). So some way to make this configurable would be great IMO. Patch welcome!

colinbdclark commented 9 years ago

+1 for some way to adjust this built-in latency. I understand that it's coming from mpg123 not node-speaker itself, but I have received a lot of complaints from users of Flocking (which uses node-speaker) that the lag makes it unusable for real-time performance with a MIDI or OSC controller.

felixroos commented 4 weeks ago

I also just ran into the problem of node-speaker having too much latency for a realtime setting. might or might not be helpful for people looking into this, this commit seems to fix it directly in mpg123: https://github.com/TooTallNate/node-speaker/commit/1218253ffa165272de40853ae3c1a87df8b1e0bb (untested)