| 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 |
|
| 13 |
;Some macros |
| 14 |
#define ATS_NP # 3 # ;number of Partials |
| 15 |
#define ATS_DU # 7 # ;duration |
| 16 |
|
| 17 |
instr 1 |
| 18 |
|
| 19 |
/*read some ATS data from the file header*/ |
| 20 |
iatsfile = p11 |
| 21 |
i_number_of_partials ATSinfo iatsfile, $ATS_NP |
| 22 |
i_duration ATSinfo iatsfile, $ATS_DU |
| 23 |
|
| 24 |
iamp = p4 ;amplitude scaler |
| 25 |
ifreqdev = 2^(p5/12) ;frequency deviation (p5=semitones up or down) |
| 26 |
itable = p6 ;audio table |
| 27 |
|
| 28 |
/*here we deal with number of partials, offset and increment issues*/ |
| 29 |
inpars = (p7 < 1 ? i_number_of_partials : p7) ;inpars can not be <=0 |
| 30 |
ipofst = (p8 < 0 ? 0 : p8) ;partial offset can not be < 0 |
| 31 |
ipincr = (p9 < 1 ? 1 : p9) ;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 |
print imax, i_number_of_partials |
| 38 |
inpars = 0 |
| 39 |
ipofst = 0 |
| 40 |
ipincr = 1 |
| 41 |
OK: ;data is OK |
| 42 |
/********************************************************************/ |
| 43 |
igatefn = p10 ;amplitude scaling table |
| 44 |
|
| 45 |
ktime linseg 0, p3, i_duration |
| 46 |
asig ATSadd ktime, ifreqdev, iatsfile, itable, inpars, ipofst, ipincr, igatefn |
| 47 |
|
| 48 |
out asig*iamp |
| 49 |
endin |
| 50 |
|
| 51 |
</CsInstruments> |
| 52 |
<CsScore> |
| 53 |
|
| 54 |
;change to put any ATS file you like |
| 55 |
#define ats_file #"basoon-C4.ats"# |
| 56 |
|
| 57 |
;audio table (sine) |
| 58 |
f1 0 16384 10 1 |
| 59 |
;some tables to test amplitude gating |
| 60 |
;f2 reduce progressively partials with amplitudes from 0.5 to 1 |
| 61 |
;and eliminate partials with amplitudes below 0.5 (-6dBFs) |
| 62 |
f2 0 1024 7 0 512 0 512 1 |
| 63 |
;f3 boost partials with amplitudes from 0 to 0.125 (-12dBFs) |
| 64 |
;and attenuate partials with amplitudes from 0.125 to 1 (-12dBFs to 0dBFs) |
| 65 |
f3 0 1024 -5 8 128 8 896 .001 |
| 66 |
|
| 67 |
; start dur amp freq atable npars offset pincr gatefn atsfile |
| 68 |
i1 0 2.82 1 0 1 0 0 1 0 $ats_file |
| 69 |
i1 + . 1 0 1 0 0 1 2 $ats_file |
| 70 |
i1 + . .8 0 1 0 0 1 3 $ats_file |
| 71 |
|
| 72 |
e |
| 73 |
</CsScore> |
| 74 |
</CsoundSynthesizer> |
| 75 |
;example by Oscar Pablo Di Liscia |