beep icon indicating copy to clipboard operation
beep copied to clipboard

Minimizing the bufferSize

Open lucianthorr opened this issue 5 years ago • 4 comments

I've been working on a super simple midi-based synthesizer based heavily on your approach to handling the audio signal. I'd like to keep working on it but I can't seem to get the buffersize down enough so that the latency isn't so noticeable. I can get it down to about 22 milliseconds but any lower and there's a clicking sound. Do you have an idea as to why the smaller buffer sizes become problematic?

My start is here, if you're curious: https://github.com/lucianthorr/aja/blob/3ee2d82b74f5ab6755732f9f30a0899d18cc2464/main.go#L24

lucianthorr avatar Jun 16 '19 22:06 lucianthorr

Hi, which OS are you using? AFAIK, the implementation on Linux allows for really short buffer sizes, while implementations on other OSs are a little worse (but still completely fine for games, media apps, etc).

faiface avatar Jun 16 '19 22:06 faiface

I'm on a Mac. But that's good to know. I could very well be doing something else wrong somewhere else.

lucianthorr avatar Jun 16 '19 22:06 lucianthorr

Try Linux. Even a virtual machine could help. I was able to get 1/100s and less buffer size on Linux. Beep uses Oto for low level audio playback. Me and Hajime Hosi collaborated on it. It's a little unfortunate that the low level implementation for Mac isn't as good as for Linux. This is because the Mac implementation uses OpenAL, which is a pretty shit library with regards to latency. Hopefully, we'll improve it someday. The driver for Windows may actually also be good, but I've never tried it personally (Hajime Hoshi has implemented it).

faiface avatar Jun 16 '19 22:06 faiface

Awesome. I'll give it a shot in virtualBox. I'll dig through some of that Oto code also. I'm trying to get a better understanding of how the lower level audio stuff works anyway. Thanks for the feedback!

lucianthorr avatar Jun 16 '19 22:06 lucianthorr