<info>
i is ex6-1
ECMC Csound Tutorial example ex6-1
</info>
<tk_interface>
</tk_interface>
<mono>
    ; csound header
sr=44100
kr=2205
ksmps=20
nchnls=1

;  #############################################################
;  soundfile ex6-1 : harmonizer  ECMC Csound Tutorial
;  #############################################################

   ;  p4 =  gen1 function.# number of source soundfile} ,

   ;     p6 = rise {fade-in} time
   ;     p7 = decay {fade-out} time

instr 1
;----- SOUNDFILE INPUT --------------------
	ifunc = p4 ; gen1 function number of input soundfile
	iampscale = (p5 = 0 ? 1. : p5)  ; adjust input amplitude
	irise = (p6 = 0 ? .001 : p6)   ; fade-in time
	idecay =( p7  = 0 ? .001 : p7)  ; fade-out time

    ; loscil arguments
    ibasepitch = (p8 < 13. ? cpspch(p8) : p8) ; base pitch of soundfile in pch or cps
    ioutpitch = (p9 < 13. ? cpspch(p9) : p9) ; output pitch in pch or cps
    ioutpitch = (p9 < 3 ? p9 * ibasepitch :ioutpitch) ; or as multiplier of basepitch

 ; output amplitude envelope
kamp  expseg  .005 ,irise  , iampscale  , p3 - (irise + idecay) , iampscale , idecay , .005
asource  loscil  kamp, ioutpitch, ifunc, ibasepitch

;----- HARMONIZER --------------------
	imin init 0
	imin = (p10 < 1. ? p10 * ioutpitch : imin)
	imin = (p10 > 1. && p10 < 13. ? cpspch(p10) : imin)
	imin = (p10 > 13 ? p10 : imin)

      ; max. freq. variance
                     ; as % of output source pitch or in pch or cps
	imaxvar = (p11 < 1. ? p11 : p11 / ioutpitch)
        imode = p12 ; if 0, iharm1 & iharm2 are ratios * ioutpitch
                    ;  if 1, iharm1 & iharm2 are notes in pch or cps
        iprd = p15  ; pitch analysis window size
iharm1 init p13
iharm2 init p14
if imode = 0 igoto doit
if p13 = 0 igoto harm2
	iharm1 = (p13 < 13. ? cpspch(p13) : p13)
harm2: if p14 = 0 igoto doit
	iharm2 = (p14 < 13. ? cpspch(p14) : p14)
doit:

aharm harmon asource, ioutpitch, imaxvar, iharm1, iharm2, imode, imin, iprd
print ioutpitch, imaxvar, iharm1, iharm2, imode, imin, iprd
;----- SIGNAL OUTPUTS  {source/harmonizer mix} ---------------
out (p16 * asource) + (p17 * aharm)
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 524288 -1 "/sflib/voice/sop1.b3" 0 0 0 
f2 0 262144 -1 "/sflib/string/vln.b3" 0 0 0 
f3 0 524288 -1 "/sflib/wind/trp.b3" 0 0 0 
  i1 0.000 3.000 1 0.600 0 0.200 7.11 7.11 7.09 0.500 1 7.08 8.01 0.040 0.500 1
  i1 4.000 3.000 2 0.400 0 0.200 7.11 7.11 7.09 0.500 1 7.08 8.01 0.040 0 1
  i1 8.000 3.000 3 0.400 0 0.200 7.11 8.00 7.09 0.500 1 7.08 8.01 0.040 0.200 1
e
</score>
