Recording and Resizing a Buffer on the Fly

realisms's icon

Hi All,

I am trying to make a looping mechanism whereby when a record~ object it starts, a counter starts, counting the time elapsed until it stops, at this point it sends a size messsage to the buffer it just recorded to and resizes it. I am getting strange and difficult to describe results however. Could anyone advise if there is a more proven method of achieving something like this?

Cheers!

davidestevens's icon

When you resize a buffer its contents are deleted. The thing to do is to have an adequately large buffer to record into, then when record is finished size a separate buffer to the length of the recording using the time elapsed, and then copy the recording (start to elapsed time)into the resized buffer using peek~/poke~.
HTH

Christopher Dobrian's icon

A possible solution is provided here.https://cycling74.com/forums/automatic-buffer-cropping-after-recording/
Use timer (not counter) to time the duration of the recording, then use the 'crop' message to buffer~ to change its size (although you really don't need to crop it, because the timer will have already told you the ending time of the recording).

realisms's icon

Folks,

Thanks for your feedback, I eventually implemented by giving the buffer an arbitrary "Max Length" then using a time between two button presses to start/stop the recording to produce a ms time used to rezise after the recording finishes. I think I may be wasting memory with my pre sized buffer mind you but it's working so far!

Evan's icon

Yeah you're wasting memory, but not much, and it's probably nearly negligible. I had a system rigged up that cropped a buffer to the length of recording, but it ended up being more trouble than it's worth. I just reference a portion of a longer buffer for things like this.