1class:: TBall
2summary:: physical model of bouncing object
3categories:: UGens>Filters>Nonlinear, UGens>Generators>PhysicalModels
4related:: Classes/Ball, Classes/Spring
5
6description::
7models the impacts of a bouncing object that is reflected by a vibrating surface
8
9classmethods::
10
11method:: ar, kr
12
13argument::in
14modulated surface level
15
16argument::g
17gravity
18
19argument::damp
20damping on impact
21
22argument::friction
23proximity from which on attraction to surface starts
24
25examples::
26code::
27// mouse x controls switch of level
28// mouse y controls gravity
29(
30{
31	var t, sf;
32	sf = K2A.ar(MouseX.kr > 0.5) > 0;
33	t = TBall.ar(sf, MouseY.kr(0.01, 1.0, 1), 0.01);
34	Pan2.ar(Ringz.ar(t * 10, 1200, 0.1), MouseX.kr(-1,1));
35}.play;
36)
37
38
39// mouse x controls step noise modulation rate
40// mouse y controls gravity
41(
42{
43	var t, sf, g;
44	sf = LFNoise0.ar(MouseX.kr(0.5, 100, 1));
45	g = MouseY.kr(0.01, 10, 1);
46	t = TBall.ar(sf, g, 0.01, 0.002);
47	Ringz.ar(t * 4, [600, 645], 0.3);
48}.play;
49)
50
51// mouse x controls sine modulation rate
52// mouse y controls friction
53// gravity changes slowly
54(
55{
56	var f, g, h, fr;
57	fr = MouseX.kr(1, 1000, 1);
58	h = MouseY.kr(0.0001, 0.001, 1);
59	g = LFNoise1.kr(0.1, 3, 5);
60	f = TBall.ar(SinOsc.ar(fr), g, 0.1, h);
61	Pan2.ar(Ringz.ar(f, 1400, 0.04),0,5)
62}.play;
63)
64
65// sine frequency rate is modulated with a slow sine
66// mouse y controls friction
67// mouse x controls gravity
68(
69{
70	var f, g, h, fr;
71	fr = LinExp.kr(SinOsc.kr(0.1), -1, 1, 1, 600);
72	h = MouseY.kr(0.0001, 0.001, 1);
73	g = MouseX.kr(1, 10);
74	f = TBall.ar(SinOsc.ar(fr), g, 0.1, h);
75	Pan2.ar(Ringz.ar(f, 1400, 0.04),0,5)
76}.play;
77)
78
79// this is no mbira: vibrations of a bank of resonators that are
80// triggered by some bouncing things that bounce one on each resonator
81
82// mouse y controls friction
83// mouse x controls gravity
84(
85	{
86	var sc, g, d, z, lfo, rate;
87	g = MouseX.kr(0.01, 100, 1);
88	d = MouseY.kr(0.00001, 0.2);
89	sc = #[451, 495.5, 595, 676, 734.5]; //azande harp tuning by B. Guinahui
90	lfo = LFNoise1.kr(1, 0.005, 1);
91	rate = 2.4;
92	rate = rate * sc.size.reciprocal;
93	z = sc.collect { |u,i|
94		var f, in;
95		in = Decay.ar(
96				Mix(Impulse.ar(rate, [1.0, LFNoise0.kr(rate / 12)].rand, 0.1)), 					0.001
97			);
98		in = Ringz.ar(in,
99					Array.fill(4, { |i| (i+1) + 0.1.rand2 }) / 2
100					* Decay.ar(in,0.02,rand(0.5,1), lfo)						* u,
101					Array.exprand(4, 0.2, 1).sort
102					);
103		in = Mix(in);
104		f = TBall.ar(in * 10, g, d, 0.001);
105
106		in + Mix(Ringz.ar(f, u * Array.fill(4, { |i| (i+1) + 0.3.rand2 }) * 2, 0.1))
107	};
108	Splay.ar(z) * 0.8
109	}.play;
110)
111::
112
113