Forums > MaxMSP

timer question

July 7, 2010 | 7:03 am

Hi,

Is there a smart way to make a timer that counds minutes, seconds and reports milli seconds every 100 milliseconds?

I would like to set this kind of timer to a specific value at any given time, and then the timer should just continue to count from the set time value given in minutes, seconds and milliseconds.

I have tried to do something with metros and counters, but it has become a hazzle to solve it in that way … any better ideas?

Thanks ahead!

ana


July 7, 2010 | 7:57 am

i am not sure if you ask this
but .. (just copy paste in a new patcher-requires max5)

{
"boxes" : [ {
"box" : {
"maxclass" : "number",
"outlettype" : [ "int", "bang" ],
"fontname" : "Arial Black",
"presentation_rect" : [ 180.0, 310.0, 0.0, 0.0 ],
"numinlets" : 1,
"id" : "obj-23",
"patching_rect" : [ 178.0, 313.0, 50.0, 19.0 ],
"numoutlets" : 2,
"fontsize" : 9.0
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "% 60",
"outlettype" : [ "int" ],
"fontname" : "Arial Black",
"numinlets" : 2,
"id" : "obj-22",
"patching_rect" : [ 178.0, 286.0, 35.0, 19.0 ],
"numoutlets" : 1,
"fontsize" : 9.0
}

}
, {
"box" : {
"maxclass" : "number",
"outlettype" : [ "int", "bang" ],
"fontname" : "Arial Black",
"presentation_rect" : [ 124.0, 309.0, 0.0, 0.0 ],
"numinlets" : 1,
"id" : "obj-20",
"patching_rect" : [ 124.0, 312.0, 50.0, 19.0 ],
"numoutlets" : 2,
"fontsize" : 9.0
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "/ 60",
"outlettype" : [ "int" ],
"fontname" : "Arial Black",
"numinlets" : 2,
"id" : "obj-21",
"patching_rect" : [ 124.0, 285.0, 32.5, 19.0 ],
"numoutlets" : 1,
"fontsize" : 9.0
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "/ 1000",
"outlettype" : [ "int" ],
"fontname" : "Arial Black",
"numinlets" : 2,
"id" : "obj-15",
"patching_rect" : [ 178.0, 252.0, 40.0, 19.0 ],
"numoutlets" : 1,
"fontsize" : 9.0
}

}
, {
"box" : {
"maxclass" : "toggle",
"outlettype" : [ "int" ],
"numinlets" : 1,
"id" : "obj-14",
"patching_rect" : [ 247.0, 105.0, 18.0, 18.0 ],
"numoutlets" : 1
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "metro 100",
"outlettype" : [ "bang" ],
"fontname" : "Arial Black",
"numinlets" : 2,
"id" : "obj-12",
"patching_rect" : [ 247.0, 145.0, 61.0, 19.0 ],
"numoutlets" : 1,
"fontsize" : 9.0
}

}
, {
"box" : {
"maxclass" : "button",
"outlettype" : [ "bang" ],
"numinlets" : 1,
"id" : "obj-11",
"patching_rect" : [ 230.0, 143.0, 20.0, 20.0 ],
"numoutlets" : 1
}

}
, {
"box" : {
"maxclass" : "number",
"outlettype" : [ "int", "bang" ],
"fontname" : "Arial Black",
"numinlets" : 1,
"id" : "obj-9",
"patching_rect" : [ 246.0, 207.0, 65.0, 19.0 ],
"numoutlets" : 2,
"fontsize" : 9.0
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "timer",
"outlettype" : [ "float", "" ],
"fontname" : "Arial Black",
"numinlets" : 2,
"id" : "obj-5",
"patching_rect" : [ 230.0, 175.0, 36.0, 19.0 ],
"numoutlets" : 2,
"fontsize" : 9.0
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "timer",
"outlettype" : [ "float", "" ],
"fontname" : "Arial Black",
"numinlets" : 2,
"id" : "obj-1",
"patching_rect" : [ 306.0, 477.0, 36.0, 19.0 ],
"numoutlets" : 2,
"fontsize" : 9.0
}

}
],
"lines" : [ {
"patchline" : {
"source" : [ "obj-22", 0 ],
"destination" : [ "obj-23", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-15", 0 ],
"destination" : [ "obj-22", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-15", 0 ],
"destination" : [ "obj-21", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-21", 0 ],
"destination" : [ "obj-20", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-5", 0 ],
"destination" : [ "obj-15", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-14", 0 ],
"destination" : [ "obj-11", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-14", 0 ],
"destination" : [ "obj-12", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-12", 0 ],
"destination" : [ "obj-5", 1 ],
"hidden" : 0,
"midpoints" : [ ]
}

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

}
, {
"patchline" : {
"source" : [ "obj-11", 0 ],
"destination" : [ "obj-5", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
]
}


July 7, 2010 | 8:06 am

@ tada.

just for your own personal knowledge. to post patches up on the forum that dont take up so much room.
highlight the parts of the patch that you want to copy on the forum, then go to edit and click on ‘copy compressed’.
this will give a much smaller code which will do the exact same as the code as you had posted, but much smaller.

lewis edwards
——
smokingbunny.co.uk


July 7, 2010 | 8:11 am

thank you.. wise advise :)


July 7, 2010 | 8:41 am

I’d probably use [accum] to do this, it would make it very simple to reset the timer to whenever you like. Poll it with a [metro 100] that adds 100 each time. Then you can use the modulo/divide method to split it into minutes, seconds and milliseconds.

lh


Viewing 5 posts - 1 through 5 (of 5 total)