Crude "realtime" time expansion - issue with playback head positioning

Roald Baudoux's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Here's a patcher for crude "realtime" time expansion. The idea is to expand the time on an incoming signal recorded into a circular buffer with a granular engine (of course, no time compression is not possible in real time). As the buffer is long, the recording head is supposed not to catch up with playback head on its next lap. When expansion factor goes to the no-expansion value (1.0), the playback head to catches up to the recording head. There's some room for improvement of course (intelligent segmentation, playback position randomizing...). However there is an issue: the playback head is often ahead the recording head instead of being behind. There's something with the wrapping I guess but I can't find where. Any idea?

bertrandfraysse's icon

why are you translating sample value into phase ? I think it could be a source of problems.
I think your wraping should start with 1, the first sample of the buffer, and not 0.

Roald Baudoux's icon

I thought sample's object demanded playback position to be expressed as phase but now I understand it can be expressed as samples, so indeed I can remove the samples-to-phase translation. However I don't agree for the wrapping, the first sample's position is 0, not 1.

Roald Baudoux's icon

I have made another correction, as using mstosamps to convert the current position within a grain doesn't go down to 0. So I have replaced the mstosamps with a "/ 1000." object followed by "* samplerate".

Max Patch
Copy patch and select New From Clipboard in Max.

However I haven't solved the main issue yet.

Roald Baudoux's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Issue solved. There was a calculation which didn't make sense in big codebox (see line #8).