L (mono) / R type input switch

jbl's icon

I'm working on a few modules that I'm building hoping to be able to re-use them in many projects, so it has to be versatile. I often have mono sources and stereo sources.

At the moment, I switch between both using a button. But I would like it to be automatic based on the signal. The problem I am foreseeing is if I have a stereo input that I pan all the way to the left, It will detect it as a mono signal and I don't want that.

Do you guys have any ideas on how to detect whether the signal is mono or stereo that wouldn't get confused when I pan the signal?

3751.xyfade.maxpat
Max Patch
AudioLemon's icon

if you load the audio into a buffer you can use [mxj buf.Op your_named_buffer] to get the number of channels - if you are doing it live maybe you could use a peakamp~ to check if any signal is coming into both channels and if not you could trigger a switch to send a single channel to both (do your panning after that stage) - or you could make an abstraction with a creation argument stating the number of channels in advance. Too late now to make an example but it might help.

jbl's icon

Right now I'm having it so it detects if there is something coming in the right channel. The sacrifice of not being able to pan all the way to the left doesn't seem that terrible, it is just my perfectionism that made me want to fix this. Panning after isn't a bad idea, but I know I will do some panning before because these sources aren't from max, they are from hardware.

I guess there's a way to feed all my external sources into buffers and have these played in my patcher.. but that seems to be overkill simply to detect the number of channels for each of my sources.