«Silly Voice» by Bruno Ruviaro

on 13 Nov'13 06:31 in formant 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
117
118
119
120
121
////////////////////////////////////////////
// Silly formant synthesis example.
// Using Pmono or Pbind to create a voice.
// SynthDef is hardwired to bass formants.

// Evaluate SynthDef first, then scroll down for examples

(
// SynthDef
SynthDef("sillyVoice", { arg
	freq = 220,
	amp = 0.5,
	vibratoSpeed = 6,
	vibratoDepth = 4,
	vowel = 0,
	att = 0.01,
	rel = 0.1,
	pos = 0,
	gate = 1;

	var in, vibrato, above, below, env, va, ve, vi, vo, vu, snd;

	// calculate vibrato 
	// vibratoDepth is number of semitones to go up and down
	above = (freq.cpsmidi + vibratoDepth).midicps - freq;
	below = (freq.cpsmidi - vibratoDepth).midicps - freq;
	vibrato = SinOsc.kr(vibratoSpeed).range(below, above); 
	// this is the basic sound source
	in = Saw.ar(Lag.kr(freq) + vibrato);
	// amplitude envelope
	env = Env.asr(att, amp, rel).kr(doneAction: 2, gate: gate);

	va = BBandPass.ar(
		in: in,
		freq: [ 600, 1040, 2250, 2450, 2750 ],
		bw: [ 0.1, 0.0673, 0.0488, 0.0489, 0.0472 ],
		mul: [ 1, 0.4466, 0.3548, 0.3548, 0.1 ]);

	ve = BBandPass.ar(
		in: in,
		freq: [ 400, 1620, 2400, 2800, 3100 ] ,
		bw: [ 0.1, 0.0494, 0.0417, 0.0429, 0.0387 ],
		mul: [ 1, 0.2512, 0.3548, 0.2512, 0.1259 ]);

	vi = BBandPass.ar(
		in: in,
		freq: [ 250, 1750, 2600, 3050, 3340 ] ,
		bw: [ 0.24, 0.0514, 0.0385, 0.0393, 0.0359 ],
		mul: [ 1, 0.0316, 0.1585, 0.0794, 0.0398 ] );

	vo = BBandPass.ar(
		in: in,
		freq:[ 400, 750, 2400, 2600, 2900 ] ,
		bw: [ 0.1, 0.1067, 0.0417, 0.0462, 0.0414 ],
		mul: [ 1, 0.2818, 0.0891, 0.1, 0.01 ]);

	vu = BBandPass.ar(
		in: in,
		freq: [ 350, 600, 2400, 2675, 2950 ],
		bw: [ 0.1143, 0.1333, 0.0417, 0.0449, 0.0407 ],
		mul: [ 1, 0.1, 0.0251, 0.0398, 0.0158 ]);

	snd = SelectX.ar(Lag.kr(vowel, 0.3), [va, ve, vi, vo, vu]);
	snd = Pan2.ar(Mix(snd), pos);
	Out.ar(0, snd * env * 2);
}).add;
)

// Play around with these examples/
// Vowels a e i o u correspond to number 0 1 2 3 4

// Example 1
(
Pbind(
	\instrument, "sillyVoice",
	\note, Pseq([0, -5, -3, -8, -7, 0, -7, -5], inf),
	\ctranspose, -12,
	\dur, 1,
	\amp, 1,
	\vibratoSpeed, 6,
	\vibratoDepth, 1, // in semitones
	\vowel, Pseq([0, 1, 2, 3, 4], inf),
	\legato, 1,
	\att, 0.1,
	\rel, 0.1,
	\pos, Pwhite(-1, 1.0)
).play;
)


// Example 2
(
Pbind(
	\instrument, "sillyVoice",
	\note, Prand([0, 5, 7, 9, -11, -7], inf),
	\ctranspose, -14,
	\dur, Pwhite(0.61, 1.7),
	\amp, 1,
	\vibratoSpeed, Pwhite(6,8),
	\vibratoDepth, Pwhite(0.5, 1.5),
	\vowel, Pwrand([0, 1, 3], [0.8, 0.1, 0.1], inf),
	\legato, 2, // notes overlap
	\att, 1.1, // softer attack
	\rel, 2.5
).play;
)

// Example 3: using Pmono
(
Pmono(
	"sillyVoice",
	\note, Pseq([-5, -3, -1, 0], inf),
	\ctranspose, -14,
	\dur, Pwhite(0.5, 1.0),
	\amp, 1,
	\vibratoSpeed, Pwhite(6,7),
	\vibratoDepth, 1,
	\vowel, Prand([0, 1, 2, 3, 4], inf),
	\lag, 0.3
).play;
)
raw 2914 chars (focus & ctrl+a+c to copy)
reception
comments
josepssv user 05 Jan'14 11:06

I add your code in this song http://www.wikiloops.com/backingtrack.php?jamsession=13889 Thanks