| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
-o dac |
| 4 |
</CsOptions> |
| 5 |
<CsInstruments> |
| 6 |
|
| 7 |
sr = 44100 |
| 8 |
ksmps = 32 |
| 9 |
nchnls = 1 |
| 10 |
0dbfs = 1 |
| 11 |
|
| 12 |
;Some macros |
| 13 |
#define ATS_NP # 3 # ;number of Partials |
| 14 |
#define ATS_DU # 7 # ;duration |
| 15 |
|
| 16 |
instr 1 |
| 17 |
iatsfile = p11 |
| 18 |
/*read some ATS data from the file header*/ |
| 19 |
i_number_of_partials ATSinfo iatsfile, $ATS_NP |
| 20 |
i_duration ATSinfo iatsfile, $ATS_DU |
| 21 |
print i_number_of_partials |
| 22 |
|
| 23 |
iamp = p4 ;amplitude scaler |
| 24 |
ifreqdev = 2^(p5/12) ;frequency deviation (p5=semitones up or down) |
| 25 |
isinlev = p6 ;deterministic part gain |
| 26 |
inoislev = p7 ;residual part gain |
| 27 |
|
| 28 |
/*here we deal with number of partials, offset and increment issues*/ |
| 29 |
inpars = (p8 < 1 ? i_number_of_partials : p8) ;inpars can not be <=0 |
| 30 |
ipofst = (p9 < 0 ? 0 : p9) ;partial offset can not be < 0 |
| 31 |
ipincr = (p10 < 1 ? 1 : p10) ;partial increment can not be <= 0 |
| 32 |
imax = ipofst + inpars*ipincr ;max. partials allowed |
| 33 |
|
| 34 |
if imax <= i_number_of_partials igoto OK |
| 35 |
;if we are here, something is wrong! |
| 36 |
;set npars to zero, so as the output will be zero and the user knows |
| 37 |
prints "wrong number of partials requested", imax, i_number_of_partials |
| 38 |
inpars = 0 |
| 39 |
ipofst = 0 |
| 40 |
ipincr = 1 |
| 41 |
OK: ;data is OK |
| 42 |
/********************************************************************/ |
| 43 |
|
| 44 |
ktime linseg 0, p3, i_duration |
| 45 |
asig ATSsinnoi ktime, isinlev, inoislev, ifreqdev, iatsfile, |
| 46 |
inpars, ipofst, ipincr |
| 47 |
|
| 48 |
out asig*iamp |
| 49 |
endin |
| 50 |
|
| 51 |
</CsInstruments> |
| 52 |
<CsScore> |
| 53 |
;change to put any ATS file you like |
| 54 |
#define ats_file #"female-speech.ats"# |
| 55 |
|
| 56 |
; start dur amp freqdev sinlev noislev npars offset pincr atsfile |
| 57 |
i1 0 3.66 .79 0 1 0 0 0 1 $ats_file |
| 58 |
;deterministic only |
| 59 |
i1 + 3.66 .79 0 0 1 0 0 1 $ats_file |
| 60 |
;residual only |
| 61 |
i1 + 3.66 .79 0 1 1 0 0 1 $ats_file |
| 62 |
;deterministic and residual |
| 63 |
; start dur amp freqdev sinlev noislev npars offset pincr atsfile |
| 64 |
i1 + 3.66 2.5 0 1 0 80 60 1 $ats_file |
| 65 |
;from partial 60 to partial 140, deterministic only |
| 66 |
i1 + 3.66 2.5 0 0 1 80 60 1 $ats_file |
| 67 |
;from partial 60 to partial 140, residual only |
| 68 |
i1 + 3.66 2.5 0 1 1 80 60 1 $ats_file |
| 69 |
;from partial 60 to partial 140, deterministic and residual |
| 70 |
e |
| 71 |
</CsScore> |
| 72 |
</CsoundSynthesizer> |
| 73 |
;example by Oscar Pablo Di Liscia |