Monome button press question
Hello. I'm fairly new to max and I was hoping someone could help. Basically you press a button on the monome grid and it gives you an x, y, z(1/on) coordinate. When you release it it sends x, y, z(0/off). By changing the order with $ and using route 1 for the on off press I can make it so that you press once for on and a second time for off. Using an if then statement, I can sort of filter out buttons that I don't want to do that (sometimes I want the normal button down 1 button up 0, or press once and it stays down until an event happens).
I was wondering if there was a better way to do that than write a different object for each button.
i hope that I made that clear. Here's the code:
{
"boxes" : [ {
"box" : {
"maxclass" : "comment",
"text" : "left path press-on release-off",
"linecount" : 2,
"style" : "",
"numinlets" : 1,
"id" : "obj-22",
"numoutlets" : 0,
"patching_rect" : [ 111.0, 561.0, 154.0, 34.0 ]
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "
"linecount" : 2,
"style" : "",
"numinlets" : 1,
"id" : "obj-5",
"numoutlets" : 0,
"patching_rect" : [ 307.0, 222.0, 150.0, 34.0 ]
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "if $i2 == 4 && $i1 == 2 then $i1 $i2 $i3 else out2 $i1 $i2 $i3",
"linecount" : 4,
"outlettype" : [ "", "" ],
"style" : "",
"numinlets" : 3,
"id" : "obj-19",
"numoutlets" : 2,
"patching_rect" : [ 437.0, 490.0, 111.0, 64.0 ]
}
}
, {
"box" : {
"maxclass" : "message",
"text" : "/monome/grid/led/set 1 4 1",
"linecount" : 2,
"outlettype" : [ "" ],
"style" : "",
"numinlets" : 2,
"id" : "obj-18",
"numoutlets" : 1,
"patching_rect" : [ 307.0, 490.0, 94.0, 36.0 ]
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "if $i2 == 4 && $i1 == 1 && $i3 == 1 then bang else out2 $i1 $i2 $i3",
"linecount" : 4,
"outlettype" : [ "", "" ],
"style" : "",
"numinlets" : 3,
"id" : "obj-15",
"numoutlets" : 2,
"patching_rect" : [ 366.0, 386.0, 110.0, 64.0 ]
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "s onepress",
"style" : "",
"numinlets" : 1,
"id" : "obj-14",
"numoutlets" : 0,
"patching_rect" : [ 72.0, 266.0, 100.0, 22.0 ]
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "s monomelights",
"style" : "",
"numinlets" : 1,
"id" : "obj-9",
"numoutlets" : 0,
"patching_rect" : [ 265.0, 607.5, 100.0, 22.0 ]
}
}
, {
"box" : {
"maxclass" : "message",
"text" : "/monome/grid/led/set 0 4 1",
"linecount" : 2,
"outlettype" : [ "" ],
"style" : "",
"numinlets" : 2,
"id" : "obj-7",
"numoutlets" : 1,
"patching_rect" : [ 268.0, 360.0, 94.0, 36.0 ]
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "if $i2 == 4 && $i1 == 0 && $i3 == 1 then bang else out2 $i1 $i2 $i3",
"linecount" : 4,
"outlettype" : [ "", "" ],
"style" : "",
"numinlets" : 3,
"id" : "obj-3",
"numoutlets" : 2,
"patching_rect" : [ 268.0, 277.5, 106.0, 64.0 ]
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "r monomelights",
"outlettype" : [ "" ],
"style" : "",
"numinlets" : 0,
"id" : "obj-2",
"numoutlets" : 1,
"patching_rect" : [ 132.0, 66.0, 100.0, 22.0 ]
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "right path -- press buttonc twice for on/off",
"linecount" : 2,
"style" : "",
"numinlets" : 1,
"id" : "obj-37",
"numoutlets" : 0,
"patching_rect" : [ 617.0, 301.5, 168.0, 34.0 ]
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "s twopress",
"style" : "",
"numinlets" : 1,
"id" : "obj-33",
"numoutlets" : 0,
"patching_rect" : [ 681.0, 183.0, 100.0, 22.0 ]
}
}
, {
"box" : {
"maxclass" : "message",
"text" : "$1 $2 inc",
"outlettype" : [ "" ],
"style" : "",
"numinlets" : 2,
"id" : "obj-20",
"numoutlets" : 1,
"patching_rect" : [ 505.0, 381.0, 81.0, 22.0 ]
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "route 1",
"outlettype" : [ "", "" ],
"style" : "",
"numinlets" : 2,
"id" : "obj-17",
"numoutlets" : 2,
"patching_rect" : [ 505.0, 347.0, 100.0, 22.0 ]
}
}
, {
"box" : {
"maxclass" : "message",
"text" : "$3 $1 $2",
"outlettype" : [ "" ],
"style" : "",
"numinlets" : 2,
"id" : "obj-16",
"numoutlets" : 1,
"patching_rect" : [ 505.0, 305.0, 90.0, 22.0 ]
}
}
, {
"box" : {
"maxclass" : "matrixctrl",
"outlettype" : [ "list", "list" ],
"style" : "",
"presentation_rect" : [ 15.0, 15.0, 130.0, 130.0 ],
"rows" : 8,
"numinlets" : 1,
"id" : "obj-12",
"numoutlets" : 2,
"patching_rect" : [ 515.5, 29.0, 130.0, 130.0 ],
"parameter_enable" : 0
}
}
, {
"box" : {
"maxclass" : "message",
"text" : "/monome/grid/led/set $1 $2 $3",
"outlettype" : [ "" ],
"style" : "",
"numinlets" : 2,
"id" : "obj-11",
"numoutlets" : 1,
"patching_rect" : [ 169.0, 110.0, 187.0, 22.0 ]
}
}
, {
"box" : {
"maxclass" : "matrixctrl",
"outlettype" : [ "list", "list" ],
"autosize" : 1,
"style" : "",
"presentation_rect" : [ 0.0, 0.0, 128.0, 128.0 ],
"rows" : 8,
"numinlets" : 1,
"id" : "obj-8",
"numoutlets" : 2,
"patching_rect" : [ 124.0, 305.0, 130.0, 130.0 ],
"parameter_enable" : 0
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "route /monome/grid/key",
"outlettype" : [ "", "" ],
"style" : "",
"numinlets" : 2,
"id" : "obj-6",
"numoutlets" : 2,
"patching_rect" : [ 138.0, 222.0, 148.0, 22.0 ]
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "serialosc",
"outlettype" : [ "", "int", "", "" ],
"style" : "",
"numinlets" : 2,
"id" : "obj-1",
"numoutlets" : 4,
"patching_rect" : [ 139.0, 160.0, 100.0, 22.0 ]
}
}
],
"lines" : [ {
"patchline" : {
"source" : [ "obj-7", 0 ],
"destination" : [ "obj-9", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-6", 0 ],
"destination" : [ "obj-8", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-6", 0 ],
"destination" : [ "obj-3", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-6", 0 ],
"destination" : [ "obj-14", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-3", 0 ],
"destination" : [ "obj-7", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-3", 1 ],
"destination" : [ "obj-15", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-20", 0 ],
"destination" : [ "obj-12", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-2", 0 ],
"destination" : [ "obj-1", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-19", 1 ],
"destination" : [ "obj-16", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-19", 0 ],
"destination" : [ "obj-11", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-18", 0 ],
"destination" : [ "obj-9", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-17", 0 ],
"destination" : [ "obj-20", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-16", 0 ],
"destination" : [ "obj-17", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-15", 1 ],
"destination" : [ "obj-19", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-15", 0 ],
"destination" : [ "obj-18", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-12", 0 ],
"destination" : [ "obj-33", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-12", 0 ],
"destination" : [ "obj-11", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-11", 0 ],
"destination" : [ "obj-1", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-1", 0 ],
"destination" : [ "obj-6", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
],
"appversion" : {
"major" : 7,
"minor" : 2,
"revision" : 3,
"architecture" : "x86",
"modernui" : 1
}
}
I appreciate the help. Thanks
Ishmael
It's unclear from the example what you want to do exactly, but this do what you want?
(when copy/pasting code to share use the "copy compressed" from the edit menu, as it's much tidier)
Hey Rodrigo, thanks for the response. Basically I want to do with everything but 3 or 4 buttons. I can do it running serialosc into a few if/then chains, ex: [if $i2 == 4 && $i1 == 0 && $i3 == 1 then bang else out2 $i1 $i2 $i3], but I was just wondering if there was a better way.
I'm actually making a random sampler/performance patch for monome with your karma~ object. Nothing like TPV of course. It ended up working with the monome on Max 7 btw save a couple dozen waveform~:unknown message tickmarkcolor.
Thanks,
Ishmael
It still depends on what you want to do. For example, in TPV I'll route one button (using similar [if] objects) to its own set of controls and pass everything else elsewhere, or send a whole row somewhere etc...
I try to condense things down into as few if's as possible, as it can be hard to read otherwise (as you're finding out!).
This might do what you want:
Ah cool about karma~, really handy object!
The waveform~ tickmarkercolor can be ignored. They just removed that message from waveform~ in Max7. Doesn't really effect anything in functionality (although TPV crashes in Max7 for me in general).
Yea I see what you mean. For example if you want row the first two buttons in row four stay on until some other function stops it, you can filter out row four (y) using an if statemet , then use a greater than for the x coordinate with an out2 $i1 $i2 $i3 for the rest.
I actually figured out how to make pages on the monome looking at your pages subpatcher in TPV.
Thanks for everything, you're a huge help.
Happy to help.
And yeah you've got the idea.
The way I did the paging in TPV is not a great way to do it as it's based around UI objects, but it's easy to visualize. More recently I'm using a tweaked version of the 'Grid Monitor' from the BEAP suite as it can handle all kinds of monome messages (most of the monome stuff nowadays is varibrightness so matrixctrl doesn't really cut it anymore).