; #############################################################
; soundfile ex3-5  : "Classical" FM with modulation index envelope : ECMC Csound Tutorial
; FM - single carrier, single modulator "classical fm" instrument 
; p3 = duration ; p4 = pitch (cps or pch); p5 = amplitude 
; p6 = attack time ; p7 = decay time ; p8 = atss amplitude multiplier 
; frequency modulation : p9 freq. ratio of modulator to carrier 
; fm index envelope values : p10 beginning; p11 after p6; p12 before p7 

   sr = 44100
   kr = 4410
   ksmps = 10
   nchnls = 1

instr 38
ipitch = ( p4 >  13.0 ? p4 : cpspch(p4) ) 
p8 = (p8 > 9.99 ? p8 : p8*p5) ; p8 can be an absolute value or * p5 
kamp expseg 1, p6, p5, p3-(p6+p7), p8, p7, 1 ; amplitude envelope 

kfmindex expseg p10, p6, p11, p3-(p6+p7), p12, p7, .3*p12 ; fm index envelope 

a1 foscili kamp, ipitch , 1, p9, kfmindex , 100 
out a1 
endin
