sf2 instrument

instr 20
;;parameters names
; 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 
; i st dur amp num ft1 atk rel hd1 hd2 gl1 gl2 fq1 fq2 fq3 pa1 pa2 del rvn rvs vel frq idx pnb bnk rvs off
;;Csgrouper param recognition (for Trumpet):
; CSGF=3:dur=0.25; CSGF=4:amp=1; CSGF=5:mid=60; CSGF=6:ft1=0; CSGF=7:atk=0.02; CSGF=8:rel=0.2; CSGF=9:hd1=0.2; CSGF=10:hd2=0.2; 
; CSGF=11:gl1=0.2; CSGF=12:gl2=0.2; CSGF=13:fq1=1; CSGF=14:fq2=1.1; CSGF=15:fq3=1.1; CSGF=16:pa1=0.5; CSGF=17:pa2=0.5;
; CSGF=18:del=0.1; CSGF=19:rvn=1; CSGF=20:rvs=0.07; CSGF=21:amf=100; CSGF=22:frq=0; CSGF=23:idx=0; CSGF=24:pnb=0;
; CSGF=25:bnk=0; CSGF=26:flg=0; CSGF=27:off=0;
; init: gisf1 sfload "/usr/local/csound/IN/sf2/Trumpet_JL.sf2" ; 
isf= gisf1 ; 
; 
idur = p3 ; ENVELOPE
iamp = p4 ; 
inum = p5 ; 
ift1 = p6 ; 
iatk = p7 ; 
irel = p8 ; 
ihd1 = p9 ; during the attack
ivel = p21 ; 
ifrq = p22 ; 
idx = p23 ; 
ista = idur-iatk-irel ; 
if (ift1 == 0) goto NOFTNV ; 
kenv envlpx iamp, iatk, idur, irel, ift1, 1, .01 ; 
goto GLISS ; 
; 
NOFTNV: ; 
kenv linseg 0, iatk, iamp, idur-irel-iatk, iamp, irel, 0 ; END ENVELOPE
; 
GLISS: ; PITCH
ifreq = p22 ; 
ihd2 = p10 ; during the release
igl1 = p11 ; from freq1 to freq2
igl2 = p12 ; from freq2 to freq3
itop = idur-ihd1-ihd2-igl1-igl2 ; 
ifq1 = p13 ; 1 / local factor
ifq2 = p13 ; 
ifq3 = p13 ; 
iflg = p26 ; 0=local pitch/GLISS, 1=note num.
if (iflg == 1) goto NOGLIS ; absolute freq.
if (ifrq == 1) goto NOGLIS ; notenum no GLISS.
ifq2 = p14 ; 
ifq3 = p15 ; 
kfrq linseg ifq1, ihd1, ifq1, igl1, ifq2, itop, ifq2, igl2, ifq3, ihd2, ifq3 ; 
goto ENDGLI ; 
; 
NOGLIS: ; 
kfrq = ifreq ; 
; 
ENDGLI: ; END PITCH 
; 
ipn1 = p16 ; PAN (*must* be set)
ipn2 = p17 ; 
idel = p18 ; pan ratio
ifd1 = idur-(idur*idel) ; 
ifd2 = idur-ifd1 ; 
ipn1 = abs(ipn1) ; Starting balance: <.5 = R, >.5 = L. 
ipn2 = abs(ipn2) ; Target balance.
kpan linseg ipn1, ifd1, ipn2, ifd2, ipn2 ; END PAN 
; 
iprg = p24 ; PRESET
ibnk = p25 ; 
ioff = p27 ; 
ipre sfpreset iprg, ibnk, isf, idx ; 
a1,a2 sfplay3 ivel, inum, iamp*kenv, kfrq, ipre, iflg, ioff ; END PRESET
; 
irvn = p19 ; EFFECT (nbr)
irvs = p20 ; (amp ratio)
; REVERB
if (irvn == 0) goto NOREV ; 
if (irvn == 1) goto REV1 ;
if (irvn == 2) goto REV2 ;
if (irvn == 3) goto REV3 ; 
if (irvn == 4) goto REV4 ; 
if (irvn == 5) goto ECH1 ; 
if (irvn == 6) goto EFF1 ; 
if (irvn == 7) goto EFF2 ; 
goto NOREV ; 
; 
REV1: ; 
garvbsig= garvbsig+(((a1+a2)/2)*irvs) ; 
goto NOREV ; 
REV2: ; 
garvb = garvb+(((a1+a2)/2)*irvs) ; 
goto NOREV ; 
REV3: ; 
garvb1 = garvb1+(((a1+a2)/2)*irvs) ; 
goto NOREV ; 
REV4: ; 
gamet1 = gamet1+(((a1+a2)/2)*irvs) ; 
goto NOREV ; 
ECH1: 
gacmb1 = gacmb1+(((a1+a2)/2)*irvs) ; 
goto NOREV ; 
EFF1: 
ga1eff1 = ga1eff1+(((a1+a2)/2)*irvs) ; 
goto NOREV ; 
EFF2: 
ga2eff1 = ga2eff1+(((a1+a2)/2)*irvs) ; 
goto NOREV ; 
; 
NOREV: ; END EFFECT 
; 
outs a1*(1-kpan),a2*kpan ; OUT
; 
endin
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s