<info>
i is ex5-3
ECMC Csound Tutorial example ex5-3
</info>
<tk_interface>
</tk_interface>
<mono>
;  #############################################################
;  ex5-3  : Balance used as envelope follower
;  #############################################################

; p4  = soundin.#  number  of audio soundfile
; p5 = ampltidue multiplier  ; p6 = skip from front of audio soundfile
; p7 = optional exponential fade in time ; p8 = optional exponential fade out time
; p9  = soundin.#  number  of control soundfile
; p10 = skip time into control soundfile

instr 1

audio  soundin  p4, p6   ; read in the audio soundfile
aenv soundin p9 , p10    ; read in the control soundfile

 ; impose control soundfile envelope on audio file
audio  balance  audio , aenv 
 ; vary output amplitude from note to note :
p5 = ( p5 = 0 ? 1. : p5 )
audio  =  audio * p5

; optional fade-in & fade-out 
itest =  p7 + p8
if itest = 0  goto done
   kfades expseg .01, p7, 1.,p3-(p7 + p8), 1., p7,.01
   audio = audio * kfades
done:
out audio
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

  i1 0.000 0.153 6 0.200 0 0 0 9 0
  i1 0.300 0.179 7 0.600 1.000 0 0 10 0
  i1 0.600 0.250 8 0.400 0.400 0 0 11 0
  i1 0.900 3.000 5 0.900 2.000 0 0 12 0
  i1 4.100 1.180 6 0.900 0 0 0 13 0
  i1 5.600 1.430 7 0.900 1.000 0 0 14 0
  i1 7.100 3.300 8 0.900 0.400 0 0 15 0
  i1 11.100 7.290 5 0.900 2.000 0 0 16 0
e
</score>
