example using SubNoise Ugen as a control signal
Unified · Split
| @@ -0,0 +1,27 @@ | ||
| 1 | +//------------------------------------------------------------------------------ | |
| 2 | +// name: subnoise_control.ck | |
| 3 | +// desc: demo showcasing the subnoise UGen as a control signal to modulate | |
| 4 | +// the frequency of a SinOsc | |
| 5 | +// | |
| 6 | +// SubNoise generates a random value between [-1, 1] every `rate` audio ticks. | |
| 7 | +// You can get/set the rate in code via the .rate() method. | |
| 8 | +// This example showcases uses SubNoise to randomly change the frequency of a | |
| 9 | +// SinOsc every half-second. | |
| 10 | +// | |
| 11 | +// author: azaday | |
| 12 | +// date: Spring 2023 | |
| 13 | +//------------------------------------------------------------------------------ | |
| 14 | +SubNoise sn => blackhole; | |
| 15 | +SinOsc osc => dac; | |
| 16 | + | |
| 17 | +// tell subnoise to only change its output every half second | |
| 18 | +.5::second => dur period; | |
| 19 | +(period/samp) $ int => sn.rate; | |
| 20 | +<<< "setting subnoise rate: " + sn.rate() >>>; | |
| 21 | + | |
| 22 | +repeat (10) { | |
| 23 | + // remap subnoise sample from [-1, 1] to an osc frequency in [220, 880]hz | |
| 24 | + Math.remap(sn.last(), -1.0, 1.0, 220.0, 880.0) => osc.freq; | |
| 25 | + <<< "remapping osc frequency to: " + osc.freq() >>>; | |
| 26 | + period => now; | |
| 27 | +} | |