Debian Codegraph @

examples/effects/chorus.ck

raw
1 //------------------------------------------------------------------------------
2 // name: chorus.ck
3 // desc: basic demo of the Chorus UGen
4 //
5 // The Chorus UGen adds a chorus effect to a signal. Chorus refers to an audio
6 // effect in which multiple sounds occur close together in time, and with
7 // similar pitch. The slight deviations in pitch and time are generally small
8 // enough such that the signals are not perceived as being out-of-tune. The
9 // effect is often described as adding "shimmer", "richness", or "complexity"
10 // to the timbre. When implemented digitally, the chorus effect is acheived by
11 // taking a source signal, and mixing it with delayed copies of itself. The
12 // pitch of these copies is usually modulated using another signal like an LFO.
13 // In ChucK, you can adjust the depth and frequency of this modulation of pitch,
14 // as well as the amount of delay and how much of the chorus effect is present
15 // in the mix.
16 //
17 // author: Alex Han
18 // date: Spring 2023
19 //------------------------------------------------------------------------------
20
21 // set up signal chain
22 SinOsc s[4]; Chorus chor[4];
23 // chorus often "shines" best with polyphonic textures!
24 [62, 65, 69, 72] @=> int notes[];
25
26 // connect
27 for( int i; i < s.size(); i++ )
28 {
29 // patch each voice
30 s[i] => chor[i] => dac;
31
32 // sine wave as source signal
33 s[i].gain( .2 );
34 s[i].freq( Std.mtof(notes[i]) );
35
36 // initializing a light chorus effect
37 // (try tweaking these values!)
38 chor[i].baseDelay( 10::ms );
39 chor[i].modDepth( .4 );
40 chor[i].modFreq( 1 );
41 chor[i].mix( .2 );
42 }
43
44 // time loop
45 while( true )
46 {
47 // nothing to do here except advance time
48 1::second => now;
49 }