(Uzi) send CC to selected midi channels | ctlout

Buma's icon

Hi !
I'm looking for experienced users to give me their opinion about this subject.
I want to send random CC values to an external device. The CC parameter number is fixed, the value is randomised by an [expr random (0,127)] and I use a [ctlout] at the end. What changes is the midi channel.
For channel 1 to 8, I want to send a different value. And I want to simplify the patch and avoid duplicating the [ctlout] objects and having 8 of them for each CC parameter.

Max Patch
Copy patch and select New From Clipboard in Max.

So, I started with this :

It works well if I want to send a different value for CC parameter X, to channel 1 to 8 consecutively. But sometimes, I'd like to bypass channel 3 and 4, or 5 and 6 for example.
I'd like to add an option to choose which channels are selected and then, to which channel a value should be sent.
I'd like to avoid doing it with [gates] etc. I thought I could populate a list in [coll], count the number of elements in the list (n), bang uzi (n) times etc. But I 'm sure there's a simple way to do this, maybe with the ZL objects (and I'm not familiar with them yet), that's why I ask for your help...

How would you do that ?

Thank you !

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

If I tweak your patch a bit then all you have to do is send a list of the channels you want to change.

Buma's icon

Thank you for your reply Rick. But in this modification, the system sending (N) messages in a row is gone.
My question is how do I populate this list based on a selection made with checkboxes or toggle ?

Buma's icon

I found this solution which gives me the number of bangs for uzi and the midi channel numbers concerned, based on checkboxes state. I don't know if it's very elegant and for some reason, the list length never falls back to zero when all toggles are off.

Max Patch
Copy patch and select New From Clipboard in Max.

Now, I just have to find a way to 'connect' it to the rest of the patch.

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

I don't think you can get a list of size 0 in Max.
zl.filter doesn't output anything if it receives 0 0 0 0 0 0 0 0 as it filters out all datas in the list. To get a 0, you can do something like this:

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

With zl.sum you can find zero

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

Thanks a lot. I'm gonna adapt one of these solutions to my patch. In the meantime, I made this. That works almost fine. The zl.queue is not always updated, but close to the goal. Thanks again.

Buma's icon

And this is the final patch. It works fine this time.

Max Patch
Copy patch and select New From Clipboard in Max.

`