Clock with ms definition

    Mar 26 2011 | 3:18 pm
    I need to have a clock in a patch that start to count when it receives a time message from another patch. Example, the first patch send a msg: 13:52:22:982031, the second patch read the content and start to count from that time. This is my implementation but I would like to know if there is any object with precise clock in Max, [date] has just tick as smallest definition.

    • Mar 26 2011 | 6:06 pm
      Looking at the help file says "can be used to time real world events with microsecond precision" but if I monitor it at a constant (1000ms) rate with a [metro] object, I get different results, with high differences up to 23ms error. The problem could be both in the metro object and the cpuclock, I am doing this test in two computers, one is a macbook and a low performance netbook. I get the biggest differences between time results in the netbook. I noticed also with other tests that this time differences are accentuated when the computers are under high cpu usage. My main purpose is to run in this two computer a clock that would give me a costant time reference in both of them but this shift is creating obviously some problems.
      From the helpfile of the cpuclock, I get that the output of cpuclock is the time elapsed in ms from the moment the application was launched, so the smallest value is 1ms. Am I right?
    • Mar 26 2011 | 7:37 pm
      Make sure to eliminate the influence of monitoring, for example by collecting the values in a list before printing. When doing this I get quite exact values with differences less than 0.1ms!
    • Mar 26 2011 | 10:44 pm
      Thanks, I do not get the same precision as you but is better without lists, but I have not tested on the netbook yet. Anyway how do you truncate a decimal number taking only the last two digits of it? I have tried with [sprintf %.2f] but does not work. the fact is that i am dealing with big numbers as, 14705867.976603 , apart from the fact that I do not need all that decimal points but just one or two, I think I am going over the capabilities of Max for the 32bit.
    • Mar 28 2011 | 10:40 am
      I am not entirely surprised about [metro 1000] showing 23ms deviation. That's sort of high, but if you were expecting 0 deviation that was simply illusory.
      In re: sprintf… you might try the symout option.
    • Mar 28 2011 | 1:06 pm
      @ vanille bechamel I looked at the sched_test already but only on my main computer, the mac, but i did not on the netbook. I am posting here the patch that you are curious to see, it is not a benchmark patch, but a patch I need to read the cpuclock in order to use it as an indication for other duties. The 23ms was an high peak anyway and not a constant variation on the netbook, on the other two computers, where I tested, the variations were always in the order of 2 ms, maximum. Removing message boxes and other lists the variation diminished even more. I think a problem with the netbook when I did the test was the fact that I was collecting all the result in a [coll] object, the patch I am showing you now is then an old and wrong version. I have all the results in a text file collected in the [coll] object from the netbook.
      @ Peter Castine I did not expect 0 deviation but was a big surprise anyway to see even 2ms variations. I thought that that the maximum would be around 0.1ms, but I was wrong. :) using the symout option seems to work but if i need to convert the symbol again into a number seems to restore part of the decimal number I previously rounded, the fun part is that it does it just when I am using as source to round the values from the cpuclock object. The second problem is that as soon as some time elapse since I open Max, and the cpuclock numbers are getting bigger, when I connect the cpuclock output to a floatnum it loses definition in the decimals.
    • Mar 28 2011 | 6:31 pm
      i think it is a scary (and cool) test. i get 2.5ms with overdrive off and between wide spectrum of 0.7 and 1.1 with overdrive on. maybe i need to optimise my system a bit more?!...
    • Mar 30 2011 | 6:37 am
      What do you need this precision for? Any scheduler event has a jitter/variance of about what you experience. The CPU clock is still very exact, the variance is only due to the moment you look at it. Inside its absolutely precise. The only application I can think of where this variance within the scheduler interval is not acceptable is combining sounds in MSP (which would change the sound, not the rhythm/timing). But there you have a sampling rate, and could use that as reference. Just never leave the audio domain.
      For anything else, 1.1 ms is more than adequate. Keep overdrive on, and you can tweak the scheduler parameters in the preferences. For sure a netbook has more difficulties to pack all scheduler events together. You might create a backlog...
    • Mar 30 2011 | 12:24 pm
      I agree that 23ms seems high. OTOH, you referred earlier to a "low performance netbook". Depending on your patch and how you're measuring things, yeah, sure.
      On the "rounding" front: are you aware of how 32-bit floats work? I don't want to sound rude, but math in Max makes a *lot* more sense after spending a bit of time with a tutorial on digital arithmetic. There's a very good tutorial by Peter Elsea on this subject specifically for Max
    • Oct 19 2011 | 10:07 am
      your idea is great . Sorry to say that i am unable to answer but definitely i will give you a link through whch you will be able to find your solution.math tutors
    • Nov 02 2011 | 1:37 pm
      Having difficulty working out Math problems? Stuck with your homework and having nightmares before your next Math test? TutorVista's tutors can help you. get you online tutoring