Saturday, 18 March 2017

MorningMood



//mtof values
//          C        C#            D       D#            E       F       F#            G       G#            A       A#            B
//                   ====>Db               ====>Eb                       ====>Gb               ====>Ab               ====>Bb  
//
 0=>int C1;  1=>int Cs1=>int Df1;  2=>int D1;  3=>int Ds1=>int Ef1;  4=>int E1;  5=>int F1;  6=>int Fs1=>int Gf1;  7=>int G1;  8=>int Gs1=>int Af1;  9=>int A1; 10=>int As1=>int Bf1; 11=>int B1;
12=>int C2; 13=>int Cs2=>int Df2; 14=>int D2; 15=>int Ds2=>int Ef2; 16=>int E2; 17=>int F2; 18=>int Fs2=>int Gf2; 19=>int G2; 20=>int Gs2=>int Af2; 21=>int A2; 22=>int As2=>int Bf2; 23=>int B2;
24=>int C3; 25=>int Cs3=>int Df3; 26=>int D3; 27=>int Ds3=>int Ef3; 28=>int E3; 29=>int F3; 30=>int Fs3=>int Gf3; 31=>int G3; 32=>int Gs3=>int Af3; 33=>int A3; 34=>int As3=>int Bf3; 35=>int B3;
36=>int C4; 37=>int Cs4=>int Df4; 38=>int D4; 39=>int Ds4=>int Ef4; 40=>int E4; 41=>int F4; 42=>int Fs4=>int Gf4; 43=>int G4; 44=>int Gs4=>int Af4; 45=>int A4; 46=>int As4=>int Bf4; 47=>int B4;
48=>int C5; 49=>int Cs5=>int Df5; 50=>int D5; 51=>int Ds5=>int Ef5; 52=>int E5; 53=>int F5; 54=>int Fs5=>int Gf5; 55=>int G5; 56=>int Gs5=>int Af5; 57=>int A5; 58=>int As5=>int Bf5; 59=>int B5;
60=>int C6; 61=>int Cs6=>int Df6; 62=>int D6; 63=>int Ds6=>int Ef6; 64=>int E6; 65=>int F6; 66=>int Fs6=>int Gf6; 67=>int G6; 68=>int Gs6=>int Af6; 69=>int A6; 70=>int As6=>int Bf6; 71=>int B6;
72=>int C7; 73=>int Cs7=>int Df7; 74=>int D7; 75=>int Ds7=>int Ef7; 76=>int E7; 77=>int F7; 78=>int Fs7=>int Gf7; 79=>int G7; 80=>int Gs7=>int Af7; 81=>int A7; 82=>int As7=>int Bf7; 83=>int B7;
84=>int C8; 85=>int Cs8=>int Df8; 86=>int D8; 87=>int Ds8=>int Ef8; 88=>int E8; 89=>int F8; 90=>int Fs8=>int Gf8; 91=>int G8; 92=>int Gs8=>int Af8; 93=>int A8; 94=>int As8=>int Bf8; 95=>int B8;
96=>int C9; 97=>int Cs9=>int Df9; 98=>int D9; 99=>int Ds9=>int Ef9;100=>int E9;101=>int F9;102=>int Fs9=>int Gf9;103=>int G9;104=>int Gs9=>int Af9;105=>int A9;106=>int As9=>int Bf9;107=>int B9;

//F#     Eb      C#      B       C#      Eb     
//F#     Eb      C#      B       C#      Eb
//F#     Eb      F#      G#      Eb      G#
//F#     Eb      C#      B       





[Fs5,4,  Ef5,4,  Cs5,4,  B4,4,    Cs5,4,   Ef5,4,   
 Fs5,4,  Ef5,4,  Cs5,4,  B4,4,    Cs5,4,   Ef5,4,  
 Fs5,4,  Ef5,4,  Fs5,4,  Gs5,4,   Ef5,4,   Gs5,4,
 Fs5,4,  Ef5,4,  Cs5,4,  B4,6,    0,6
] @=> int notedur[]; //sequence data




SinOsc inst =>  JCRev r =>  dac;

0.1 => r.gain;

