c++ - How to handle audio buffer sizes that are not divisible by 64 when working with libpd? -
libpd's api allows process audio in frames of 64 samples @ time. i've done in past set audio device buffer size number divisible 64. no problems there.
now, need make windows app asio compatible. i'm using rtaudio. issue when initialize asio sound card (roland fa-66) rtaudio api, ignores buffer size parameter , chooses 1 of it's own, not divisible 64.
i thought of workaround. take place in audio callback function:
- check if buffer size not divisible 64. if so:
- tell libpd process number of frames larger needed size , store in temp buffer.
- use memcpy copy right amount of frames temp buffer output buffer.
- use memcpy store samples in buffer (called extra) , use them in following call audio callback.
i have not tried think work.
however, i'd know if there "standard" or "well known" procedure dealing problem. maybe there warnings or tips i'm not aware of?
your approach seems valid. thing need careful memory alignment.
here's excellent (and short) article memcpy's pitfalls may cause headache: http://www.codepolice.org/c/memcpy.html
Comments
Post a Comment