linux: shared memory interface - link with librt
[supercollider.git] / HelpSource / Classes / Gendy2.schelp
blob0f41532428a0ce5e12c04e9dd49a3511516f5cc1
1 class:: Gendy2
2 summary:: Dynamic stochastic synthesis generator.
3 related:: Classes/Gendy1, Classes/Gendy3
4 categories::  UGens>Generators>Stochastic
7 Description::
9 See  link::Classes/Gendy1::  help file for background. This variant of
10 GENDYN is closer to that presented in emphasis::Hoffmann, Peter. (2000) The New GENDYN Program. Computer Music Journal 24:2, pp 31-38::.
12 note::
13 Random walk is of the amplitude and time delta, not the amp and time
14 directly. The amplitude step random walk uses a lehmer style number
15 generator whose parameters are accessible.
18 SuperCollider implementation by Nick Collins
20 classmethods::
22 method::ar, kr
24 discussion::
25 All parameters can be modulated at control rate except for code::initCPs:: which is used only at initialisation.
27 argument::ampdist
29 Choice of probability distribution for the next perturbation of
30 the amplitude of a control point.
32 The distributions are (adapted from the GENDYN program in Formalized Music):
33 table::
34 ## 0: || LINEAR.
35 ## 1: || CAUCHY.
36 ## 2: || LOGIST.
37 ## 3: || HYPERBCOS.
38 ## 4: || ARCSINE.
39 ## 5: || EXPON.
40 ## 6: || SINUS.
43 Where the sinus (Xenakis' name) is in this implementation taken
44 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.
51 argument::adparam
53 A parameter for the shape of the amplitude probability
54 distribution, requires values in the range 0.0001 to 1 (there are
55 safety checks in the code so don't worry too much if you want to
56 modulate!).
58 argument::ddparam
60 A parameter for the shape of the duration probability
61 distribution, requires values in the range 0.0001 to 1.
64 argument::minfreq
66 Minimum allowed frequency of oscillation for the Gendy1
67 oscillator, so gives the largest period the duration is allowed
68 to take on.
71 argument::maxfreq
73 Maximum allowed frequency of oscillation for the Gendy1
74 oscillator, so gives the smallest period the duration is allowed
75 to take on.
78 argument::ampscale
80 Normally 0.0 to 1.0, multiplier for the distribution's delta
81 value for amplitude. An ampscale of 1.0 allows the full range
82 of  -1 to 1 for a change of amplitude.
85 argument::durscale
87 Normally 0.0 to 1.0, multiplier for the distribution's delta
88 value for duration. An ampscale of 1.0 allows the full range of
89 -1 to 1 for a change of duration.
92 argument::initCPs
94 Initialise the number of control points in the memory.
95 Xenakis specifies 12. There would be this number of control
96 points per cycle of the oscillator, though the oscillator's
97 period will constantly change due to the duration distribution.
100 argument::knum
102 Current number of utilised control points, allows modulation.
105 argument::a
107 Parameter for Lehmer random number generator perturbed by
108 Xenakis as in
110 formula::
111 ((old*a)+c)%1.0
114 argument::c
116 Parameter for Lehmer random number generator perturbed by
117 Xenakis.
120 argument::mul
121 Output will be multiplied by this value.
123 argument::add
124 This value will be added to the output.
126 Examples::
127 warning::
128 if you have lots of CPs and you have fast frequencies, the CPU cost goes up a lot because a new CP move happens every sample!
131 code::
132 //LOUD! defaults like a rougher Gendy1
133 {Pan2.ar(Gendy2.ar)}.play
135 //advantages of messing with the random number generation- causes periodicities
136 {Pan2.ar(Gendy2.ar(a:MouseX.kr(0.0,1.0),c:MouseY.kr(0.0,1.0)))}.play
139 {Pan2.ar(
140 Normalizer.ar(
141 RLPF.ar(
142 RLPF.ar(Gendy2.ar(a:SinOsc.kr(0.4,0,0.05,0.05),c:SinOsc.kr(0.3,0,0.1,0.5)),
143 MouseX.kr(10,10000,'exponential'),0.05),
144 MouseY.kr(10,10000,'exponential'),0.05)
145 ,0.9)
146 ,Lag.kr(LFNoise0.kr(1),0.5))}.play
151 {Pan2.ar(Gendy2.ar(3,5,1.0,1.0,50,1000,MouseX.kr(0.05,1),MouseY.kr(0.05,1),15, 0.05,0.51,mul:0.5))}.play
154 //play me
155 {Pan2.ar(RLPF.ar(Gendy2.ar(1,3,minfreq:20,maxfreq:MouseX.kr(100,1000),durscale:0.0,initCPs:4),500,0.3, 0.2),0.0)}.play
158 //1 CP = random noise effect
159 {Pan2.ar(Gendy2.ar(initCPs:1))}.play
161 //2 CPs = suudenly an oscillator (though a fast modulating one here)
162 {Pan2.ar(Gendy2.ar(initCPs:2))}.play
165 //used as an LFO
167 {Pan2.ar(SinOsc.ar(Gendy2.kr(2,1,SinOsc.kr(0.1,0,0.49,0.51),SinOsc.kr(0.13,0,0.49,0.51),
168 3.4,3.5, 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
171 //very angry wasp
172 {Pan2.ar(Gendy2.ar(0, 0, SinOsc.kr(0.1, 0, 0.1, 0.9),1.0, 50,1000, 1,0.005, 12, 12, 0.2,0.2,0.2), 0.0)}.play
175 //modulate distributions
176 //change of pitch as distributions change the duration structure and spectrum
177 {Pan2.ar(Gendy2.ar(MouseX.kr(0,7),MouseY.kr(0,7),mul:0.2), 0.0)}.play
180 //modulate num of CPs
181 {Pan2.ar(Gendy2.ar(knum:MouseX.kr(1,13),mul:0.2), 0.0)}.play
184 (//Gendy1 into Gendy2...with cartoon side effects
185 {Pan2.ar(Gendy2.ar(maxfreq:Gendy1.kr(5,4,0.3, 0.7, 0.1, MouseY.kr(0.1,10),
186     1.0, 1.0, 5,5, 500, 600), knum:MouseX.kr(1,13),mul:0.2), 0.0)}.play
189 //use SINUS to track any oscillator and take CP positions from it, use adparam and ddparam as the inputs to sample
190 {Pan2.ar(Gendy2.ar(6,6,LFPulse.kr(100, 0, 0.4, 1.0), SinOsc.kr(30, 0, 0.5),mul:0.2), 0.0)}.play
193 (//try out near the corners especially
194 {Pan2.ar(Gendy2.ar(6,6,LFPulse.kr(MouseX.kr(0,200), 0, 0.4, 1.0),
195     SinOsc.kr(MouseY.kr(0,200), 0, 0.5),mul:0.2), 0.0)}.play
198 //texture- the howling wind?
201     Mix.fill(10,{
202     var freq;
204     freq= rrand(130,160.3);
205     Pan2.ar(SinOsc.ar(Gendy2.ar(6.rand,6.rand,SinOsc.kr(0.1,0,0.49,0.51),SinOsc.kr(0.13,0,0.49,0.51),
206         freq ,freq, SinOsc.kr(0.17,0,0.49,0.51), SinOsc.kr(0.19,0,0.49,0.51),
207         12, 12, 0.4.rand, 0.4.rand, 200, 400), 0, 0.1), 1.0.rand2)
208     });
209 }.play
212 //CAREFUL! mouse to far right causes explosion of sound
214 {Pan2.ar(
215 CombN.ar(
216 Resonz.ar(
217 Gendy2.ar(2,3,minfreq:1, maxfreq:MouseX.kr(10,700), initCPs:100),
218 MouseY.kr(50,1000), 0.1)
219 ,0.1,0.1,5, 0.16
221 , 0.0)}.play
224 //storm
227     var n;
228     n=15;
230     0.5*Mix.fill(n,{
231     var freq, numcps;
233     freq= rrand(130,160.3);
234     numcps= rrand(2,20);
235     Pan2.ar(Gendy2.ar(6.rand,6.rand,10.0.rand,10.0.rand,freq,freq*exprand(1.0,2.0),
236         10.0.rand, 10.0.rand, numcps, SinOsc.kr(exprand(0.02,0.2), 0, numcps/2, numcps/2),
237         10.0.rand, 10.0.rand, 0.5/(n.sqrt)), 1.0.rand2)
238     });
239 }.play
242 //another traffic moment
245     var n;
246     n=10;
248     Resonz.ar(
249     Mix.fill(n,{
250     var freq, numcps;
252     freq= rrand(50,560.3);
253     numcps= rrand(2,20);
254     Pan2.ar(Gendy2.ar(6.rand,6.rand,1.0.rand,1.0.rand,freq ,freq,
255         1.0.rand, 1.0.rand, numcps, SinOsc.kr(exprand(0.02,0.2), 0,
256         numcps/2, numcps/2), 0.5/(n.sqrt)), 1.0.rand2)
257     })
258     ,MouseX.kr(100,2000), MouseY.kr(0.01,1.0), 0.3)
259     ;
260     }.play