now/ms => float mystart;
now/ms => float runtime;
while(true)
{
    for (1 => int i;i < notedur.cap(); i+2 => i) 
{ //infinite loop
                Std.mtof( Math.random2(-4,4)*.01 + 32 + notedur[i-1] ) => inst.freq; //set the note
                now/ms - mystart => runtime;
                <<< "i=",i, "  runtime in s=", runtime/1000, " notedur[i-1]=", notedur[i-1], " notedur[i]=", notedur[i] >>>;
                ( Math.random2(-25,200) +(notedur[i]*85))::ms => now; //getdur from array
                0  => inst.freq; //set the note
                50::ms => now; //getdur from array

  
       }
}
    

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

Tuesday, 28 February 2017

InstrSeq2

// 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],


//Instr, Gain, FreqX, Period

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 


] @=> int Perc1Array[]; //sequence data
//800::ms => dur wait => dur the_wait;
1 => int i;
Gain g => dac;
.1 => g.gain;
SndBuf Perc1[8];
me.dir() + "data/snare-chili.wav" => Perc1[1].read;
me.dir() + "data/kick.wav" => Perc1[2].read;
me.dir() + "data/snare-hop.wav" => Perc1[3].read;
me.dir() + "data/snare.wav" => Perc1[4].read;
me.dir() + "data/hihat-open.wav" => Perc1[5].read;
me.dir() + "data/hihat.wav" => Perc1[6].read;
me.dir() + "data/Menupopup.wav" => Perc1[7].read;





while (true){
    for( 3 => int i; i < Perc1Array.cap(); i+4 => i)
    
    {
Perc1Array[i-3] => int ThisPerc1Instr;
Perc1Array[i-2] => int ThisPerc1Gain;
Perc1Array[i-1] => int ThisPerc1FreqX;
Perc1Array[i] => int ThisPerc1Period;
        
        // Instr [i-3], Gain [i-2], FreqX [i-1], Period [i],


//***   Set Frequency Multiplier on SndBuf for the instrument   
        ThisPerc1FreqX *0.01=> Perc1[ThisPerc1Instr].rate;
        
//***  Set Period and play it
//***   Set Gain on Instrument
        Perc1[ThisPerc1Instr] => g;
        1 => Perc1[ThisPerc1Instr].pos;
        ThisPerc1Gain*.001  =>  Perc1[ThisPerc1Instr].gain;  // turn on SndBuf

            <<< "i=",i >>>;
            <<<"Instr Perc1Array[i-3]=", ThisPerc1Instr,",  Gain Perc1Array[i-2]=", ThisPerc1Gain>>>;
            <<< "FreqX  Perc1Array[i-1]=", ThisPerc1FreqX, ",  Period  Perc1Array[i]=", ThisPerc1Period >>>;
         
         
         
         
         Perc1[ThisPerc1Instr].gain() => float currentPerc1GainGain;
         g.gain() => float currentGainGain;
         dac.gain() => float currentDacGain;
         Perc1[0].gain() => float currentPerc10Gain;
         Perc1[1].gain() => float currentPerc11Gain;
         Perc1[2].gain() => float currentPerc12Gain;
         Perc1[3].gain() => float currentPerc13Gain;
         Perc1[4].gain() => float currentPerc14Gain;
         Perc1[5].gain() => float currentPerc15Gain;
         Perc1[6].gain() => float currentPerc16Gain;
         Perc1[7].gain() => float currentPerc17Gain;
         Perc1[ThisPerc1Instr].rate() => float currentPerc1FreqX;
         <<<"GainGain", currentGainGain,",  InstrGain", currentPerc1GainGain >>>;
         <<<"DacGain", currentDacGain  >>>;
           <<<"SB0Gain", currentPerc10Gain >>>;
           <<<"SB1Gain", currentPerc11Gain >>>;
           <<<"SB2Gain", currentPerc12Gain >>>;
           <<<"SB3Gain", currentPerc13Gain >>>;
           <<<"SB4Gain", currentPerc14Gain >>>;
           <<<"SB5Gain", currentPerc15Gain >>>;
           <<<"SB6Gain", currentPerc16Gain >>>;
           <<<"SB7Gain", currentPerc17Gain >>>;
            
            
            
  //    <<< "FreqX  SndArray[i-1]=", currentFreqX, ",  Period  SndArray[i]=", instr[ThisPeriod] >>>;

        ThisPerc1Period*14::ms  => now;
  // 2::second => now;
    0.0 => Perc1[ThisPerc1Instr].gain;                          // turn off SndBuf

  //  0.04 :: second => now;                  // hang out a bit

    }  //end for loop
} //end while true

  
 //   0.04 :: second => now;                  // hang out a bit

