History

Adding subnoise examples. Part 1: subnoise-control.ck

example using SubNoise Ugen as a control signal

AndrewAday committed 3 years ago

Commit bf05c091 parent 854e0501 file · +27 −0Browse files

Unified · Split

examples/stk/subnoise-control.ck+27−0
@@ -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+}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t