<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.apple-tab-span
        {mso-style-name:apple-tab-span;}
span.E-mailStijl18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=NL link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Hi, I’m not sure, but this seems to have to do something with your soundcard-driver. You probably need ASIO drivers, check out ASIO4ALL if you do not have an expensive soundcard… Then you will also need a ChucK version compiled with ASIO, to be found somewhere on this page: <a href="http://electro-music.com/forum/topic-18931.html">http://electro-music.com/forum/topic-18931.html</a>.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Good luck!<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>Van:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> chuck-users-bounces@lists.cs.princeton.edu [mailto:chuck-users-bounces@lists.cs.princeton.edu] <b>Namens </b>Kyle Hipke<br><b>Verzonden:</b> woensdag 24 augustus 2011 21:30<br><b>Aan:</b> chuck-users@lists.cs.princeton.edu<br><b>Onderwerp:</b> [chuck-users] Chuck Latency<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal style='margin-bottom:12.0pt'>I'm working on a project that requires low latency peak detection. But I'm struggling with the low-latency part. I'm not sure if there's just a problem with chuck, my code, or if my computer is slow. I'm on an Intel Core 2 Duo 2.13 GHz processor.<br>The following code illustrates the problem:<o:p></o:p></p><div><div><p class=MsoNormal>time chrono;<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Impulse i => dac;<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>adc => Gain g => OnePole p => blackhole;<o:p></o:p></p></div><div><p class=MsoNormal>adc => g;<o:p></o:p></p></div><div><p class=MsoNormal>3 => g.op;<o:p></o:p></p></div><div><p class=MsoNormal>.9999 => p.pole;<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>now => time start;<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>10::samp => dur peakPollRate;<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>//ADJUST THIS<o:p></o:p></p></div><div><p class=MsoNormal>.001 => float threshold;<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>spork ~makeImpulses();<o:p></o:p></p></div><div><p class=MsoNormal>while (1) {  <o:p></o:p></p></div><div><p class=MsoNormal>    if (p.last() > threshold) {<o:p></o:p></p></div><div><p class=MsoNormal>       <<< "peak at", (now - chrono) /ms >>>;<o:p></o:p></p></div><div><p class=MsoNormal>        .2::second => now;<o:p></o:p></p></div><div><p class=MsoNormal>    }<o:p></o:p></p></div><div><p class=MsoNormal>    <o:p></o:p></p></div><div><p class=MsoNormal>    peakPollRate => now;<o:p></o:p></p></div><div><p class=MsoNormal>}<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>fun void makeImpulses() {<o:p></o:p></p></div><div><p class=MsoNormal><span class=apple-tab-span>            </span>while (true) {<o:p></o:p></p></div><div><p class=MsoNormal><span class=apple-tab-span>                        </span>1 => i.next;<o:p></o:p></p></div><div><p class=MsoNormal><span class=apple-tab-span>                        </span>.8::second => now;<o:p></o:p></p></div><div><p class=MsoNormal><span class=apple-tab-span>                        </span><<< "Impulse at ", (now - start) / ms >>>;<o:p></o:p></p></div><div><p class=MsoNormal><span class=apple-tab-span>            </span>}<o:p></o:p></p></div><div><p class=MsoNormal>}<o:p></o:p></p></div></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>This code uses an impulse as a metronome and listens to the adc through a OnePole filter for peaks above a threshold.<br><br>Here's two ways to demonstrate the problem (you'll need speakers and a mic):<br>1. With headphones in, adjust the threshold as low as possible without picking up room noise (under //ADJUST THIS) then run the code. Make a percussive sound into your mic that coincides with one of the impulses, then kill chuck and look at the output. On my machine, it detects the peak ~200ms after the metronome, even though I made the sound immediately when I heard the metronome.<o:p></o:p></p></div><div><p class=MsoNormal>2. With speakers on, adjust the threshold and your speaker volume so that the Impulses are detected as peaks, but no room noise is. Run the program for a few clicks and kill it, then look at the output. On my machine, again, I get a ~200ms delay.<br><br>Do other people have this same problem? Why is this happening?<o:p></o:p></p></div></div></body></html>