// let time pass for reverb to go...

Monday, 27 February 2017

2InstrSeq3

// 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],


//Instr, Gain, FreqX, Period
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 


] @=> 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 


] @=> int Osc1Array[]; //sequence data
//800::ms => dur wait => dur the_wait;
1 => int i;
Gain g => dac;
.1 => g.gain;
SndBuf Perc1[8];
me.dir() + "data/snare-chili.wav" => Perc1[1].read;
me.dir() + "data/kick.wav" => Perc1[2].read;
me.dir() + "data/snare-hop.wav" => Perc1[3].read;
me.dir() + "data/snare.wav" => Perc1[4].read;
me.dir() + "data/hihat-open.wav" => Perc1[5].read;
me.dir() + "data/hihat.wav" => Perc1[6].read;
me.dir() + "data/Menupopup.wav" => Perc1[7].read;

SndBuf Osc1[9];
me.dir() + "data/k_cp80_90_46.wav" => Osc1[1].read;
me.dir() + "data/pno_wh_03.wav" => Osc1[2].read;
me.dir() + "data/s_em_10.wav" => Osc1[3].read;
me.dir() + "data/s_es_120_02.wav" => Osc1[4].read;
me.dir() + "data/s_es_120_16.wav" => Osc1[5].read;
me.dir() + "data/s_n3_96_84.wav" => Osc1[6].read;
me.dir() + "data/syn_ni_trp_60.wav" => Osc1[7].read;
me.dir() + "data/s_nfx_125_20.wav" => Osc1[8].read;




while (true){
    for( 3 => int i; i < Osc1Array.cap(); i+4 => i)
    
    {
Perc1Array[i-3] => int ThisPerc1Instr;
Perc1Array[i-2] => int ThisPerc1Gain;
Perc1Array[i-1] => int ThisPerc1FreqX;
Perc1Array[i] => int ThisPerc1Period;

Osc1Array[i-3] => int ThisOsc1Instr;
Osc1Array[i-2] => int ThisOsc1Gain;
Osc1Array[i-1] => int ThisOsc1FreqX;
Osc1Array[i] => int ThisOsc1Period;
        
        // Instr [i-3], Gain [i-2], FreqX [i-1], Period [i],


//***   Set Frequency Multiplier on SndBuf for the instrument   
        ThisPerc1FreqX *0.01=> Perc1[ThisPerc1Instr].rate;
        ThisOsc1FreqX *0.01=> Osc1[ThisOsc1Instr].rate;
       
//***  Set Period and play it
//***   Set Gain on Instrument
        Perc1[ThisPerc1Instr] => g;  //patch in Perc1
        Osc1[ThisOsc1Instr] => g;   //patch in Osc1
        1 => Perc1[ThisPerc1Instr].pos;
        1 => Osc1[ThisOsc1Instr].pos;
        ThisPerc1Gain*.001  =>  Perc1[ThisPerc1Instr].gain;  // turn on SndBuf
        ThisOsc1Gain*.001  =>  Osc1[ThisOsc1Instr].gain;  // turn on SndBuf
       Perc1[ThisPerc1Instr].gain() => float currentPerc1GainGain;


      g.gain() => float currentGainGain;
      dac.gain() => float currentDacGain;
      Perc1[0].gain() => float currentPerc10Gain;
      Perc1[1].gain() => float currentPerc11Gain;
      Perc1[2].gain() => float currentPerc12Gain;
      Perc1[3].gain() => float currentPerc13Gain;
      Perc1[4].gain() => float currentPerc14Gain;
      Perc1[5].gain() => float currentPerc15Gain;
      Perc1[6].gain() => float currentPerc16Gain;
      Perc1[7].gain() => float currentPerc17Gain;
      Perc1[ThisPerc1Instr].rate() => float currentPerc1FreqX;
       <<< "FreqX  Perc1Array[i-1]=", currentPerc1FreqX, ",  Period  Perc1Array[i]=", ThisPerc1Period >>>;
       <<<"GainGain", currentGainGain,",  InstrGain", currentPerc1GainGain >>>;
      <<<"DacGain", currentDacGain  >>>;
      <<<"Perc10Gain", currentPerc10Gain >>>;
      <<<"Perc11Gain", currentPerc11Gain >>>;
      <<<"Perc12Gain", currentPerc12Gain >>>;
      <<<"Perc13Gain", currentPerc13Gain >>>;
      <<<"Perc14Gain", currentPerc14Gain >>>;
      <<<"Perc15Gain", currentPerc15Gain >>>;
      <<<"Perc16Gain", currentPerc16Gain >>>;
      <<<"Perc17Gain", currentPerc17Gain,"\n" >>>;

 
         
        ThisPerc1Period*15::ms  => now;
        ThisOsc1Period*15::ms  => now;
  // 2::second => now;
    0.0 => Perc1[ThisPerc1Instr].gain;                          // turn off SndBuf
    0.0 => Osc1[ThisOsc1Instr].gain;                          // turn off SndBuf

  //  0.04 :: second => now;                  // hang out a bit

    }  //end for loop
} //end while true
 
  
 //   0.04 :: second => now;                  // hang out a bit

