Well, this is for the phase vocoder patch, which is based on miller's I07 example.
There's a counter that reads over the table, and I expanded the thing allowing it to loop and other convenient sampling controls.
I never needed a perfect loop, cause I never loaded real perfectly looped files in it, so I just check when the counter grows bigger than the table size and restart it. As for recording on the tables, I do fade-in and fade-out, because it would click anyway.
Now, for the ring buffer, it needs to be in perfect sync, so I can have tables that are multiples of the block size and use [bang~], it's not that much of a big restrain at all. You won't be able to specify an exact table size, but the resolution is 64 samples, and that is like 1.45 miliseconds (about nothing). So I got over it, did it, and it works!!!
I can adapt the thing for loaded samples, and have it the table size rounded up to multiples of the block + 1. This is not a perfect loop, but they weren't perfect before anyhow...
But why stop there? How to make it loop perfectly? This is the issue now. *Checking Miller's Phase Vocoder example. If you load a sample, how to make it loop perfectly?*
I know one could use phasor~ and other stuff to read the table. But for the Phase Vocoder patch, we need that structure with the counter and everything.
Well, I'll keep thinking.
Thanks
2012/1/8 Charles Henry czhenry@gmail.com
On 1/8/12, Alexandre Torres Porres porres@gmail.com wrote:
Hi folks, I'm trying to implement a ring buffer with a table for a
sampler
patch based on an array.
But I'm having the hardest time cause it always "clicks" when I start writing back on the beginning of the array.
I made this simple test attached below using metro. But I'm figuring the flaw is because is not trivial at all to keep control data in sync with audio blocks
any hints or ideas?
I think you might be better able to keep the data in sync with a vline~/metro/tabread4~ construction, because it preserves the timing information in the messages. Instead of vline~/metro, you could also use phasor~ which makes the looping implicit.
To work around clicks, crossfading is what I hear about the most on list. I'm not sure how it's implemented.
When I think about coding in C, I always want to have N contiguous samples to avoid having to check against the end of the array. To do that, you make the buffer 2*N-1 in length. Then, on each write, you write to two locations (0,N), (1,N+1), (2,N+2)... That ensures there is always N samples in a row to read from, and you just move the read pointer by 1 each time you get a vector of N samples long. (my personal method...nothing more).