«Pluck (Karplus-Strong) example» by Bruno Ruviaro

on 13 Nov'13 06:32 in karplusstrong synthesis
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
(
SynthDef("plucking", {arg amp = 0.1, freq = 440, decay = 5, dampen = 0.1;

var env, snd;
env = Env.linen(0, decay, 0).kr(doneAction: 2);
snd = Pluck.ar(
        in: WhiteNoise.ar(amp),
        trig: Impulse.kr(0),
        maxdelaytime: 0.1,
        delaytime: freq.reciprocal,
        decaytime: decay,
        coef: dampen);
    Out.ar(0, [snd, snd]);
}).add;
)

// Example 1
(
Pbind(
    \instrument, "plucking",
    \freq, Pwhite(440, 880),
    \amp, 0.1,
    \decay, 4,
    \dampen, 0.1,
    \dur, Prand([0.51, 0.1, 0.1], inf)
).play;
)

// Example 2
(
Pbind(
    \instrument, "plucking",
    \scale, Scale.locrian,
    \degree, Pwhite(7, 15),
    \amp, Pwhite(0.1, 0.5),
    \decay, Pwhite(7, 12),
    \dampen, Pwhite(0.01, 0.1),
    \dur, Prand([0.1, 0.2, 0.4, 0.27, 0.13, 0.38], inf)
).play;
)

// Example 3
(
Pbind(
    \instrument, "plucking",
    \scale, Scale.lydian,
    \degree, Pseq([8, 17, 8, 9, 8, 17, 7], inf),
    \amp, Pwhite(0.1, 0.5),
    \decay, Pwhite(1, 2),
    \dampen, Pseq([0.7, 0.8, 0.4], inf),
    \dur, Prand([0.1, 0.2, 0.4], inf)
).play;
)

// Example 4
(
Pbind(
    \instrument, "plucking",
    \degree, Pseq([-5, -2, 1, 4, 6, 9], inf),
    \mtranspose, -7,
    \amp, Pwhite(0.2, 0.3),
    \decay, Pseq([7, 6, 6, 5, 4, 3], inf),
    \dampen, Pseq([0.45, 0.3, 0.3, 0.2, 0.2, 0.1], inf),
    \dur, Prand([0.9, 0.8, 0.7], inf)
).play;

Pbind(
    \instrument, "plucking",
    \degree, Prand([0, 1, 3, 4, 6, Pseq([7, 8, 9], 1), 9], inf),
	\mtranspose, 7,
    \amp, Pwhite(0.4, 0.5),
    \decay, Pwhite(6, 10),
    \dampen, Pseq([0.05, 0.1, 0.15], inf),
    \dur, Prand([0.1, 0.2, 0.4, Rest(0.3)], inf)
).play;

)

// Example 5


(
a = Pbind(
    \instrument, "plucking",
	\degree, Pseq([7, 8, 9, 10, 11, 12, 13], inf),
    \amp, 0.2,
    \decay, 4,
    \dampen, 0.05,
    \dur, Prand([0.51, 0.1, 0.1], inf)
);

b = Pbind(
    \instrument, "plucking",
	\degree, Pseq([
		[-7, 2, 4], // chord 1
		[0, 3, 5] // chord 2
	], inf),
    \amp, 0.1,
    \decay, 7,
    \dampen, 0.1,
    \dur, Prand([2, 4], inf)
);
)

// sequence in time
(
{
	~player1 = a.play;
	4.wait;
	~player2 = b.play;
	10.wait;
	~player1.stop;
	4.wait;
	~player2.stop;
}.fork
)
raw 2286 chars (focus & ctrl+a+c to copy)
reception
comments
beryann.parker user 05 Jan'24 10:54

very nice streams of sounds...the patch is very interesting!