-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathself_voices.inc
596 lines (522 loc) · 25 KB
/
self_voices.inc
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
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
; Copyright 2014 Oeyvind Brandtsegg and Axel Tidemann
;
; This file is part of [self.]
;
; [self.] is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License version 3
; as published by the Free Software Foundation.
;
; [self.] is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with [self.]. If not, see <http://www.gnu.org/licenses/>.
;******************************
;test
instr 59
print p1,p2,p3,p5,p6,p7,p8,p9,p10,p11
Ssound strget p4
puts Ssound, 1
endin
;******************************
; audio file playback
instr 60
;print p1,p2,p3,p5,p6,p7,p8,p9,p10,p11
kplay = 1
chnset kplay, "i_am_speaking" ; signals cognition that I'm currently speaking
Ssound strget p4
ilen filelen Ssound
; regular instr parameters
iamp = ampdbfs(p7) ; amp
imaxamp = p8 ; max amp in this sound file
ivoice = p9 ; 1 or 2, for primary or secondary association
idel2 = ampdbfs(p10) ; send to delay (2)
irvb2 = ampdbfs(p11) ; send to reverb (2)
ispeed = p12 ; playback speed
; start and end for segment
istart = p5 ; segment start
iend = p6 ; segment end
if iend == 0 then
iend = ilen
endif
idur = iend - istart
p3 = idur/ispeed
aenv linen iamp, 0.01, p3, 0.2
; sound generator
aout diskin Ssound, ispeed, istart
aout = aout * aenv * (1/imaxamp)
; output
if ivoice == 1 then
iout1 = 1
iout2 = 0
elseif ivoice == 2 then
iout1 = 0
iout2 = 1
endif
chnmix aout*iout1, "MasterOut1"
chnmix aout*iout2, "SecondaryDry"
chnmix aout*idel2, "SecondaryDelaySend"
chnmix aout*irvb2, "SecondaryReverbSend"
endin
;******************************
; Spectral voice 1
instr 61
kplay = 1
chnset kplay, "i_am_speaking" ; signals cognition that I'm currently speaking
Ssound strget p4
ilen filelen Ssound
; regular instr parameters
iamp = ampdbfs(p7) ; amp
imaxamp = p8 ; max amp in this sound file
ivoice = p9 ; 1 or 2, for primary or secondary association
idel2 = ampdbfs(p10) ; send to delay (2)
irvb2 = ampdbfs(p11) ; send to reverb (2)
ispeed = p12 ; playback speed
; start and end for segment
istart = p5 ; segment start
iend = p6 ; segment end
if iend == 0 then
iend = ilen
endif
idur = iend - istart
p3 = idur/ispeed
aenv linen iamp, 0.01, p3, 0.2
; sound generator
iscale = semitone(1)
ishift = -50;p13
ilowest = 200;p14
kblurTime = 0.15
ifftsize = 1024
ioverlap = ifftsize / 4
iwinsize = ifftsize
iwinshape = 1; von-Hann window
ibuffer, ilen, k0 FileToPvsBuf Ssound, ifftsize, ioverlap, iwinsize, iwinshape, istart, iend
;p3 = ilen/ispeed
;print istart, p3, idur
ktmpnt linseg 0, p3, idur
fread pvsbufread ktmpnt, ibuffer
ikeepform = 1
fscale pvscale fread,iscale, ikeepform
ikeepform2 = 0
fshift pvshift fscale, ishift, ilowest, ikeepform2
iMax = 1.7
fblur pvsblur fshift, kblurTime, iMax
aout1 pvsynth fshift
aout2 pvsynth fblur
aout = (aout1+aout2)
aout butterhp aout, 150
aout = aout * iamp * 2 * aenv * (1/imaxamp)
aout pareq aout, 6800, ampdb(-5), 0.6, 0
; output
if ivoice == 1 then
iout1 = 1
iout2 = 0
elseif ivoice == 2 then
iout1 = 0
iout2 = 1
endif
chnmix aout*iout1, "MasterOut1"
chnmix aout*iout2, "SecondaryDry"
chnmix aout*idel2, "SecondaryDelaySend"
chnmix aout*irvb2, "SecondaryReverbSend"
endin
;******************************
; Spectral voice 2
instr 62
kplay = 1
chnset kplay, "i_am_speaking" ; signals cognition that I'm currently speaking
Ssound strget p4
ilen filelen Ssound
; regular instr parameters
iamp = ampdbfs(p7) ; amp
imaxamp = p8 ; max amp in this sound file
ivoice = p9 ; 1 or 2, for primary or secondary association
idel2 = ampdbfs(p10) ; send to delay (2)
irvb2 = ampdbfs(p11) ; send to reverb (2)
ispeed = p12 ; playback speed
; start and end for segment
istart = p5 ; segment start
iend = p6 ; segment end
if iend == 0 then
iend = ilen
endif
idur = iend - istart
p3 = idur/ispeed
aenv linen iamp, 0.01, p3, 0.2
; sound generator
ktimeAmp = 0.4 ; p12
ktimeFreq = 0.06 ; p13
kblurTime = 0.15 ; p14
ifftsize = 1024
ioverlap = ifftsize / 4
iwinsize = ifftsize
iwinshape = 1; von-Hann window
ibuffer, ilen, k0 FileToPvsBuf Ssound, ifftsize, ioverlap, iwinsize, iwinshape, istart, iend
ktmpnt linseg 0, p3, idur
fread pvsbufread ktmpnt, ibuffer
iframetime = (ioverlap/sr) ; time per fft frame rate
kamountAmp = iframetime/ktimeAmp ; smoothing frequency (in fraction of 1/2 fft framerate)
kamountFreq = iframetime/ktimeFreq ; smoothing frequency (in fraction of 1/2 fft framerate)
fsmooth pvsmooth fread, kamountAmp, kamountFreq
iMax = 1.7
fblur pvsblur fread, kblurTime, iMax
aout1 pvsynth fsmooth
aout2 pvsynth fblur
aout1 = aout1 * iamp * 4
aout2 = aout2 * iamp * 3
aout = (aout1+aout2) * 0.8 * aenv * (1/imaxamp)
aout pareq aout, 6800, ampdb(-5), 0.6, 0
; output
if ivoice == 1 then
iout1 = 1
iout2 = 0
elseif ivoice == 2 then
iout1 = 0
iout2 = 1
endif
chnmix aout*iout1, "MasterOut1"
chnmix aout*iout2, "SecondaryDry"
chnmix aout*idel2, "SecondaryDelaySend"
chnmix aout*irvb2, "SecondaryReverbSend"
endin
;******************************
; Spectral voice 3
instr 63
kplay = 1
chnset kplay, "i_am_speaking" ; signals cognition that I'm currently speaking
Ssound strget p4
ilen filelen Ssound
; regular instr parameters
iamp = ampdbfs(p7) ; amp
imaxamp = p8 ; max amp in this sound file
ivoice = p9 ; 1 or 2, for primary or secondary association
idel2 = ampdbfs(p10) ; send to delay (2)
irvb2 = ampdbfs(p11) ; send to reverb (2)
ispeed = p12 ; playback speed
; start and end for segment
istart = p5 ; segment start
iend = p6 ; segment end
if iend == 0 then
iend = ilen
endif
idur = iend - istart
p3 = idur/ispeed
aenv linen iamp, 0.01, p3, 0.2
; sound generator
ktimeAmp = 0.3
ktimeFreq = 0.06
kblurTime = 0.2
kscale = semitone(-0.3)
kshift = 100
klowest = 700
ifftsize = 1024
ioverlap = ifftsize / 4
iwinsize = ifftsize
iwinshape = 1; von-Hann window
ibuffer, ilen, k0 FileToPvsBuf Ssound, ifftsize, ioverlap, iwinsize, iwinshape, istart, iend
;p3 = ilen/ispeed
ktmpnt linseg 0, p3, idur
fread pvsbufread ktmpnt, ibuffer
iframetime = (ioverlap/sr) ; time per fft frame rate
kamountAmp = iframetime/ktimeAmp ; smoothing frequency (in fraction of 1/2 fft framerate)
kamountFreq = iframetime/ktimeFreq ; smoothing frequency (in fraction of 1/2 fft framerate)
fsmooth pvsmooth fread, kamountAmp, kamountFreq
iMax = 1.7
fblur pvsblur fread, kblurTime, iMax
fblurg pvsgain fblur, 0.8
fmix pvsmix fsmooth, fblurg
ikeepform = 0
fscale pvscale fmix,kscale, ikeepform
ikeepform2 = 0
fshift pvshift fscale, kshift, klowest, ikeepform2
aout pvsynth fshift
aout butterhp aout, 100
aout = aout * iamp * 4.5 * aenv * (1/imaxamp)
aout pareq aout, 6800, ampdb(-5), 0.6, 0
; output
if ivoice == 1 then
iout1 = 1
iout2 = 0
elseif ivoice == 2 then
iout1 = 0
iout2 = 1
endif
chnmix aout*iout1, "MasterOut1"
chnmix aout*iout2, "SecondaryDry"
chnmix aout*idel2, "SecondaryDelaySend"
chnmix aout*irvb2, "SecondaryReverbSend"
endin
;******************************
; Spectral voice 4
instr 64
kplay = 1
chnset kplay, "i_am_speaking" ; signals cognition that I'm currently speaking
Ssound strget p4
ilen filelen Ssound
; regular instr parameters
iamp = ampdbfs(p7) ; amp
imaxamp = p8 ; max amp in this sound file
ivoice = p9 ; 1 or 2, for primary or secondary association
idel2 = ampdbfs(p10) ; send to delay (2)
irvb2 = ampdbfs(p11) ; send to reverb (2)
ispeed = p12 ; playback speed
; start and end for segment
istart = p5 ; segment start
iend = p6 ; segment end
if iend == 0 then
iend = ilen
endif
idur = iend - istart
p3 = idur/ispeed
aenv linen iamp, 0.01, p3, 0.2
; sound generator
ifftsize = 1024
ioverlap = ifftsize / 4
iwinsize = ifftsize
iwinshape = 1; von-Hann window
inbins = (ifftsize/2)
ibuffer, ilen, k0 FileToPvsBuf Ssound, ifftsize, ioverlap, iwinsize, iwinshape, istart, iend
ktmpnt linseg 0, p3, idur
fread pvsbufread ktmpnt, ibuffer
fnois pvsgain fread, 1
ifn_amp ftgen 0,0,inbins,10,1 ; make ftable for spectral profile (amp)
ifn_freq ftgen 0,0,inbins,10,1 ; make ftable for spectral profile (amp)
kflag_in pvsftw fnois,ifn_amp,ifn_freq ; export to table,
if kflag_in == 0 kgoto contin ; only proc when frame is ready
kcount = 0
process:
klev = 1
knois rnd31 klev, 1
kfq table kcount, ifn_freq
tablew kfq+(kfq*knois), kcount, ifn_freq ; add noise, noise level dependent on value in table
kcount = kcount + 1
if kcount < inbins goto process
; read modified data back to fsrc
pvsftr fnois, ifn_amp,ifn_freq
contin:
ktimeAmp = 0.1
ktimeFreq = 0.02
iframetime = (ioverlap/sr) ; time per fft frame rate
kamountAmp = iframetime/ktimeAmp ; smoothing frequency (in fraction of 1/2 fft framerate)
kamountFreq = iframetime/ktimeFreq ; smoothing frequency (in fraction of 1/2 fft framerate)
fsmooth pvsmooth fnois, kamountAmp, kamountFreq
fshift pvshift fread, 600, 1500
fshift2 pvshift fshift, -100, 500
aout1 pvsynth fshift2
aout2 pvsynth fsmooth
aout = (aout1*0.6)+(aout2*1)
aout butterhp aout, 150
aout = aout * iamp * 2 * aenv * (1/imaxamp)
aout pareq aout, 6800, ampdb(-5), 0.6, 0
; output
if ivoice == 1 then
iout1 = 1
iout2 = 0
elseif ivoice == 2 then
iout1 = 0
iout2 = 1
endif
chnmix aout*iout1, "MasterOut1"
chnmix aout*iout2, "SecondaryDry"
chnmix aout*idel2, "SecondaryDelaySend"
chnmix aout*irvb2, "SecondaryReverbSend"
endin
;******************************
; Spectral voice 5
instr 65
kplay = 1
chnset kplay, "i_am_speaking" ; signals cognition that I'm currently speaking
Ssound strget p4
ilen filelen Ssound
; regular instr parameters
iamp = ampdbfs(p7) ; amp
imaxamp = p8 ; max amp in this sound file
ivoice = p9 ; 1 or 2, for primary or secondary association
idel2 = ampdbfs(p10) ; send to delay (2)
irvb2 = ampdbfs(p11) ; send to reverb (2)
ispeed = p12 ; playback speed
; start and end for segment
istart = p5 ; segment start
iend = p6 ; segment end
if iend == 0 then
iend = ilen
endif
idur = iend - istart
p3 = idur/ispeed
aenv linen iamp, 0.01, p3, 0.2
; sound generator
ifftsize = 1024
ioverlap = ifftsize / 4
iwinsize = ifftsize
iwinshape = 1; von-Hann window
inbins = (ifftsize/2)
ibuffer, ilen, k0 FileToPvsBuf Ssound, ifftsize, ioverlap, iwinsize, iwinshape, istart, iend
ktmpnt linseg 0, p3, ilen
fread pvsbufread ktmpnt, ibuffer
fnois pvsgain fread, 1
ifn_amp ftgen 0,0,inbins,10,1 ; make ftable for spectral profile (amp)
ifn_freq ftgen 0,0,inbins,10,1 ; make ftable for spectral profile (amp)
kflag_in pvsftw fnois,ifn_amp,ifn_freq ; export to table,
if kflag_in == 0 kgoto contin ; only proc when frame is ready
kcount = 0
process:
klev = 1
knois rnd31 klev, 1
kfq table kcount, ifn_freq
tablew kfq+(kfq*knois), kcount, ifn_freq ; add noise, noise level dependent on value in table
kcount = kcount + 1
if kcount < inbins goto process
; read modified data back to fsrc
pvsftr fnois, ifn_amp,ifn_freq
contin:
ktimeAmp = 0.4
ktimeFreq = 0.3
iframetime = (ioverlap/sr) ; time per fft frame rate
kamountAmp = iframetime/ktimeAmp ; smoothing frequency (in fraction of 1/2 fft framerate)
kamountFreq = iframetime/ktimeFreq ; smoothing frequency (in fraction of 1/2 fft framerate)
fsmooth pvsmooth fnois, kamountAmp, kamountFreq
fshift pvshift fread, 700, 1500
fshift2 pvshift fread, 100, 700
iMax = 1.7
kblurTime = 0.12
fblur pvsblur fshift2, kblurTime, iMax
ashift pvsynth fshift
ashift2 pvsynth fshift2
ablur pvsynth fblur
asmooth pvsynth fsmooth
anois pvsynth fnois
aout = (ashift * 0.9) +\
(ashift2 * 0.5) +\
(ablur * 1) +\
(asmooth * 1.2)+\
(anois * 1)
aout butterhp aout, 150
aout = aout * iamp * aenv * (1/imaxamp)
aout pareq aout, 6800, ampdb(-5), 0.6, 0
; output
if ivoice == 1 then
iout1 = 1
iout2 = 0
elseif ivoice == 2 then
iout1 = 0
iout2 = 1
endif
chnmix aout*iout1, "MasterOut1"
chnmix aout*iout2, "SecondaryDry"
chnmix aout*idel2, "SecondaryDelaySend"
chnmix aout*irvb2, "SecondaryReverbSend"
endin
;******************************
; Partikkel voice 1, "slowdown but at original speed"
instr 66
kplay = 1
chnset kplay, "i_am_speaking" ; signals cognition that I'm currently speaking
Ssound strget p4
ilen filelen Ssound
; regular instr parameters
iamp = ampdbfs(p7) ; amp
imaxamp = p8 ; max amp in this sound file
ivoice = p9 ; 1 or 2, for primary or secondary association
idel2 = ampdbfs(p10) ; send to delay (2)
irvb2 = ampdbfs(p11) ; send to reverb (2)
ispeed = p12*0.5 ; playback speed
; start and end for segment
istart = p5 ; segment start
iend = p6 ; segment end
if iend == 0 then
iend = ilen
endif
idur = iend - istart
ichangeRate = 4 ; grain subsegment spawn rate
iTimeRate2 = ispeed*0.5 ; grain subsegment time pointer rate
idurSamplepos = (idur/ispeed)
p3 = (idur/ispeed)+((1/ichangeRate)*iTimeRate2)
aenv linen iamp, 0.01, p3, 0.2
; sound generator
iSound ftgentmp 0, 0, 0, 1, Ssound, istart,0,0
konce init 1
ktempCount init 0
if konce > 0 then
if ktempCount < idur*sr then
ktemp table ktempCount, iSound
tablew ktemp, ktempCount, iSound
ktempCount = ktempCount+1
endif
endif
konce = 0
#include "partikkel3_self.inc"
aout = aout * iamp * aenv * (1/imaxamp) * 4
; output
if ivoice == 1 then
iout1 = 1
iout2 = 0
elseif ivoice == 2 then
iout1 = 0
iout2 = 1
endif
chnmix aout*iout1, "MasterOut1"
chnmix aout*iout2, "SecondaryDry"
chnmix aout*idel2, "SecondaryDelaySend"
chnmix aout*irvb2, "SecondaryReverbSend"
endin
;******************************
; Partikkel voice 1, "PSGS", Pitch Synchronous Granular Synthesis
instr 67
kplay = 1
chnset kplay, "i_am_speaking" ; signals cognition that I'm currently speaking
Ssound strget p4
ilen filelen Ssound
; regular instr parameters
iamp = ampdbfs(p7) ; amp
imaxamp = p8 ; max amp in this sound file
ivoice = p9 ; 1 or 2, for primary or secondary association
idel2 = ampdbfs(p10) ; send to delay (2)
irvb2 = ampdbfs(p11) ; send to reverb (2)
ispeed = p12 ; playback speed
; start and end for segment
istart = p5 ; segment start
iend = p6 ; segment end
if iend == 0 then
iend = ilen
endif
idur = iend - istart
p3 = idur/ispeed
aenv linen iamp, 0.01, p3, 0.2
; sound generator
; load sound
iSound ftgentmp 0, 0, 0, 1, Ssound, 0,0,0
/*
konce init 1
ktempCount init 0
if konce > 0 then
if ktempCount < idur*sr then
ktemp table ktempCount, iSound
tablew ktemp, ktempCount, iSound
endif
endif
konce = 0
*/
; load pitch file
istrlen strlen Ssound
Spitchfile strsub Ssound, 0, istrlen-4
Spitchfile strcat Spitchfile, "_pitch.txt"
iPitchFn ftgentmp 0, 0, 1048576, -23, Spitchfile
iformant = semitone(1) ; formant change in semitones
itransp = semitone(-12) ; transposition in semitones
#include "partikkel4_psgs.inc"
aout = aout * iamp * aenv * (1/imaxamp) * 5
; output
if ivoice == 1 then
iout1 = 1
iout2 = 0
elseif ivoice == 2 then
iout1 = 0
iout2 = 1
endif
chnmix aout*iout1, "MasterOut1"
chnmix aout*iout2, "SecondaryDry"
chnmix aout*idel2, "SecondaryDelaySend"
chnmix aout*irvb2, "SecondaryReverbSend"
endin