| 1 |
//Under-sampling based resonant Lowpass filter by Kassen |
| 2 |
//Internal workings are explained in the source, for those who need that. |
| 3 |
//let's have a look at how to use it in practice here. |
| 4 |
|
| 5 |
chout <= "hi there! \n"; |
| 6 |
chout <= "Let's do some filtering! \n"; |
| 7 |
chout <= "Let's start with a simple example: \n"; |
| 8 |
chout <= "... \n"; |
| 9 |
chout.flush(); |
| 10 |
BlitSaw s => KasFilter kf => dac; //we use a BlitSaw because it doesn't alias. |
| 11 |
|
| 12 |
220 => s.freq; |
| 13 |
|
| 14 |
|
| 15 |
Envelope ramp => blackhole; //our modulation signal. |
| 16 |
|
| 17 |
220 => ramp.value; |
| 18 |
5::second => ramp.duration; |
| 19 |
5000 => ramp.target; |
| 20 |
|
| 21 |
while (ramp.value() < ramp.target()) |
| 22 |
{ |
| 23 |
ramp.value() => kf.freq; |
| 24 |
samp => now; |
| 25 |
} |
| 26 |
0 => s.freq; |
| 27 |
0 => s.op; |
| 28 |
|
| 29 |
chout <= "That sounded a bit like a filter and a bit like under-sampling, right? \n"; |
| 30 |
chout <= "That's because that's exactly what's going on. \n"; |
| 31 |
chout <= "But we can do more, we can add resonance to it, like a normal filter. \n"; |
| 32 |
chout <= "Let's try the same sweep again, but now with some resonance. \n"; |
| 33 |
chout <= "... \n"; |
| 34 |
chout.flush(); |
| 35 |
2::second => now; |
| 36 |
|
| 37 |
220 => s.freq; |
| 38 |
1 => s.op; |
| 39 |
|
| 40 |
220 => ramp.value; |
| 41 |
5::second => ramp.duration; |
| 42 |
5000 => ramp.target; |
| 43 |
.85 => kf.resonance; |
| 44 |
|
| 45 |
while (ramp.value() < ramp.target()) |
| 46 |
{ |
| 47 |
ramp.value() => kf.freq; |
| 48 |
samp => now; |
| 49 |
} |
| 50 |
0 => s.freq; |
| 51 |
0 => s.op; |
| 52 |
|
| 53 |
|
| 54 |
chout <= "With resonance there is a lot more emphasis on the filter sweep. \n"; |
| 55 |
chout <= "It also brings the artefacts of this technique more to the foreground. \n"; |
| 56 |
chout <= "That might be good or it could be bad, depending on what you want... \n"; |
| 57 |
chout <= "I quite like it, so we can go one step further; \n"; |
| 58 |
chout <= "We can also add a overdrive effect to this resonance, let's try that, \n"; |
| 59 |
chout <= "we'll also turn the frequency of the input way down for the occasion.... \n"; |
| 60 |
chout <= "... \n"; |
| 61 |
chout.flush(); |
| 62 |
2::second => now; |
| 63 |
|
| 64 |
8 => s.freq; |
| 65 |
1 => s.op; |
| 66 |
|
| 67 |
75 => ramp.value; |
| 68 |
5::second => ramp.duration; |
| 69 |
1000 => ramp.target; |
| 70 |
.75 => kf.accent; |
| 71 |
.95 => kf.resonance; |
| 72 |
|
| 73 |
while (ramp.value() < ramp.target()) |
| 74 |
{ |
| 75 |
ramp.value() => kf.freq; |
| 76 |
samp => now; |
| 77 |
} |
| 78 |
0 => s.freq; |
| 79 |
0 => s.op; |
| 80 |
chout <= "That's about it. \n"; |
| 81 |
chout <= "I found it's especially good for lo-fi acid techna, \n"; |
| 82 |
chout <= "it might be good for other things as well, \n"; |
| 83 |
chout <= "Have fun! \n"; |
| 84 |
chout.flush(); |
| 85 |
|
| 86 |
2::second => now; |
| 87 |
|
| 88 |
/* |
| 89 |
Documentation; |
| 90 |
kf.freq(float) //sets the cutoff frequency. |
| 91 |
This sets both the frequency at which the 2 sample&holds sample the input signal |
| 92 |
and the frequency of the sine that crossfades between them. |
| 93 |
kf.freq() //gets the cutoff frequency |
| 94 |
kf.resonance(float) //sets the resonance, which is implemented as negative feedback. |
| 95 |
accepts values between 0 and 0.95 |
| 96 |
kf.resonance() // gets the resonance. |
| 97 |
kf.accent(float) //sets the amount of waveshaping on the crossfading sine. |
| 98 |
Ranges from 0 to 1, where 1 is close to regular under-sampling |
| 99 |
(if no resonance is used). |
| 100 |
kf.accent() //gets the accent value. |
| 101 |
|
| 102 |
Please report bugs, problems or confusing bits to the ChucK mailing list. |
| 103 |
If that fails or you need me for some other reason try; |
| 104 |
signal [dot] automatique [at] gmail [another dot] com |
| 105 |
*/ |