libpd's API only allows to process audio in frames of 64 samples at a time. What I've done in the past is set the audio device buffer size to a number that is divisible by 64. No problems there.
Now, I need to make a Windows app that is ASIO compatible. I'm using RtAudio. The issue is that when I initialize my ASIO sound card (Roland FA-66) with the RtAudio API, it ignores the buffer size parameter and chooses one of it's own, which is not divisible by 64.
I thought of a workaround. This would take place in the audio callback function:
- Check if buffer size is not divisible by 64. If so:
- Tell libpd to process a number of frames larger than the needed size and store that in a temp buffer.
- Use memcpy to copy the right amount of frames from the temp buffer to the output buffer.
- Use memcpy to store the extra samples in another buffer (called extra) and use them in the following call to the audio callback.
I have not tried this but I think it will work.
However, I'd like to know if there is a "standard" or "well known" procedure for dealing with this problem. Maybe there are warnings or tips that I'm not aware of?