«Rate Player» by joehigham

on 30 Jul'18 18:40 in samplerpiano player

This is a player that I use for live work. It takes piano samples (or anything else I guess) and plays them in a rhythmic way that is also based on chord pitches. You'll see the GUI has (for me) chord names to remind me of what harmonic area this plays in. I'm using small sample of Morton Feldman's "Triadic Memories", if that's of any interest.

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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
s.boot;

/*============================================
LOAD SOME PIANO SOUNDS HERE
===============================================*/

(
~chords = Array.new;
~folder = PathName.new(""); // Load your path name here
~folder.entries.do({
	arg path;
	~chords = ~chords.add(Buffer.read(s,path.fullPath));
});
)

~chords[rand(7)].play; // test here


(
SynthDef(\pnoRhyth, {
	arg out=0, relTime=1, bufnum=0, rate=1, amp=1;
	var env, pno;
	env = EnvGen.ar(Env.perc(0.01, relTime),doneAction:2);
	pno = BufRd.ar(1, bufnum,Phasor.ar(0,BufRateScale.kr(bufnum)*rate,0,BufFrames.kr(bufnum)));
	pno = pno*env;
	pno = pno*amp;
	Out.ar(out, pno);
}).add;
)

Synth(\pnoRhyth, [\bufnum, ~chords[rand(7)], \relTime, 1.5, \out, 4, \amp, 1.5]); // Test again

/*=====================================================
PIANO PLAYERS - there are pno_1 & pno_2
======================================================*/
t = TempoClock.new(100/60).permanent_(true);

(
Pdefn(\rate, Pseq([0,3],inf).midiratio);
Pdefn(\amp, 1.5);
Pbindef(\pno_1,
	\instrument, \pnoRhyth,
	\dur, Pseq([Pseq([0.5],2), Pseq([0.25],2), Pseq([Rest(0.5)],2)],inf),
	\rate, Pdefn(\rate),
	\bufnum, ~chords[0], // Pindex(~chords,Pseq((0..7),inf), inf),
	\relTime, 0.3,
	\out, 0,
	\amp, Pdefn(\amp),
);
// Player2 //
(
Pdefn(\rate, Pseq([0,3],inf).midiratio);
Pdefn(\amp, 1.5);
Pbindef(\pno_2,
	\instrument, \pnoRhyth,
	\dur, Pseq([
		Pseq([0.5],2),
		Pseq([0.25],4),
		Pseq([Rest(0.5)],2)
	],inf),
	\rate, Pdefn(\rate),
	\bufnum, ~chords[3], // Pindex(~chords,Pseq((0..7),inf), inf),
	\relTime, 0.2,
	\out, 0,
	\amp, Pdefn(\amp),
);
)
)

/*=====================================================
CONTROLS for PLAYERS
=======================================================*/

Pbindef(\pno_1).play(t,quant:4);
Pbindef(\pno_2).play(t,quant:4);

Pbindef(\pno_1).resume(t,quant:1);
Pbindef(\pno_2).resume(t,quant:1);

Pbindef(\pno_1).pause;
Pbindef(\pno_2).pause;


Pbindef(\pno_1).resume;

Pbindef(\pno_1).stop;Pbindef(\pno_2).stop;

Pbindef(\pno_1).clear;Pbindef(\pno_2).clear;

/*======================================================
AMP BOOST ---------- if needed
=======================================================*/

Pdefn(\amp, 1.8);

/*======================================================
BUTTON FOR CHANGING RATES

=======================================================*/


(
Window.closeAll;
w=Window("rate changer",Rect(900,200,300,150))
.front
.alwaysOnTop_(true);

w.view.decorator_(FlowLayout(w.bounds, 20@10,50@10));

~tex_1 = StaticText(w.view, 80@20)
.string_("Button_1")
.align_(\center)
.font_(Font("Monaco", 10))
.background_(Color.white);

~tex_2 = StaticText(w.view, 80@20)
.string_("Button_2")
.align_(\center)
.font_(Font("Monaco", 10))
.background_(Color.white);

w.view.decorator.nextLine;

~button_1 = Button(w.view, 80@80)
.states_([
	["Ebm_1", Color.black, Color.red],
])
.action_({ |button|
	switch (button.value,
		0, { Pdefn(\rate, Pseq([0,3],inf).midiratio) },
	)
});

~button_2 = Button(w.view, 80@80)
.states_([
    ["Eb_2", Color.black, Color.green],
	["F7_3", Color.white, Color.blue]
])
.action_({ |button|
	switch (button.value,
		0, { Pdefn(\rate, Pseq([Pseq([0],3),Pseq([2],1)],inf).midiratio) },
		1, { Pdefn(\rate, Pseq([Pseq([0],4),Pseq([Prand([2,4],inf)],2)],inf).midiratio) }
	)
});
);


/*=============================================================
Pdefn info
================================================================*/
Pdefn(\rate, Pseq([0,3],inf).midiratio);
Pdefn(\rate, Pseq([Pseq([0],3),Pseq([2],1)],inf).midiratio);
Pdefn(\rate, Pseq([0,3],inf).midiratio);
Pdefn(\rate, Pseq([Pseq([0],4),Pseq([Prand([2,4],inf)],2)],inf).midiratio);
/*=================================================================*/

t.tempo_(90/60); // Tempo change if needed
raw 3915 chars (focus & ctrl+a+c to copy)
reception
comments