sr = 44100
kr = 44100
ksmps = 1
nchnls = 2
;Simple FM drum instrument using foscil
;Built in class on 09/28/06
instr 1 ;FM Percussion Instr
ipkamp = ampdb(p4)
ibasoct = octpch(p5)
icarfac = p6
imodfac = p7
imaxbnd = p8
itrdur = p9
itridur = itrdur*.75 ;slightly shorter index envelope duration
itrbdur = itrdur*1.5 ;slightly longer pitch bend duration
iendbnd = p10
indx1 = p11
indx2 = p12
isusamp = ampdb(p13)
kbend linseg imaxbnd,itrbdur,iendbnd,1,iendbnd ;pitch bend in oct
koct = ibasoct+kbend
kcarhz = cpsoct(koct*icarfac)
kmodhz = cpsoct(koct*imodfac)
kndx expseg indx1,itridur,indx2,p3-itridur,indx2
aamp expseg ipkamp,itrdur,isusamp,p3-itrdur,.01
asig foscili aamp,cpsoct(ibasoct+kbend),icarfac,imodfac,kndx,1
outs asig,asig
endin
;test score for fm drum instrument
;single sine cycle
f01 0 8192 10 1
;half second of silence at start of tests
f0 .5
s
;Test a range of pitches, bend amounts, transient durations, and indexes.
; st dur ipkdb ipch carfac modfac maxbnd trdur endbnd indx1 indx2 isusdb
i01 0 .75 90 7.00 1 .31791 1 .2 0 7 .005 82
i01 + . . 6.08 . . < < . <
i01 + . . 6.04
i01 + . . 6.00
i01 + . . 5.08
i01 + . . 5.04 . . 1.5 .5 . 15
e