<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Very interesting, I'd love to see more info, like the numbers and the patch you used to run these tests.  Its a good start.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>.hc</DIV><BR><DIV><DIV>On Jul 19, 2006, at 10:35 AM, rubber glove wrote:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite">I managed to run some tests on the HID timing. <BR><BR>The contestants were:<BR>-regular HID object in OS X<BR>-regular HID object in OS X with blocksize=64<BR> -dissected HID object in OS X<BR>   (i basically tore the read functions out of the hid code, and put them in my own object, which was recording the values. I did a messy, quick job of it, but...)<BR>-ctlin midi object in os x <BR>-regular HID object in Linux<BR><BR>the winner, with &lt; 4 ms of timing error was:<BR><BR>linux... I was short on time in the lab (getting the eMac machines booting off the livecd took a bit of time), so I wasn't able to try out different latency settings, or try the midi controller in linux. <BR><BR>the others were all approximately the same, at around or just above a 10 ms spread in timing offsets (I don't have the numbers in front of me.... but One interesting thing is the standard deviation. it seems like mostly the timing error is very close to a mean value, then periodically, there will be a value that is way off, which throws off the average. I haven't made enough measurements to see if there is some sort of periodicity to those 'way off' readings, maybe due to some process switching/memory management by the kernel?) <BR><BR>the smaller blocksize did slightly better than the default setting, the dissected object did slightly better than that...<BR>so I would hazard the guess that the delays due to control message passing are not a huge contribution. <BR><BR>and for some reason, the midi object did even worse than the hid object. not at all sure why that is, but it could have to do with the midi devices I was using - who knows. <BR><BR>One thing I realize I should have done is try pd in os x as superuser, as this may give the process a higher priority? I ran sudo pd in linux to have access to the hid devices... <BR><BR>I'm not sure how much more experimentation I will be doing on this, as they are pretty satisfied with &lt; 5 ms error and probably won't pay me to just play around with their expensive timing test equipment....<BR> <BR> <BR>-martin<BR><BR><DIV><SPAN class="gmail_quote">On 7/5/06, <B class="gmail_sendername">Hans-Christoph Steiner</B> &lt;<A href="mailto:hans@eds.org">hans@eds.org</A>&gt; wrote:</SPAN><BLOCKQUOTE class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> <DIV><DIV style=""></DIV><DIV><SPAN class="e" id="q_10c3d342273abfee_1"><BR><DIV><DIV>On Jul 4, 2006, at 10:08 AM, rubber glove wrote:</DIV><BR><BLOCKQUOTE type="cite"><BR><DIV><BLOCKQUOTE class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> The main factor seems to be that pd only processes control messages in<BR> between audio frames. Reducing the audio latency seems to bring the<BR>jitter down to about 5ms but no further when I try it on WinXP or Linux.</BLOCKQUOTE> <DIV><BR>Aha... that makes sense to me. So it is not so much just the 'hardware to pd' step, but also the control message passing within PD that is throwing off the timing here. <BR><BR> </DIV><BLOCKQUOTE class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> I would expect USB to add more jitter, as it passes through a more <BR>complex path than serial or MIDI data before being handed to pd.</BLOCKQUOTE><DIV><BR>I think I am basically stuck with USB no matter how I go, as the computers involved here are all eMacs. Using midi or serial would involve a USB interface anyway. <BR><BR> </DIV><BLOCKQUOTE class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">If you need better timing, why not record the audio into one channel<BR>along with the button on the other channel? There is essentially no <BR>jitter with the audio stream because it passes through the sound <BR>hardware at a fixed rate. The button could just emit a click when<BR>pressed. Then you have no jitter beyond the time it takes to push the<BR>button. </BLOCKQUOTE><DIV><BR>That's an interesting possibility, but I am only really using the button clicking as a simple way to test the timing. In actual use, the input would be a range of values from the rotary encoder of the knob... converting that into audio and back into numerical values seems altogether too complicated (frequency modulation?) <BR> </DIV></DIV>However, it brings to mind other possibilities: <BR><BR>If I modify the HID object to convert it into a signal-based external, then pass the values as signals, the timing should be much tighter?  This seems to have the advantage that the input values will always be automatically lined up with the audio, no matter what the latency is set to. <BR><BR>Alternatively, If I incorporate the HID code into my external, and process the knob events myself, I would avoid any additional timing errors and be left with only the jitter inherent to the device, no?<BR><BR>Thanks much for the info...  <BR></BLOCKQUOTE><BR></DIV></SPAN></DIV><DIV><DIV>I would also like to see the [<SPAN id="st" name="st" class="st">hid</SPAN>] code be as low jitter as possible.  I haven't had a chance to measure it yet tho.  Unless things are really taxing the CPU, I don't think that the Pd messaging will cause more than ~1.5ms of jitter (1 block of 64 samples divided by 44100 samples).  Perhaps running Pd at 96KHz or 192KHz would reduce that jitter, provided that the block size remains 64. </DIV><DIV><BR></DIV><DIV>I think that the first step is to devise some tests to find the true source of the jitter.  I did some quick searches about USB <SPAN id="st" name="st" class="st">HID</SPAN> jitter and didn't find much, except this: </DIV><DIV><BR></DIV><DIV><A href="http://elists.resynthesize.com/max-msp/2005/08/1515529/" title="http://elists.resynthesize.com/max-msp/2005/08/1515529/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"> http://elists.resynthesize.com/max-msp/2005/08/1515529/</A></DIV><DIV><BR></DIV><DIV>It seems that this person thinks that Mac OS X's USB MIDI driver has lower jitter than the USB <SPAN id="st" name="st" class="st">HID</SPAN> driver.  Ultimately, if we find the source of the problem, I would like to include it in the next version of [<SPAN id="st" name="st" class="st">hid</SPAN>].</DIV><DIV><BR></DIV><DIV>.hc</DIV><DIV><BR></DIV><DIV><SPAN style="border-collapse: separate; border-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"> <DIV><BR></DIV><DIV>------------------------------------------------------------------------</DIV><DIV><BR></DIV><DIV>Using ReBirth is like trying to play an 808 with a long stick.    -David Zicarelli</DIV><BR></SPAN> </DIV> <BR></DIV> </DIV></BLOCKQUOTE></DIV><BR></BLOCKQUOTE></DIV><BR><DIV> <SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><P style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><BR></P><DIV>------------------------------------------------------------------------</DIV><P style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px"><BR></P><P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica">If you are not part of the solution, you are part of the problem.        </FONT><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica">- Eldridge Cleaver</FONT></P><BR class="Apple-interchange-newline"></SPAN> </DIV><BR></BODY></HTML>