<info>
i is ex5-2
ECMC Csound Tutorial example ex5-2
</info>
<tk_interface>
</tk_interface>
<mono>
;  #############################################################
;  soundfile ex5-2    :  Tone & Balance   (same score as ex5-1)
;  #############################################################

; mono soundfile input:

instr 39

; functions : optional : 98 (soundin. numbers) & 99 (durations)
; p4  = soundin. number or, if negative, index pointer to funcs. 98 & 99
; p5 = ampfac  ; p6 = skip from front of soundfile
; p7 = exponential fade in time ; p8 = exponential fade out time
isfnum init p4
idur init p3
if p4 > 0 goto gotit
	isfnum table abs(p4),98
	idur table abs(p4),99
 ; to prevent hangs, when true dur. is slightly < than dur. provided by sndinfo
          idur = idur - .005
	timout 0,idur,gotit
   	turnoff   ;shut down when duration in table 99 is reached
gotit:

a1 soundin isfnum,p6 

iampfac  = (p5 =0?1:p5 )     
; fade-in & fade-out defaults & checks:
	ip7  = (p7 =0?.001:p7 )
	ip8  = (p8 =0?.001:p8 )
	ip7  = (p7 >100? (p7 -100) * idur : ip7 )
	ip8  = (p8 >100? (p8 -100) * idur : ip8 )
        ip7 = (p7 < 0 ? abs(p7) * idur : ip7)
        ip8 = (p8 < 0 ? abs(p8) * idur : ip8)
	ifades = ip7 + ip8
	if ifades < idur goto noproblem
	print idur, ifades
noproblem:
a3 expseg .01,ip7 ,iampfac,idur-(ip7 +ip8 ),iampfac,ip8 ,.01
a1 = a1*a3

;Added users code
 ; instrument for low pass filtering of soundfiles
; p9 = 1st half-power point, p10 = 2nd h.p. point
; p11 = rate of change between p9 & p10, p12= func. for change
irate = (p11=0? 1/p3 : p11)
k1 oscili p10-p9,irate,p12
khp = k1 + p9     ; changing half-power point
afilt tone a1, khp
a1 balance afilt,a1
out a1

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

f1 0 65 7 0 64 1
f2 0 65 7 0 32 1. 32 0
f3 0 65 5 .01 32 1. 32 .01
  i39 0.000 3.000 5 0.900 0.500 1.000 1.000 100 3000 0 1
  i39 3.500 3.000 5 0.900 0.500 1.000 1.000 2000 150 0 2
  i39 7.000 3.000 5 0.900 0.500 1.000 1.000 2000 100 0.750 3
  i39 10.500 3.000 5 0.900 0.500 1.000 1.000 200 900 4.000 3
e
</score>
