03-10-2010 11:47 AM
03-10-2010 02:21 PM
No, not directly. You'd have to manage this yourself. I thought about this before when I thought I might need to do something similar. I haven't implemented it yet, but I think the basic concept is solid.
I like to break up the output buffer.into thirds to help provide a little leeway. The idea goes like this:
1. Size the buffer to hold "N" complete cycles of the continuous pattern. I would choose a big enough "N" that the initial pattern fills
only about 1/3 of the buffer.
2. Fill the buffer with the initial pattern plus whatever portion of the continuous pattern you need to "pad it out" to the end. Know where you left off.
3. Wait until about 2/3 of the buffer has been output. Then write 1/3 of the buffer worth of the continuous pattern. This data will be overwriting the initial pattern starting at the beginning of the memory buffer. Be sure to start the pattern from where you left off in step 2.
4. Wait for another 1/3 of the buffer to be output, then write the next 1/3. Repeat (if necessary) to update the final 1/3 of the buffer.
5. Now it should just keep regenerating and you don't have to write anything again.
Note that by following this "rule of thirds", you will begin writing at a point 1/3 buffer in front of the next sample to output and you will end writing at a point 1/3 buffer behind it. This buys you a little bit of leeway on getting the timing right.
For a very fast output, the buffer may need to be pretty big. If it were up to me, I'd aim for a buffer length of at least 1.5 seconds, so that you still get a 0.5 second leeway.
-Kevin P