<div dir="ltr">I noticed in the source code that there&#39;s a UAna that just does the domain change (Flip). That&#39;s exactly what was needed; no implementation change necessary. :)<div><br></div><div>Corrected example:<br><div><font face="monospace">SinOsc s =&gt; Flip f =^ AutoCorr c =&gt; blackhole;<br></font></div><div><font face="monospace">440 =&gt; s.freq;<br>1024 =&gt; f.size;</font></div><div><font face="monospace">f.size()::samp =&gt; now;<br>c.upchuck();<br></font><div><font face="monospace">Plot plot;<br>&quot;autocorrelation of 440 hz, 1024 samples&quot; =&gt; plot.title;<br>plot.plot(c.fvals());<br>100::ms =&gt; now;<br></font></div><div><br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jul 23, 2020 at 11:14 PM Curtis Ullerich &lt;<a href="mailto:curtullerich@gmail.com">curtullerich@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I believe I found the bug. I sent a <a href="https://github.com/ccrma/chuck/pull/151" target="_blank">pull request</a> with the fix and a lengthy description. xcorr_fft is taking the FFT of the input, but the upstream unit of the XCorr/AutoCorr UAnae is <a href="https://github.com/ccrma/chuck/blob/main/src/core/uana_extract.cpp#L1210" target="_blank">already required to be a UAna</a> (so, it&#39;s already an FFT).</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 21, 2020 at 1:07 AM Curtis Ullerich &lt;<a href="mailto:curtullerich@gmail.com" target="_blank">curtullerich@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">As a preamble, I&#39;ll note that I posted a question on chuck-dev about AutoCorr/XCorr always crashing for me. <a href="https://github.com/ccrma/chuck/pull/150" target="_blank">This patch</a> seems to fix that.<div><br></div><div>That said, I don&#39;t understand the results I get from AutoCorr. For periodic inputs, I expect to see periodicity in the output. For small FFT sample sizes, I see the expected peak at 0, and at large sample sizes I see a second peak at the end of the window. See example plots at <a href="https://i.ibb.co/BBZXgBB/autocorr-128.png" target="_blank">128</a> and <a href="https://i.ibb.co/Mn5fty5/autocorr-4096.png" target="_blank">4096</a>. That second peak is correlated with the window size, not the input frequency.</div><div><br></div><div>Thanks to Mario for his <a href="https://github.com/mariobuoninfante/ChucK_various" target="_blank">gnuplot wrapper</a> that captured those plots.</div><div><br></div><div>Here&#39;s the plotting code if anyone would like to repro:</div><div><font face="monospace">SinOsc s =&gt; FFT fft =^ AutoCorr c =&gt; blackhole;<br>4400 =&gt; s.freq;<br>128 =&gt; fft.size;<br>300::ms =&gt; now;<br>c.upchuck();<br>Plot plot;<br>&quot;autocorrelation of 4400 hz, 128 samples&quot; =&gt; plot.title;<br>plot.plot(c.fvals());<br>200::ms =&gt; now;<br></font></div><div><br></div><div>Should I be using AutoCorr differently? Am I looking at the power spectrum or something, and not the correlation vector like I think I am? My current understanding comes from reading uana_extract.cpp many times with references like <a href="http://paulbourke.net/miscellaneous/correlate/" target="_blank">this</a>.</div><div><br></div><div>Thanks,</div><div>Curtis</div></div>
</blockquote></div>
</blockquote></div>