My Python program to record sound has problems with overruns.
I am using threads to do the reording and do FFT’s simultaneously. It works most of the time but there are occaisional gaps and read errors.
I am using pyalsaaudio to connect to ALSA.
I think I need a bigger input buffer to avoid the overruns, but I can’t seem to do this in pyalsaaudio. There is a method to do this - .set periodsize, but it doesn’t do anything.
Is there a way in the ALSA.config files to set a default buffer size?
Thank you for posting your question about recording with the Raspberry Pi. I assume you are using our USB-Audio adapter.
I’m not at work as I answer this, but tomorrow when I am, I will check on my Raspberry Pi, and also consult with our in-house expert on the USB-Audio.
I found the answer at this link:
This is also relevant:
The ALSA docs leave a lot to the imagination, so I don’t quite see what how all these commands work, but this /etc/asound.conf file allows you to change the buffer size for both pyalsaaudio and Pyaudio.
buffer_size 32768 # change buffer
Thanks for posting the answer!