;-g -A -o fm01.aif
-g -odac -iadc -+rtmidi=portmidi -M0
sr = 44100
ksmps=10
nchnls=2
massign 1,1
prealloc 1,10
instr 1 ; example of fm synthesis w/midi
; duration
idur = .25
; overall amplitude
iamp ampmidi 12000
; convert pitch notation to Hz
inote cpsmidi
; carrier ratio
kcarRatio = 1
; modulator ratio
kmodRatio = 1
; environmental shape function
ienvshape = 2
; modulator shape function
iidxshape = 2
; max modulator amplitude
imaxidx = .5
; min modulator amplitude
iminidx = .2
; create a linear envelope of the note duration
; kenvshape linen iamp, 0.5*idur, idur, 0.5*idur
kenvshape oscil1i 0, iamp, idur, ienvshape
; this is triangle envelope the length of the duration
; kidxshape linen imaxidx-iminidx, 0.3*idur, idur, 0.2*idur
kidxshape oscil1i 0, imaxidx-iminidx, idur, iidxshape
; modulation signal
; amplitude is frequency dependent
; frequency is some multiple of the carrier
am oscili (iminidx + kidxshape)*kmodRatio*inote, kmodRatio*inote, 1
; the output signal
; amplitude is the given Amp and duration envelope
; frequency is (carrier frequency + modulation)
ac oscili kenvshape, kcarRatio*inote + am, 1
out ac, ac
endin
f0 3600
; function table 1
; GEN 10: sine wave
; index start samples GEN max amplitude
f 1 0 8192 10 1
; hamming window
f 2 0 1024 20 1
; gaussian noise
f 3 0 4096 21 6 1
; linear ramp
f 4 0 4096 7 0 4096 1 0 1
;CLARINET TONES, AFTER CHOWNING
f 5 0 512 7 0 50 0.4 50 1 348 1 16 0.8 16 0.5 16 0.3 16 0 ;AMPLITUDE
f 6 0 512 7 0 50 0.4 50 1 412 1 ;INDEX
;MEMBRANOPHONE, AFTER CHOWNING
f 7 0 2048 7 0.8 256 0.85 256 1 128 0.9 192 0.45 64 0.3 1152 0 ;AMPLITUDE
f 8 0 512 5 1 512 .2 ;INDEX
;BRASS, AFTER CHOWNING
f 9 0 512 7 0 86 1 86 .75 254 0.6 86 0 ;AMPLITUDE AND INDEX
; exponential falloff (bells)
f 10 0 513 5 1 513 .0001
f 11 0 513 5 1 513 .02
e