;----------------------------;
; Pinkston: FM Instrument 2a ;
;----------------------------;
sr = 44100
kr = 4410
ksmps = 10
nchnls = 1
instr 2 ;simple PM instrument
isine = 1 ;f01 has a sine wave
iamp = p4 ;peak amp of carrier
ihz0 = cpspch(p5)+p18 ;theoretical fundamental+detune
icfac = p6 ;carrier factor
imfac = p7 ;modulator factor
i2pi = 6.2832 ;2 PI radians per cycle
indx = p8/i2pi ;maximum index value/2PI
ieva = p9 ;attack time of main envelope
ievd = p10 ;decay time of main envelope
iamp2 = p11*iamp ;main amp sustain level
ievr = p12 ;release time of main envelope
ievss = p3-ieva-ievd-ievr ;env steady state
indx1 = p13*indx ;initial/final index
idxa = p14 ;attack time of index
idxd = p15 ;decay time of index
indx2 = p16*indx ;sustained index
idxr = p17 ;release time of index
idxss = p3-idxa-idxd-idxr ;index steady state
kndx linseg indx1,idxa,indx,idxd,indx2,idxss,indx2,idxr,indx1
kamp linseg 0,ieva,iamp,ievd,iamp2,ievss,iamp2,ievr,0
amodsig oscili kndx,ihz0*imfac,isine ;the modulator
acarphs phasor ihz0*icfac ;moving phase at the carrier frequency
;Phase modulation of carrier takes place here:
asig tablei acarphs+amodsig,isine,1,0,1 ; normalized index and wrap flag on
out asig*kamp ;apply the envlp here
endin
;---------------------------------------------------;
;Pinkston: Sample Score for FM Instruments 2 and 2a ;
;---------------------------------------------------;
f01 0 2048 10 1 ;simple sine wave
; st dur amp pch cfac mfac index rise dec
i02 0 1 20000 8.09 1 1 5 .05 .01
; afact rel xfac1 xris xdec xfac2 xrel detune
1 .2 0 .1 .5 .25 .25 0
i02 2 . . . 3 1 2 . .
. . . . .01 1 .25
i02 4 . . 6.09 5 1 1.5
i02 6 . . 8.09 3 2 4 . .
. . .5 . . 1
;three notes slightly detuned and slightly staggered entrances
i02 8 6 10000 6.00 1 1.4 10 3 1.9
.7 1 0 3 1.9 .25 1
i02 8.005 . . . . . . . .
. . . . . . . 1
i02 8.012 . . . . . . . .
. . . . . . . -1
e