Using Paulstretch Mono algorithm as a starting point, I used the Chuck programming language to generate the track.
I am aware it is indeed quite a boring / droning track but as my first foray into audio synthesis, it will do for now.
Here is the Chuck code I used for the track:
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
SndBuf buff => FFT fft =^ IFFT ifft => blackhole;
Impulse imp => LPF lpf => blackhole;
dac => WvOut w => blackhole;
lpf => PitShift ps1 => dac;
lpf => PitShift ps2 => dac;
lpf => PitShift ps3 => dac;
1000 => lpf.freq;
0.25 => ps1.shift;
0.5 => ps1.gain;
2 => ps2.shift;
0.8 => ps2.gain;
0.125 => ps3.shift;
0.5 => ps3.gain;
30.0 => float stretch;
5 :: second => dur window_dur;
me.sourceDir () + "/cc.wav" => string filename;
buff.read (filename);
buff.samples () / (buff.length () / 1 :: second) => float sample_rate;
me.sourceDir () + "/output_cc.wav" => w.wavFilename;
((window_dur / 1 :: second) * sample_rate) $ int => int window_size;
(window_size / 2 ) $ int => int half_window_size;
window_size => fft.size;
Windowing.hann (window_size) => fft.window;
Windowing.hann (window_size) => ifft.window;
complex s[half_window_size];
float ifft_s[window_size];
float old_ifft_s[half_window_size];
(1 + Math.sqrt (0.5 ))* 0.5 => float hinv_sqrt2;
float hinv_buf[half_window_size];
for (int i; i hinv_buf[i];
}
0 => int start_pos;
(half_window_size / stretch) $ int => int displace_pos;
// control loop
while ( start_pos buff.pos;
fft.upchuck ();
fft.spectrum (s);
polar pol;
for (int i; i pol;
Math.random2f (0 , 2 * pi) => pol.phase;
pol $ complex => s[i];
}
ifft.transform (s);
ifft.samples (ifft_s);
float output;
for (int i; i output;
ifft_s[i+ half_window_size] => old_ifft_s[i];
if (output > 1.0 ) {
1.0 => output;
} else if (output output;
}
output => imp.next;
1 :: samp => now;
}
displace_pos +=> start_pos;
}
There needs to be an input file named “cc.wav” in the same directory as the .ck file (for my track, I used the song “Creataceous Chasm” by Blotted Science ). An output Wav file can be obtained with the command:
chuck --silent stretch_simple.ck
(Unfortunately, my stretch algorithm produces audible clicks in real-time mode so “–silent” must be used)
For contrast, here is a video for the Blotted Science song used as input:
VIDEO