2 summary:: physical model of resonating spring
3 categories:: UGens>Filters>Nonlinear, UGens>Generators>PhysicalModels
4 related:: Classes/Ball, Classes/TBall
7 models the force of a resonating string
17 spring constant (incl. mass)
25 // trigger gate is mouse button
26 // spring constant is mouse x
27 // mouse y controls damping
30 var inforce, outforce, freq, k, d;
31 inforce = K2A.ar(MouseButton.kr(0,1,0)) > 0;
32 k = MouseY.kr(0.1, 20, 1);
33 d = MouseX.kr(0.00001, 0.1, 1);
34 outforce = Spring.ar(inforce, k, d);
35 freq = outforce * 400 + 500; // modulate frequency with the force
36 SinOsc.ar(freq, 0, 0.2)
41 // several springs in series.
42 // trigger gate is mouse button
43 // spring constant is mouse x
44 // mouse y controls damping
46 { var m0, m1, m2, m3, d, k, inforce;
47 d = MouseY.kr(0.00001, 0.01, 1);
48 k = MouseX.kr(0.1, 20, 1);
49 inforce = K2A.ar(MouseButton.kr(0,1,0)) > 0;
50 m0 = Spring.ar(inforce, k, 0.01);
51 m1 = Spring.ar(m0, 0.5 * k, d);
52 m2 = Spring.ar(m0, 0.6 * k + 0.2, d);
53 m3 = Spring.ar(m1 - m2, 0.4, d);
54 SinOsc.ar(m3 * 200 + 500, 0, 0.2) // modulate frequency with the force
59 // modulating a resonating string with the force
60 // spring constant is mouse x
61 // mouse y controls damping
63 { var m0, m1, m2, m3, m4, d, k, t;
64 k = MouseX.kr(0.5, 100, 1);
65 d = MouseY.kr(0.0001, 0.01, 1);
67 m0 = Spring.ar(ToggleFF.ar(t), 1 * k, 0.01);
68 m1 = Spring.ar(m0, 0.5 * k, d);
69 m2 = Spring.ar(m0, 0.6 * k, d);
70 m3 = Spring.ar([m1,m2], 0.4 * k, d);
71 m4 = Spring.ar(m3 - m1 + m2, 0.1 * k, d);
72 CombL.ar(t, 0.1, LinLin.ar(m4, -10, 10, 1/8000, 1/100), 12)