public class Phrase { //global variables... SawOsc s => Envelope e => dac; 60 => float key; //C4 e.duration(20::ms); 1.0 => float tempo; //60 bpm s.gain(0.6); 4 => int timeSignatureNumerator; 4 => int timeSignatureDenominator; 0 => float pickup; 2 => int numImportantBeatsPerMeasure; 0 => float phraseLength; 1 => float beatCounter; 0 => float measureCounter; 0.0 => float importantBeat; /////////////////////////////////////////////////////////////////// // functions ///////////////////////////////////////////////////// fun void setKey(float value){value => key;} fun void setEnvDuration(dur t){e.duration(t);} fun void setTempo(float value){value => tempo;} fun void setMasterGain(float value){s.gain(value);} fun void meterIs(int value1, int value2, float value3){ value1 => timeSignatureNumerator; value2 => timeSignatureDenominator; value3 => pickup;} fun int[] getMeterInfo(int timeSigNumerator, int timeSigDenom){ if( Math.remainder(timeSigNumerator, 2) == 0 ){ timeSigNumerator/2 => numImportantBeatsPerMeasure; int b[numImportantBeatsPerMeasure]; for ( 0 => int i; i< b.cap(); i++){1+(2*i) @=> b[i];} return b;} if( Math.remainder(timeSigNumerator, 3) == 0 && Math.remainder(timeSigNumerator, 2) != 0 ){ timeSigNumerator/3 => numImportantBeatsPerMeasure; int b[numImportantBeatsPerMeasure]; for ( 0 => int i; i< b.cap(); i++){1+(3*i) @=> b[i];} return b;}} fun void findPhraseLength(float rhythm[]){ for( 0 => int i; i phraseLength;}} fun float[] rhythm2meter(float rhythm[]){ float beats[rhythm.cap()]; pickup -=> beatCounter; for( 0 => int i; i measureCounter; beatCounter - (timeSignatureNumerator*measureCounter) @=> beats[i]; rhythm[i] +=> beatCounter;} return beats;} fun float[] getVolumeInfo(float beats[], int b[]){ float volume[beats.cap()]; for( 0 => int i; i int j; j volume[i]; break;}}} return volume;} fun void play(int notes[], float rhythm[]){ getMeterInfo(timeSignatureNumerator,timeSignatureDenominator) @=> int b[]; rhythm2meter(rhythm) @=> float beats[]; getVolumeInfo(beats, b) @=> float volume[]; //findImportantPitches(); for( 0 => int i; i e.keyOn; s.freq(Std.mtof(notes[i]+key)); s.gain(s.gain() + volume[i]); (tempo*rhythm[i])::second => now; 1 => e.keyOff; s.gain(s.gain()-volume[i]); 20::ms => now;}} fun void playTest(int notes[], float rhythm[]){ for( 0 => int i; i e.keyOn; s.freq(Std.mtof(notes[i]+key)); (tempo*rhythm[i])::second => now; 1 => e.keyOff; 20::ms => now;}} fun void noteLengthSensitivity(float sensitiv ){} fun void articulationStrength(float artStrenght){} fun void maxTimePerBow(dur bowDur){} fun void vibratoIntensity(float vibIntensity){} fun void dynamicRange( float minDyn, float maxDyn){} fun void percentBowHairContact( float percent){} //bow starts //frog tip //string crossings //slurs //whichString() //meterIs() ? pickups //placement, i.e. between bridge and fb //pitch inflections //phrase and motion with ambisonics //grit in sound on/off // function for internal use /* fun void assignValues( int notes[]){// rank parts of the phrase usefully notes.cap() => int numNotes; } fun int findHighest( float notes[])// finds highest notes (only 2...) high1 high2 { // spot1 spot2 0 => float high; int positionH; float high2; int positionH2; for( 0 => int i; i>notes.cap(); i++ ) { if( notes[i] == high ){ notes[i] => high2; i => positionH2;} if( notes[i] > high ){ notes[i] => high; i => positionH;} } [ [high,high2], [positionH,positionH2] ] @=> int highest[][]; return highest; } // assume lowest notes are 0 fun int findLowest( float notes[]) // finds lowest notes (only 2...) low1 low2 { // spot1 spot2 -1 => int positionL; int positionL2; for( 0 => int i; i>notes.cap(); i++ ) { if( notes[i] == 0 && positionL == -1 ){ i => positionL;} if( notes[i] == 0 && positionL > 0 ){ i => positionL2;} } [ [0,0], [positionL, positionL2] ] @=> int lowest[][]; return lowest; } */ }