Debian Codegraph @

examples/book/digital-artists/chapter7/Listing7.10.ck

raw
1 // Listing 7.10 Spectral modeling using the ModalBar UGen: a struck glass sound
2
3 // Synthesize a modal glass sound from spectral model
4 ModalBar glass => dac;
5
6 [1206.0,2240.0,3919.0,5965.0] @=> float modeFreqs[];
7 [100.0,93.0,97.0,92.0] @=> float modeGainsdB[];
8 [0.9999,0.9997,0.9998,0.9996] @=> float modeRadii[];
9
10 for (0 => int i; i < 4; i++) {
11 i => glass.mode;
12 // (1) Sets frequency of each mode as ratio with zero-eth mode.
13 modeFreqs[i]/modeFreqs[0] => glass.modeRatio;
14 // (2) Uses dbtorms() to get a gain from a dB magnitude.
15 Std.dbtorms(modeGainsdB[i]) => glass.modeGain;
16 // (3) Radius sets decay time.
17 modeRadii[i] => glass.modeRadius;
18 }
19
20 // set to first mode frequency, set gain too
21 1206 => glass.freq;
22 0.2 => glass.gain;
23
24 // whack it!!!
25 1 => glass.noteOn;
26 3.0 :: second => now;