// let time pass for reverb to go...

Saturday, 12 November 2016

Patching


Inserting a new unit generator on demand.
   from http://soundlab.cs.princeton.edu/publications/chuck_nime2005.pdf

 // inserting a new unit generator 
 if( switch_hit )
   { 
        // disconnect foo from bar w/ 'unchuck' operator 
    foo =< bar; 
        // reconnect foo to new Filter to bar
    foo => Filter f => bar; 
    } 


Connecting and disconnecting two existing unit generator sub-patches
   from http://soundlab.cs.princeton.edu/publications/chuck_nime2005.pdf

 // connect/disconnect two unit generator graphs 
 if( toggle ) pa => pb;         // connect 
         else pa =< pb;         // disconnect

Tuesday, 1 November 2016

Funcky Somewhere - Illustrating functions and note-duration arrays

// "Notes" by Hugh R Frazer
//  ugen info at 
//   http://chuck.cs.princeton.edu/doc/program/ugen.html

//mtof values
//  C   C#  D   D#  E   F   F#  G   G#  A   A#  B
//     /Db     /Eb         /Gb     /Ab     /Bb  

//  0   1   2   3   4   5   6   7   8   9   10  11
//  12  13  14  15  16  17  18  19  20  21  22  23
//  24  25  26  27  28  29  30  31  32  33  34  35
//  36  37  38  39  40  41  42  43  44  45  46  47
//  48  49  50  51  52  53  54  55  56  57  58  59
//  60  61  62  63  64  65  66  67  68  69  70  71
//  72  73  74  75  76  77  78  79  80  81  82  83
//  84  85  86  87  88  89  90  91  92  93  94  95
//  96  97  98  99 100 101 102 103 104 105 106 107
// 
//  C   C#  D   D#  E   F   F#  G   G#  A   A#  B
//  C   Db  D   Eb  E   F   Gb  G   Ab  A   Bb  B



