Checking amount of channels in a buffer

Apr 10, 2012 at 2:28pm

Checking amount of channels in a buffer

How can you get how many audio channels a buffer has ? (I’m trying to use it with a polybuffer) It has to be cpu efficient so I don’t want to read the file from the disk.

#62878
Apr 11, 2012 at 10:01am

Actually, i’m not sure that you can. You can ask for that for a soundfile using sfinfo~, but it seems info~ doesn’t offer the same feature. I suggest trying using cues via sflist~ and such anyway, as it’s not consuming so much more cpu than multiple buffers from my own experience : I came across the same problem earlier, and here’s a possibly buggy workaround i used first, before switching everything to the sflist~ system (also because i needed ram memory) :

– Pasted Max Patch, click to expand. –

the aim of this is to duplicate the ch1 output into where ch2 should go, if and only if there is strictly nothing coming out the ch2 output. If you don’t use a peakamp~ before checking if it’s == 0, it’s all buggy because zero crossing is obviously a common thing in time domain. There is probably a better way to detect if a signal is continuously equal to 0, in ways allowing to stay in signal time-domain (like with 2 thresh~maybe ?) but you get the idea.

#226989
Apr 11, 2012 at 7:40pm

Sending a getChannels message to [mxj buf.Op] will do it,
Cheers
Roger

#226990
Apr 12, 2012 at 12:27pm

Hello,
wonderful ! thanks ! is that part of the default distribution ? so many (nearly)hidden things…

#226991
Apr 12, 2012 at 1:05pm

buf.Op is nice, but I had trouble with it when the patch is built as an app.

I just found a [gen~] solution… for Max6 users.

– Pasted Max Patch, click to expand. –
#226992
Apr 13, 2012 at 10:36am

doesn’t seem to work here ?… yes it doesn’t work, because the gen patcher in your patch is empty. the copy compressed feature probably doesn’t work well for gen subpatchers.

#226993
Apr 13, 2012 at 12:07pm

You’re right!
Here it goes!

#226994
Apr 14, 2012 at 4:17pm

Thanks ! ahso it seems like a new gen~ feature… seems there is even an operator, [channel], that is specifically there for reporting a buffer number of channels !

#226995

You must be logged in to reply to this topic.