<info>
i is ex3-4
ECMC Csound Tutorial example ex3-4
</info>
<tk_interface>
</tk_interface>
<mono>
;  #############################################################
;  soundfile ex3-4   :  F.M. Glissando Instrument : Csound Tutorial
;  #############################################################

instr 1
    k1 linen p5,p6,p3,p7   ; amplitude envelope

    ; Glissando control signal :
    i1 = cpspch(p4)        ; 1st pitch
    i2 = cpspch(p10)       ; 2nd pitch
    i3 = p8*i1             ; ratio of mod. freq. to carrier freq.
    p12 = (p12 < .0001 ? .0001 : p12)  ; for notes with no gliss
                                         ; p12 cannot be 0 in expseg below
    kgliss expseg i1,p11,i1,p12,i2,p3-(p11+p12),i2 ; gliss. envelope
    display kgliss,p3            ; let's see how it looks

    ; Scale fm index : the lower the pitch, the higher the index
    k3 = octcps(kgliss)  ; convert cps to oct for scalar
    kscale = (18-k3)*.1  ; index scalar ; c4 = 1., c3=1.1, c5 = .9 etc
    kscale = kscale*kscale ; now c4 =1., c3 = 1.21, c5 = .81 etc
;   display kscale,p3

    ; F.M.
    amod  oscili p9*p8*kgliss, p8*kgliss, 100     ; modulating oscillator
    amod = kscale*amod  ; now scale the fm index
    acar  oscili k1, kgliss+amod, 100   ; carrier oscillator
    out acar
endin

</mono>
<stereo>
</stereo>
<score>

                  SCORE-11, Version 1.4
Copyright (C) 1982, 1990, 1992, 1995 by Alexander R. Brinkman
     Eastman School of Music, University of Rochester

f100 0 1024 10 1.
  i1 0.000 3.000 7.09 8000 0.150 0.700 2.003 1.500 7.09 3.000 0
  i1 3.000 4.000 7.09 8000 0.150 0.700 2.003 1.500 9.00 0.500 1.500
  i1 7.000 5.500 11.02 8000 0.150 1.200 2.005 1.300 6.03 0.750 2.500
e
</score>