[100, 1, //Comment - Verse
69,4, 64,4, 64,4, 61,8,    61,4, 61,4, 61,4, 61,4,
62,4, 62,4, 62,4, 62,2,62,2, 62,4, 62,4, 62,4, 61,4, 71,2,62,2, 61,4,
69,2,64,2, 64,4, 61,8,   61,4,  61,4, 61,4, 61,4,
62,4, 62,4, 62,4, 62,2,62,2, 62,4, 62,4, 62,4, 61,4, 71,2,62,2, 61,4
] @=> int verse_notedur[]; //sequence data
[100, 2, //Comment - Bridge
60,4, 68,4, 68,4, 65,4,
60,4, 63,4, 63,4, 60,4,
61,4, 61,2,61,2, 61,4, 61,4, 61,4, 61,4, 61,2,60,2, 70,4, 60,2,61,2,60,2,
60,4, 68,4, 68,4, 65,4,
60,4, 60,2,60,2, 63,4, 63,4, 60,4,
61,4, 61,2,61,2, 61,4, 61,4, 61,4, 61,4, 61,2,60,2, 70,4, 60,2,61,2,60,2
] @=> int bridge_notedur[]; //sequence data
[100, 3, //Comment - Chorus
70,4, 70,4, 69,2,69,2,67,2, 62,2,60,2, 62,4, 65,2,62,2, 60,4,
70,4, 69,2,69,2,67,2, 62,2,60,2, 62,4, 65,2,62,2,60,2,
70,4, 69,2,69,2,67,2, 62,4, 60,4, 62,2,65,2,62,2,60,2,
62,4, 60,4, 65,2,62,2, 60,4,             
62,4, 60,4, 65,2,62,2, 60,4,             
62,2,60,2, 62,4, 65,2,60,2,70,2
] @=> int chorus_notedur[]; //sequence data
SqrOsc inst => JCRev r =>  dac;

.9 => inst.width;
.1 => r.gain;
.5 => r.mix;

now/ms => float mystart;
now/ms => float runtime;
while(true){//infinite loop
<<< "Begin" >>>;    
play ( verse_notedur );
play ( bridge_notedur );
play ( verse_notedur );
play ( bridge_notedur );
play ( chorus_notedur );
play ( bridge_notedur );
play ( chorus_notedur );
//Order of the song
//1. verse #1
//2. bridge
//3. verse #2
//4. bridge
//5. chorus
//6. bridge
//7. chorus   
}//While True infinate loop
fun void play(int part[])


      <<<"part=", part >>>;  
   for (1 => int i;i < part.cap(); i+2 => i) 
    { //for as long as we have notes in the array
    if (part[i-1] == 100) //if comment statement
        {
            if (part[i] == 1){ 
            <<< "--intro--" >>>; 
            }
            if (part[i] == 2){ 
            <<< "--bridge--" >>>; 
            }
            if (part[i] == 3){ 
            <<< "--chorus--" >>>; 
            }    
        } else 
        { 
        <<< "i=",i-1,"+",i, " runtime in s=", runtime/1000, " notedur[i-1]=", part[i-1], " notedur[i]=", part[i] >>>;
        Std.mtof(0 + part[i-1] ) => inst.freq; //set the note
        } //end if comment statement 
    now/ms - mystart => runtime;
   (part[i]*85)::ms => now; //getdur from array and play
  }// end for loop
}//end of function play

//  C   C#  D   D#  E   F   F#  G   G#  A   A#  B
//     /Db     /Eb         /Gb     /Ab     /Bb  
//  48  49  50  51  52  53  54  55  56  57  58  59
//  60  61  62  63  64  65  66  67  68  69  70  71
   
//Verse:
//A E E C#    C# C# C# C#
//1. I walked across    an empty land
//2. I came across        a  fallen tree
//
//D D D DD D D D C# B D C#
//1. I knew the pathway like the back of my hand
//2. I felt the branches of it looking at me
//
//A E E C#   C#  C# C# C#
//1. I felt the earth   beneath my feet
//2. Is this the place   we used to love
//
//D D D DD D D D C# B D C#
//1. sat by the river and it made me complete
//2. is this the place that i've been dreaming of
//
//Bridge:
//C Ab Ab F
//oh simple thing
//C Eb Eb C
//where have you gone
//C# C#C# C# C# C# C# C#C Bb CC#C
//I'm getting old and i neeed something to rely on
//C Ab Ab F
//so tell me when
//C CC Eb Eb C
//you're gonna let me in
//C# C#C# C# C# C# C# C#C Bb CC#C
//i'm getting tired and i need somewhere to begin
//
//Chorus:
//Bb Bb^ A A G DC D F D C
//and if you have a minute why don't we go
//Bb AA G DC D F DC
//talk about it somewhere only we know
//Bb A A G D C DFDC
//this could be the end of everything
//D C F D C             ]2x
//so why dont we go]
//DC D F CBb
//somewhere only we know
//
//
//Order of the song
//1. verse #1
//2. bridge
//3. verse #2
//4. bridge
//5. chorus
//6. bridge
//7. chorus