I don’t think there’s any way to do this directly - I think you can only free the allocated memory of a Buffer all at once. You could of course always allocate a new Buffer with the necessary length, copy over the data from the initial Buffer (using Buffer's .copydata method) and then free the initial Buffer. However, I don’t really understand your specific use case here or why you would need to do this at all - are you working with very large buffers and trying to save up memory space?
Thanks, yes I’d thought of that solution. I was just wanting to see if there was a more direct way of trimming down the existing buffer, just because I’ve got limited programming time and I want to limit the proliferation of buffers (I’m using several arrays of buffers already).
I’m not short of memory space, but I want to do this as some of my synths assume the whole buffer contains meaningful audio (eg granulators that process the whole buffer, PlayBuf that loops the whole buffer etc). It just means more programming… (lazy me)
I think you could do that with a routine. Declare the number of frames as a variable and then have the routine change the value.
Not sure though, not at my computer at the moment but I’ll give it a shot tomorrow
Your choices are as stated above: copy the part of the buffer that you want into a new buffer (then free the original), or edit your SynthDefs to use only a specified part of the buffer.