Tell me what I am doing wrong! (problem with counter object)

Jun 29, 2008 at 4:01pm

Tell me what I am doing wrong! (problem with counter object)

I am trying to make a subpatch that counts up to a value at a random speed; then when it hits the max or minumum, waits a random length of time, then counts down. The logical way to do this would seem to be with the ‘counter’ object, but I haven’t come up with a way of shutting it off that works (I am using ‘metro’ to control it). I’m certain I am doing something wrong, as it ramps fine, but the delay/stop mechanism doesn’t. This is probably something simple that I am missing.

Here’s the patch, as it stands now (don’t worry that the ‘kill’ switch isn’t wired up):

{
“patcher” : {
“fileversion” : 1,
“rect” : [ 123.0, 157.0, 691.0, 551.0 ],
“bglocked” : 0,
“defrect” : [ 123.0, 157.0, 691.0, 551.0 ],
“openrect” : [ 0.0, 0.0, 0.0, 0.0 ],
“openinpresentation” : 0,
“default_fontsize” : 12.0,
“default_fontface” : 0,
“default_fontname” : “Arial”,
“gridonopen” : 0,
“gridsize” : [ 15.0, 15.0 ],
“gridsnaponopen” : 0,
“toolbarvisible” : 1,
“boxanimatetime” : 200,
“imprint” : 0,
“metadata” : [ ],
“boxes” : [ {
"box" : {
"maxclass" : "comment",
"text" : "kill",
"fontsize" : 12.0,
"numoutlets" : 0,
"patching_rect" : [ 122.0, 35.0, 22.0, 20.0 ],
“id” : “obj-27″,
“fontname” : “Arial”,
“numinlets” : 1
}

}
, {
“box” : {
“maxclass” : “comment”,
“text” : “start”,
“fontsize” : 12.0,
“numoutlets” : 0,
“patching_rect” : [ 72.0, 34.0, 35.0, 20.0 ],
“id” : “obj-26″,
“fontname” : “Arial”,
“numinlets” : 1
}

}
, {
“box” : {
“maxclass” : “button”,
“numoutlets” : 1,
“outlettype” : [ "bang" ],
“patching_rect” : [ 117.0, 60.0, 20.0, 20.0 ],
“id” : “obj-23″,
“numinlets” : 1
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “del”,
“fontsize” : 12.0,
“numoutlets” : 1,
“outlettype” : [ "bang" ],
“patching_rect” : [ 286.0, 389.0, 32.5, 20.0 ],
“id” : “obj-16″,
“fontname” : “Arial”,
“numinlets” : 2
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “random 6000″,
“fontsize” : 12.0,
“numoutlets” : 1,
“outlettype” : [ "int" ],
“patching_rect” : [ 286.0, 359.0, 81.0, 20.0 ],
“id” : “obj-17″,
“fontname” : “Arial”,
“numinlets” : 2
}

}
, {
“box” : {
“maxclass” : “message”,
“text” : “stop”,
“fontsize” : 12.0,
“numoutlets” : 1,
“outlettype” : [ "" ],
“patching_rect” : [ 286.0, 329.0, 33.0, 18.0 ],
“id” : “obj-18″,
“fontname” : “Arial”,
“numinlets” : 2
}

}
, {
“box” : {
“maxclass” : “button”,
“numoutlets” : 1,
“outlettype” : [ "bang" ],
“patching_rect” : [ 286.0, 299.0, 20.0, 20.0 ],
“id” : “obj-19″,
“numinlets” : 1
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “del”,
“fontsize” : 12.0,
“numoutlets” : 1,
“outlettype” : [ "bang" ],
“patching_rect” : [ 196.0, 389.0, 32.5, 20.0 ],
“id” : “obj-13″,
“fontname” : “Arial”,
“numinlets” : 2
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “random 6000″,
“fontsize” : 12.0,
“numoutlets” : 1,
“outlettype” : [ "int" ],
“patching_rect” : [ 196.0, 359.0, 81.0, 20.0 ],
“id” : “obj-10″,
“fontname” : “Arial”,
“numinlets” : 2
}

}
, {
“box” : {
“maxclass” : “message”,
“text” : “stop”,
“fontsize” : 12.0,
“numoutlets” : 1,
“outlettype” : [ "" ],
“patching_rect” : [ 196.0, 329.0, 33.0, 18.0 ],
“id” : “obj-9″,
“fontname” : “Arial”,
“numinlets” : 2
}

}
, {
“box” : {
“maxclass” : “button”,
“numoutlets” : 1,
“outlettype” : [ "bang" ],
“patching_rect” : [ 196.0, 299.0, 20.0, 20.0 ],
“id” : “obj-7″,
“numinlets” : 1
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “metro”,
“fontsize” : 12.0,
“numoutlets” : 1,
“outlettype” : [ "bang" ],
“patching_rect” : [ 136.0, 194.0, 41.0, 20.0 ],
“id” : “obj-6″,
“fontname” : “Arial”,
“numinlets” : 2
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “random 500″,
“fontsize” : 12.0,
“numoutlets” : 1,
“outlettype” : [ "int" ],
“patching_rect” : [ 175.0, 168.0, 75.0, 20.0 ],
“id” : “obj-4″,
“fontname” : “Arial”,
“numinlets” : 2
}

}
, {
“box” : {
“maxclass” : “number”,
“fontsize” : 12.0,
“numoutlets” : 2,
“outlettype” : [ "int", "bang" ],
“patching_rect” : [ 136.0, 299.0, 50.0, 20.0 ],
“id” : “obj-3″,
“fontname” : “Arial”,
“numinlets” : 1
}

}
, {
“box” : {
“maxclass” : “button”,
“numoutlets” : 1,
“outlettype” : [ "bang" ],
“patching_rect” : [ 86.0, 61.0, 20.0, 20.0 ],
“id” : “obj-2″,
“numinlets” : 1
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “counter 2 0 60″,
“fontsize” : 12.0,
“numoutlets” : 4,
“outlettype” : [ "int", "", "", "int" ],
“patching_rect” : [ 136.0, 224.0, 87.0, 20.0 ],
“id” : “obj-1″,
“fontname” : “Arial”,
“numinlets” : 5
}

}
],
“lines” : [ {
"patchline" : {
"source" : [ "obj-6", 0 ],
“destination” : [ "obj-1", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-1", 0 ],
“destination” : [ "obj-3", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-1", 1 ],
“destination” : [ "obj-7", 0 ],
“hidden” : 0,
“midpoints” : [ 168.166672, 284.0, 205.5, 284.0 ]
}

}
, {
“patchline” : {
“source” : [ "obj-7", 0 ],
“destination” : [ "obj-9", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-9", 0 ],
“destination” : [ "obj-6", 0 ],
“hidden” : 0,
“midpoints” : [ 205.5, 347.0, 121.0, 347.0, 121.0, 191.0, 145.5, 191.0 ]
}

}
, {
“patchline” : {
“source” : [ "obj-13", 0 ],
“destination” : [ "obj-2", 0 ],
“hidden” : 0,
“midpoints” : [ 205.5, 411.0, 72.0, 411.0, 72.0, 57.0, 95.5, 57.0 ]
}

}
, {
“patchline” : {
“source” : [ "obj-19", 0 ],
“destination” : [ "obj-18", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-1", 2 ],
“destination” : [ "obj-19", 0 ],
“hidden” : 0,
“midpoints” : [ 190.833328, 284.0, 295.5, 284.0 ]
}

}
, {
“patchline” : {
“source” : [ "obj-16", 0 ],
“destination” : [ "obj-2", 0 ],
“hidden” : 0,
“midpoints” : [ 295.5, 421.0, 71.0, 421.0, 71.0, 58.0, 95.5, 58.0 ]
}

}
, {
“patchline” : {
“source” : [ "obj-18", 0 ],
“destination” : [ "obj-6", 0 ],
“hidden” : 0,
“midpoints” : [ 295.5, 347.0, 271.0, 347.0, 271.0, 200.0, 178.0, 200.0, 178.0, 191.0, 145.5, 191.0 ]
}

}
, {
“patchline” : {
“source” : [ "obj-10", 0 ],
“destination” : [ "obj-13", 1 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-10", 0 ],
“destination” : [ "obj-13", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-7", 0 ],
“destination” : [ "obj-10", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-19", 0 ],
“destination” : [ "obj-17", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-17", 0 ],
“destination” : [ "obj-16", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-17", 0 ],
“destination” : [ "obj-16", 1 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-2", 0 ],
“destination” : [ "obj-4", 0 ],
“hidden” : 0,
“midpoints” : [ 95.5, 82.0, 173.0, 82.0, 173.0, 163.0, 184.5, 163.0 ]
}

}
, {
“patchline” : {
“source” : [ "obj-4", 0 ],
“destination” : [ "obj-6", 1 ],
“hidden” : 0,
“midpoints” : [ 184.5, 188.0, 167.5, 188.0 ]
}

}
, {
“patchline” : {
“source” : [ "obj-2", 0 ],
“destination” : [ "obj-6", 0 ],
“hidden” : 0,
“midpoints” : [ 95.5, 81.0, 72.0, 81.0, 72.0, 180.0, 145.5, 180.0 ]
}

}
]
}

}

#38650
Jun 29, 2008 at 4:09pm

Whoops. I apparently can’t edit the original post. Here’s the patch in ‘compressed’ format.

– Pasted Max Patch, click to expand. –
#134953
Jun 29, 2008 at 5:56pm

Notice that the Hit Minimum and Mit Maximum outlets of counter sets the
flag, it doesn’t send bang!

– Pasted Max Patch, click to expand. –

jr.abstractions for MaxMSP – new version (2008-06-11)

http://www.sonicescape.net/maxmsp/

#134954
Jun 29, 2008 at 6:14pm

On Jun 29, 2008, at 9:01 AM, toddbert wrote:

> I am trying to make a subpatch that counts up to a value at a random
> speed; then when it hits the max or minumum, waits a random length
> of time, then counts down. The logical way to do this would seem to
> be with the ‘counter’ object, but I haven’t come up with a way of
> shutting it off that works (I am using ‘metro’ to control it). I’m
> certain I am doing something wrong, as it ramps fine, but the delay/
> stop mechanism doesn’t. This is probably something simple that I am
> missing.

You’ll be much happier with your current patch if you set the
counter’s “Carry Flag Output” to “bang” in the inspector:

– Pasted Max Patch, click to expand. –

Chris Muir
cbm@well.com

http://www.xfade.com

#134955
Jun 29, 2008 at 6:24pm

Thanks. I think I was looking at it too long. :-)

#134956

You must be logged in to reply to this topic.