Tuesday, 7 March 2017

Test_Spork_Instr_v3good.ck

// Instr [i-3], Gain [i-2], FreqX [i-1], Period [i],
//      so to get array position first element is 0 so 
//          for Instr you need i (which moves from the start pos 3) to be -3 to be 1st or [i-3]
//          for Gain you need i (which moves from the start pos 3) to be -2 to be 2nd or [i-2]
//          for Freakwency you need i (which moves from the start pos 3) to be -1 to be 3rd or [i-1]
//          for Period you need i (which increments from the start pos 3) to be -0 to be 4th item or [i]
// Instr [i-3], Gain [i-2], FreqX [i-1], Period [i],
//  (find the formatted array commented at end of chuck script)

[3,50,50,16, 7,80,120,1, 7,70,75,14, 3,50,100,16, 4,70,100,16, 3,50,100,16, 7,50,200,16, 4,50,100,16, 4,70,200,16, 2,50,100,16, 7,70,100,16, 2,50,75,16, 1,50,100,16,2,70,75,8,0,0,100,8,0,0,100,8,2,80,100,8,2,50,400,16,2,70,100,16,  5,50,50,4,  6,50,50,4,  5,50,50,4,  6,50,50,4,  2,50,50 ,8,  2,50,50,8,  5,50,50,4,    6,50,50,4,    5,50,50,4,    6,50,50,4,     2,70,100,16,  3,50,100,16,  7,50,200,16,  4,50,100,16,4,70,200,16,2,50,100,16,7,70,100,16,2,50,75,16,1,50,100,16,2,70,75,8,0,0,100,8,0,0,100,8,2,80,100,8,2,50,400,16,2,70,100,16
] @=> int Perc1[];  //sequencedata

[3,50,50,16, 7,80,120,1, 7,70,75,15, 3,50,100,16, 4,70,100,16, 3,50,100,16, 7,50,200,16, 4,50,100,16, 4,70,200,16, 2,50,100,16, 7,70,100,16, 2,50,75,16, 1,50,100,16,2,70,75,8,0,0,100,8,0,0,100,8,2,80,100,8,2,50,400,16,2,70,100,16,  6,7 ,33,4,  6,7 ,35,4,  6,9 ,38,4,  6,11,42,4,  7,80,120,8,  7,70,75,8,  6,6,51+12,4,  6,6,43+12,4,  6,8,38+12,4,  6,10,35+12,4,  4,70,100,16,  3,50,100,16,  7,50,200,16,  4,50,100,16,4,70,200,16,2,50,100,16,7,70,100,16,2,50,75,16,1,50,100,16,2,70,75,8,0,0,100,8,0,0,100,8,2,80,100,8,2,50,400,16,2,50,400,16
] @=> int Osc1[];  //sequencedata

[3,50,50,16, 7,80,120,1, 7,70,75,14, 3,50,100,16, 4,70,100,16, 3,50,100,16, 7,50,200,16, 4,50,100,16, 4,70,200,16, 2,50,100,16, 7,70,100,16, 2,50,75,16, 1,50,100,16,2,70,75,8,0,0,100,8,0,0,100,8,2,80,100,8,2,50,400,16,2,70,100,16,  5,50,50,4,  6,50,50,4,  5,50,50,4,  6,50,50,4,  2,50,50 ,8,  2,50,50,8,  5,50,50,4,    6,50,50,4,    5,50,50,4,    6,50,50,4,     2,70,100,16,  3,50,100,16,  7,50,200,16,  4,50,100,16,4,70,200,16,2,50,100,16,7,70,100,16,2,50,75,16,1,50,100,16,2,70,75,8,0,0,100,8,0,0,100,8,2,80,100,8,2,50,400,16,2,70,100,16
] @=> int Perc2[];  //sequencedata

