Programmatically set number of channels in buffer~

AlexHarker's icon

Is there any way to set the number of channels in a buffer~ object from another object - either a max method or another (safe) method is fine. I am resizing the buffer~ at the same time.

Thanks

Alex

Emmanuel Jourdan's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Unlike what the reference says... (which is already fixed), the size message can be also use to change the number of channels (1, 2 or 4):

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

Hi EJ. Thanks. I should have said I'm interested in resizing the buffer in samples. This sort of seems to work, but seems like the display doesn't catch up properly..

Emmanuel Jourdan's icon

RIght. I can confirm the issue. the sizeinsamps doesn't refresh the buffer window. size works fine though in the meantime. It has been fixed for the next incremental.

Timo Rozendal's icon

nice coincidence: I am also busy with a c external today which changes the content and number of channels of buffers (in a seperate thread)

it works fine, changes and loads the channels correctly, though the waveform~ which appears when you doubleclick the buffer~ is not correctly updated:
-if it was 1 channel and now is 2 channels it will only display the left channel
-if it was 2 channels and now is 1 channel it will display the left channel twice

I do see that it responds on my 'dirty' message that I send to the maxobject and I properly set the b_oldnchans, is there something else I should do to ensure a proper waveform~ update?

pdelges's icon

EJ, did you also correct the reference for sizeinsamps?

BTW, when I try to create a size message thru the contextual menu of buffer~ leftmost inlet, I get a sendbox size $1 $2 message!

p

Timothy Place's icon

Thanks for the report, Patrick. I've fixed the size/sendbox thing for a future version of Max.

Cheers,
Tim

Timo Rozendal's icon

so?... how do you properly change and update the channels?