<info>
SuperBrassage
Using fof2 ugen.

Jean Piche, 1996
</info>
<tk_interface>
cfilein name -lab Source

cgraph index				-label Index -min  0 -max 1 -func "0 0 1 1"
csepar
csepar -label "stream profile"
cgraph grainfreq				-label "Grain\nFrequency"  -rel lo -min .1 -max 2500 -init 10
cgraph overlap				-label "Density\n(overlaps)" -rel lo -min 1 -max 60 -init 4
cgraph gliss				-label "Glissando"  -min -3.0 -max 3.0 -init 0 
csepar
csepar -label "randomness"
cgraph pitchrand				-label "Pitch Range"  -min 0 -max 1 -init 0 
cgraph grainrand  				-label "Grain placement"  -min 0 -max 1 -init 0 
cgraph indexrandamp				-label "Index Range"  -min 0 -max 1 -init 0
cgraph indexrandspeed				-label "Index Freq" -rel lo -min .01 -max 2000 -init 1
csepar

csepar -label "amplitude"
cgraph gate -label "Grain Gate"   -min 0 -max 1 -init 1 
cgraph gain -label  "Gain" -min 0 -max 1 -init .25  

cslider att			-label "Grain Attack Time"   -res .001 -min 0 -max 1 -init .01
cslider dec			-label "Grain Decay Time"  -res .001 -min 0 -max 1 -init .01
cslider total_time	-label "Total Duration"  -ra i -unit sec. -res 1 -min 5 -max 240 -init 30
cslider streams			-label "No. of Streams" -ra i -res 1 -min 1 -max 6 -init 3
cslider chorus			-label "Chorusing" -ra i  -res .001 -min 0 -max 1 -init .105
cslider seed			-label "Random Seed" -ra i -res .001 -min 0 -max 1 -init .5
</tk_interface>
<mono>

</mono>
<stereo>
	instr 1
      idroite		=	sin(p5*1.57)
      igauche		=	cos(p5*1.57)
      krand1		rand 	gkpitchrand, .345*[seed]
      krand2		randi 	gkgrainrand, 1042, .765*[seed]*p5
      kov     		=	gkoverlap  
      insnd  		= 	10        
      ilen		=	[sinfo name frames] / ftlen(insnd)  
      ibas    		=	(sr/ [sinfo name frames])* ([sinfo name sr]/sr) 
      kfund 		= 	gkgrainfreq  * (1+krand2)
      kgate		randh 	.5, kfund, .432*[seed]
      krist		=	(kgate+.5<gkgate?0:200)  
      kform 		= 	ibas * (1+krand1) * ilen
      kspeed		=	gkindexrandspeed
      kind2		randi 	gkindexrandamp, gkindexrandspeed, .9765*[seed]

      kindex		=	(gkindex+kind2+gkindexrandamp )*ilen
      kdur   	=  	(kov/kfund);
      kris 	= 	((kdur *gkatt)+krist)
      kdec 	= 	kdur*gkdec
      iolaps 	= 	300

      a1 	fof2 	gkgain, kfund, kform*p4, 0, 0, kris, kdur, kdec, iolaps, insnd, 7, p3, kindex, gkgliss

if [sinfo name chn] == 1 goto getout

      a2	fof2 	gkgain, kfund, kform*p4, 0, 0, kris, kdur, kdec, iolaps, insnd, 7, p3, kindex, gkgliss

if gistreams == 1 goto single
 	outs 	(a1+a2)*idroite, (a1+a2)*igauche
	goto oute

single:
 	outs 	(a1)*idroite, (a2)*igauche
	goto oute

getout:

if gistreams == 1 goto single2
 	outs 	(a1)*idroite, (a1)*igauche
	goto oute
single2:
 	outs 	(a1)*idroite, (a1)*igauche

oute:
					endin
</stereo>
<quad>

</quad>
<score>
#tcl
proc makeScore {} {
	global  value realArr
	set size [findgenSize [sinfo name frames]]
	set thescore "f7   0 8192    9  .25  1      0 \n"
	append thescore "f10 0 $size -1 \"$value(name)\" 0 4 1\n"
	if {[sinfo name chn] != "1"} {
	append thescore "f11 0 $size -1 \"$value(name)\" 0 4 2\n"
	}
	set inc { {.5} { 0 1} {0 .5 1} {0 .33 .66 1} {0 .25 .5 .75 1} { 0 .2 .4 .6 .8 1} }
	foreach not [lindex $inc [expr $value(streams) - 1] ] {
		set pitch [expr 1.0+(($not-0.5)* $value(chorus))]
		append thescore "i1 0 $value(total_time)   $pitch $not \n"
	}
	return $thescore
}

makeScore
</score>
