<div dir="ltr">I noticed in the source code that there's a UAna that just does the domain change (Flip). That's exactly what was needed; no implementation change necessary. :)<div><br></div><div>Corrected example:<br><div><font face="monospace">SinOsc s => Flip f =^ AutoCorr c => blackhole;<br></font></div><div><font face="monospace">440 => s.freq;<br>1024 => f.size;</font></div><div><font face="monospace">f.size()::samp => now;<br>c.upchuck();<br></font><div><font face="monospace">Plot plot;<br>"autocorrelation of 440 hz, 1024 samples" => plot.title;<br>plot.plot(c.fvals());<br>100::ms => 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 <<a href="mailto:curtullerich@gmail.com">curtullerich@gmail.com</a>> 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'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 <<a href="mailto:curtullerich@gmail.com" target="_blank">curtullerich@gmail.com</a>> 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'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'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's the plotting code if anyone would like to repro:</div><div><font face="monospace">SinOsc s => FFT fft =^ AutoCorr c => blackhole;<br>4400 => s.freq;<br>128 => fft.size;<br>300::ms => now;<br>c.upchuck();<br>Plot plot;<br>"autocorrelation of 4400 hz, 128 samples" => plot.title;<br>plot.plot(c.fvals());<br>200::ms => 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>