[chuck-users] AutoCorr behavior

Curtis Ullerich curtullerich at gmail.com
Sun Jul 26 20:06:14 EDT 2020


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. :)

Corrected example:
SinOsc s => Flip f =^ AutoCorr c => blackhole;
440 => s.freq;
1024 => f.size;
f.size()::samp => now;
c.upchuck();
Plot plot;
"autocorrelation of 440 hz, 1024 samples" => plot.title;
plot.plot(c.fvals());
100::ms => now;


On Thu, Jul 23, 2020 at 11:14 PM Curtis Ullerich <curtullerich at gmail.com>
wrote:

> I believe I found the bug. I sent a pull request
> <https://github.com/ccrma/chuck/pull/151> 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 already required to be a UAna
> <https://github.com/ccrma/chuck/blob/main/src/core/uana_extract.cpp#L1210> (so,
> it's already an FFT).
>
> On Tue, Jul 21, 2020 at 1:07 AM Curtis Ullerich <curtullerich at gmail.com>
> wrote:
>
>> As a preamble, I'll note that I posted a question on chuck-dev about
>> AutoCorr/XCorr always crashing for me. This patch
>> <https://github.com/ccrma/chuck/pull/150> seems to fix that.
>>
>> 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 128
>> <https://i.ibb.co/BBZXgBB/autocorr-128.png> and 4096
>> <https://i.ibb.co/Mn5fty5/autocorr-4096.png>. That second peak is
>> correlated with the window size, not the input frequency.
>>
>> Thanks to Mario for his gnuplot wrapper
>> <https://github.com/mariobuoninfante/ChucK_various> that captured those
>> plots.
>>
>> Here's the plotting code if anyone would like to repro:
>> SinOsc s => FFT fft =^ AutoCorr c => blackhole;
>> 4400 => s.freq;
>> 128 => fft.size;
>> 300::ms => now;
>> c.upchuck();
>> Plot plot;
>> "autocorrelation of 4400 hz, 128 samples" => plot.title;
>> plot.plot(c.fvals());
>> 200::ms => now;
>>
>> 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 this <http://paulbourke.net/miscellaneous/correlate/>.
>>
>> Thanks,
>> Curtis
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20200726/fd747850/attachment.html>


More information about the chuck-users mailing list