Reversing the content of a buffer?

Masa's icon

Is there any way to reverse the content of a buffer~ immediately?

Thanks a lot,
Masa

Evan's icon

Not immediately. You could send up a gen patch that did this with a for loop pretty easily. for example:

for(i = 0; i < length_of_buffer < i += 1){
sample_to_write = peek(buffer_name,i,channel);
poke(buffer_name,sample_to_write, length_of_buffer - i,channel);
}

You could also do this with standard max objects, but I've been loving gen lately, so that's my solution.

pdelges's icon

You can also use [mxj buf.Op myBuff]'s reverse method.

Source Audio's icon
Masa's icon

Thanks a lot Evan. As I am not familiar with gen~ yet (definitively I would love to be), is it the 'codebox' I need to put your code into?

Masa's icon

Thanks a lot Patrick. I will look into the mxj object.

Masa's icon

Thanks a lot SOURCE AUDIO, being 'very fast' helps a lot. I will try the object.

Masa's icon

SOURCE AUDIO, do you happen to know if there is the Windows version of LyonPotpourri 3.0 Package? I use both Mac and Windows.

Source Audio's icon

There was a release for windows, but only 32 bit.
http://disis.music.vt.edu/eric/LyonSoftware/MaxMSP

But if You have time You could try to compile windows version from the source.
https://github.com/ericlyon/LyonPotpourri3.0-MaxMSP

Roman Thilenius's icon

in many situations you would just read out the buffer reversed but leave the content as is.

Masa's icon

Thank you SOURCE AUDIO.

Hi Roman. Sure, the reason I am trying to reverse the buffer content is to remain at the same playback position when reading the content in reverse (with the signal of -1).

Evan's icon

In that case, you might want to just calculate the index when you hit reverse, and start reading backwards from there, instead of reversing the whole buffer. Likely much cheaper computationally.

Or have two copies of the buffer, one reversed. But that doesn't seem necessary.

Masa's icon

Thank you Evan. I didn't know that groove~ can receive index value. Or are you referring to another method?

Masa's icon

[mxj buf.Op myBuff] simply did the trick. Thanks a lot all.