 < This example illustrates the use of granular synthesis procedures
 <  to generate a new, composite timbre by mixing grains from various
 <  source timbres.
 
 < mix together four source soundfiles :
 *f1 0 524288 -1 "/sflib/voice/sop1.fs4.wav" 0 0 0;
 *f2 0 262144 -1 "/sflib/wind/fl.gs4.wav" 0 0 0;
 *f3 0 262144 -1 "/sflib/string/vln.g4.wav" 0 0 0;
 *f4 0 262144 -1 "/sflib/perc/crt.fs6.wav" 0 0 0;

instr gran  0 6;   < output lasts 6 seconds
p3  mo 3. .03 .04 .01 .02/ x 3. .01 .02 .1;  < time between grains gets
                              < shorter, then further apart at end
  < duty factor:  determines overlap of grains
  < normal range is between 100.02 and 100.2 {producing .02-.2 second overlaps}
du  mx 6.  100.07  100.12;   < overlap time increases slightly
   < p4 cross-fade time for both fade-in & fade-out ;
   <   p4  normally = c. 1/2 duty factor fraction { 1/2 the grain overlap time}
p4  mx  6.  .03  .06;  < cross-fade times increase, like the duty factor

   < p5 = output amplitude : raw amp {10.1-32767} or multiplier {.001 - 10.}
       < default 0 = same amplitude as input soundfile
p5  nu 15000/ 18000 / 12000/ 22000; < attempt to balance the 4 timbres

   < p6 = gen1 function number
p6  nu 1 / 2 / 3 / 4; <  alternate the soprano, flute, violin & crotale sources

   < p7 = length of soundfile to be used, in seconds {duration} OR # of samples
p7  6.5;  < use all but the very end of the soprano tone
    3.5;  < use all but the very end of the flute tone
    3.5;  < use all but the very end of the violin tone
    2.;  < use only 1st 2. seconds of crotale soundfile

   < p8 = skip time into gen1 func : if positive p8  = skip time in seconds
      < if negative {between -.001 and -.999}, p8 = % of soundfile skipped
p8  mo 6.  -.001  -.98 ; < read inthe grains from the beginnings to the
                         < ends of the 4 source soundfiles

   < p9 = pitch multiplier {default 0 = no pitch change}
  < tranpose all the source soundfiles to f#4, with slight deviations
p9  1. 1.01 .99; < soprano tone already at f#4 -- add slight detunings
    1, .91 .89 ;< flute g#4 -- tranpose down a major second, w/ slight detunings
    1, .94 .95  ; < vln g4 -- tranpose down a minor second, w/ slight detunings
    1. .51 .49  ; < crotate fs6 - transposed down an octave w/ slight detunings
   < for stereo output only p10 = pan location {1. = hard left, 0 = hard right}
p10
  <  Added user p-fields: 
end;  <<< End of ### granmix1 ### example score >>>
