<info>
i is exapp2-1
ECMC Csound Tutorial example exapp2-1
</info>
<tk_interface>
</tk_interface>
<mono>
; this examples uses a STEREO orchestra
</mono>
<stereo>
;  #############################################################
;  soundfile exapp2-1  : Double carrier F.M. instrument with formant
;  #############################################################
; phase (frequency) modulation  instrument with 2 carriers; STEREO OUT
;  NORMALLY THIS WOULD BE A MONO INSTRUMENT. THE TWO CARRIER OUTPUTS
; ARE SENT TO THE LEFT AND RIGHT CHANNELS IN THIS EXAMPLE ONLY SO THAT THE
; OUTPUT OF EACH CARRIER CAN BE HEARD INDIVIDUALLY. TO HEAR THE 2 CHANNELS
; (CARRIERS) INDIVIDUALLY, MOVE THE BALANCE POT BACK ON THE CS-115 BACK & 
; FORTH BETWEEN LEFT & RIGHT CHANNEL OUTPUTS
; p-fields :
; p3 Duration ;  p4 Pitch        ;p5 Amplitude   ;p6 Attack Time 
; p7 Decay time  ; p8 atss       ;p9 rise function
; Fm :
; p10  1st carrier freq. (*p4)  ; p11 = 1st mod. freq. (*p4)
; p12  2nd carrier freq. (*p4)  ; p13  2nd mod. freq. (*p4)
; Modulation index: p14 opening index; p15  index after p6; p16 index before p7
; Ampiltude % for 2nd carrier : p17 opening ; p18 after p6 ; p19 before p7
; p20 attack hardness (1. ord)

instr 1
i1 = cpspch(p4)
a1 envlpx p5,p6,p3,p7,p9,p8,.005

; Random frequency deviation ( for attack noise)
i2 = octcps(i1)
i2 = (18-i2) * .1     ; scalar : c4 = 1.,c5 =.9, c3 = 1.1, etc.
k1 expseg .5*p20,p20*p6,.003,p3,.002
k2 expseg 999,p20*p6,15
k1 randi  k1*i1,k2
k1 = i1+k1              ; pitch
; Fm index:
k2 expseg p14,p6,p15,p3-(p6+p7),p16,p7,.5*p7

a2 foscili a1,k1,p12,p13,k2,100      ; 2nd carrier (usually higher frequencies)
a1 foscili a1,k1,p10,p11,k2,100      ; 1st carrier
; envelope for % 2nd carrier
k1 expseg p17,p6,p18,p3-(p6+p7),p19,p7,.5*p19

     ; The next four lines are the normal output
     ; a1 = (k1*k2)+((1-k1)*a1)
     ; a2 reson a1,p21,p22,1           ; formant
     ; a1 balance .5*a2+.5*a1,a1
     ; out a1

  ; The following lines send the output of carrier 1 to the left channel and
  ; the output of carrier two to the right channel, so that they can be heard
  ; separately
a3 reson a1,p21,p22,1        ; formant for carrier 1
a4 reson a2,p21,p22,1        ; same formant for carrier 2
a1 balance .5*a1+.5*a3,a1
a2 balance .5*a2+.5*a4,a2
outs (1-k1)*a1,k1*a2
endin
<score>

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

f60 0 65 5 .005 64 1. 
f70 0 65 9 .25 1. 0
f100 0 512 10 1.
  i1 0.000 2.000 7.11 7000 0.075 0.300 0.900 60 1.000 1.998 2.001 2.003 1.700 1.400 1.100 0.600 0.490 0.440 1.000 420 200
  i1 2.000 2.000 7.11 7000 0.080 0.200 0.940 70 1.002 0.998 6.000 1.002 3.000 2.200 1.900 0.600 0.400 0.360 1.200 500 350
  i1 4.000 2.000 7.11 7000 0.015 0.500 0.700 60 1.996 3.002 3.005 2.996 1.000 0.800 0.600 0.700 0.550 0.400 1.000 900 60
  i1 6.000 2.000 7.11 7000 0.085 0.150 0.820 60 0.998 1.008 2.003 0.997 1.600 1.300 1.000 0.500 0.520 0.430 0.900 600 400
  i1 8.000 4.000 7.11 7000 0.800 1.100 0.300 60 1.400 3.100 1.000 2.400 0.250 0.800 1.500 0.050 0.100 0.950 0.500 300 700
e
</score>
