Inverse toggle switch with multiple toggle inputs

Nick Penrod's icon

I'm working on something involving an HI device. With this, I have multiple things that, when held, will activate toggles, but when none are held, should active a separate toggle.

Here's screenshots of a separate patch representing this problem; everything above the toggles are just representative placeholderss.

Here's the clipboard for this mock-up:

{
    "patcher" :     {
        "fileversion" : 1,
        "appversion" :         {
            "major" : 8,
            "minor" : 1,
            "revision" : 0,
            "architecture" : "x64",
            "modernui" : 1
        }
,
        "classnamespace" : "box",
        "rect" : [ 84.0, 132.0, 880.0, 581.0 ],
        "bglocked" : 0,
        "openinpresentation" : 0,
        "default_fontsize" : 12.0,
        "default_fontface" : 0,
        "default_fontname" : "Arial",
        "gridonopen" : 1,
        "gridsize" : [ 15.0, 15.0 ],
        "gridsnaponopen" : 1,
        "objectsnaponopen" : 1,
        "statusbarvisible" : 2,
        "toolbarvisible" : 1,
        "lefttoolbarpinned" : 0,
        "toptoolbarpinned" : 0,
        "righttoolbarpinned" : 0,
        "bottomtoolbarpinned" : 0,
        "toolbars_unpinned_last_save" : 0,
        "tallnewobj" : 0,
        "boxanimatetime" : 200,
        "enablehscroll" : 1,
        "enablevscroll" : 1,
        "devicewidth" : 0.0,
        "description" : "",
        "digest" : "",
        "tags" : "",
        "style" : "",
        "subpatcher_template" : "",
        "boxes" : [             {
                "box" :                 {
                    "id" : "obj-31",
                    "maxclass" : "comment",
                    "numinlets" : 1,
                    "numoutlets" : 0,
                    "patching_rect" : [ 156.0, 430.0, 173.0, 20.0 ],
                    "presentation_linecount" : 2,
                    "text" : "Any toggle turned off, breaks"
                }

            }
,             {
                "box" :                 {
                    "id" : "obj-30",
                    "maxclass" : "comment",
                    "numinlets" : 1,
                    "numoutlets" : 0,
                    "patching_rect" : [ 156.0, 399.0, 150.0, 20.0 ],
                    "text" : "Multiple toggles on, works"
                }

            }
,             {
                "box" :                 {
                    "id" : "obj-29",
                    "maxclass" : "comment",
                    "numinlets" : 1,
                    "numoutlets" : 0,
                    "patching_rect" : [ 156.0, 370.0, 150.0, 20.0 ],
                    "text" : "One toggle on, works"
                }

            }
,             {
                "box" :                 {
                    "id" : "obj-27",
                    "linecount" : 6,
                    "maxclass" : "comment",
                    "numinlets" : 1,
                    "numoutlets" : 0,
                    "patching_rect" : [ 420.0, 161.0, 209.0, 89.0 ],
                    "text" : "I want the inverse-toggle to be on ONLY when ALL other toggles are off. Currently, if multiple toggles are on, and one turns off, it will trigger the inverse-toggle to turn back on when it shouldn't."
                }

            }
,             {
                "box" :                 {
                    "id" : "obj-145",
                    "maxclass" : "toggle",
                    "numinlets" : 1,
                    "numoutlets" : 1,
                    "outlettype" : [ "int" ],
                    "parameter_enable" : 0,
                    "patching_rect" : [ 406.0, 298.559565037488937, 24.0, 24.0 ]
                }

            }
,             {
                "box" :                 {
                    "fontname" : "Arial",
                    "fontsize" : 11.595186999999999,
                    "id" : "obj-143",
                    "maxclass" : "newobj",
                    "numinlets" : 2,
                    "numoutlets" : 1,
                    "outlettype" : [ "int" ],
                    "patching_rect" : [ 406.0, 256.0, 29.5, 22.0 ],
                    "text" : "!- 1"
                }

            }
,             {
                "box" :                 {
                    "id" : "obj-25",
                    "maxclass" : "message",
                    "numinlets" : 2,
                    "numoutlets" : 1,
                    "outlettype" : [ "" ],
                    "patching_rect" : [ 149.0, 286.0, 107.0, 22.0 ],
                    "text" : "chain further down"
                }

            }
,             {
                "box" :                 {
                    "id" : "obj-22",
                    "maxclass" : "newobj",
                    "numinlets" : 1,
                    "numoutlets" : 2,
                    "outlettype" : [ "list", "" ],
                    "patching_rect" : [ 175.0, 73.0, 29.5, 22.0 ],
                    "text" : "hi"
                }

            }
,             {
                "box" :                 {
                    "id" : "obj-21",
                    "maxclass" : "newobj",
                    "numinlets" : 6,
                    "numoutlets" : 6,
                    "outlettype" : [ "", "", "", "", "", "" ],
                    "patching_rect" : [ 175.0, 112.0, 93.0, 22.0 ],
                    "text" : "route A B C D E"
                }

            }
,             {
                "box" :                 {
                    "id" : "obj-19",
                    "maxclass" : "number",
                    "numinlets" : 1,
                    "numoutlets" : 2,
                    "outlettype" : [ "", "bang" ],
                    "parameter_enable" : 0,
                    "patching_rect" : [ 365.0, 161.0, 50.0, 22.0 ]
                }

            }
,             {
                "box" :                 {
                    "id" : "obj-20",
                    "maxclass" : "toggle",
                    "numinlets" : 1,
                    "numoutlets" : 1,
                    "outlettype" : [ "int" ],
                    "parameter_enable" : 0,
                    "patching_rect" : [ 365.0, 206.0, 24.0, 24.0 ]
                }

            }
,             {
                "box" :                 {
                    "id" : "obj-15",
                    "maxclass" : "number",
                    "numinlets" : 1,
                    "numoutlets" : 2,
                    "outlettype" : [ "", "bang" ],
                    "parameter_enable" : 0,
                    "patching_rect" : [ 313.0, 161.0, 50.0, 22.0 ]
                }

            }
,             {
                "box" :                 {
                    "id" : "obj-16",
                    "maxclass" : "toggle",
                    "numinlets" : 1,
                    "numoutlets" : 1,
                    "outlettype" : [ "int" ],
                    "parameter_enable" : 0,
                    "patching_rect" : [ 313.0, 206.0, 24.0, 24.0 ]
                }

            }
,             {
                "box" :                 {
                    "id" : "obj-13",
                    "maxclass" : "number",
                    "numinlets" : 1,
                    "numoutlets" : 2,
                    "outlettype" : [ "", "bang" ],
                    "parameter_enable" : 0,
                    "patching_rect" : [ 261.0, 161.0, 50.0, 22.0 ]
                }

            }
,             {
                "box" :                 {
                    "id" : "obj-14",
                    "maxclass" : "toggle",
                    "numinlets" : 1,
                    "numoutlets" : 1,
                    "outlettype" : [ "int" ],
                    "parameter_enable" : 0,
                    "patching_re

inverse toggle problem.maxpat
Max Patch

Pedro Santos's icon

Hint: if you sum all the values and the result is "0" you want "1". If it's not, you want "0".

Another thing: your "!- 1" box is only processing the last value that is sent to it, it has no memory of previous ones.