Toggle Output Between Two Inputs

Dev Wright's icon

Hi, I have two input sources. I want to be able to push a toggle button and have one of the inputs sent to the output, depending on the state of the toggle. I've tried switch, select, pak, and other things to no avail. This is sorta stressing me out because of how simple it is.

Thanks.

Source Audio's icon

why not simple gswitch ?
or toggle -> +1 -> switch 2 1 ?


Dev Wright's icon

@ Source Audio

Thank you for your advice. I followed it, but it unfortunately did not work. I have attached a video detailing the problem I am having when I use the toggle switch. This may have more to do with the inputs to the switch device than the method of switching. Using the toggle switch does not send the corresponding input to the output, unless the message is clicked on or the value of the number box is changed.

Excuse the granulator thing

Dominik Dudek's icon

Something like this?

solution.maxpat
text/plain 3.69 KB

Pedro Santos's icon

I think this is what youu want:
a switch that pushes the last value of the chosen input and stays open in order to update it.

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

testcase's icon

I would do it this way -

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

Roman Thilenius's icon


"Using the toggle switch does not send the corresponding input"


which corresponding input? there is nothing what would correspond to a control message for gate/switch.

Pedro Santos's icon

@Roman:

which corresponding input? there is nothing what would correspond to a control message for gate/switch.

The data in the inputs of the gate/switch that is being controlled by the control message, since a control message on the left input of a gate/switch does not trigger anything by itself (cold inlet). Dev Wright wants to click on a toggle and switch between 2 different sources, but these sources are not continuous streams, so he wants the last value of that source to be pushed after toggling a switch.

@TestCase: such similarity with a 1-minute difference is noteworthy! I even had zl.reg initially (more universal) instead of "int" but changed it in the end for the patch to be more easily understood.

Roman Thilenius's icon


then i vote for the [i ] method.

#P window setfont "Sans Serif" 9.;
#P number 366 267 45 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 282 267 45 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 366 179 50 9109513 i;
#P newex 282 179 50 9109513 i;
#P newex 43 159 180 9109513 if $i1==0 then bang else out2 bang;
#P toggle 43 94 25 0;
#P number 366 91 45 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 282 91 45 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P connect 3 1 5 0;
#P connect 3 0 4 0;
#P connect 5 0 7 0;
#P connect 4 0 6 0;
#P connect 1 0 5 0;
#P connect 0 0 4 0;
#P connect 2 0 3 0;
#P window clipboard copycount 8;