[3,50,50,16, 7,80,120,1, 7,70,75,15, 3,50,100,16, 4,70,100,16, 3,50,100,16, 7,50,200,16, 4,50,100,16, 4,70,200,16, 2,50,100,16, 7,70,100,16, 2,50,75,16, 1,50,100,16,2,70,75,8,0,0,100,8,0,0,100,8,2,80,100,8,2,50,400,16,2,70,100,16,  6,7 ,33,4,  6,7 ,35,4,  6,9 ,38,4,  6,11,42,4,  7,80,120,8,  7,70,75,8,  6,6,51+12,4,  6,6,43+12,4,  6,8,38+12,4,  6,10,35+12,4,  4,70,100,16,  3,50,100,16,  7,50,200,16,  4,50,100,16,4,70,200,16,2,50,100,16,7,70,100,16,2,50,75,16,1,50,100,16,2,70,75,8,0,0,100,8,0,0,100,8,2,80,100,8,2,50,400,16,2,50,400,16
] @=> int Osc2[];  //sequencedata


spork~Play(8, Perc1);
spork~Play(8, Osc1);
//spork~Play(40, Perc2);
//spork~Play(65, Osc2);
// define function
   // infinite time loop - to keep child shreds around
   while( true )
        1::second => now;

fun void Play(int Timing, int Part[])
{
1 => int i;
Gain g => dac;
.1 => g.gain;
SndBuf instr[8];
me.dir() + "data/snare-chili.wav" => instr[1].read;
me.dir() + "data/kick.wav" => instr[2].read;
me.dir() + "data/snare-hop.wav" => instr[3].read;
me.dir() + "data/snare.wav" => instr[4].read;
me.dir() + "data/hihat-open.wav" => instr[5].read;
me.dir() + "data/hihat.wav" => instr[6].read;
me.dir() + "data/Menupopup.wav" => instr[7].read;
<<< Part >>>;
 //   10000::ms =>now;

while (true){
    for( 3 => int i; i < Part.cap(); i+4 => i)
    
    {
        Perc1[i-3] => int ThisPartInstr;
        Perc1[i-2] => int ThisPartGain;
        Perc1[i-1] => int ThisPartFreqX;
        Perc1[i] => int ThisPartPeriod;
        // Instr [i-3], Gain [i-2], FreqX [i-1], Period [i],

//***   Set Frequency Multiplier on SndBuf for the instrument   
        ThisPartFreqX *0.01=> instr[ThisPartInstr].rate;
       
//***  Set Period and play it
//***   Set Gain on Instrument
        instr[ThisPartInstr] => g;  //patch in Perc1
        1 => instr[ThisPartInstr].pos;
        ThisPartGain*.001  =>  instr[ThisPartInstr].gain;  // turn on SndBuf

        Display("Just before Playing Note", i, instr[ThisPartInstr].gain(), g.gain(), dac.gain(), ThisPartPeriod*Timing,instr[ThisPartInstr].rate(), instr[0].gain(), instr[1].gain(), instr[2].gain(), instr[3].gain(), instr[4].gain(), instr[5].gain(), instr[6].gain(), instr[7].gain() );        

        ThisPartPeriod*Timing::ms  => now;
        0.0 => instr[ThisPartInstr].gain;                          // turn off SndBuf
        ThisPartPeriod*Timing::ms  => now;

    } //end for loop
  } //end while true
} //End of function

fun void Display(string Wayfinding, int i, float GainGain, float instrGainGain,  float DacGain,  float ThisinstrPeriod, float instrFreqX, float instr0Gain, float instr1Gain, float instr2Gain, float instr3Gain, float instr4Gain, float instr5Gain, float instr6Gain, float instr7Gain)
{

       <<< "i=", i, ",  Wayfinding = \"", Wayfinding, "\"">>>;
       <<< "FreqX =", instrFreqX, ",  Period =", ThisinstrPeriod >>>;
       <<<"GainGain =", GainGain,",  InstrGain =", instrGainGain >>>;
       <<<"DacGain", DacGain>>>;
       <<<"instr0Gain", instr0Gain,"instr4Gain", instr4Gain  >>>;
       <<<"instr1Gain", instr1Gain,"instr5Gain", instr5Gain  >>>;
       <<<"instr2Gain", instr2Gain,"instr6Gain", instr6Gain  >>>;
       <<<"instr3Gain", instr3Gain,"instr7Gain", instr7Gain,"\n"  >>>;

  }

