-
Notifications
You must be signed in to change notification settings - Fork 3
/
saybuf_synthdefs.scd
332 lines (251 loc) · 10.2 KB
/
saybuf_synthdefs.scd
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
/***
This file shows possibilities of is a collection of synthdefs that manipulate
soundfiles recorded with Say/SayBuf.
*** SELECT ALL AND ENTER TO LOAD ALL SYNTHDEFS! ****
--- Manipulating speech synthesis params with Say:
1. rate manipulation within say soundfile preparation
--- SynthDefs for SayBuf which add buffer-level parameters
2. pitch inflections within buffer playback
3. ring modulation for spectral coloring/shift
4. time-strech/compression with granular transforms
---
1. For speech tempo manipulation within say, use the 'wordrate' parameter in soundfile preparation:
(type: \say, text: "tempo 1 2 3", wordrate: 90).play; // this is the minimum rate
(type: \say, text: "tempo 1 2 3", wordrate: 180).play; // this is default rate
(type: \say, text: "tempo 1 2 3", wordrate: 360).play; //
(type: \say, text: "tempo 1 2 3", wordrate: 720).play; // fastest rate
***/
/*** ///// SYNTHDEFS FOR playing with Say-Produced BUFFERS
s.boot;
x = SayBuf.prepare((type: \say, text: "pitch inflections with say..."));
b = x.buf;
////// NOTE: depending on the voice, Say-Produced soundfiles begin and end with silence.
////// if timing is critical, these could be accounted for as offsets in the synthdefs.
x.buf.plot;
x.buf.loadToFloatArray(0, -1, { |arr| a = arr });
a.detectIndex { |el, i| el.abs > 0.01 }.postln / x.buf.sampleRate; // 0.11 sec before start
a.reverse.detectIndex { |el, i| el.abs > 0.01 }.postln / x.buf.sampleRate;
a.reverse.detectIndex { |el, i| el.abs > 0.0001 }.postln / x.buf.sampleRate; // 0.2 seconds after end
///// 2. simple pitch inflections within buffer playback:
- playback rate -> like tape speed
- vibrato has rate and depth
- tilt: raises start and lowers end playback rate (or vice versa)
// straight:
(instrument: \saybuf, buf: b).play;
// rate - also works in \saybuf:
(instrument: \saybufPch, buf: b, rate: 1).play;
(instrument: \saybufPch, buf: b, rate: 1.2).play;
(instrument: \saybufPch, buf: b, rate: 1.5).play;
(instrument: \saybufPch, buf: b, rate: 0.6666).play;
(instrument: \saybufPch, buf: b, rate: -0.8).play; // reverse!
// vibrato
(instrument: \saybufPch, buf: b, vib: 0.0).play;
(instrument: \saybufPch, buf: b, vib: 0.1).play; // depth
(instrument: \saybufPch, buf: b, vib: 0.2).play; // more depth
(instrument: \saybufPch, buf: b, vib: 0.2, vibRate: 2).play; // vibrato rate
(instrument: \saybufPch, buf: b, vib: 0.2, vibRate: 4).play;
(instrument: \saybufPch, buf: b, vib: 0.2, vibRate: 8).play;
(instrument: \saybufPch, buf: b, vib: 0.2, vibRate: 16).play;
// tilt
(instrument: \saybufPch, buf: b, tilt: -0.6).play; // start high and fall
(instrument: \saybufPch, buf: b, tilt: -0.3).play;
(instrument: \saybufPch, buf: b, tilt: -0.0).play; // flat
(instrument: \saybufPch, buf: b, tilt: 0.3).play; // rising
(instrument: \saybufPch, buf: b, tilt: 0.6).play; // rising more
***/
(
SynthDef(\saybufPch, { |out, amp = 0.1, pan, pos,
buf, endPause = 0.2, rate = 1,
tilt = 0, vib = 0.0, vibRate = 8|
// subtract standard pause at buffer end
var dur2 = BufDur.ir(buf) - endPause;
var ratesig = Line.kr(rate - tilt, rate + tilt, dur2 * rate);
var vibsig = SinOsc.ar(vibRate, 0, vib, 1);
var startpos = (ratesig.sign * pos * BufSampleRate.ir(buf))
// add tiny offset so neg rate does not reach doneAction immediately
+ (rate.sign * 0.01)
// ... and wrap to legal range
.wrap(0, BufFrames.ir(buf) - 1);
var snd = PlayBuf.ar(1, buf,
BufRateScale.ir(buf) * ratesig * vibsig,
startPos: startpos,
doneAction: 2
);
Out.ar(out,
Pan2.ar(snd, pan, amp)
)
}).add;
);
/***
3. ringmodulation - fixed frequency SinOsc shifts spetrum
(instrument: \saybufPchRng ).play;
(instrument: \saybufPchRng, buf: b, amp: 0.5, ringFreq: 2000, ringMod: 0.2).play;
(instrument: \saybufPchRng, buf: b, amp: 0.5, ringFreq: 2000, ringMod: 0.5).play;
(instrument: \saybufPchRng, buf: b, amp: 0.5, ringFreq: 2000, ringMod: 0.8).play;
(instrument: \saybufPchRng, buf: b, amp: 0.5, ringFreq: 2000, ringMod: 1).play;
(instrument: \saybufPchRng, buf: b, amp: 0.5, ringFreq: 500, ringMod: 0.2).play;
(instrument: \saybufPchRng, buf: b, amp: 0.5, ringFreq: 500, ringMod: 0.5).play;
(instrument: \saybufPchRng, buf: b, amp: 0.5, ringFreq: 500, ringMod: 0.8).play;
(instrument: \saybufPchRng, buf: b, amp: 0.5, ringFreq: 500, ringMod: 1).play;
(instrument: \saybufPchRng, buf: b, amp: 0.5, ringFreq: 50, ringMod: 0.2).play;
(instrument: \saybufPchRng, buf: b, amp: 0.5, ringFreq: 50, ringMod: 0.5).play;
(instrument: \saybufPchRng, buf: b, amp: 0.5, ringFreq: 50, ringMod: 0.8).play;
(instrument: \saybufPchRng, buf: b, amp: 0.5, ringFreq: 50, ringMod: 1).play;
***/
(
SynthDef(\saybufPchRng, { |out, amp = 0.1, pan, pos,
buf, endPause = 0.2, rate = 1,
tilt = 0, vib = 0.0, vibRate = 8,
ringFreq = 200, ringMod = 0.5|
// subtract standard pause at buffer end
var dur2 = BufDur.ir(buf) - endPause;
var ratesig = Line.kr(rate - tilt, rate + tilt, dur2 * rate);
var vibsig = SinOsc.ar(vibRate, 0, vib, 1);
var startpos = (ratesig.sign * pos * BufSampleRate.ir(buf))
// add tiny offset so neg rate does not reach doneAction immediately
+ (rate.sign * 0.01)
// ... and wrap to legal range
.wrap(0, BufFrames.ir(buf) - 1);
var ringsig = SinOsc.ar(ringFreq, 0, ringMod, 1-ringMod);
var snd = PlayBuf.ar(1, buf,
BufRateScale.ir(buf) * ratesig * vibsig,
startPos: startpos,
doneAction: 2);
Out.ar(out,
Pan2.ar(snd * ringsig, pan, amp)
)
}).add;
);
///////// with granular treatment
/***
y = SayBuf.prepare((type: \say, text: "granular time-processing with saybuf ..."));
g = y.buf;
g.play;
// speed with which to move thru file
(instrument: \saybufGrn, buf: g, amp: 0.5, speed: 1).play;
(instrument: \saybufGrn, buf: g, amp: 0.5, speed: 2).play;
(instrument: \saybufGrn, buf: g, amp: 0.5, speed: 3).play;
(instrument: \saybufGrn, buf: g, amp: 0.5, speed: 4).play;
(instrument: \saybufGrn, buf: g, amp: 0.5, speed: 0.5).play;
(instrument: \saybufGrn, buf: g, amp: 0.5, speed: 0.2).play;
// rate and tilt also used:
(instrument: \saybufGrn, buf: g, amp: 0.5, speed: 0.5, tilt: 0.5).play;
(instrument: \saybufGrn, buf: g, amp: 0.5, speed: 0.5, tilt: -0.5).play;
(instrument: \saybufGrn, buf: g, rate: 3/2, speed: 0.5, amp: 0.5).play;
(instrument: \saybufGrn, buf: g, rate: 2/3, speed: 0.5, amp: 0.5).play;
// grDur sets grain duration (with fixed overlap of 2)
(instrument: \saybufGrn, buf: g, amp: 0.5, speed: 0.5, grDur: 0.08).play;
(instrument: \saybufGrn, buf: g, amp: 0.5, speed: 0.5, grDur: 0.06).play;
(instrument: \saybufGrn, buf: g, amp: 0.5, speed: 0.5, grDur: 0.04).play;
(instrument: \saybufGrn, buf: g, amp: 0.5, speed: 0.5, grDur: 0.02).play;
***/
(
SynthDef(\saybufGrn, { |out, amp = 0.1, pan, pos,
buf, endPause = 0.2, rate = 1,
tilt = 0, speed = 1, grDur = 0.1|
var dur2 = BufDur.ir(buf) - endPause / speed;
var ratesig = Line.kr(rate - tilt, rate + tilt, dur2 * rate);
var snd, posSig;
var startpos = (ratesig.sign * pos * BufSampleRate.ir(buf))
// add tiny offset so neg rate does not reach doneAction immediately
+ (rate.sign * 0.01)
// ... and wrap to legal range
.wrap(0, BufFrames.ir(buf) - 1);
posSig = Line.kr(startpos / dur2, 1 + pos - 0.1, dur2, doneAction: 2);
snd = GrainBuf.ar(1,
Impulse.ar(2 / grDur),
grDur,
buf,
ratesig,
posSig,
4
);
Out.ar(out,
Pan2.ar(snd, pan, amp)
)
}).add;
);
///////// granular + bandpass filtering:
/***
y = SayBuf.prepare((type: \say, text: "granular time-processing with saybuf ..."));
g = y.buf;
g.play;
(instrument: \saybufGrnBpf, buf: g, amp: 0.5, filtFreq: 700).play;
(instrument: \saybufGrnBpf, buf: g, amp: 0.5, filtFreq: 700, filtBW: 0.5).play;
(instrument: \saybufGrnBpf, buf: g, amp: 0.5, filtFreq: 700, filtBW: 0.25).play;
// maybe distance could be modeled with this?
(instrument: \saybufGrnBpf, buf: g, amp: 0.5, filtFreq: 3000).play;
(instrument: \saybufGrnBpf, buf: g, amp: 0.5, filtFreq: 3000, filtBW: 0.5).play;
(instrument: \saybufGrnBpf, buf: g, amp: 0.5, filtFreq: 3000, filtBW: 0.25).play;
// too low does not work well
(instrument: \saybufGrnBpf, buf: g, amp: 0.5, filtFreq: 200).play;
(instrument: \saybufGrnBpf, buf: g, amp: 0.5, filtFreq: 200, filtBW: 0.5).play;
(instrument: \saybufGrnBpf, buf: g, amp: 0.5, filtFreq: 200, filtBW: 0.25).play;
***/
(
SynthDef(\saybufGrnBpf, { |out, amp = 0.1, pan, pos,
buf, endPause = 0.2, rate = 1,
tilt = 0, speed = 1, grDur = 0.1,
filtFreq = 700, filtBW = 2|
var dur2 = BufDur.ir(buf) - endPause / speed;
var ratesig = Line.kr(rate - tilt, rate + tilt, dur2 * rate);
var snd, posSig;
var startpos = (ratesig.sign * pos * BufSampleRate.ir(buf))
// add tiny offset so neg rate does not reach doneAction immediately
+ (rate.sign * 0.01)
// ... and wrap to legal range
.wrap(0, BufFrames.ir(buf) - 1);
posSig = Line.kr(startpos / dur2, 1 + pos - 0.1, dur2, doneAction: 2);
snd = GrainBuf.ar(1,
Impulse.ar(2 / grDur),
grDur,
buf,
ratesig,
posSig,
4
);
snd = BPF.ar(snd, filtFreq, filtBW);
Out.ar(out,
Pan2.ar(snd, pan, amp)
)
}).add;
);
/**********
// emphasis by envelope
- where to put peak in time from 0 (start) to 1 (end),
- and how much louder/softer in dB :
Env([0, 6, 0], [0.3, 0.7]).plot;
(instrument: \saybufGrnBpfEnv, buf: b, envDB: 12, envTime: 0).play; // at start, dimin
(instrument: \saybufGrnBpfEnv, buf: b, envDB: 12, envTime: 1).play; // at end, cresc
(instrument: \saybufGrnBpfEnv, buf: b, envDB: 12, envTime: 0.5).play; // peak in center
(instrument: \saybufGrnBpfEnv, buf: b, envDB: -12, amp: 0.5).play; // env dip in center
***********/
(
SynthDef(\saybufGrnBpfEnv, { |out, amp = 0.1, pan, pos,
buf, endPause = 0.2, rate = 1,
tilt = 0, speed = 1, grDur = 0.1,
filtFreq = 700, filtBW = 2,
envDB = 0, envTime = 0.5 |
var dur2 = BufDur.ir(buf) - endPause / speed;
var ratesig = Line.kr(rate - tilt, rate + tilt, dur2 * rate);
var startpos = (ratesig.sign * pos * BufSampleRate.ir(buf))
// add tiny offset so neg rate does not reach doneAction immediately
+ (rate.sign * 0.01)
// ... and wrap to legal range
.wrap(0, BufFrames.ir(buf) - 1);
var posSig = Line.kr(startpos / dur2, 1 + pos - 0.1, dur2, doneAction: 2);
var snd = GrainBuf.ar(1,
Impulse.ar(2 / grDur),
grDur,
buf,
ratesig,
posSig,
4
);
var env = Env([0, envDB, 0], [envTime, 1-envTime] * dur2).kr.dbamp;
snd = BPF.ar(snd, filtFreq, filtBW) * env;
Out.ar(out,
Pan2.ar(snd, pan, amp)
)
}).add;
);