Crop buffer lenght in gen~

MMa's icon

Hi everyone,

is it possible to record a file in a buffer in gen~ and resize it according to the length of the file?

Thanks in advance

Graham Wakefield's icon

I'm not sure what you mean.

You can load a file (wav, aiff, etc.) into a buffer~ object in Max, and refer directly to that buffer~ inside gen~ by using a buffer object with the same name. There is no need to record anything. If you replace the file in the Max buffer~, it will also be updated in the gen~ buffer.


To answer the title question, no it is not possible to resize a buffer in gen~, because the buffer is just a reference to the buffer~ object that belongs to the containing Max patcher. You can resize a buffer~ in Max using various messages.


If you are live recording into a buffer (or data) object in gen~, you can keep track of how many samples you have recorded (e.g. using a counter operator that is sent a "1" while recording and "0" when not recording), and use that in your calculations for playback. For example, feed the sample count to the 3rd inlet of a wave operator.

Graham

MMa's icon

Hi, thanks for your answer.

but I can log data to a buffer ~ in Max through gen ~ and then perform resize operations on the buffer ~ in Max. Is that correct?

Graham Wakefield's icon

You can write values into a buffer in gen~, and you will be able to see those same values in the buffer~ in Max, yes. So long as they have the same name, e.g. [buffer~ foo] in Max and [buffer foo] in gen~, they refer to the exact same chunk of memory.