| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
-o dac |
| 4 |
</CsOptions> |
| 5 |
<CsInstruments> |
| 6 |
sr = 44100 |
| 7 |
ksmps = 32 |
| 8 |
nchnls = 1 |
| 9 |
0dbfs = 1 |
| 10 |
|
| 11 |
instr 1 |
| 12 |
itabc = p7 ;table with the 25 critical band frequency edges |
| 13 |
iscal = 1 ;reson filter scaling factor |
| 14 |
iamp = p4 ;amplitude scaler |
| 15 |
iband = p5 ;energy band required |
| 16 |
if1 table iband-1, itabc ;lower edge |
| 17 |
if2 table iband, itabc ;upper edge |
| 18 |
idif = if2-if1 |
| 19 |
icf = if1 + idif*.5 ;center frequency value |
| 20 |
ibw = icf*p6 ;bandwidth |
| 21 |
iatsfile = p8 ;ats file name |
| 22 |
|
| 23 |
idur ATSinfo iatsfile, 7 ;get duration |
| 24 |
|
| 25 |
ktime line 0, p3, idur ;time pointer |
| 26 |
|
| 27 |
ken ATSreadnz ktime, iatsfile, iband ;get frequency and amplitude values |
| 28 |
anoise gauss 1 |
| 29 |
aout reson anoise*sqrt(ken), icf, ibw, iscal ;synthesize with scaling |
| 30 |
|
| 31 |
out aout*iamp |
| 32 |
endin |
| 33 |
|
| 34 |
</CsInstruments> |
| 35 |
<CsScore> |
| 36 |
; sine wave table |
| 37 |
f1 0 16384 10 1 |
| 38 |
;the 25 critical bands edge's frequencies |
| 39 |
f2 0 32 -2 0 100 200 300 400 510 630 770 920 1080 1270 1480 1720 2000 2320 \ |
| 40 |
2700 3150 3700 4400 5300 6400 7700 9500 12000 15500 20000 |
| 41 |
|
| 42 |
;an ats file name |
| 43 |
#define atsfile #"female-speech.ats"# |
| 44 |
|
| 45 |
;a macro that synthesize the noise data along all the 25 critical bands |
| 46 |
#define all_bands(start'dur'amp'bw'file) |
| 47 |
# |
| 48 |
i1 $start $dur $amp 1 $bw 2 $file |
| 49 |
i1 . . . 2 . . $file |
| 50 |
i1 . . . 3 . . . |
| 51 |
i1 . . . 4 . . . |
| 52 |
i1 . . . 5 . . . |
| 53 |
i1 . . . 6 . . . |
| 54 |
i1 . . . 7 . . . |
| 55 |
i1 . . . 8 . . . |
| 56 |
i1 . . . 9 . . . |
| 57 |
i1 . . . 10 . . . |
| 58 |
i1 . . . 11 . . . |
| 59 |
i1 . . . 12 . . . |
| 60 |
i1 . . . 13 . . . |
| 61 |
i1 . . . 14 . . . |
| 62 |
i1 . . . 15 . . . |
| 63 |
i1 . . . 16 . . . |
| 64 |
i1 . . . 17 . . . |
| 65 |
i1 . . . 18 . . . |
| 66 |
i1 . . . 19 . . . |
| 67 |
i1 . . . 20 . . . |
| 68 |
i1 . . . 21 . . . |
| 69 |
i1 . . . 22 . . . |
| 70 |
i1 . . . 23 . . . |
| 71 |
i1 . . . 24 . . . |
| 72 |
i1 . . . 25 . . . |
| 73 |
# |
| 74 |
|
| 75 |
;ditto...original sound duration is 3.633 secs. |
| 76 |
;stretched 300% |
| 77 |
$all_bands(0'10.899'1'.05'$atsfile) |
| 78 |
|
| 79 |
e |
| 80 |
</CsScore> |
| 81 |
</CsoundSynthesizer> |
| 82 |
;example by Oscar Pablo Di Liscia |