47 lines · 1.1 KB · Text
RawDownload
// name: xcorr.ck// desc: calculting how much delay is applied to a signal// author: Curtis Ullerich // signal sourceSndBuf signal => dac;// delayed signalsignal => DelayL delay => dac;// load sound"special:dope" => signal.read;// randomize delayMath.random2f(100, 400)$int => int delayMs;// set delaydelayMs::ms => delay.max => delay.delay;// set gain0.8 => signal.gain; // set analysissignal => Flip f1 =^ XCorr xcorr => blackhole;delay => Flip f2 =^ xcorr;(second/samp)$int => int srate; // will get bumped to the next power of two for the actual// Fourier transformsignal.samples() + delayMs*srate/1000 => float size;// FFT sizessize$int => f1.size => f2.size;// waitsignal.samples()::samp + delayMs::ms => now;// analyze!xcorr.upchuck(); // iterate0 => int maxI;for (0 => int i; i < size; i++){    // look for max    if (xcorr.fval(i) >= xcorr.fval(maxI)) {        i => maxI;    }} // print<<< "    actual delay was", delayMs, "milliseconds" >>>;<<< "calculated delay was", 1000*maxI/srate$float, "milliseconds" >>>;// wait1::second => now;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t