Merge pull request #506 from andrewcsmith/patch-2
[supercollider.git] / HelpSource / Classes / Gendy3.schelp
blob9bb9907376e0caec02fdb608c072eb5120ef9e8c
1 class:: Gendy3
2 summary:: Dynamic stochastic synthesis generator.
3 related:: Classes/Gendy1, Classes/Gendy2
4 categories::  UGens>Generators>Stochastic
7 Description::
9 See  link::Classes/Gendy1::  help file for background. This variant of
10 GENDYN normalises the durations in each period to force oscillation at
11 the desired pitch. The breakpoints still get perturbed as in
12 link::Classes/Gendy1:: .
14 There is some glitching in the oscillator caused by the stochastic
15 effects - control points as they vary cause big local jumps of amplitude.
16 Put  code::ampscale::  and  code::durscale::
17 low to minimise the rate of this.
19 SuperCollider implementation by Nick Collins
21 classmethods::
23 method::ar, kr
25 argument::ampdist
27 Choice of probability distribution for the next perturbation of
28 the amplitude of a control point.
30 The distributions are (adapted from the GENDYN program in Formalized Music):
32 table::
33 ## 0: || LINEAR.
34 ## 1: || CAUCHY.
35 ## 2: || LOGIST.
36 ## 3: || HYPERBCOS.
37 ## 4: || ARCSINE.
38 ## 5: || EXPON.
39 ## 6: || SINUS.
42 Where the sinus (Xenakis' name) is in this implementation taken
43 as sampling from a third party oscillator. See example below.
46 argument::durdist
48 Choice of distribution for the perturbation of the current inter
49 control point duration.
52 argument::adparam
54 A parameter for the shape of the amplitude probability
55 distribution, requires values in the range 0.0001 to 1 (there are
56 safety checks in the code so don't worry too much if you want to
57 modulate!).
60 argument::ddparam
62 A parameter for the shape of the duration probability
63 distribution, requires values in the range 0.0001 to 1.
66 argument::freq
68 Oscillation frquency.
71 argument::ampscale
73 Normally 0.0 to 1.0, multiplier for the distribution's delta
74 value for amplitude. An ampscale of 1.0 allows the full range
75 of  -1 to 1 for a change of amplitude.
78 argument::durscale
80 Normally 0.0 to 1.0, multiplier for the distribution's delta
81 value for duration. An ampscale of 1.0 allows the full range of
82 -1 to 1 for a change of duration.
85 argument::initCPs
87 Initialise the number of control points in the memory.
88 Xenakis specifies 12. There would be this number of control
89 points per cycle of the oscillator, though the oscillator's
90 period will constantly change due to the duration distribution.
93 argument::knum
95 Current number of utilised control points, allows modulation.
97 argument::mul
99 argument::add
101 discussion::
102 All parameters can be modulated at control rate except for code::initCPs:: which is used only at initialisation.
105 Examples::
107 code::
109 //LOUD! defaults like a rougher Gendy1
110 {Pan2.ar(Gendy3.ar(mul:0.5))}.play
112 {Pan2.ar(Gendy3.ar(freq:MouseX.kr(220,880,'exponential'), durscale:0.01, ampscale:0.02, mul:0.2))}.play
114 //stochastic waveform distortion- also play me at the same time as the previous example...
115 {Pan2.ar(Gendy3.ar(1,2,0.3,-0.7,MouseX.kr(55,110,'exponential'),0.03,0.1))}.play
119 {Pan2.ar(
120 Normalizer.ar(
121 RLPF.ar(
122 RLPF.ar(Mix.new(Gendy3.ar(freq:[230, 419, 546, 789])),
123 MouseX.kr(10,10000,'exponential'),0.05),
124 MouseY.kr(10,10000,'exponential'),0.05)
125 ,0.9)
126 ,Lag.kr(LFNoise0.kr(1),0.5))}.play
130 //concrete pH?
132 {Pan2.ar(
133 Mix.new(Gendy3.ar(freq:([1,1.2,1.3,1.76,2.3]*MouseX.kr(3,17,'exponential')),mul:0.2)))}.play
136 //glitch low, mountain high
138 {Pan2.ar(
139 Mix.new(Gendy3.ar(3,5,1.0,1.0,(Array.fill(5,{LFNoise0.kr(1.3.rand,1,2)})*MouseX.kr(100,378,'exponential')),MouseX.kr(0.01,0.05),MouseY.kr(0.001,0.016),5,mul:0.1)))}.play
142 //play me
143 {Pan2.ar(RLPF.ar(Gendy3.ar(1,3,freq:MouseX.kr(100,1000), durscale:0.0, ampscale:MouseY.kr(0.0,0.1), initCPs:7, knum: MouseY.kr(7,2)), 500,0.3, 0.2), 0.0)}.play
147 //used as an LFO
149 {Pan2.ar(SinOsc.ar(Gendy3.kr(2,5,SinOsc.kr(0.1,0,0.49,0.51),SinOsc.kr(0.13,0,0.49,0.51), 0.34, SinOsc.kr(0.17,0,0.49,0.51), SinOsc.kr(0.19,0,0.49,0.51),10,10,mul:50, add:350), 0, 0.3), 0.0)}.play
152 //buzzpipes
153 {Pan2.ar(Mix.new(Gendy3.ar(0, 0, SinOsc.kr(0.1, 0, 0.1, 0.9),1.0, [100,205,410], 0.011,0.005, 12, 12, 0.12)), 0.0)}.play
156 //modulate distributions
157 //change of pitch as distributions change the duration structure and spectrum
158 {Pan2.ar(Gendy3.ar(MouseX.kr(0,7),MouseY.kr(0,7),mul:0.2), 0.0)}.play
161 //modulate num of CPs
162 {Pan2.ar(Gendy3.ar(knum:MouseX.kr(2,13),mul:0.2), 0.0)}.play
165 //Gendy1 into Gendy2 into Gendy3...with cartoon side effects
167 {Pan2.ar(Gendy3.ar(1,2,freq:Gendy2.ar(maxfreq:Gendy1.kr(5,4,0.3, 0.7, 0.1, MouseY.kr(0.1,10), 1.0, 1.0, 5,5, 25,26),minfreq:24, knum:MouseX.kr(1,13),mul:150, add:200), durscale:0.01, ampscale:0.01, mul:0.1), 0.0)}.play
170 //use SINUS to track any oscillator and take CP positions from it, use adparam and ddparam as the inputs to sample
171 {Pan2.ar(Gendy3.ar(6,6,LFPulse.kr(LFNoise0.kr(19.0,0.5,0.6), 0, 0.4, 0.5), Gendy1.kr(durscale:0.01,ampscale:0.01), MouseX.kr(10,100),mul:0.2), 0.0)}.play
175 //wolf tones
178 Mix.fill(10,{
179 var freq;
181 freq= exprand(130,1160.3);
182 Pan2.ar(SinOsc.ar(Gendy3.ar(6.rand,6.rand,SinOsc.kr(0.1,0,0.49,0.51),SinOsc.kr(0.13,0,0.49,0.51),freq, SinOsc.kr(0.17,0,0.0049,0.0051), SinOsc.kr(0.19,0,0.0049,0.0051), 12, 12, 200, 400), 0, 0.1), 1.0.rand2)
184 }.play
187 //CAREFUL! mouse to far right causes explosion of sound-
188 //notice how high frequency and num of CPs affects CPU cost
190 {Pan2.ar(
191 CombN.ar(
192 Resonz.ar(
193 Gendy3.ar(2,3,freq:MouseX.kr(10,700), initCPs:100),
194 MouseY.kr(50,1000), 0.1)
195 ,0.1,0.1,5, 0.16
197 , 0.0)}.play
201 //storm
204 var n;
205 n=15;
207 0.5*Mix.fill(n,{
208 var freq, numcps;
210 freq= rrand(130,160.3);
211 numcps= rrand(2,20);
212 Pan2.ar(Gendy3.ar(6.rand,6.rand,10.0.rand,10.0.rand,freq*exprand(1.0,2.0), 10.0.rand, 10.0.rand, numcps, SinOsc.kr(exprand(0.02,0.2), 0, numcps/2, numcps/2), 0.5/(n.sqrt)), 1.0.rand2)
214 }.play
219 //another glitchy moment
222 var n;
223 n=10;
225 Resonz.ar(
226 Mix.fill(n,{
227 var freq, numcps;
229 freq= rrand(50,560.3);
230 numcps= rrand(2,20);
231 Pan2.ar(Gendy3.ar(6.rand,6.rand,1.0.rand,1.0.rand,freq, 1.0.rand, 1.0.rand, numcps, SinOsc.kr(exprand(0.02,0.2), 0, numcps/2, numcps/2), 0.5/(n.sqrt)), 1.0.rand2)
233 ,MouseX.kr(100,2000), MouseY.kr(0.01,1.0), 0.3)
235 }.play