File: TBall.schelp

package info (click to toggle)
supercollider 1%3A3.13.0%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 80,292 kB
  • sloc: cpp: 476,363; lisp: 84,680; ansic: 77,685; sh: 25,509; python: 7,909; makefile: 3,440; perl: 1,964; javascript: 974; xml: 826; java: 677; yacc: 314; lex: 175; objc: 152; ruby: 136
file content (112 lines) | stat: -rw-r--r-- 2,507 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
class:: TBall
summary:: physical model of bouncing object
categories:: UGens>Filters>Nonlinear, UGens>Generators>PhysicalModels
related:: Classes/Ball, Classes/Spring

description::
models the impacts of a bouncing object that is reflected by a vibrating surface

classmethods::

method:: ar, kr

argument::in
modulated surface level

argument::g
gravity

argument::damp
damping on impact

argument::friction
proximity from which on attraction to surface starts

examples::
code::
// mouse x controls switch of level
// mouse y controls gravity
(
{
	var t, sf;
	sf = K2A.ar(MouseX.kr > 0.5) > 0;
	t = TBall.ar(sf, MouseY.kr(0.01, 1.0, 1), 0.01);
	Pan2.ar(Ringz.ar(t * 10, 1200, 0.1), MouseX.kr(-1,1));
}.play;
)


// mouse x controls step noise modulation rate
// mouse y controls gravity
(
{
	var t, sf, g;
	sf = LFNoise0.ar(MouseX.kr(0.5, 100, 1));
	g = MouseY.kr(0.01, 10, 1);
	t = TBall.ar(sf, g, 0.01, 0.002);
	Ringz.ar(t * 4, [600, 645], 0.3);
}.play;
)

// mouse x controls sine modulation rate
// mouse y controls friction
// gravity changes slowly
(
{
	var f, g, h, fr;
	fr = MouseX.kr(1, 1000, 1);
	h = MouseY.kr(0.0001, 0.001, 1);
	g = LFNoise1.kr(0.1, 3, 5);
	f = TBall.ar(SinOsc.ar(fr), g, 0.1, h);
	Pan2.ar(Ringz.ar(f, 1400, 0.04),0,5)
}.play;
)

// sine frequency rate is modulated with a slow sine
// mouse y controls friction
// mouse x controls gravity
(
{
	var f, g, h, fr;
	fr = LinExp.kr(SinOsc.kr(0.1), -1, 1, 1, 600);
	h = MouseY.kr(0.0001, 0.001, 1);
	g = MouseX.kr(1, 10);
	f = TBall.ar(SinOsc.ar(fr), g, 0.1, h);
	Pan2.ar(Ringz.ar(f, 1400, 0.04),0,5)
}.play;
)

// this is no mbira: vibrations of a bank of resonators that are
// triggered by some bouncing things that bounce one on each resonator

// mouse y controls friction
// mouse x controls gravity
(
	{
	var sc, g, d, z, lfo, rate;
	g = MouseX.kr(0.01, 100, 1);
	d = MouseY.kr(0.00001, 0.2);
	sc = #[451, 495.5, 595, 676, 734.5]; //azande harp tuning by B. Guinahui
	lfo = LFNoise1.kr(1, 0.005, 1);
	rate = 2.4;
	rate = rate * sc.size.reciprocal;
	z = sc.collect { |u,i|
		var f, in;
		in = Decay.ar(
				Mix(Impulse.ar(rate, [1.0, LFNoise0.kr(rate / 12)].rand, 0.1)), 					0.001
			);
		in = Ringz.ar(in,
					Array.fill(4, { |i| (i+1) + 0.1.rand2 }) / 2
					* Decay.ar(in,0.02,rand(0.5,1), lfo)						* u,
					Array.exprand(4, 0.2, 1).sort
					);
		in = Mix(in);
		f = TBall.ar(in * 10, g, d, 0.001);

		in + Mix(Ringz.ar(f, u * Array.fill(4, { |i| (i+1) + 0.3.rand2 }) * 2, 0.1))
	};
	Splay.ar(z) * 0.8
	}.play;
)
::