File: win.ck

package info (click to toggle)
chuck 1.5.5.7-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 41,260 kB
  • sloc: cpp: 124,539; ansic: 35,893; javascript: 2,111; yacc: 609; makefile: 457; python: 174; perl: 86
file content (35 lines) | stat: -rw-r--r-- 606 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// our patch
SinOsc g => FFT fft => blackhole;
// synthesis
IFFT ifft => dac;
// set srate
second / samp => float srate;

// set parameters
1024 => fft.size;
// window
Windowing.hamming(512) => fft.window;
Windowing.hamming(512) => ifft.window;

// use this to hold contents
complex s[fft.size()/2];
// divide
int div;

// control loop
while( true )
{
    // set freq
    srate / fft.size() * div++ => g.freq;
    fft.size()/2 %=> div;
    
    // take fft
    fft.upchuck();
    // get contents
    fft.spectrum( s );
    // take ifft
    ifft.transform( s );

    // advance time
    256::samp => now;
}