Accurate LCD timer?


    Sep 07 2007 | 7:32 pm
    I've been trying to build a 'control' patch for a composition I wrote
    some years ago.
    I cobbled together something from examples in archives for an LCD based timer.
    I got it working alright, but it isn't accurate at all. The period
    between seconds is irregular, it sometimes skips numbers, if I set the
    milliseconds to work, it lags behind if I have other things
    running(making sure all the millisecond counts go through?)
    Also, sometimes the numbers in the LCD seem to draw on the edge, or
    off the LCD itself, with no way to get them back. (The patch worked
    fine at first, now all the numbers are off the LCD screen)
    There has to be an easier way to get a large, accurate, effecient
    timer going in max.
    I'm surprised there isn't a default object for this, since stopwatches
    are pretty standard in contemporary music.
    Also, I was going to use the time produced from the stopwatch to
    mute/unmute audio running through the patch as well. I looked at
    timeline, but decided it'd be simpler to use a long select
    object(select 0 28 32 45 58 112 etc..) being fed by the raw seconds of
    the timer. Is there a more effecient way to do this?
    Basically I'd like to get the structural part of the patch as
    effecient as possible, to leave CPU free for audio based concerns. And
    of course the timer needs to be airtight, since everything else is
    based on it.
    heres the patch(the numbers are drawing off the LCD screen at the moment)
    max v2;

    • Sep 07 2007 | 11:19 pm
      If you need an accurate timer i would suggest you base you timing on an audio rate object such as phasor~ as in my patch below. If you are running other audio it's a reliable way to keep the two worlds in sync as you can drive the timer and other audio objects from one master phasor~.
      The problem with using tick based timing from the date object is that you have to poll date with a metro who's timing is based on the max scheduler who's timing varies - search archive for more info on this.
      Personally i find the ms readout fairly useless as it's not easy for musicians to follow and means you have to redraw the LCD much more often. Instead I've added flashing separators to give a sense of time passing between seconds.
    • Sep 07 2007 | 11:32 pm
      Ah i just realised i made an error in how the mins tick over - easy to solve but i don't have time right now....
    • Sep 08 2007 | 12:57 am
      thats perfect!
      i figured it would need some kind of audio domain control, but ive
      never worked with LCD before, or non metro based timing either, so i
      was a bit in the dark as to how to fix it
      i fixed the minute wrapping over as well,
      thats a good method for punctuating the passing time, simple but effective
      i changed it to just one "." flashing after the second display, so it
      doesnt 'feel' like a clock that doesnt have the time set where the
      12:00 flashing
      thanks
      On 9/8/07, Leafcutter John wrote:
      >
      > If you need an accurate timer i would suggest you base you timing on an audio rate object such as phasor~ as in my patch below. If you are running other audio it's a reliable way to keep the two worlds in sync as you can drive the timer and other audio objects from one master phasor~.
      >
      > The problem with using tick based timing from the date object is that you have to poll date with a metro who's timing is based on the max scheduler who's timing varies - search archive for more info on this.
      >
      > Personally i find the ms readout fairly useless as it's not easy for musicians to follow and means you have to redraw the LCD much more often. Instead I've added flashing separators to give a sense of time passing between seconds.
      >
      > #P window setfont "Sans Serif" 9.;
      > #P window linecount 1;
      > #P comment 384 53 61 196617 turn me on!;
      > #P toggle 366 52 15 0;
      > #P newex 366 76 31 196617 dac~;
      > #P button 48 30 15 0;
      > #P toggle 15 29 15 0;
      > #N vpatcher 12 66 612 466;
      > #P inlet 208 73 15 0;
      > #P inlet 124 61 15 0;
      > #P outlet 157 283 15 0;
      > #P window setfont "Sans Serif" 9.;
      > #P window linecount 0;
      > #P newex 129 95 41 196617 sel 0 1;
      > #P window linecount 1;
      > #P newex 157 247 70 196617 snapshot~ 10;
      > #P message 212 135 14 196617 0;
      > #P message 129 158 14 196617 0;
      > #P flonum 241 154 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
      > #P message 146 158 55 196617 0.000001;
      > #P newex 157 185 94 196617 phasor~;
      > #P connect 8 0 6 0;
      > #P connect 6 0 3 0;
      > #P connect 6 1 1 0;
      > #P connect 1 0 0 0;
      > #P connect 3 0 0 0;
      > #P connect 0 0 5 0;
      > #P connect 5 0 7 0;
      > #P connect 9 0 4 0;
      > #P connect 2 0 0 1;
      > #P connect 4 0 0 1;
      > #P pop;
      > #P newobj 15 60 43 196617 p timer;
      > #N vpatcher 282 80 931 671;
      > #P origin -240 -20;
      > #P window setfont "Sans Serif" 9.;
      > #P window linecount 1;
      > #P newex 269 90 27 196617 t f f;
      > #P newex 428 288 27 196617 i;
      > #P newex 68 161 40 196617 change;
      > #P newex 68 208 41 196617 sel 0 1;
      > #P newex 68 140 27 196617 i;
      > #P newex 68 184 27 196617 % 2;
      > #P newex 68 120 41 196617 * 200.;
      > #P newex 434 347 141 196617 sprintf write %.2i.%.2i.%.2i;
      > #P inlet 327 24 15 0;
      > #P window linecount 0;
      > #P message 329 46 14 196617 0;
      > #P window linecount 1;
      > #P newex 483 292 27 196617 t b i;
      > #P newex 483 241 27 196617 i;
      > #P newex 270 291 27 196617 i;
      > #P newex 483 268 40 196617 change;
      > #P newex 268 71 53 196617 * 10000.;
      > #P message 287 467 158 196617 clear , font 5 150 , moveto 5 135;
      > #P newex 270 432 27 196617 t l b;
      > #P outlet 287 530 15 0;
      > #P window linecount 0;
      > #P newex 270 347 143 196617 sprintf write %.2i:%.2i:%.2i;
      > #P newex 398 182 68 196617 expr $f1-$i2;
      > #P newex 483 206 33 196617 * 60.;
      > #P newex 302 134 68 196617 expr $f1-$i2;
      > #P newex 371 159 33 196617 * 60.;
      > #P newex 286 109 34 196617 / 36.;
      > #P inlet 268 47 15 0;
      > #P fasten 24 0 18 0 274 113 73 113;
      > #P connect 18 0 20 0;
      > #P connect 20 0 22 0;
      > #P connect 22 0 19 0;
      > #P connect 19 0 21 0;
      > #P fasten 15 0 10 0 334 64 273 64;
      > #P connect 0 0 10 0;
      > #P connect 10 0 24 0;
      > #P fasten 14 0 12 0 488 316 314 316 314 285 275 285;
      > #P connect 12 0 6 0;
      > #P connect 17 0 8 0;
      > #P connect 6 0 8 0;
      > #P connect 24 1 1 0;
      > #P connect 1 0 12 1;
      > #P connect 8 1 9 0;
      > #P connect 9 0 7 0;
      > #P fasten 8 0 7 0 275 506 292 506;
      > #P fasten 1 0 3 0 291 131 307 131;
      > #P connect 16 0 15 0;
      > #P connect 2 0 6 1;
      > #P fasten 1 0 3 1 291 130 365 130;
      > #P fasten 3 0 2 0 307 155 376 155;
      > #P fasten 2 0 5 0 376 178 403 178;
      > #P fasten 14 1 6 2 505 319 407 319;
      > #P fasten 21 1 23 0 88 256 433 256;
      > #P connect 23 0 17 0;
      > #P connect 1 0 23 1;
      > #P fasten 2 0 5 1 376 178 461 178;
      > #P fasten 5 0 4 0 403 203 488 203;
      > #P connect 4 0 13 0;
      > #P connect 13 0 11 0;
      > #P connect 11 0 14 0;
      > #P connect 2 0 17 1;
      > #P connect 14 1 17 2;
      > #P pop;
      > #P newobj 15 98 59 196617 p h:m:s:ms;
      > #P hidden comment -102 617 100 196617 cound down by lcd?;
      > #P user lcd 15 122 715 159 1 1 0 0 0;
      > #P hidden comment -102 599 100 196617 add timeline?;
      > #P comment 75 63 229 196617 you can time just over 275hrs using this method;
      > #P connect 9 0 8 0;
      > #P connect 7 0 5 1;
      > #P fasten 7 0 4 1 53 56 69 56;
      > #P connect 6 0 5 0;
      > #P connect 5 0 4 0;
      > #P connect 4 0 2 0;
      > #P window clipboard copycount 11;
      >
      > --
      > http://www.leafcutterjohn.com
      >
      > "The Forest And The Sea"
      > Out on Staubgold Records
      > Staubgold 68 CD/LP
      >
    • Sep 08 2007 | 1:18 pm
      I'm glad that was useful to you. Would you mind posting the correction so others can use it?
      Thanks,
      J.
    • Sep 08 2007 | 1:51 pm
      Indeed, mybad.
      I did truncate it down to just Minutes:Seconds, with a period flashing
      at the end.
      And I added a 'raw seconds' output, for timing other things off of it.
      max v2;
      On 9/8/07, Leafcutter John wrote:
      >
      > I'm glad that was useful to you. Would you mind posting the correction so others can use it?
      >
      > Thanks,
      >
      > J.
      > --
      > http://www.leafcutterjohn.com
      >
      > "The Forest And The Sea"
      > Out on Staubgold Records
      > Staubgold 68 CD/LP
      >
    • Sep 08 2007 | 9:15 pm
      Rodrigo Constanzo schrieb:
      > I cobbled together something from examples in archives for an LCD based timer.
      >
      > I got it working alright, but it isn't accurate at all. The period
      > between seconds is irregular, it sometimes skips numbers, if I set the
      > milliseconds to work, it lags behind if I have other things
      > running(making sure all the millisecond counts go through?)
      I first wanted to point you to my St.opwatch abstraction, to find out
      you seem to have found an older version of it in the archives... ;-)
      To make it working for you, you just need to make the metro bang faster.
      Then it wouldn't skip seconds. use something like 100 ms...
      Then I'd just take a prepend set and a maximized message box instead of
      the LCD, way easier...
      There is one advantage over the audiorate example. It doesn't need a
      snapshot (very expensive) and it would count correct if you switch off
      audio, and even would survive and keep the correct time if you set the
      computer to sleep... ;-)
      Stefan
      --
      Stefan Tiedje------------x-------
      --_____-----------|--------------
      --(_|_ ----|-----|-----()-------
      -- _|_)----|-----()--------------
      ----------()--------www.ccmix.com
    • Sep 10 2007 | 8:03 pm
      how did you get the message-box (and/or the font) so big??
      thanks for a hint
      ole
    • Sep 13 2007 | 6:46 pm
      Ole Schmidt schrieb:
      > how did you get the message-box (and/or the font) so big??
      >
      > thanks for a hint
      If you open a patch with a message box as text, you see some numbers and
      since 4.5x or so even a font size line. They can be changed and the
      repasted...
      Look at the differences between my patch and a normal size...
      Once you have bigger than allowed messageboxes create some prototypes
      for the messagebox to have them handy whenever you need them...
      Stefan
      --
      Stefan Tiedje------------x-------
      --_____-----------|--------------
      --(_|_ ----|-----|-----()-------
      -- _|_)----|-----()--------------
      ----------()--------www.ccmix.com