// 
// [ 
// 3,  50, 50,  16,       7,  80, 120, 1,
//                        7,  70, 75,  14,       3,  50, 100, 16,       4,  70, 100, 16,  //20  (-1 for 0 start)
// 
// 3,  50, 100, 16,       7,  50, 200, 16,       4,  50, 100, 16,       4,  70, 200, 16,  //36  (-1 for 0 start)
// 
// 2,  50, 100, 16,       7,  70, 100, 16,       2,  50, 75,  16,       1,  50, 100, 16,  //52  (-1 for 0 start)
// 
// 2,  70, 75,  8,        
// 0,   0, 100, 8,        0,  0,  100, 8,        
//                        2,  80, 100, 8,        2,  50, 400, 16,       2,  70, 100, 16,   //76  (-1 for 0 start)
//-----
// 5,  50, 50,  4,
// 6,  50, 50,  4,
// 5,  50, 50,  4,
// 6,  50, 50,  4,       2,  50, 50,  8,
//                       2,  50, 50,  8,      5,  50, 50,  4,
//                                            6,  50, 50,  4,
//                                            5,  50, 50,  4,
//                                            6,  50, 50,  4,
//                                                             2,  70, 100, 16,            //+44=120  (-1 for 0 start)
// 
// 3,  50, 100, 16,       7,  50, 200, 16,       4,  50, 100, 16,       4,  70, 200, 16,  //136  (-1 for 0 start)
// 
// 2,  50, 100, 16,       7,  70, 100, 16,       2,  50, 75,  16,       1,  50, 100, 16,  //152  (-1 for 0 start)
// 
// 2,  70, 75,  8,        
// 0,   0, 100, 8,        0,  0,  100, 8,        
//                        2,  80, 100, 8,        2,  50, 400, 16,       2,  70, 100, 16   //176  (-1 for 0 start)
// ] @=> int Perc1Array[]; //sequence data
// 
// 
// [ 
// 3,  50, 50,  16,       7,  80, 120, 1,
//                        7,  70, 75,  15,       3,  50, 100, 16,       4,  70, 100, 16,  
// 
// 3,  50, 100, 16,       7,  50, 200, 16,       4,  50, 100, 16,       4,  70, 200, 16,  
// 
// 2,  50, 100, 16,       7,  70, 100, 16,       2,  50, 75,  16,       1,  50, 100, 16,  
// 
// 2,  70, 75,  8,        
// 0,   0, 100, 8,        0,  0,  100, 8,        
//                        2,  80, 100, 8,        2,  50, 400, 16,       2,  70, 100, 16, 
//-----
// 6,  7,  33,  4,
// 6,  7,  35,  4,
// 6,  9,  38,  4,
// 6,  11, 42,  4,        7,  80, 120, 8,
//                        7,  70, 75,  8,       6,  6, 51+12, 4,
//                                              6,  6, 43+12, 4,
//                                              6,  8, 38+12, 4,
//                                              6,  10, 35+12, 4,
//                                                                 4,  70, 100, 16,  
// 
// 3,  50, 100, 16,       7,  50, 200, 16,       4,  50, 100, 16,       4,  70, 200, 16,  
// 
// 2,  50, 100, 16,       7,  70, 100, 16,       2,  50, 75,  16,       1,  50, 100, 16,  
// 
// 2,  70, 75,  8,        
// 0,   0, 100, 8,        0,  0,  100, 8,        
//                        2,  80, 100, 8,        2,  50, 400, 16,      2,  50, 400, 16
// 
// ] @=> int Osc1Array[]; //sequence data

No comments:

Post a Comment