view HeresyBigBangDone/application.macosx/source/HeresyBigBangDone.java @ 50:f4c6999ecfe9 tip

added the files on my computer that aren't aiff s> these shoudl be everything for the big bang fair 2011 - heresy, and tim's file's also here
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Sat, 08 Oct 2011 22:12:49 +0100
parents
children
line wrap: on
line source
import processing.core.*; 
import processing.xml.*; 

import oscP5.*; 
import netP5.*; 
import maxlink.*; 
import processing.opengl.*; 

import com.cycling74.max.*; 
import com.cycling74.net.*; 
import com.cycling74.msp.*; 
import netP5.*; 
import maxlink.*; 
import com.cycling74.io.*; 
import com.cycling74.util.*; 
import com.cycling74.mxjedit.*; 
import oscP5.*; 

import java.applet.*; 
import java.awt.Dimension; 
import java.awt.Frame; 
import java.awt.event.MouseEvent; 
import java.awt.event.KeyEvent; 
import java.awt.event.FocusEvent; 
import java.awt.Image; 
import java.io.*; 
import java.net.*; 
import java.text.*; 
import java.util.*; 
import java.util.zip.*; 
import java.util.regex.*; 

public class HeresyBigBangDone extends PApplet {

 

public void setup(){
    markovStuff();
    for (int i = 0; i < 16; i++)
        VPA[i] = new VPArray(); // creates the virtual playing array for Heresy AI.
    for (int i = 0; i < noteOnArray.length; i++)   
        noteOnArray[i] = false; // makes sure there are initial random inputs from openFrameworks
        
    oscP5return = new OscP5(this,12346); 
 
    frameRate(tempo);
    img = createGraphics(imageWidth,imageHeight,P2D);
    size(800,imageHeight,P2D);
    arial = createFont("Arial",32);
    textFont(arial,15);
    
    // initialize the tracks
    
    tracks[0] = new Track("Chord track", true, grid * beatsPerBar, 8, true, true);
    tracks[1] = new Track("Drums", true, grid * beatsPerBar, 8, false, true);
    tracks[2] = new Track("Bass", true, grid * beatsPerBar, 8, false, true);
    tracks[3] = new Track("Pizz Strings", true, grid * beatsPerBar, 8, false, true);
    tracks[4] = new Track("Synth", true, grid * beatsPerBar, 8, false, true);
    tracks[5] = new Track("Voice", true, grid * beatsPerBar, 8, false, true);
    tracks[6] = new Track("Voice", true, grid * beatsPerBar, 8, false, true);
    chordsTemp = new Track("Chord track", true, loopLength, 8, true, false);
    trSelected = 1;
    backgroundColour();
    drawLines();
    drawBarLines();
    imgNoteFan = createGraphics(fanWidth,imageHeight,P2D);
    lastTrack = trSelected;
    clickTrackOn = true;
 //   loadSequences();
 //   tracks[2].sequence[15][16] = new NoteEvent (14, 2, bar,beat,fraction,pulse);
 //   tracks[2].sequence[15][grid * beatsPerBar -20] = new NoteEvent (14, 2, bar,beat,fraction,pulse, true);
  
 //   tracks[3].sequence[13][16] = new NoteEvent (13, 3, bar,beat,fraction,pulse);
 //   tracks[3].sequence[13][20] = new NoteEvent (13, 3, bar,beat,fraction,pulse, true); 
 //   tracks[3].sequence[12][16] = new NoteEvent (12, 3, bar,beat,fraction,pulse);
 //   tracks[3].sequence[12][20] = new NoteEvent (12, 3, bar,beat,fraction,pulse, true);     
 //   tracks[3].sequence[11][16] = new NoteEvent (11, 3, bar,beat,fraction,pulse);
 //   tracks[3].sequence[11][20] = new NoteEvent (11, 3, bar,beat,fraction,pulse, true);   
 //   tracks[3].sequence[10][16] = new NoteEvent (10, 3, bar,beat,fraction,pulse);
 //   tracks[3].sequence[10][20] = new NoteEvent (10, 3, bar,beat,fraction,pulse, true);  
}


//-------------------------------------------------------------------------------------------------------------------------------

public void draw(){
 /*   if (currentPulse % (grid * beatsPerBar) == grid * beatsPerBar -1){
        int tempTrackSelected = trSelected;
        for (int j = 0; j < 16; j++){
            trSelected = j; 
            if (tracks[j] != null){
                for (int i = 0; i < 16; i++){
                    noteOnArray[i] = false;
                    finishNote(i);
                    displayNoteOnArray[i] = false;
                    for (int z = 24; z < 109; z++)
                        outputToMax(z, 0, j);
                }
                tracks[j] = new Track(tracks[j].name, true,  tracks[j].loopLength, tracks[j].quantize, false, false);
                imgNotes = null;
            }
        }
        trSelected = tempTrackSelected;
    }
    */
  //  tracks[0] = new Track("Chord track", true, grid * beatsPerBar, 8, true, true);
  //  tracks[1] = new Track("Drums", true, grid * beatsPerBar, 8, false, true);
  //  tracks[2] = new Track("Bass", true, grid * beatsPerBar, 8, false, true);
  //  tracks[3] = new Track("Pizz Strings", true, grid * beatsPerBar, 8, false, true);
  //  tracks[4] = new Track("Synth", true, grid * beatsPerBar, 8, false, true);
  //  tracks[5] = new Track("Voice", true, grid * beatsPerBar, 8, false, true);
  //  }
    workOutPosition(); // calculates current bar, beat and pulse position
    //println(bar + " " + beat + " " + fraction + " " + pulse);
//    if (chordAI && bar > 1)
//        chordCalc();
    if (eraseOn)
        eraseNotes();
    calcColours(); // calcs chord colours for background and grid
    heresyChange = false;
    heresyChordChanged = false;
    if (trackStorer != trSelected){ // resets display when changing tracks
        for (int i = 0; i < 16; i++)
            if (noteOnArray[i] = true){
                noteOnArray[i] = false;
                displayNoteOnArray[i] = false;
            }
        trackStorer = trSelected;    
        imgNotes = null;
    }
    if (imgNotes == null)
        imgNotes = createGraphics(tracks[trSelected].loopLength,imageHeight,P2D);
    background(0);
    image (img,width-x2-playArea,0);
    drawTempImageGrid();
    createNoteFan(); 
    drawNotes();
    fill (0);
    noStroke();
    rect (width-playArea,0,playArea,height);
    image (imgNoteFan, width-playArea+3,0);
    pulseFrame(x); // Draws a pulsing white line at the left edge of the edit area
    if (haveQuestion) writeQuestion(); // for input request messages
    x++; // counter for grid movement
    x2++; // counter for note image movement
    if (x2 == width - playArea + grid * beatsPerBar)
        x2 = width - playArea;
    if (x == width - playArea + tracks[trSelected].loopLength)
        x = width - playArea;

    
   /* if (clickTrackOn){ // click track
        if (fraction == 1){
            if (pulse == 1){
                String noteOut = ("37 80 1");
                link.output(noteOut);
            }
            if (pulse == 2){
                String noteOut = ("37 0 1" );
                link.output(noteOut); 
            } 
        }
    }
    */
    checkForMutes();
    checkCycled();
    playTrackEvents();

    fill(255,255,255);
    textSize(15);
    text(bar + " " + beat + " " + fraction + " " + pulse, 10,20); // draws current time position to screen

    fill(200,0,0);
    textSize(15);
    // this section draws current track and track info to screen
    if (tracks[trSelected].ducking) 
        text(tracks[trSelected].name + " ducking", 100,20); 
    else
        text(tracks[trSelected].name, 100,20); 
    if (tracks[trSelected].muteIn > bar)
        if (!tracks[trSelected].mute)
             text("mute in " + (tracks[trSelected].muteIn - bar), 200,20);
         else 
             text("unmute in " + (tracks[trSelected].muteIn - bar), 200,20);
             
    if (haveQuestion){ // asks input questions
        writeQuestion();
    }
 //   println(currentPulse + " ");


    currentPulse++; // advances the sequencer to next pulse
}
        

//-------------------------------------------------------------------------------------------------------------------------------

public void eraseNotes(){ // erases notes in current track if selected
    if (trSelected != 0){
        for (int i = 0; i < 16; i++){
           if (tracks[trSelected].sequence[i][(currentPulse%(tracks[trSelected].loopLength))] != null){
               tracks[trSelected].sequence[i][(currentPulse%(tracks[trSelected].loopLength))] = null;
           }
        }
    }
    if (trSelected == 0){
        for (int i = 0; i < 16; i++){
           if (chordsTemp.sequence[i][(currentPulse%(tracks[trSelected].loopLength))] != null){
               chordsTemp.sequence[i][(currentPulse%(tracks[trSelected].loopLength))] = null;
           }
        }
    }     
}  
           

//-------------------------------------------------------------------------------------------------------------------------------

public void workOutPosition(){ // works out current position
  if (currentPulse%(grid*beatsPerBar) == 0)
    ++bar;
  if (currentPulse%grid == 0)
    ++beat;
  if (beat > beatsPerBar)
    beat = 1;
  if (currentPulse%(grid/fractions) == 0)
    ++fraction;
  if (fraction > fractions)
    fraction = 1;
    ++pulse;
  if (pulse > (grid/fractions))
    pulse = 1;
}


//-------------------------------------------------------------------------------------------------------------------------------

public void finishNote(int noteArrayPosition){ // writes note offs into the sequencers
  if (trSelected != 0)
      tracks[trSelected].sequence[noteArrayPosition][(currentPulse%(tracks[trSelected].loopLength))] = new NoteEvent (noteArrayPosition, trSelected+1, bar,beat,fraction,pulse, true);
  if (trSelected == 0)
      chordsTemp.sequence[noteArrayPosition][(currentPulse%(chordsTemp.loopLength))] = new NoteEvent (noteArrayPosition, trSelected+1, bar,beat,fraction,pulse, true);
  displayNoteOnArray[noteArrayPosition] = false;
}

public void finishNote(int noteArrayPosition, int channel){ // writes note offs into the sequencers
  if (trSelected != 0)
      tracks[trSelected].sequence[noteArrayPosition][(currentPulse%(tracks[trSelected].loopLength))] = new NoteEvent (noteArrayPosition, channel, bar,beat,fraction,pulse, true);
  if (trSelected == 0)
      chordsTemp.sequence[noteArrayPosition][(currentPulse%(chordsTemp.loopLength))] = new NoteEvent (noteArrayPosition, channel, bar,beat,fraction,pulse, true);
  displayNoteOnArray[noteArrayPosition] = false;
}


//-----------------------------------------------------------------------------------------------------------------------------

public void finishNoteCutOff(int noteArrayPosition){ // writes note offs for unfinished notes in to the last track if track is changed and note ons are active
    tracks[lastTrack].sequence[noteArrayPosition][(currentPulse%(tracks[lastTrack].loopLength))] = new NoteEvent (noteArrayPosition, lastTrack+1, bar,beat,fraction,pulse, true);
}


//-------------------------------------------------------------------------------------------------------------------------------

public void writeNote(int noteArrayPosition, int veloc){ // writes note ons into the sequencers
    if (trSelected != 0){
        int quantizeOffset = getQuantizeOffset();
        if (quantizeOffset >= 0){
            tracks[trSelected].sequence[noteArrayPosition][(currentPulse+quantizeOffset)%(tracks[trSelected].loopLength)] = new NoteEvent (noteArrayPosition, trSelected+1, bar,beat,fraction,pulse);
        }
        if (quantizeOffset < 0){
            tracks[trSelected].sequence[noteArrayPosition][(currentPulse+quantizeOffset)%(tracks[trSelected].loopLength)] = new NoteEvent (noteArrayPosition, trSelected+1, bar,beat,fraction,pulse);  

            VPA[trSelected].VPArrayNotes[noteArrayPosition].VPNoteOn = true;
            if (trSelected !=1 && trSelected !=5)
                VPA[trSelected].VPArrayNotes[noteArrayPosition].VPNotePitch = heresyPitch(noteArrayPosition, 3);
            else
                VPA[trSelected].VPArrayNotes[noteArrayPosition].VPNotePitch = heresyPitch(noteArrayPosition, 1);
            VPA[trSelected].VPArrayNotes[noteArrayPosition].VPNoteVelocity = veloc;
            sendNote(VPA[trSelected].VPArrayNotes[noteArrayPosition], trSelected);
            displayNoteOnArray[noteArrayPosition] = true;
            
        }
    }
    if (trSelected == 0){
        int quantizeOffset = getQuantizeOffset();
        if (quantizeOffset >= 0){
            chordsTemp.sequence[noteArrayPosition][(currentPulse+quantizeOffset)%(tracks[trSelected].loopLength)] = new NoteEvent (noteArrayPosition, trSelected+1, bar,beat,fraction,pulse);
        }
        if (quantizeOffset < 0){
            chordsTemp.sequence[noteArrayPosition][(currentPulse+quantizeOffset)%(tracks[trSelected].loopLength)] = new NoteEvent (noteArrayPosition, trSelected+1, bar,beat,fraction,pulse);  

            if (noteArrayPosition > 3)
                currentChord = 15 - noteArrayPosition;
             displayNoteOnArray[noteArrayPosition] = true;
        }
    }
}

public void writeNote(int noteArrayPosition, int veloc, int channel){ // writes note ons into the sequencers
    VPA[channel].VPArrayNotes[noteArrayPosition].VPNoteOn = true;
    VPA[channel].VPArrayNotes[noteArrayPosition].VPNotePitch = heresyPitch(noteArrayPosition, 1);
    VPA[channel].VPArrayNotes[noteArrayPosition].VPNoteVelocity = veloc;
    sendNote(VPA[channel].VPArrayNotes[noteArrayPosition], channel);
}




//-------------------------------------------------------------------------------------------------------------------------------

public int getQuantizeOffset(){  // tells write note method the quantize offset.
    int quantizeInPulses = pulsesPerBar/(tracks[trSelected].quantize);
    int quantizeOffset = currentPulse % quantizeInPulses;
    if (quantizeOffset > quantizeInPulses/2.0f){
        return ((quantizeOffset - quantizeInPulses) * -1) ;
    }
    else{
        return quantizeOffset * -1;
    }
}



//-------------------------------------------------------------------------------------------------------------------------------

public void drawNotes(){ // places the note display grid into the apropriate screen positions
        int loopsOnScreen = ((width-playArea) / tracks[trSelected].loopLength) + 1;
        if (loopsOnScreen > currentPulse / tracks[trSelected].loopLength)
            loopsOnScreen = currentPulse / tracks[trSelected].loopLength;
        for (int i = 0; i <= loopsOnScreen; i++)
          image (imgNotes, (width-playArea-(i*tracks[trSelected].loopLength))-currentPulse%(tracks[trSelected].loopLength),0); 
    }



//-------------------------------------------------------------------------------------------------------------------------------

public void pulseFrame(int frameNo){ // Draws a pulsing line at left hand side of the input area when loop restarts
    strokeWeight(3);
    if (currentPulse % (tracks[trSelected].loopLength) == 0 || (currentPulse-1) % (tracks[trSelected].loopLength) == 0 || (currentPulse-2) % (tracks[trSelected].loopLength) == 0)
        stroke(255,255,255);
    else
        stroke(255,111,111);
    line (width-playArea+3, 1, width-playArea+3, 300);  
} 


//-------------------------------------------------------------------------------------------------------------------------------
      
public void drawTempImageGrid(){ // draws the note display image grid
    imgNotes.stroke(209,137,255);
    imgNotes.strokeWeight(15); 
    for(int i = 0; i < 16; i++){
       if ((tracks[trSelected].sequence[i][currentPulse%(tracks[trSelected].loopLength)] != null && tracks[trSelected].sequence[i][currentPulse%(tracks[trSelected].loopLength)].noteVelocity > 0) || displayNoteOnArray[i]){
            imgNotes.beginDraw();
            imgNotes.line (currentPulse%(tracks[trSelected].loopLength), i*imageHeight/16+imageHeight/32, currentPulse%(tracks[trSelected].loopLength)+1, i*imageHeight/16+imageHeight/32);
            imgNotes.endDraw(); 
            displayNoteOnArray[i] = true;
        }
        if (tracks[trSelected].sequence[i][currentPulse%(tracks[trSelected].loopLength)] != null && tracks[trSelected].sequence[i][currentPulse%(tracks[trSelected].loopLength)].noteVelocity == 0){
            displayNoteOnArray[i] = false;
        }
    
        if(trSelected ==0){
            if ((chordsTemp.sequence[i][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[i][currentPulse%(chordsTemp.loopLength)].noteVelocity > 0) || displayNoteOnArray[i]){
                imgNotes.beginDraw();
                imgNotes.line (currentPulse%(chordsTemp.loopLength), i*imageHeight/16+imageHeight/32, currentPulse%(chordsTemp.loopLength)+1, i*imageHeight/16+imageHeight/32);
                imgNotes.endDraw(); 
                displayNoteOnArray[i] = true;
            }
            if (chordsTemp.sequence[i][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[i][currentPulse%(chordsTemp.loopLength)].noteVelocity == 0){
                displayNoteOnArray[i] = false;
            }
        }
    }
}


//-------------------------------------------------------------------------------------------------------------------------------

public void drawLines(){ // draws beat lines
     int linePosition = 1;
     int i = 0;
     for (; linePosition <= imageWidth;){
         linePosition = i * grid;
         img.beginDraw();
         img.stroke(lineColour);
         img.strokeWeight(2);
         img.line (linePosition, 0, linePosition, imageHeight);
         img.endDraw();
         i++;
     }
}


//-------------------------------------------------------------------------------------------------------------------------------

public void drawBarLines(){ // draws bar lines
     int linePosition = 1;    
     for (int i = 0; linePosition <= imageWidth;){
         linePosition = i * grid * beatsPerBar;
         img.beginDraw();
         img.stroke(barLineColour);
         img.strokeWeight(2);
         img.line (linePosition, 0, linePosition, imageHeight);
         img.endDraw();
         i++;
     }
}


//-------------------------------------------------------------------------------------------------------------------------------

public void backgroundColour(){ // sets background colour
     img.beginDraw();
     img.background (backGround);
     img.endDraw();
}



//-------------------------------------------------------------------------------------------------------------------------------

public void createNoteFan(){ // creates the input fan
    if (rpulseup)
        rpulse++;
    else rpulse--;
    if (rpulse == grid)
        rpulseup = false;
    if (rpulse < 1)
        rpulseup = true;
    imgNoteFan.beginDraw();
    imgNoteFan.stroke(rpulse/grid*255,50,50);
    imgNoteFan.strokeWeight(1);
    for (int i = 0; i < 16; i++){
        if (!chordSelecter)
            if ((tracks[trSelected].sequence[i][currentPulse%(tracks[trSelected].loopLength)] != null && tracks[trSelected].sequence[i][currentPulse%(tracks[trSelected].loopLength)].noteVelocity > 0) || displayNoteOnArray[i]){
                imgNoteFan.fill(209,137,255);
            }
            else
                imgNoteFan.fill(0,0,0);
         else
            if (i == 14 || i == 12 || i == 9 || i == 7 || i == 5 || i == 3 || i == 2 || i == 1 || i == 0)
                imgNoteFan.fill(0,0,0);
         else
                imgNoteFan.fill(255,255,255);    
      imgNoteFan.quad(0, i*(imageHeight/16.0f), 0, (i+1)*(imageHeight/16.0f), fanWidth, (imageHeight/2.0f), fanWidth, (imageHeight/2.0f));
    }

    imgNoteFan.endDraw();
    
}

//-------------------------------------------------------------------------------------------------------------------------------

public void calcColours(){ // sets up colour values for background, bar and beat lines

    if(heresyChordChanged){

        if(currentChord == 0){
            redC = 0;
            greenC = 0;
            blueC = 0;
        }
        
        if(currentChord == 1){
            redC = 90;
            greenC = 76;
            blueC = 3;
        }
        
        if(currentChord == 2){
            redC = 254;
            greenC = 255;
            blueC = 18;
        }
        
         if(currentChord == 3){
            redC = 0;
            greenC = 0;
            blueC = 0;
        }
        
        if(currentChord == 4){
            redC = 136;
            greenC = 245;
            blueC = 49;
        }
        
        if(currentChord == 5){
            redC = 9;
            greenC = 18;
            blueC = 232;
        }
        
        if(currentChord == 6){
            redC = 99;
            greenC = 99;
            blueC = 100;
        }
        
        if(currentChord == 7){
            redC = 255;
            greenC = 166;
            blueC = 21;
        }
        
        if(currentChord == 8){
            redC = 13;
            greenC = 79;
            blueC = 147;
        }
        
        if(currentChord == 9){
            redC = 255;
            greenC = 165;
            blueC = 165;
        }
        
        if(currentChord == 10){
            redC = 89;
            greenC = 110;
            blueC = 134;
        }
        
        if(currentChord == 11){
            redC = 68;
            greenC = 242;
            blueC = 250;
        }

        backGround = color(redC, greenC, blueC);
        lineColour = color((redC + 100) % 255,(greenC + 69) % 255,(blueC + 214) % 255);
        barLineColour = color((redC + 205) % 255, (greenC + 174) % 255, (blueC + 159) % 255);
        
        backgroundColour();
        drawLines();
        drawBarLines();
    }
}
        
        
      
     
 
 


OscP5 oscP5return;
NetAddress ableton = new NetAddress("localhost", 12345); // OSC to ableton
MaxLink link = new MaxLink(this, "midiCom");

int imageWidth = 1000;
int imageHeight = 300;
int fanWidth = 400;

float rpulse;
boolean rpulseup;
boolean clickTrack;
int currentPulse = 0;
int grid = 32;
int fractions = 4;
int pulseFrequency = grid / fractions;
int beatsPerBar = 4;
int bar = 0, beat = 0, fraction = 0, pulse = 0;
int pulsesPerBar = beatsPerBar * grid;

int lineColour = color(150,150,150);
int barLineColour = color(255,255,95);
int backGround = color(50,81,191);
int redC = 50;
int greenC = 81;
int blueC = 191;
PImage screenImage;
PGraphics img, imgNotes, imgNoteFan;
PImage test;

int barOfPixels = grid * beatsPerBar;
int playArea = 200;
int x= 0;
int x2= 0;
PFont arial;
int arraySize = 800-playArea;
int bpm = 130;
int tempo = bpm/60*grid;
int noOfBars = 2;
int loopLength = grid*beatsPerBar*noOfBars;
Track[] tracks = new Track[16];
Track chordsTemp;
int trSelected;
boolean[] noteOnArray = new boolean[16];
boolean[] displayNoteOnArray = new boolean[16];
int[] noteOnArrayLength = new int[16];
boolean chordSelecter, clickTrackOn;
int lastTrack;
int trackStorer, screenAni;
boolean quantizeValueIn, loopLengthValueIn, haveQuestion, aniOut, muteValueIn;
String screenQuestion;
boolean eraseOn;

int crneeded = 24;
int noOfChords;
boolean tonicNeeded;
boolean chordAI = true;
int lastChordChange;
boolean lastMinor; 
int barCounter;

boolean heresyMinor, oldHeresyMinor, heresy7th, oldHeresy7th, heresy9th, oldHeresy9th, heresy11th, oldHeresy11th, heresy13th, oldHeresy13th, heresyDom; 
boolean heresyMinorChanged, heresyChordChanged, heresy7thChanged, heresy9thChanged, heresy11thChanged, heresy13thChanged, heresyChange, dontRevoice;
int currentChord, lastChord;
VPArray[] VPA = new VPArray[16];
int[] notesOnArray = new int[16];
int no1s = 0; int no3s = 0; int no5s = 0; int no7s = 0; int no9s = 0; int no11s = 0; int no13s = 0;
int tonic = 0;





//-------------------------------------------------------------------------------------------------------------------------------

  /*  public int getHeresyPitch(int extension, int notePosition){  // delivers heresy pitches
        int value = getExtentionPitch(extension) % 12;
        if (notePosition == 15) value += 24;
        if (notePosition == 14) value += 36;
        if (notePosition == 13) value += 36;
        if (notePosition == 12) value += 48;
        if (notePosition == 11) value += 48;        
        if (notePosition == 10) value += 48;     
        if (notePosition == 9) value += 48;
        if (notePosition == 8) value += 60;
        if (notePosition == 7) value += 60;
        if (notePosition == 6) value += 60;
        if (notePosition == 5) value += 60;        
        if (notePosition == 4) value += 72;  
        if (notePosition == 3) value += 72;
        if (notePosition == 2) value += 72;
        if (notePosition == 1) value += 72;
        if (notePosition == 0) value += 84;
        return value;
    }*/
    
 
    public int heresyPitchInfo(int arrayPosition){ // returns a value for checking if note required is currently playing
        int value = 0;
        if (heresyMinor && heresy7th && heresy9th && heresy11th && !heresy13th){
            if (arrayPosition == 15) value = (15-currentChord) + 24;
            if (arrayPosition == 14) value = (15-currentChord) + 36;
            if (arrayPosition == 13) value = (15-currentChord) + 43;
            if (arrayPosition == 12) value = (15-currentChord) + 50;
            if (arrayPosition == 11) value = (15-currentChord) + 51;
            if (arrayPosition == 10) value = (15-currentChord) + 58; 
            if (arrayPosition == 9) value = (15-currentChord) + 65;
            if (arrayPosition == 8) value = (15-currentChord) + 67;
            if (arrayPosition == 7) value = (15-currentChord) + 70;
            if (arrayPosition == 6) value = (15-currentChord) + 72;
            if (arrayPosition == 5) value = (15-currentChord) + 74;
            if (arrayPosition == 4) value = (15-currentChord) + 75;
            if (arrayPosition == 3) value = (15-currentChord) + 77;
            if (arrayPosition == 2) value = (15-currentChord) + 79;
            if (arrayPosition == 1) value = (15-currentChord) + 82;
            if (arrayPosition == 0) value = (15-currentChord) + 84;
        }
        if (!heresyMinor && heresy7th && heresy9th && heresy11th && !heresy13th){
            if (arrayPosition == 15) value = (15-currentChord) + 24;
            if (arrayPosition == 14) value = (15-currentChord) + 36;
            if (arrayPosition == 13) value = (15-currentChord) + 43;
            if (arrayPosition == 12) value = (15-currentChord) + 50;
            if (arrayPosition == 11) value = (15-currentChord) + 52;
            if (arrayPosition == 10) value = (15-currentChord) + 59; 
            if (arrayPosition == 9) value = (15-currentChord) + 66;
            if (arrayPosition == 8) value = (15-currentChord) + 71;
            if (arrayPosition == 7) value = (15-currentChord) + 74;
            if (arrayPosition == 6) value = (15-currentChord) + 78;
            if (arrayPosition == 5) value = (15-currentChord) + 83;
            if (arrayPosition == 4) value = (15-currentChord) + 75;
            if (arrayPosition == 3) value = (15-currentChord) + 77;
            if (arrayPosition == 2) value = (15-currentChord) + 79;
            if (arrayPosition == 1) value = (15-currentChord) + 82;
            if (arrayPosition == 0) value = (15-currentChord) + 84;
        }
    return value;
    }


//-------------------------------------------------------------------------------------------------------------------------------

    public void playTrackEvents(){ // initiates the playing Heresy AI logic
      
        workOutExtensions();
        //workOutChord();
        heresyChangeHistory();
        VpaNoteStater();
   //   heresyVoicingArray();
        countNoteOns();

        
     }


 //-------------------------------------------------------------------------------------------------------------------------------
     
    public void sendNoteEvents(){  // sends sequencer evernts to the IO section for out put to max
        for(int i = 1; i < Track.currentNumberOfTracks; i++){
            if (tracks[i] != null ){
                for (int ii = 0; ii < 16; ii++) {
                   if (!VPA[i].VPArrayNotes[ii].played){
                       outputToMax (VPA[i].VPArrayNotes[ii].VPNotePitch, VPA[i].VPArrayNotes[ii].VPNoteVelocity, i);
                       VPA[i].VPArrayNotes[ii].played = true;
                   }
               }
            }
        }
    }
    

//-------------------------------------------------------------------------------------------------------------------------------
     
    public void VpaNoteStater(){  // calculates pitches based on Heresy AI voice leading and voicing tables.
      for(int i = 1; i < Track.currentNumberOfTracks; i++){
            if (tracks[i] != null){
                for (int ii = 0; ii < 16; ii++) {
                    if (tracks[i].sequence[ii][currentPulse%(tracks[i].loopLength)] != null){
                        if (tracks[i].sequence[ii][currentPulse%(tracks[i].loopLength)].noteVelocity != 0){
                            if (VPA[i].VPArrayNotes[ii].VPNoteOn && heresyPitchInfo(ii) != VPA[i].VPArrayNotes[ii].VPNotePitch){
                           //   println("in...");
                                VPA[i].VPArrayNotes[ii].VPNoteVelocity = 0;
                                sendNote(VPA[i].VPArrayNotes[ii], i);
                                if (i != 1 && i != 5)
                                    VPA[i].VPArrayNotes[ii].VPNotePitch = heresyPitch(ii, 3);
                                else
                                    VPA[i].VPArrayNotes[ii].VPNotePitch = heresyPitch(ii, 1);
                                VPA[i].VPArrayNotes[ii].VPNoteVelocity = tracks[i].sequence[ii][currentPulse%(tracks[i].loopLength)].noteVelocity;
                                sendNote(VPA[i].VPArrayNotes[ii], i);
                            }else{
                           //      println("in2...");
                                if (i != 1 && i != 5)
                                    VPA[i].VPArrayNotes[ii].VPNotePitch = heresyPitch(ii, 3);
                                else
                                    VPA[i].VPArrayNotes[ii].VPNotePitch = heresyPitch(ii, 1);
                                VPA[i].VPArrayNotes[ii].VPNoteVelocity = tracks[i].sequence[ii][currentPulse%(tracks[i].loopLength)].noteVelocity;
                                sendNote(VPA[i].VPArrayNotes[ii], i);
                            }
                        }
                        if (tracks[i].sequence[ii][currentPulse%(tracks[i].loopLength)].noteVelocity == 0){
                            VPA[i].VPArrayNotes[ii].VPNoteVelocity = 0;
                            sendNote(VPA[i].VPArrayNotes[ii], i);
                        }
                    }
                }
            }
        }
    }


//-------------------------------------------------------------------------------------------------------------------------------

/*    public void heresyVoicingArray(){  // sets the voicing array to be used for note ons
        if (!heresy7th && !heresy9th && !heresy11th && !heresy13th) hvArray = hchoice135;
        if (heresy7th && !heresy9th && !heresy11th && !heresy13th) hvArray = hchoice7;
        if (!heresy7th && heresy9th && !heresy11th && !heresy13th) hvArray = hchoice9;
        if (!heresy7th && !heresy9th && heresy11th && !heresy13th) hvArray = hchoice11;
        if (!heresy7th && !heresy9th && !heresy11th && heresy13th) hvArray = hchoice13;
        if (heresy7th && heresy9th && !heresy11th && !heresy13th) hvArray = hchoice79;
        if (heresy7th && !heresy9th && heresy11th && !heresy13th) hvArray = hchoice711;
        if (heresy7th && !heresy9th && !heresy11th && heresy13th) hvArray = hchoice713;
        if (!heresy7th && heresy9th && heresy11th && !heresy13th) hvArray = hchoice911;
        if (!heresy7th && heresy9th && !heresy11th && heresy13th) hvArray = hchoice913;
        if (!heresy7th && !heresy9th && heresy11th && heresy13th) hvArray = hchoice1113;
        if (heresy7th && heresy9th && heresy11th && !heresy13th) hvArray = hchoice7911;
        if (heresy7th && heresy9th && !heresy11th && heresy13th) hvArray = hchoice7913;
        if (heresy7th && !heresy9th && !heresy11th && heresy13th) hvArray = hchoice71113;
        if (!heresy7th && heresy9th && heresy11th && heresy13th) hvArray = hchoice91113;
    }
    
    */
    
    
//------------------------------------------------------------------------------------------------------------------------------- 
 
    public void countNoteOns(){    // counts the note ons for all tracks
        for (int ii = 0; ii < 16; ii++){
            notesOnArray[ii] = 0;}
        for(int i = 1; i < Track.currentNumberOfTracks; i++){
            for (int ii = 0; ii < 16; ii++){
                if (VPA[i].VPArrayNotes[ii].VPNoteOn == true)
                notesOnArray[i]++;
            }
        }
    }


//-------------------------------------------------------------------------------------------------------------------------------

 /*   public void calculateHeresyNoteExtensions(){
        for(int tracki = 1; tracki < Track.currentNumberOfTracks; tracki++){
            no1s = 0; no3s = 0; no5s = 0; no7s = 0; no9s = 0; no11s = 0; no13s = 0;
            
            checkIfNotesAlreadyFit(tracki);
            
            calcRemainingNotes(tracki);
            
            for (int t = 0; t < 16; t++){
                VPA[tracki].VPArrayNotes[t].done = false;
            }
         }
     }
     
     */
    
    
//-------------------------------------------------------------------------------------------------------------------------------

/*    public void calcRemainingNotes(int tracki){
        int counter = -1;
        int looped = 0;
        while (no1s + no3s + no5s + no7s + no9s + no11s + no13s != 0){
            counter++;
            if (counter >= notesOnArray[tracki]){
                counter = 0;
                looped++;
            }
            int nextExtension = hvArray[counter];
            if(extensionNeeded(nextExtension)){
                for (int playingNotesi = 0; playingNotesi < 16; playingNotesi++){
                    if (VPA[tracki].VPArrayNotes[playingNotesi].VPNoteOn == true && !VPA[tracki].VPArrayNotes[playingNotesi].done){
                        if (extensionPossible(playingNotesi, nextExtension)){
                            VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch = getHeresyPitch(nextExtension, playingNotesi);
                            VPA[tracki].VPArrayNotes[playingNotesi].done = true;
                            println("got pitch " + VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch); 
                      //    correctIfNeeded(tracki, playingNotesi, nextExtension); 
                        }else println("wasn't possible");
                    }
                }
            }
            if (looped > 3) {
                for (int playingNotesi = 0; playingNotesi < 16; playingNotesi++){
                    if (VPA[tracki].VPArrayNotes[playingNotesi].VPNoteOn == true && !VPA[tracki].VPArrayNotes[playingNotesi].done){
                        VPA[tracki].VPArrayNotes[playingNotesi].VPNoteOn = false;
                        VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch = -1;
                    }
                }
                System.out.println("Had to break_________________");
                break;
            }
        }
    }
    
    */
    
    
//-------------------------------------------------------------------------------------------------------------------------------    
  
 /*   public void correctIfNeeded(int tracki, int playingNotesi, int nextExtension){ // changes note pitch of a virtual note on to a different octave in needed for voice leading
        boolean alreadyGotNote = false; boolean alreadyGotNotePlus12 = false; boolean alreadyGotNoteMinus12 = false; 
        int pitchAverage = 0;
        for (int i = 0; i < 16; i++)
            if (i != playingNotesi){
                if (VPA[tracki].VPArrayNotes[i].done)
                    pitchAverage += VPA[tracki].VPArrayNotes[i].VPNotePitch;
                if (VPA[tracki].VPArrayNotes[i].VPNotePitch == VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch) 
                    alreadyGotNote = true;
                if (VPA[tracki].VPArrayNotes[i].VPNotePitch == VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch + 12) 
                    alreadyGotNotePlus12 = true;
                if (VPA[tracki].VPArrayNotes[i].VPNotePitch == VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch - 12) 
                    alreadyGotNoteMinus12 = true;  
            }
            if (notesOnArray[tracki]-1 > 0)
                pitchAverage = pitchAverage / (notesOnArray[tracki]-1);
            else 
                pitchAverage = VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch;
            boolean correctedIt = false;
            if (alreadyGotNote){
                println("correcting note..........");
                if (!alreadyGotNotePlus12 && pitchAverage > VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch){
                    VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch = VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch + 12;
                    correctedIt = true;
                }else
                    if (!alreadyGotNoteMinus12){
                        VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch = VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch - 12;
                        correctedIt = true;
                    }
                if (!alreadyGotNoteMinus12 && pitchAverage < VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch){
                    VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch = VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch - 12;
                    correctedIt = true;
                }else
                    if (!alreadyGotNotePlus12){
                        VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch = VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch + 12;
                        correctedIt = true;
                    }
               }
               if (alreadyGotNote && !correctedIt)
                   VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch = -2;
               if (!alreadyGotNote || correctedIt){
                   VPA[tracki].VPArrayNotes[playingNotesi].VPNoteVelocity = 80;
                   VPA[tracki].VPArrayNotes[playingNotesi].done = true;
                   VPA[tracki].VPArrayNotes[playingNotesi].played = false;
                   extensionCounter(false, nextExtension);    
               }else{
                   VPA[tracki].VPArrayNotes[playingNotesi].VPNoteVelocity = 80;
                   VPA[tracki].VPArrayNotes[playingNotesi].done = true;
               }
    }
    
    */


//------------------------------------------------------------------------------------------------------------------------------- 



 /*   public void checkIfNotesAlreadyFit(int tracki){
        for (int extensioni = 0; extensioni < notesOnArray[tracki]; extensioni++){
            boolean extensionFound = false;
            for (int playingNotesi = 0; playingNotesi < 16; playingNotesi++){
                if (VPA[tracki].VPArrayNotes[playingNotesi].VPNoteOn && !VPA[tracki].VPArrayNotes[playingNotesi].done && !extensionFound && VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch >= 24){
                    if (disiredPitch(VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch, hvArray[extensioni])){
                        VPA[tracki].VPArrayNotes[playingNotesi].done = true;
                        extensionFound = true;
                    }
                }
            }
            if (!extensionFound){
                extensionCounter(true, hvArray[extensioni]);
            }
        }
    }
    
*/
            
            
//-------------------------------------------------------------------------------------------------------------------------------             

 /*   public boolean pitchInChord(int currentPitch){
        boolean returnValue = false;
        for (int i = 0; i < 16; i++){
          //  println("currentPitch " + currentPitch + " getHeresyPitch(hvArray[i], 5) % 12) " + (getHeresyPitch(hvArray[i], 5)));
            if (currentPitch % 12 == (getHeresyPitch(hvArray[i], 5) % 12));
                returnValue = true;
        }
        return returnValue;
    }
 */       
    
//-------------------------------------------------------------------------------------------------------------------------------           

 /*    public boolean extensionNeeded(int extension){
     boolean needed = false;
         if (extension == 1 && no1s > 0) needed = true;
         if (extension == 3 && no3s > 0) needed = true;
         if (extension == 5 && no5s > 0) needed = true;
         if (extension == 7 && no7s > 0) needed = true;
         if (extension == 9 && no9s > 0) needed = true;
         if (extension == 11 && no11s > 0) needed = true;
         if (extension == 13 && no13s > 0) needed = true;
         return needed;
     }
   */
    

//------------------------------------------------------------------------------------------------------------------------------- 

  /*  public int extensionMatch(){
        int returnValue = -1;
        for (int i = 0; i < 16; i++){
            if( hvArray[i] == 1 && no1s > 0){
                returnValue =  hvArray[i];
                break;
            }
            if( hvArray[i] == 3 && no3s > 0){
                returnValue =  hvArray[i];
                break;
            }
            if( hvArray[i] == 5 && no5s > 0){
                returnValue = hvArray[i];
                break;
            }
            if( hvArray[i] == 7 && no7s > 0){
                returnValue = hvArray[i];
                break;
            }
            if( hvArray[i] == 9 && no9s > 0){
                returnValue = hvArray[i];
                break;
            }
            if( hvArray[i] == 11 && no11s > 0){
                returnValue = hvArray[i];
                break;
            }
            if( hvArray[i] == 13 && no13s > 0){
                returnValue = hvArray[i];
                break;
            }
        }
        return returnValue;
    }
    
    */
      

    
    
//-------------------------------------------------------------------------------------------------------------------------------   

/*    public boolean extensionPossible(int playingNotesi, int extentionNeeded){
        Boolean returnValue = true;
        if (extentionNeeded != 1 && playingNotesi < 2) returnValue =  false;
        if ((extentionNeeded == 5 || extentionNeeded == 7 || extentionNeeded == 1) && playingNotesi == 3) returnValue = false;
        if (!returnValue) println ("returning no on playingNotesi = " + playingNotesi + " and " + extentionNeeded);
        return returnValue;
    }
 */   
    
//-------------------------------------------------------------------------------------------------------------------------------

/*    public boolean disiredPitch(int pitch, int extension){  // returns a value for voice leading purposes.  If true then pitch is already in current chord
        if (pitch % 12 == getExtentionPitch(extension) % 12)
            return true;
        else return false;
    }
  */ 
    
//-------------------------------------------------------------------------------------------------------------------------------

  /*  public int getExtentionPitch(int extension){  //
        if (!heresyMinor){
            if (currentChord-tonic == 1)  return tritoneSystem[extension/2]+currentChord;
            if (currentChord-tonic == 7)  return dom7System[extension/2]+currentChord;
            if (currentChord-tonic != 1 || currentChord-tonic != 7) return major7System[extension/2]+currentChord;
        }
        if (heresyMinor)
            return minorSystem[extension/2]+currentChord;
        else
            return -1;
   }
    */
    
    
//-------------------------------------------------------------------------------------------------------------------------------

 /*   public void extensionCounter(boolean positive, int currentDesiredExtention){
        if (currentDesiredExtention == 1) if (positive) no1s++; else no1s--;
        if (currentDesiredExtention == 3) if (positive) no3s++; else no3s--;
        if (currentDesiredExtention == 5) if (positive) no5s++; else no5s--;
        if (currentDesiredExtention == 7) if (positive) no7s++; else no7s--;
        if (currentDesiredExtention == 9) if (positive) no9s++; else no9s--;
        if (currentDesiredExtention == 11) if (positive) no11s++; else no11s--;
        if (currentDesiredExtention == 13) if (positive) no13s++; else no13s--;
    }
 */                                   

//-------------------------------------------------------------------------------------------------------------------------------

    public void workOutExtensions(){  // calculates whether the performer wants chord extensions
        if (tracks[0].sequence[3][currentPulse%(tracks[0].loopLength)] != null && tracks[0].sequence[3][currentPulse%(tracks[0].loopLength)].noteVelocity == 0  && trSelected == 0 && noteOnArray[3])
            tracks[0].sequence[3][currentPulse%(tracks[0].loopLength)] = null;
        if (tracks[0].sequence[2][currentPulse%(tracks[0].loopLength)] != null && tracks[0].sequence[2][currentPulse%(tracks[0].loopLength)].noteVelocity == 0  && trSelected == 0 && noteOnArray[2])
            tracks[0].sequence[2][currentPulse%(tracks[0].loopLength)] = null;
        if (tracks[0].sequence[1][currentPulse%(tracks[0].loopLength)] != null && tracks[0].sequence[1][currentPulse%(tracks[0].loopLength)].noteVelocity == 0  && trSelected == 0 && noteOnArray[1])
            tracks[0].sequence[1][currentPulse%(tracks[0].loopLength)] = null;
        if (tracks[0].sequence[0][currentPulse%(tracks[0].loopLength)] != null && tracks[0].sequence[0][currentPulse%(tracks[0].loopLength)].noteVelocity == 0  && trSelected == 0 && noteOnArray[0])
            tracks[0].sequence[0][currentPulse%(tracks[0].loopLength)] = null;         

        if (tracks[0].sequence[3][currentPulse%(tracks[0].loopLength)] != null && tracks[0].sequence[3][currentPulse%(tracks[0].loopLength)].noteVelocity > 0)
            heresy7th = true;
        if (tracks[0].sequence[3][currentPulse%(tracks[0].loopLength)] != null && tracks[0].sequence[3][currentPulse%(tracks[0].loopLength)].noteVelocity == 0)
            heresy7th = false;
        if (tracks[0].sequence[2][currentPulse%(tracks[0].loopLength)] != null && tracks[0].sequence[2][currentPulse%(tracks[0].loopLength)].noteVelocity > 0)
            heresy9th = true;
        if (tracks[0].sequence[2][currentPulse%(tracks[0].loopLength)] != null && tracks[0].sequence[2][currentPulse%(tracks[0].loopLength)].noteVelocity == 0)
            heresy9th = false;    
        if (tracks[0].sequence[1][currentPulse%(tracks[0].loopLength)] != null && tracks[0].sequence[1][currentPulse%(tracks[0].loopLength)].noteVelocity > 0)
            heresy11th = true;
        if (tracks[0].sequence[1][currentPulse%(tracks[0].loopLength)] != null && tracks[0].sequence[1][currentPulse%(tracks[0].loopLength)].noteVelocity == 0)
            heresy11th = false;
        if (tracks[0].sequence[0][currentPulse%(tracks[0].loopLength)] != null && tracks[0].sequence[0][currentPulse%(tracks[0].loopLength)].noteVelocity > 0)
            heresy13th = true;
        if (tracks[0].sequence[0][currentPulse%(tracks[0].loopLength)] != null && tracks[0].sequence[0][currentPulse%(tracks[0].loopLength)].noteVelocity == 0)
            heresy13th = false;
            //---
        if (chordsTemp.sequence[3][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[3][currentPulse%(chordsTemp.loopLength)].noteVelocity == 0  && trSelected == 0 && noteOnArray[3])
            chordsTemp.sequence[3][currentPulse%(chordsTemp.loopLength)] = null;
        if (chordsTemp.sequence[2][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[2][currentPulse%(chordsTemp.loopLength)].noteVelocity == 0  && trSelected == 0 && noteOnArray[2])
            chordsTemp.sequence[2][currentPulse%(chordsTemp.loopLength)] = null;
        if (chordsTemp.sequence[1][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[1][currentPulse%(chordsTemp.loopLength)].noteVelocity == 0  && trSelected == 0 && noteOnArray[1])
            chordsTemp.sequence[1][currentPulse%(chordsTemp.loopLength)] = null;
        if (chordsTemp.sequence[0][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[0][currentPulse%(chordsTemp.loopLength)].noteVelocity == 0  && trSelected == 0 && noteOnArray[0])
            chordsTemp.sequence[0][currentPulse%(chordsTemp.loopLength)] = null;         

        if (chordsTemp.sequence[3][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[3][currentPulse%(chordsTemp.loopLength)].noteVelocity > 0)
            heresy7th = true;
        if (chordsTemp.sequence[3][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[3][currentPulse%(chordsTemp.loopLength)].noteVelocity == 0)
            heresy7th = false;
        if (chordsTemp.sequence[2][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[2][currentPulse%(chordsTemp.loopLength)].noteVelocity > 0)
            heresy9th = true;
        if (chordsTemp.sequence[2][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[2][currentPulse%(chordsTemp.loopLength)].noteVelocity == 0)
            heresy9th = false;    
        if (chordsTemp.sequence[1][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[1][currentPulse%(chordsTemp.loopLength)].noteVelocity > 0)
            heresy11th = true;
        if (chordsTemp.sequence[1][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[1][currentPulse%(chordsTemp.loopLength)].noteVelocity == 0)
            heresy11th = false;
        if (chordsTemp.sequence[0][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[0][currentPulse%(chordsTemp.loopLength)].noteVelocity > 0)
            heresy13th = true;
        if (chordsTemp.sequence[0][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[0][currentPulse%(chordsTemp.loopLength)].noteVelocity == 0)
            heresy13th = false;
            
    }
    
    
//-------------------------------------------------------------------------------------------------------------------------------
    
    public void workOutChord(){ // calculates current chord and major minor tonality
        for (int i = 4; i < 16; i++) {
            if (tracks[0] != null){
                if ((tracks[0].sequence[i][currentPulse%(tracks[0].loopLength)] != null && tracks[0].sequence[i][currentPulse%(tracks[0].loopLength)].noteVelocity > 0 )||
                   (chordsTemp.sequence[i][currentPulse%(tracks[0].loopLength)] != null && chordsTemp.sequence[i][currentPulse%(chordsTemp.loopLength)].noteVelocity > 0 )){
                    currentChord = 15 - i;
                    boolean iiDone = false;
                    for (int ii = 0;; ii--){
                        if (ii == 0 && iiDone)
                            break;
                        if (currentPulse%(tracks[0].loopLength)+ii  == 0)
                            ii = tracks[0].loopLength+ii-1;
                        if (i > 3){
                            if ((tracks[0].sequence[i-1][currentPulse%(tracks[0].loopLength)+ii] != null && tracks[0].sequence[i-1][currentPulse%(tracks[0].loopLength)+ii].noteVelocity == 0 ) ||
                                 (chordsTemp.sequence[i-1][currentPulse%(chordsTemp.loopLength)+ii] != null && chordsTemp.sequence[i-1][currentPulse%(chordsTemp.loopLength)+ii].noteVelocity == 0 ))
                                 break;
                            if ((tracks[0].sequence[i-1][currentPulse%(tracks[0].loopLength)+ii] != null && tracks[0].sequence[i-1][currentPulse%(tracks[0].loopLength)+ii].noteVelocity != 0 ) ||
                                 (chordsTemp.sequence[i-1][currentPulse%(chordsTemp.loopLength)+ii] != null && chordsTemp.sequence[i-1][currentPulse%(chordsTemp.loopLength)+ii].noteVelocity != 0 )){
                                heresyMinor = true;
                                break;
                            }else
                                heresyMinor = false;
                        }
                        iiDone = true;
                    }
                }
            }
        }
    }


//-------------------------------------------------------------------------------------------------------------------------------
    
    public void heresyChangeHistory(){  // remembers whether the chords or extensions have changed
        if (currentChord != lastChord){
            heresyChordChanged = true;
            lastChord = currentChord;
            heresyChange = true; 
        }
        if (heresyMinor != oldHeresyMinor){
            heresyMinorChanged = true;
            oldHeresyMinor = heresyMinor;
            heresyChange = true;
        }
        if (heresy7th != oldHeresy7th){
            heresy7thChanged = true;
            oldHeresy7th = heresy7th;
            heresyChange = true;
        }
        if (heresy9th != oldHeresy9th){
            heresy9thChanged = true;
            oldHeresy9th = heresy9th;
            heresyChange = true;
        }
        if (heresy11th != oldHeresy11th){
            heresy11thChanged = true;
            oldHeresy11th = heresy11th;
            heresyChange = true;
        }
        if (heresy13th != oldHeresy13th){
            heresy13thChanged = true;
            oldHeresy13th = heresy13th;
            heresyChange = true;
        }
    }


      
       
    
// the main voicing tables for chords requested

// root position

int[] hchoice135 = new int[]  {24,  36,  43,  48,  52,  55,  60,  64,  67,  72,  76,  79,  84,  88,  91,  96};
int[] hchoice7 = new int[]    {24,  36,  43,  48,  52,  55,  59,  64,  67,  71,  72,  76,  79,  83,  88,  95};
int[] hchoice9 = new int[]    {24,  36,  43,  48,  50,  52,  55,  60,  62,  64,  67,  74,  76,  79,  86,  91};
int[] hchoice11 = new int[]   {24,  36,  43,  48,  53,  55,  60,  65,  67,  72,  77,  79,  84,  89,  91,  96};
int[] hchoice13 = new int[]   {24,  36,  43,  48,  52,  55,  57,  60,  64,  69,  72,  76,  81,  84,  88,  93};
int[] hchoice79 = new int[]   {24,  36,  43,  48,  52,  55,  57,  59,  62,  64,  69,  71,  74,  76,  83,  86};
int[] hchoice711 = new int[]  {24,  36,  43,  48,  53,  55,  59,  60,  65,  67,  71,  72,  77,  83,  88,  95}; //nice
int[] hchoice713 = new int[]  {24,  36,  43,  48,  52,  57,  59,  64,  69,  71,  76,  79,  81,  83,  88,  93};
int[] hchoice911 = new int[]  {24,  36,  43,  48,  53,  55,  60,  62,  65,  67,  74,  77,  79,  86,  89,  96};
int[] hchoice913 = new int[]  {24,  36,  43,  48,  50,  57,  60,  62,  69,  72,  74,  81,  84,  86,  93,  96};
int[] hchoice1113 = new int[] {24,  36,  43,  48,  52,  53,  57,  60,  64,  65,  69,  72,  77,  81,  84,  93}; //nice
int[] hchoice7911 = new int[] {24,  36,  43,  48,  55,  62,  65,  71,  77,  79,  83,  84,  86,  89,  91,  96};
int[] hchoice7913 = new int[] {24,  36,  43,  48,  59,  62,  69,  71,  74,  81,  83,  84,  86,  93,  95,  96};
int[] hchoice71113 = new int[]{24,  36,  43,  48,  55,  59,  65,  69,  76,  77,  79,  84,  88,  89,  93,  96};
int[] hchoice91113 = new int[]{24,  36,  48,  50,  53,  57,  60,  62,  65,  69,  72,  74,  77,  81,  89,  96};
int[] hchoice791113 = new int[]{24,  36,  50,  53,  58,  62,  65,  70,  74,  77,  82,  84,  86,  89,  94,  96}; //dom7th full sus chord

int[] mhchoice135 = new int[]  {24,  36,  43,  48,  51,  55,  60,  63,  67,  72,  75,  79,  84,  87,  91,  96};//
int[] mhchoice7 = new int[]    {24,  36,  43,  48,  51,  55,  58,  63,  67,  70,  72,  75,  79,  82,  87,  94};//
int[] mhchoice9 = new int[]    {24,  36,  43,  48,  50,  51,  55,  60,  62,  63,  67,  72,  74,  79,  86,  91};//
int[] mhchoice11 = new int[]   {24,  36,  43,  48,  51,  53,  55,  60,  63,  65,  67,  72,  77,  79,  84,  89};//
int[] mhchoice13 = new int[]   {24,  36,  43,  48,  51,  55,  57,  60,  63,  67,  69,  72,  75,  81,  84,  91};//
int[] mhchoice79 = new int[]   {24,  36,  43,  50,  51,  55,  57,  58,  62,  63,  69,  70,  74,  75,  82,  86};//
int[] mhchoice711 = new int[]  {24,  36,  43,  51,  58,  63,  65,  69,  72,  75,  77,  79,  82,  84,  89,  96};// 
int[] mhchoice713 = new int[]  {24,  36,  43,  48,  55,  58,  59,  63,  69,  75,  79,  81,  82,  84,  93,  96};//
int[] mhchoice911 = new int[]  {24,  36,  43,  48,  51,  53,  62,  63,  65,  67,  74,  77,  79,  86,  89,  96};//
int[] mhchoice913 = new int[]  {24,  36,  43,  51,  57,  62,  63,  69,  74,  75,  81,  84,  86,  87,  93,  96};//
int[] mhchoice1113 = new int[] {24,  36,  43,  53,  57,  63,  67,  72,  75,  77,  79,  81,  84,  87,  93,  96};// 
int[] mhchoice7911 = new int[] {24,  36,  43,  50,  51,  58,  65,  67,  70,  72,  74,  75,  77,  79,  82,  86};//
int[] mhchoice7913 = new int[] {24,  36,  48,  55,  58,  62,  63,  69,  70,  74,  75,  79,  81,  84,  93,  96};//
int[] mhchoice71113 = new int[]{24,  36,  43,  48,  53,  58,  63,  65,  69,  72,  75,  77,  81,  84,  91,  96};//
int[] mhchoice91113 = new int[]{24,  36,  48,  50,  53,  57,  60,  62,  65,  69,  72,  74,  77,  81,  89,  96};//
int[] mhchoice791113 = new int[]{24,  36,  50,  53,  58,  62,  65,  70,  74,  77,  82,  84,  86,  89,  94,  96}; //dom7th full sus chord

// first inversion

int[] h1choice135 = new int[]  {24,  36,  40,  43,  48,  52,  55,  60,  64,  67,  72,  76,  79,  84,  88,  91};
int[] h1choice7 = new int[]    {24,  36,  40,  43,  48,  52,  55,  59,  64,  67,  71,  72,  76,  79,  83,  88};
int[] h1choice9 = new int[]    {24,  36,  38,  43,  48,  50,  52,  55,  60,  62,  64,  67,  74,  76,  79,  86};
int[] h1choice11 = new int[]   {24,  36,  41,  43,  48,  53,  55,  60,  65,  67,  72,  77,  79,  84,  89,  91};
int[] h1choice13 = new int[]   {24,  36,  40,  43,  48,  52,  55,  57,  60,  64,  69,  72,  76,  81,  84,  88};
int[] h1choice79 = new int[]   {24,  36,  40,  43,  48,  52,  55,  57,  59,  62,  64,  69,  71,  74,  76,  83};
int[] h1choice711 = new int[]  {24,  36,  41,  43,  48,  53,  55,  59,  60,  65,  67,  71,  72,  77,  83,  88}; //nice
int[] h1choice713 = new int[]  {24,  36,  40,  43,  48,  52,  57,  59,  64,  69,  71,  76,  79,  81,  83,  88};
int[] h1choice911 = new int[]  {24,  36,  41,  43,  48,  53,  55,  60,  62,  65,  67,  74,  77,  79,  86,  89};
int[] h1choice913 = new int[]  {24,  36,  43,  45,  48,  50,  57,  60,  62,  69,  72,  74,  81,  84,  86,  93};
int[] h1choice1113 = new int[] {24,  36,  40,  43,  48,  52,  53,  57,  60,  64,  65,  69,  72,  77,  81,  84}; //nice
int[] h1choice7911 = new int[] {24,  36,  43,  48,  50,  55,  62,  65,  71,  77,  79,  83,  84,  86,  89,  91};
int[] h1choice7913 = new int[] {24,  36,  43,  48,  55,  59,  62,  69,  71,  74,  81,  83,  84,  86,  93,  95};
int[] h1choice71113 = new int[]{24,  36,  43,  48,  53,  55,  59,  65,  69,  76,  77,  79,  84,  88,  89,  93};
int[] h1choice91113 = new int[]{24,  36,  41,  48,  50,  53,  57,  60,  62,  65,  69,  72,  74,  77,  81,  89};
int[] h1choice791113 = new int[]{24,  36,  43,  50,  53,  58,  62,  65,  70,  74,  77,  82,  84,  86,  89,  94}; //dom7th full sus chord

int[] m1hchoice135 = new int[]  {24,  36,  39,  43,  48,  51,  55,  60,  63,  67,  72,  75,  79,  84,  87,  91};//
int[] m1hchoice7 = new int[]    {24,  36,  39,  43,  48,  51,  55,  58,  63,  67,  70,  72,  75,  79,  82,  87};//
int[] m1hchoice9 = new int[]    {24,  36,  38,  43,  48,  50,  51,  55,  60,  62,  63,  67,  72,  74,  79,  86};//
int[] m1hchoice11 = new int[]   {24,  36,  39,  43,  48,  51,  53,  55,  60,  63,  65,  67,  72,  77,  79,  84};//
int[] m1hchoice13 = new int[]   {24,  36,  39,  43,  48,  51,  55,  57,  60,  63,  67,  69,  72,  75,  81,  84};//
int[] m1hchoice79 = new int[]   {24,  36,  39,  43,  50,  51,  55,  57,  58,  62,  63,  69,  70,  74,  75,  82};//
int[] m1hchoice711 = new int[]  {24,  36,  43,  46,  51,  58,  63,  65,  69,  72,  75,  77,  79,  82,  84,  89};// 
int[] m1hchoice713 = new int[]  {24,  36,  43,  46,  48,  55,  58,  59,  63,  69,  75,  79,  81,  82,  84,  93};//
int[] m1hchoice911 = new int[]  {24,  36,  39,  43,  48,  51,  53,  62,  63,  65,  67,  74,  77,  79,  86,  89};//
int[] m1hchoice913 = new int[]  {24,  36,  43,  48,  51,  57,  62,  63,  69,  74,  75,  81,  84,  86,  87,  93};//
int[] m1hchoice1113 = new int[] {24,  36,  43,  45,  53,  57,  63,  67,  72,  75,  77,  79,  81,  84,  87,  93};// 
int[] m1hchoice7911 = new int[] {24,  36,  39,  43,  50,  51,  58,  65,  67,  70,  72,  74,  75,  77,  79,  82};//
int[] m1hchoice7913 = new int[] {24,  36,  43,  48,  55,  58,  62,  63,  69,  70,  74,  75,  79,  81,  84,  93};//
int[] m1hchoice71113 = new int[]{24,  36,  43,  46,  48,  53,  58,  63,  65,  69,  72,  75,  77,  81,  84,  91};//
int[] m1hchoice91113 = new int[]{24,  36,  41,  48,  50,  53,  57,  60,  62,  65,  69,  72,  74,  77,  81,  89};//
int[] m1hchoice791113 = new int[]{24,  36,  46,  50,  53,  58,  62,  65,  70,  74,  77,  82,  84,  86,  89,  94}; //dom7th full sus chord

// second inversion

int[] h2choice135 = new int[]  {24,  31,  36,  40,  43,  48,  52,  55,  60,  64,  67,  72,  76,  79,  84,  88};
int[] h2choice7 = new int[]    {24,  31,  36,  40,  43,  48,  52,  55,  59,  64,  67,  71,  72,  76,  79,  83};
int[] h2choice9 = new int[]    {24,  31,  36,  38,  43,  48,  50,  52,  55,  60,  62,  64,  67,  74,  76,  79};
int[] h2choice11 = new int[]   {24,  31,  36,  41,  43,  48,  53,  55,  60,  65,  67,  72,  77,  79,  84,  89};
int[] h2choice13 = new int[]   {24,  31,  36,  40,  43,  48,  52,  55,  57,  60,  64,  69,  72,  76,  81,  84};
int[] h2choice79 = new int[]   {24,  31,  36,  40,  43,  48,  52,  55,  57,  59,  62,  64,  69,  71,  74,  76};
int[] h2choice711 = new int[]  {24,  31,  36,  41,  43,  48,  53,  55,  59,  60,  65,  67,  71,  72,  77,  83}; //nice
int[] h2choice713 = new int[]  {24,  31,  36,  40,  43,  48,  52,  57,  59,  64,  69,  71,  76,  79,  81,  83};
int[] h2choice911 = new int[]  {24,  31,  36,  41,  43,  48,  53,  55,  60,  62,  65,  67,  74,  77,  79,  86};
int[] h2choice913 = new int[]  {24,  31,  36,  43,  45,  48,  50,  57,  60,  62,  69,  72,  74,  81,  84,  86};
int[] h2choice1113 = new int[] {24,  31,  36,  40,  43,  48,  52,  53,  57,  60,  64,  65,  69,  72,  77,  81}; //nice
int[] h2choice7911 = new int[] {24,  31,  36,  43,  48,  50,  55,  62,  65,  71,  77,  79,  83,  84,  86,  89};
int[] h2choice7913 = new int[] {24,  31,  36,  43,  48,  55,  59,  62,  69,  71,  74,  81,  83,  84,  86,  93};
int[] h2choice71113 = new int[]{24,  31,  36,  43,  48,  53,  55,  59,  65,  69,  76,  77,  79,  84,  88,  89};
int[] h2choice91113 = new int[]{24,  31,  36,  41,  48,  50,  53,  57,  60,  62,  65,  69,  72,  74,  77,  81};
int[] h2choice791113 = new int[]{24,  31,  36,  43,  50,  53,  58,  62,  65,  70,  74,  77,  82,  84,  86,  89}; //dom7th full sus chord

int[] m2hchoice135 = new int[]  {24,  31,  36,  39,  43,  48,  51,  55,  60,  63,  67,  72,  75,  79,  84,  87};//
int[] m2hchoice7 = new int[]    {24,  31,  36,  39,  43,  48,  51,  55,  58,  63,  67,  70,  72,  75,  79,  82};//
int[] m2hchoice9 = new int[]    {24,  31,  36,  38,  43,  48,  50,  51,  55,  60,  62,  63,  67,  72,  74,  79};//
int[] m2hchoice11 = new int[]   {24,  31,  36,  39,  43,  48,  51,  53,  55,  60,  63,  65,  67,  72,  77,  79};//
int[] m2hchoice13 = new int[]   {24,  31,  36,  39,  43,  48,  51,  55,  57,  60,  63,  67,  69,  72,  75,  81};//
int[] m2hchoice79 = new int[]   {24,  31,  36,  39,  43,  50,  51,  55,  57,  58,  62,  63,  69,  70,  74,  75};//
int[] m2hchoice711 = new int[]  {24,  31,  36,  43,  46,  51,  58,  63,  65,  69,  72,  75,  77,  79,  82,  84};// 
int[] m2hchoice713 = new int[]  {24,  31,  36,  43,  46,  48,  55,  58,  59,  63,  69,  75,  79,  81,  82,  84};//
int[] m2hchoice911 = new int[]  {24,  31,  36,  39,  43,  48,  51,  53,  62,  63,  65,  67,  74,  77,  79,  86};//
int[] m2hchoice913 = new int[]  {24,  31,  36,  43,  48,  51,  57,  62,  63,  69,  74,  75,  81,  84,  86,  87};//
int[] m2hchoice1113 = new int[] {24,  31,  36,  43,  45,  53,  57,  63,  67,  72,  75,  77,  79,  81,  84,  87};// 
int[] m2hchoice7911 = new int[] {24,  31,  36,  39,  43,  50,  51,  58,  65,  67,  70,  72,  74,  75,  77,  79};//
int[] m2hchoice7913 = new int[] {24,  31,  36,  43,  48,  55,  58,  62,  63,  69,  70,  74,  75,  79,  81,  84};//
int[] m2hchoice71113 = new int[]{24,  31,  36,  43,  46,  48,  53,  58,  63,  65,  69,  72,  75,  77,  81,  84};//
int[] m2hchoice91113 = new int[]{24,  31,  36,  41,  48,  50,  53,  57,  60,  62,  65,  69,  72,  74,  77,  81};//
int[] m2hchoice791113 = new int[]{24,  31,  36,  46,  50,  53,  58,  62,  65,  70,  74,  77,  82,  84,  86,  89}; //dom7th full sus chord

int[] hvArray;
int[] minorSystem = new int[] {0, 3, 7, 10, 14, 17, 21};
int[] major7System = new int[] {0, 4, 7, 11, 14, 18, 21};
int[] dom7System = new int[] {0, 4, 7, 10, 14, 17, 21};
int[] tritoneSystem = new int[] {0, 4, 7, 10, 14, 18, 21};

public int heresyPitch(int arrayPosition, int heresyChannel){  //  calculates the pitch value to be returned for playback.
    boolean m = heresyMinor;
    boolean e7 = heresy7th;
    boolean e9 = heresy9th;
    boolean e11 = heresy11th;
    boolean e13 = heresy13th;
    int returnInt = 0;
    if ((currentChord % 12) > -1 && (currentChord % 12) < 4){
        if (!m && !e7 && !e9 && !e11 && !e13) returnInt = hchoice135[15 - arrayPosition];
        if (!m &&  e7 && !e9 && !e11 && !e13) returnInt = hchoice7[15 - arrayPosition];
        if (!m && !e7 &&  e9 && !e11 && !e13) returnInt = hchoice9[15 - arrayPosition];
        if (!m && !e7 && !e9 &&  e11 && !e13) returnInt = hchoice11[15 - arrayPosition];
        if (!m && !e7 && !e9 && !e11 &&  e13) returnInt = hchoice13[15 - arrayPosition];
        if (!m &&  e7 &&  e9 && !e11 && !e13) returnInt = hchoice79[15 - arrayPosition]; 
        if (!m &&  e7 && !e9 &&  e11 && !e13) returnInt = hchoice711[15 - arrayPosition]; 
        if (!m &&  e7 && !e9 && !e11 &&  e13) returnInt = hchoice713[15 - arrayPosition];
        if (!m && !e7 &&  e9 &&  e11 && !e13) returnInt = hchoice911[15 - arrayPosition];
        if (!m && !e7 &&  e9 && !e11 &&  e13) returnInt = hchoice913[15 - arrayPosition];
        if (!m && !e7 && !e9 &&  e11 &&  e13) returnInt = hchoice1113[15 - arrayPosition];
        if (!m &&  e7 &&  e9 &&  e11 && !e13) returnInt = hchoice7911[15 - arrayPosition];
        if (!m &&  e7 &&  e9 && !e11 &&  e13) returnInt = hchoice7913[15 - arrayPosition];
        if (!m &&  e7 && !e9 &&  e11 &&  e13) returnInt = hchoice71113[15 - arrayPosition];
        if (!m && !e7 &&  e9 &&  e11 &&  e13) returnInt = hchoice91113[15 - arrayPosition];
        if (!m &&  e7 &&  e9 &&  e11 &&  e13) returnInt = hchoice791113[15 - arrayPosition];
    
        if (m && !e7 && !e9 && !e11 && !e13) returnInt = mhchoice135[15 - arrayPosition];
        if (m &&  e7 && !e9 && !e11 && !e13) returnInt = mhchoice7[15 - arrayPosition];
        if (m && !e7 &&  e9 && !e11 && !e13) returnInt = mhchoice9[15 - arrayPosition];
        if (m && !e7 && !e9 &&  e11 && !e13) returnInt = mhchoice11[15 - arrayPosition];
        if (m && !e7 && !e9 && !e11 &&  e13) returnInt = mhchoice13[15 - arrayPosition];
        if (m &&  e7 &&  e9 && !e11 && !e13) returnInt = mhchoice79[15 - arrayPosition]; 
        if (m &&  e7 && !e9 &&  e11 && !e13) returnInt = mhchoice711[15 - arrayPosition]; 
        if (m &&  e7 && !e9 && !e11 &&  e13) returnInt = mhchoice713[15 - arrayPosition];
        if (m && !e7 &&  e9 &&  e11 && !e13) returnInt = mhchoice911[15 - arrayPosition];
        if (m && !e7 &&  e9 && !e11 &&  e13) returnInt = mhchoice913[15 - arrayPosition];
        if (m && !e7 && !e9 &&  e11 &&  e13) returnInt = mhchoice1113[15 - arrayPosition];
        if (m &&  e7 &&  e9 &&  e11 && !e13) returnInt = mhchoice7911[15 - arrayPosition];
        if (m &&  e7 &&  e9 && !e11 &&  e13) returnInt = mhchoice7913[15 - arrayPosition];
        if (m &&  e7 && !e9 &&  e11 &&  e13) returnInt = mhchoice71113[15 - arrayPosition];
        if (m && !e7 &&  e9 &&  e11 &&  e13) returnInt = mhchoice91113[15 - arrayPosition];
        if (m &&  e7 &&  e9 &&  e11 &&  e13) returnInt = mhchoice791113[15 - arrayPosition];
    }
    
        if ((currentChord % 12) > 3 && (currentChord % 12) < 8){
        if (!m && !e7 && !e9 && !e11 && !e13) returnInt = h1choice135[15 - arrayPosition];
        if (!m &&  e7 && !e9 && !e11 && !e13) returnInt = h1choice7[15 - arrayPosition];
        if (!m && !e7 &&  e9 && !e11 && !e13) returnInt = h1choice9[15 - arrayPosition];
        if (!m && !e7 && !e9 &&  e11 && !e13) returnInt = h1choice11[15 - arrayPosition];
        if (!m && !e7 && !e9 && !e11 &&  e13) returnInt = h1choice13[15 - arrayPosition];
        if (!m &&  e7 &&  e9 && !e11 && !e13) returnInt = h1choice79[15 - arrayPosition]; 
        if (!m &&  e7 && !e9 &&  e11 && !e13) returnInt = h1choice711[15 - arrayPosition]; 
        if (!m &&  e7 && !e9 && !e11 &&  e13) returnInt = h1choice713[15 - arrayPosition];
        if (!m && !e7 &&  e9 &&  e11 && !e13) returnInt = h1choice911[15 - arrayPosition];
        if (!m && !e7 &&  e9 && !e11 &&  e13) returnInt = h1choice913[15 - arrayPosition];
        if (!m && !e7 && !e9 &&  e11 &&  e13) returnInt = h1choice1113[15 - arrayPosition];
        if (!m &&  e7 &&  e9 &&  e11 && !e13) returnInt = h1choice7911[15 - arrayPosition];
        if (!m &&  e7 &&  e9 && !e11 &&  e13) returnInt = h1choice7913[15 - arrayPosition];
        if (!m &&  e7 && !e9 &&  e11 &&  e13) returnInt = h1choice71113[15 - arrayPosition];
        if (!m && !e7 &&  e9 &&  e11 &&  e13) returnInt = h1choice91113[15 - arrayPosition];
        if (!m &&  e7 &&  e9 &&  e11 &&  e13) returnInt = h1choice791113[15 - arrayPosition];
    
        if (m && !e7 && !e9 && !e11 && !e13) returnInt = m1hchoice135[15 - arrayPosition];
        if (m &&  e7 && !e9 && !e11 && !e13) returnInt = m1hchoice7[15 - arrayPosition];
        if (m && !e7 &&  e9 && !e11 && !e13) returnInt = m1hchoice9[15 - arrayPosition];
        if (m && !e7 && !e9 &&  e11 && !e13) returnInt = m1hchoice11[15 - arrayPosition];
        if (m && !e7 && !e9 && !e11 &&  e13) returnInt = m1hchoice13[15 - arrayPosition];
        if (m &&  e7 &&  e9 && !e11 && !e13) returnInt = m1hchoice79[15 - arrayPosition]; 
        if (m &&  e7 && !e9 &&  e11 && !e13) returnInt = m1hchoice711[15 - arrayPosition]; 
        if (m &&  e7 && !e9 && !e11 &&  e13) returnInt = m1hchoice713[15 - arrayPosition];
        if (m && !e7 &&  e9 &&  e11 && !e13) returnInt = m1hchoice911[15 - arrayPosition];
        if (m && !e7 &&  e9 && !e11 &&  e13) returnInt = m1hchoice913[15 - arrayPosition];
        if (m && !e7 && !e9 &&  e11 &&  e13) returnInt = m1hchoice1113[15 - arrayPosition];
        if (m &&  e7 &&  e9 &&  e11 && !e13) returnInt = m1hchoice7911[15 - arrayPosition];
        if (m &&  e7 &&  e9 && !e11 &&  e13) returnInt = m1hchoice7913[15 - arrayPosition];
        if (m &&  e7 && !e9 &&  e11 &&  e13) returnInt = m1hchoice71113[15 - arrayPosition];
        if (m && !e7 &&  e9 &&  e11 &&  e13) returnInt = m1hchoice91113[15 - arrayPosition];
        if (m &&  e7 &&  e9 &&  e11 &&  e13) returnInt = m1hchoice791113[15 - arrayPosition];
    }
    
        if ((currentChord % 12) > 7 && (currentChord % 12) < 12){
        if (!m && !e7 && !e9 && !e11 && !e13) returnInt = h2choice135[15 - arrayPosition];
        if (!m &&  e7 && !e9 && !e11 && !e13) returnInt = h2choice7[15 - arrayPosition];
        if (!m && !e7 &&  e9 && !e11 && !e13) returnInt = h2choice9[15 - arrayPosition];
        if (!m && !e7 && !e9 &&  e11 && !e13) returnInt = h2choice11[15 - arrayPosition];
        if (!m && !e7 && !e9 && !e11 &&  e13) returnInt = h2choice13[15 - arrayPosition];
        if (!m &&  e7 &&  e9 && !e11 && !e13) returnInt = h2choice79[15 - arrayPosition]; 
        if (!m &&  e7 && !e9 &&  e11 && !e13) returnInt = h2choice711[15 - arrayPosition]; 
        if (!m &&  e7 && !e9 && !e11 &&  e13) returnInt = h2choice713[15 - arrayPosition];
        if (!m && !e7 &&  e9 &&  e11 && !e13) returnInt = h2choice911[15 - arrayPosition];
        if (!m && !e7 &&  e9 && !e11 &&  e13) returnInt = h2choice913[15 - arrayPosition];
        if (!m && !e7 && !e9 &&  e11 &&  e13) returnInt = h2choice1113[15 - arrayPosition];
        if (!m &&  e7 &&  e9 &&  e11 && !e13) returnInt = h2choice7911[15 - arrayPosition];
        if (!m &&  e7 &&  e9 && !e11 &&  e13) returnInt = h2choice7913[15 - arrayPosition];
        if (!m &&  e7 && !e9 &&  e11 &&  e13) returnInt = h2choice71113[15 - arrayPosition];
        if (!m && !e7 &&  e9 &&  e11 &&  e13) returnInt = h2choice91113[15 - arrayPosition];
        if (!m &&  e7 &&  e9 &&  e11 &&  e13) returnInt = h2choice791113[15 - arrayPosition];
    
        if (m && !e7 && !e9 && !e11 && !e13) returnInt = m2hchoice135[15 - arrayPosition];
        if (m &&  e7 && !e9 && !e11 && !e13) returnInt = m2hchoice7[15 - arrayPosition];
        if (m && !e7 &&  e9 && !e11 && !e13) returnInt = m2hchoice9[15 - arrayPosition];
        if (m && !e7 && !e9 &&  e11 && !e13) returnInt = m2hchoice11[15 - arrayPosition];
        if (m && !e7 && !e9 && !e11 &&  e13) returnInt = m2hchoice13[15 - arrayPosition];
        if (m &&  e7 &&  e9 && !e11 && !e13) returnInt = m2hchoice79[15 - arrayPosition]; 
        if (m &&  e7 && !e9 &&  e11 && !e13) returnInt = m2hchoice711[15 - arrayPosition]; 
        if (m &&  e7 && !e9 && !e11 &&  e13) returnInt = m2hchoice713[15 - arrayPosition];
        if (m && !e7 &&  e9 &&  e11 && !e13) returnInt = m2hchoice911[15 - arrayPosition];
        if (m && !e7 &&  e9 && !e11 &&  e13) returnInt = m2hchoice913[15 - arrayPosition];
        if (m && !e7 && !e9 &&  e11 &&  e13) returnInt = m2hchoice1113[15 - arrayPosition];
        if (m &&  e7 &&  e9 &&  e11 && !e13) returnInt = m2hchoice7911[15 - arrayPosition];
        if (m &&  e7 &&  e9 && !e11 &&  e13) returnInt = m2hchoice7913[15 - arrayPosition];
        if (m &&  e7 && !e9 &&  e11 &&  e13) returnInt = m2hchoice71113[15 - arrayPosition];
        if (m && !e7 &&  e9 &&  e11 &&  e13) returnInt = m2hchoice91113[15 - arrayPosition];
        if (m &&  e7 &&  e9 &&  e11 &&  e13) returnInt = m2hchoice791113[15 - arrayPosition];
    }
    
    if (heresyDom && returnInt % 12 == 11)
        returnInt--;
    returnInt = currentChord + returnInt;
    
  //  if (heresyChannel == 1 || heresyChannel == 5)
  //      returnInt = 15 - arrayPosition + 36;
        

        
    return returnInt;
}


public void sendNote(VPNote note, int channel){ // send note function gathers info to output to max
    outputToMax(note.VPNotePitch, note.VPNoteVelocity, channel);
}


//-------------------------------------------------------------------------------------------------------------------------------

public void outputToMax(int note, int velocity, int channel){ // calculates the necessary note on and note offs depending on ducking and muting and sends them to max
    String noteOut = "";
    if (!tracks[channel].mute){
        if (tracks[channel].ducking){
            if (velocity != 0){
                noteOut = ("" + note + " " + velocity + " " + (channel+8));
            }
            if (velocity == 0 && !tracks[channel].cycled){
                noteOut = ("" + note + " " + velocity + " " + (channel+8));
                  OscMessage message = new OscMessage("/pitch_vel_chan");
                  message.add(noteOut);
                  oscP5return.send(message, ableton);
                link.output(noteOut);
                noteOut = ("" + note + " " + velocity + " " + channel);
            }
            if (velocity == 0 && tracks[channel].cycled){
                noteOut = ("" + note + " " + velocity + " " + (channel+8));      
            }
        }
        if (!tracks[channel].ducking){
            if (velocity != 0){
                noteOut = ("" + note + " " + velocity + " " + channel);
            }
            if (velocity == 0 && !tracks[channel].cycled){
                noteOut = ("" + note + " " + velocity + " " + (channel+8));
                  OscMessage message = new OscMessage("/pitch_vel_chan");
                  message.add(noteOut);
                  oscP5return.send(message, ableton);
                link.output(noteOut);
                noteOut = ("" + note + " " + velocity + " " + channel);
            }
            if (velocity == 0 && tracks[channel].cycled){
                noteOut = ("" + note + " " + velocity + " " + channel);  
            }
        }
        link.output(noteOut);
        OscMessage message = new OscMessage("/pitch_vel_chan");
        message.add(noteOut);
        oscP5return.send(message, ableton);
        
    }
    if (tracks[channel].mute){
        if (velocity == 0 && !tracks[channel].cycled){
            noteOut = ("" + note + " " + velocity + " " + (channel+8));
            link.output(noteOut);
            OscMessage message = new OscMessage("/pitch_vel_chan");
            message.add(noteOut);
            oscP5return.send(message, ableton);
            noteOut = ("" + note + " " + velocity + " " + channel);
            OscMessage message2 = new OscMessage("/pitch_vel_chan");
            message2.add(noteOut);
            oscP5return.send(message, ableton);
            link.output(noteOut);
        }
    }   
}


//-------------------------------------------------------------------------------------------------------------------------------

public void mouseDragged(){ // not used
}


//-------------------------------------------------------------------------------------------------------------------------------

public void mouseReleased(){ // not used
}


//-------------------------------------------------------------------------------------------------------------------------------

public void mousePressed(){ // not used
}


//-------------------------------------------------------------------------------------------------------------------------------

public void keyPressed() { // takes keyboard input
    if (key == 'c' || key == 'C') {
        chordSelecter = !chordSelecter;
        if (!chordSelecter)
            trSelected = lastTrack;
        else{
            lastTrack = trSelected;
            trSelected = 0;
            
        }
    }
    
    if (key == ' ') {
        if (trSelected != 0){
            for (int i = 0; i < 16; i++){
                noteOnArray[i] = false;
                finishNote(i);
                displayNoteOnArray[i] = false;
           }
    
           if (trSelected != 0){     
              for (int i = 24; i < 109; i++)
                outputToMax(i, 0, trSelected);
           }
           tracks[trSelected] = new Track(tracks[trSelected].name, true,  tracks[trSelected].loopLength, tracks[trSelected].quantize, false, false);
           imgNotes = null;
        }
        
        if (trSelected == 0){
           for (int i = 0; i < 16; i++){
               noteOnArray[i] = false;
               finishNote(i);
               displayNoteOnArray[i] = false;
           }
           heresyMinor = false;
           heresy7th = false;
           heresy9th = false;
           heresy11th = false;
           heresy13th = false;
           chordsTemp = new Track(tracks[trSelected].name, true,  tracks[trSelected].loopLength, tracks[trSelected].quantize, false, false);
           imgNotes = null;
        }
    }

     if (key == 'p' || key == 'P') {
         for (int i = 0; i < 16; i++){
              for (int ii = 24; ii < 109; ii++)
                outputToMax(ii, 0, trSelected);
             noteOnArray[i] = false;
             displayNoteOnArray[i] = false; 
         }
     }
     
     if (key == 'd' || key == 'D') {
         if (trSelected != 0 && trSelected != 1){
               tracks[trSelected].ducking = !tracks[trSelected].ducking;
               tracks[trSelected].cycled = false;
               tracks[trSelected].cycledPosition = currentPulse%tracks[trSelected].loopLength; 
         }
     }
    
     if (key == 'w' || key == 'W') {
       
        trSelected = 0;

        for (int i = 0; i < 16; i++){
            noteOnArray[i] = false;
            finishNoteCutOff(i);
            displayNoteOnArray[i] = false;
        }
        heresyMinor = false;
        heresy7th = false;
        heresy9th = false;
        heresy11th = false;
        heresy13th = false;
        
        tracks[trSelected] = new Track(tracks[trSelected].name, true,  tracks[trSelected].loopLength, tracks[trSelected].quantize, false, false);
        chordsTemp = new Track(tracks[trSelected].name, true,  tracks[trSelected].loopLength, tracks[trSelected].quantize, false, false);
        imgNotes = null;
    }
    
    if (key == 'q' || key == 'Q'){
        quantizeValueIn = true;
        sendToScreen(tracks[trSelected].name + " quantize?");
    }
    
    if (key == 'x' || key == 'X'){
        clickTrackOn = !clickTrackOn;
    }
    
    if (key == 'e' || key == 'E'){
        eraseOn = !eraseOn;
        if (!eraseOn) imgNotes = null;
    }
    
    if (key == 'r' || key == 'R'){
        imgNotes = null;
    }
    
    if (key == 'l' || key == 'L'){
        loopLengthValueIn = true;
        sendToScreen(tracks[trSelected].name + " loop length?");
    }
    
    if (key == 'm' || key == 'M'){
        if (trSelected != 0){
            muteValueIn = true;
            if (!tracks[trSelected].mute)
                sendToScreen(tracks[trSelected].name + " mute in?");
            if (tracks[trSelected].mute)
                sendToScreen(tracks[trSelected].name + " unmute in?");              
        }
    }

   
    if (key == '1') numberKey(1);
    if (key == '2') numberKey(2);
    if (key == '3') numberKey(3);
    if (key == '4') numberKey(4);
    if (key == '5') numberKey(5);
    if (key == '6') numberKey(6);
    if (key == '7') numberKey(7);
    if (key == '8') numberKey(8);       
    if (key == '9') numberKey(9);
    if (key == '0') numberKey(0);

    if (key == CODED) {
        if (keyCode == UP && trSelected < Track.currentNumberOfTracks-1)
            trSelected++;
        if (keyCode == DOWN && trSelected > 1) {
           trSelected--;
        } 
     }
     
     if (key == 's' || key == 'S'){
          for (int i = 0; i < 16; i++){
              for (int ii = 0; ii < tracks[0].loopLength; ii++){
                  if (chordsTemp.sequence[i][ii] != null)
                      tracks[0].sequence[i][ii] = chordsTemp.sequence[i][ii];
              }
          }
     }
     
 
}


//------------------------------------------------------------------------------------------------------------------------------- 

public void numberKey(int input){ // if a number is enterd, this method works out what to do with it
    if (quantizeValueIn == true)
        if (input == 1 || input == 2 || input == 4 || input == 8 || input == 0){
             tracks[trSelected].quantize = input;
             quantizeValueIn = false;
             aniOut = true;
        }
         
    if (loopLengthValueIn == true){
        if (input >= 1 && input <= 8 ){
            Track tempTrack = new Track(tracks[trSelected].name, tracks[trSelected].polyphonic, (input * loopLength / 2), tracks[trSelected].quantize, false, false);
            NoteEvent tempNote;
            
            for (int i = 0; i < 16; i++){
                if (tempTrack.loopLength >= tracks[trSelected].loopLength){
                    for (int ii = 0; ii < tracks[trSelected].loopLength; ii++){
                        tempTrack.sequence[i][ii] = tracks[trSelected].sequence[i][ii];
                    }
                }else{
                    for (int ii = 0; ii < tempTrack.loopLength; ii++){
                        tempTrack.sequence[i][ii] = tracks[trSelected].sequence[i][ii];
                    }
                }
            }
            tracks[trSelected] = tempTrack;
            for (int i = 0; i < 16; i++)
            if (noteOnArray[i] = true){
                noteOnArray[i] = false;
                finishNoteCutOff(i);
                displayNoteOnArray[i] = false;
            }
  
             
            loopLengthValueIn = false;
            aniOut = true;
            if (trSelected ==0){
                Track tempTrack2 = new Track(chordsTemp.name, chordsTemp.polyphonic, (input * loopLength / 2), chordsTemp.quantize, false, false);
                NoteEvent tempNote2;
            
                for (int i = 0; i < 16; i++){
                    if (tempTrack2.loopLength >= chordsTemp.loopLength){
                        for (int ii = 0; ii < chordsTemp.loopLength; ii++){
                            tempTrack2.sequence[i][ii] = chordsTemp.sequence[i][ii];
                        }
                    }else{
                        for (int ii = 0; ii < tempTrack2.loopLength; ii++){
                            tempTrack2.sequence[i][ii] = chordsTemp.sequence[i][ii];
                        }
                    }  
                }
            chordsTemp = tempTrack2;
            }
            imgNotes = null;
        }
    }
    
    if (muteValueIn == true){
        tracks[trSelected].muteIn = bar + input;
        muteValueIn = false;
        tracks[trSelected].muteDone = false;
        aniOut = true;
    }
        
         
}


//------------------------------------------------------------------------------------------------------------------------------- 

public void sendToScreen(String name){ // prepares a question for asking the user and turns the question on

      screenQuestion = name;
      screenAni = 0;
      haveQuestion = true;
    
}


//------------------------------------------------------------------------------------------------------------------------------- 

public void checkCycled(){  // checks whether after ducking or muting all note offs are played.
    for (int i = 1; i < Track.currentNumberOfTracks; i++)
        if (tracks[i].cycled == false)
            if (tracks[i].cycledPosition-1 == currentPulse%tracks[trSelected].loopLength)
                tracks[i].cycled = true;
    
}


//------------------------------------------------------------------------------------------------------------------------------- 


public void checkForMutes(){ // looks for mute / unmuted changes in tracks
    for (int i = 1; i < Track.currentNumberOfTracks; i++)
        if (tracks[i].muteIn == bar && !tracks[i].muteDone){
            tracks[i].mute = !tracks[i].mute;
            tracks[i].muteDone = true;
            tracks[trSelected].cycled = false;
            tracks[trSelected].cycledPosition = currentPulse%tracks[trSelected].loopLength; 
        }
}



//------------------------------------------------------------------------------------------------------------------------------- 

public void writeQuestion(){ // animates screen questions
  
  if (screenAni < 10 && !aniOut){
      screenAni++;
  }
  
  if (screenAni > 0 && aniOut){
     screenAni--;
  }
  
   if (screenAni == 0){
      haveQuestion = false;
      aniOut = false;
   }
  
  fill(255,0,0, screenAni*12);
  textSize((11-screenAni)*40);
  text(screenQuestion, (screenAni*50)-200,(100-screenAni*10)+150);
  
    
}


//------------------------------------------------------------------------------------------------------------------------------- 

public void oscEvent(OscMessage theOscMessage) { // recieves osc messages from openFrameworks
    println("osc message : " + theOscMessage);
    if(theOscMessage.checkAddrPattern("/test")==true) {
        println("i1 : " + theOscMessage.get(1).intValue() + "  i2 : " + theOscMessage.get(2).intValue() + "  i3 : " + theOscMessage.get(3).intValue() + "  i4 : " + theOscMessage.get(4).intValue());
        clickTrack = false;
        String stringValue = theOscMessage.get(0).stringValue();
        int firstValue = theOscMessage.get(1).intValue(); 
        int secondValue = theOscMessage.get(2).intValue();
        int thirdValue = theOscMessage.get(3).intValue(); //velocity
        int fourthValue = theOscMessage.get(4).intValue(); //channel
        if (secondValue == 1){
            noteOnArray[firstValue] = true;
            writeNote(firstValue, thirdValue, fourthValue);       
        }
        else{
            noteOnArray[firstValue] = false;
            writeNote(firstValue, 0, fourthValue); 
        }
    }
    if(theOscMessage.checkAddrPattern("/chord")==true) {
        chordCalc();
  //      writeNote(15, 80, 6);
        writeNote(14, 80, 6);
        writeNote(13, 80, 6);
        writeNote(12, 80, 6);
        writeNote(11, 80, 6);
        writeNote(10, 80, 6);
        writeNote(9, 80, 6);
    }
}



class VPArray{ // the virtual playing array for Heresy AI to play with
  
    VPNote[] VPArrayNotes;
    
    public VPArray(){
        VPArrayNotes = new VPNote[16];
        for (int i = 0; i < 16; i++)
          VPArrayNotes[i] = new VPNote();
    }
}

class VPNote{
  
    boolean played;
    boolean VPNoteOn;
    boolean done;
    int extension;
    int VPNotePitch;
    int VPNoteVelocity;
    
    public VPNote(){
       VPNoteOn = false;
       played = true;
        extension = 0;
        VPNotePitch = 0;
        VPNoteVelocity = 0;
    }
}

 
    

public void chordCalc(){
    barCounter++;
    if (barCounter % 4 == 0 || ((currentChord == 1 || currentChord == 5 || currentChord == 7) && barCounter % 4 == 3)){
        tonicNeeded = true;
        print(" tonic needed " + (barCounter % 4));
     }
     else tonicNeeded = false;
     chooseChord();
}

public void chooseChord(){

    int i = 0;
    for (; i < crneeded; i++){
        if (chordChoicesArray[i].chordNote == currentChord && chordChoicesArray[i].minor == heresyMinor)
            break;
    }
    if (currentChord == 1 && heresyDom)
        i = 16;
    if (tonicNeeded && i != 24){
        int gotOne = -1;
        int gotTwo = -1;
        if (chordChoicesArray[i].optionArray[0].chordOption == 0 && chordChoicesArray[i].optionArray[1].chordOption == 0 && PApplet.parseInt(random(2)) == 0)
            chosenChord (i, chordChoicesArray[i].optionArray[1].chordOption);
        else if 
            (chordChoicesArray[i].optionArray[0].chordOption == 0 && chordChoicesArray[i].optionArray[1].chordOption != 0)
            chosenChord (i, chordChoicesArray[i].optionArray[0].chordOption);
        else
            chosenChord (i, PApplet.parseInt(random(chordChoicesArray[i].slots)));
    }
    else if (i != 24){
        chosenChord(i, PApplet.parseInt(random(chordChoicesArray[i].slots))); 
    }else{
        currentChord = lastChordChange;
        heresyMinor = lastMinor;
    }
    println("   chord selected : " + currentChord + " minor:" + heresyMinor);
}

public void chosenChord(int p, int p2){
    lastChordChange = currentChord;
    lastMinor = heresyMinor;
 //   println("p: " + p + "  p2 : " + p2);
    currentChord = chordChoicesArray[p].optionArray[p2].chordOption;
    heresyMinor = chordChoicesArray[p].optionArray[p2].minor;
    if (PApplet.parseInt(random(4)) == 0)
        heresy7th = true;
    else
        heresy7th = false;
    if (PApplet.parseInt(random(4)) == 0)
        heresy9th = true;
    else
        heresy9th = false;       
    if (PApplet.parseInt(random(4)) == 0)
        heresy11th = true;
    else
        heresy11th = false;


}   



class chordChoices{
    int chordNote;
    boolean minor;
    ChordChoice[] optionArray;
    int slots;
    
    public chordChoices(int chordNote, boolean minor, int slotsNeeded){
        this.chordNote = chordNote;
        this.minor = minor;
        optionArray = new ChordChoice[slotsNeeded];
        slots = slotsNeeded;
    }
}

class ChordChoice{
    int chordOption;
    boolean minor, h7th, h9th, h11th, h13th, dom;
    
    public ChordChoice(int chordOption, boolean minor, boolean dom, boolean h7th, boolean h9th, boolean h11th, boolean h13th){
        this.chordOption = chordOption;
        this.minor = minor;
        this.dom = dom;
        this.h7th = h7th;
        this.h9th = h9th;
        this.h11th = h11th;
        this.h13th = h13th;       
    }
}

//void stuff(){
chordChoices[] chordChoicesArray = new chordChoices[crneeded];

public void markovStuff(){
chordChoicesArray[0] = new chordChoices(0, false, 13);
chordChoicesArray[0].optionArray[0] = new ChordChoice(2, true, false, true, true, true, true);
chordChoicesArray[0].optionArray[1] = new ChordChoice(3, false, false, true, true, true, true);
chordChoicesArray[0].optionArray[2] = new ChordChoice(4, true, false, true, true, true, true);
chordChoicesArray[0].optionArray[3] = new ChordChoice(5, true, false, true, true, true, true);
chordChoicesArray[0].optionArray[4] = new ChordChoice(5, false, false, true, true, true, true);
chordChoicesArray[0].optionArray[5] = new ChordChoice(7, true, false, true, true, true, true);
chordChoicesArray[0].optionArray[6] = new ChordChoice(7, false, false, true, true, true, true);
chordChoicesArray[0].optionArray[7] = new ChordChoice(8, true, false, true, true, true, true);
chordChoicesArray[0].optionArray[8] = new ChordChoice(8, false, false, true, true, true, true);
chordChoicesArray[0].optionArray[9] = new ChordChoice(9, true, false, true, true, true, true);
chordChoicesArray[0].optionArray[10] = new ChordChoice(9, false, false, true, true, true, true);
chordChoicesArray[0].optionArray[11] = new ChordChoice(10, false, true, true, true, true, true);
chordChoicesArray[0].optionArray[12] = new ChordChoice(10, true, false, true, true, true, true);

chordChoicesArray[1] = new chordChoices(0, true, 14);
chordChoicesArray[1].optionArray[0] = new ChordChoice(1, false, true, true, true, true, true);
chordChoicesArray[1].optionArray[1] = new ChordChoice(3, false, false, true, true, true, true);
chordChoicesArray[1].optionArray[2] = new ChordChoice(3, true, false, true, true, true, true);
chordChoicesArray[1].optionArray[3] = new ChordChoice(4, true, false, true, true, true, true);
chordChoicesArray[1].optionArray[4] = new ChordChoice(5, false, false, true, true, true, true);
chordChoicesArray[1].optionArray[5] = new ChordChoice(5, true, false, true, true, true, true);
chordChoicesArray[1].optionArray[6] = new ChordChoice(6, true, false, true, true, true, true);
chordChoicesArray[1].optionArray[7] = new ChordChoice(7, false, false, true, true, true, true);
chordChoicesArray[1].optionArray[8] = new ChordChoice(7, true, false, true, true, true, true);
chordChoicesArray[1].optionArray[9] = new ChordChoice(8, false, false, true, true, true, true);
chordChoicesArray[1].optionArray[10] = new ChordChoice(8, true, false, true, true, true, true);
chordChoicesArray[1].optionArray[11] = new ChordChoice(10, false, false, true, true, true, true);
chordChoicesArray[1].optionArray[12] = new ChordChoice(11, true, false, true, true, true, true);
chordChoicesArray[1].optionArray[13] = new ChordChoice(11, false, false, true, true, true, true);

chordChoicesArray[2] = new chordChoices(2, false, 9);
chordChoicesArray[2].optionArray[0] = new ChordChoice(1, false, true, true, true, true, true);
chordChoicesArray[2].optionArray[1] = new ChordChoice(2, true, false, true, true, true, true);
chordChoicesArray[2].optionArray[2] = new ChordChoice(5, false, false, true, true, true, true);
chordChoicesArray[2].optionArray[3] = new ChordChoice(5, true, false, true, true, true, true);
chordChoicesArray[2].optionArray[4] = new ChordChoice(7, false, false, true, true, true, true);
chordChoicesArray[2].optionArray[5] = new ChordChoice(8, false, false, true, true, true, true);
chordChoicesArray[2].optionArray[6] = new ChordChoice(9, false, false, true, true, true, true);
chordChoicesArray[2].optionArray[7] = new ChordChoice(9, true, false, true, true, true, true);
chordChoicesArray[2].optionArray[8] = new ChordChoice(10, false, false, true, true, true, true);

chordChoicesArray[3] = new chordChoices(2, true, 13);
chordChoicesArray[3].optionArray[0] = new ChordChoice(0, false, false, true, true, true, true);
chordChoicesArray[3].optionArray[1] = new ChordChoice(1, false, true, true, true, true, true);
chordChoicesArray[3].optionArray[2] = new ChordChoice(3, true, false, true, true, true, true);
chordChoicesArray[3].optionArray[3] = new ChordChoice(3, false, false, true, true, true, true);
chordChoicesArray[3].optionArray[4] = new ChordChoice(4, true, false, true, true, true, true);
chordChoicesArray[3].optionArray[5] = new ChordChoice(5, true, false, true, true, true, true);
chordChoicesArray[3].optionArray[6] = new ChordChoice(5, false, false, true, true, true, true);
chordChoicesArray[3].optionArray[7] = new ChordChoice(7, false, false, true, true, true, true);
chordChoicesArray[3].optionArray[8] = new ChordChoice(7, true, false, true, true, true, true);
chordChoicesArray[3].optionArray[9] = new ChordChoice(8, false, false, true, true, true, true);
chordChoicesArray[3].optionArray[10] = new ChordChoice(9, true, false, true, true, true, true);
chordChoicesArray[3].optionArray[11] = new ChordChoice(10, false, false, true, true, true, true);
chordChoicesArray[3].optionArray[12] = new ChordChoice(10, true, false, true, true, true, true);

chordChoicesArray[4] = new chordChoices(4, false, 4);
chordChoicesArray[4].optionArray[0] = new ChordChoice(5, true, false, true, true, true, true);
chordChoicesArray[4].optionArray[1] = new ChordChoice(9, false, false, true, true, true, true);
chordChoicesArray[4].optionArray[2] = new ChordChoice(9, true, false, true, true, true, true);
chordChoicesArray[4].optionArray[3] = new ChordChoice(11, true, false, true, true, true, true);

chordChoicesArray[5] = new chordChoices(4, true, 13);
chordChoicesArray[5].optionArray[0] = new ChordChoice(0, false, false, true, true, true, true);
chordChoicesArray[5].optionArray[1] = new ChordChoice(0, true, false, true, true, true, true);
chordChoicesArray[5].optionArray[2] = new ChordChoice(1, false, true, true, true, true, true);
chordChoicesArray[5].optionArray[3] = new ChordChoice(2, true, false, true, true, true, true);
chordChoicesArray[5].optionArray[4] = new ChordChoice(3, false, false, true, true, true, true);
chordChoicesArray[5].optionArray[5] = new ChordChoice(3, true, false, true, true, true, true);
chordChoicesArray[5].optionArray[6] = new ChordChoice(5, false, false, true, true, true, true);
chordChoicesArray[5].optionArray[7] = new ChordChoice(5, true, false, true, true, true, true);
chordChoicesArray[5].optionArray[8] = new ChordChoice(8, true, false, true, true, true, true);
chordChoicesArray[5].optionArray[9] = new ChordChoice(8, false, false, true, true, true, true);
chordChoicesArray[5].optionArray[10] = new ChordChoice(9, true, false, true, true, true, true);
chordChoicesArray[5].optionArray[11] = new ChordChoice(11, false, false, true, true, true, true);
chordChoicesArray[5].optionArray[12] = new ChordChoice(11, true, false, true, true, true, true);

chordChoicesArray[6] = new chordChoices(5, false, 14);
chordChoicesArray[6].optionArray[0] = new ChordChoice(0, false, false, true, true, true, true);
chordChoicesArray[6].optionArray[1] = new ChordChoice(0, true, false, true, true, true, true);
chordChoicesArray[6].optionArray[2] = new ChordChoice(2, true, false, true, true, true, true);
chordChoicesArray[6].optionArray[3] = new ChordChoice(4, true, false, true, true, true, true);
chordChoicesArray[6].optionArray[4] = new ChordChoice(4, false, false, true, true, true, true);
chordChoicesArray[6].optionArray[5] = new ChordChoice(5, true, false, true, true, true, true);
chordChoicesArray[6].optionArray[6] = new ChordChoice(6, true, false, true, true, true, true);
chordChoicesArray[6].optionArray[7] = new ChordChoice(7, false, false, true, true, true, true);
chordChoicesArray[6].optionArray[8] = new ChordChoice(8, true, false, true, true, true, true);
chordChoicesArray[6].optionArray[9] = new ChordChoice(8, false, false, true, true, true, true);
chordChoicesArray[6].optionArray[10] = new ChordChoice(9, true, false, true, true, true, true);
chordChoicesArray[6].optionArray[11] = new ChordChoice(9, false, false, true, true, true, true);
chordChoicesArray[6].optionArray[12] = new ChordChoice(10, true, false, true, true, true, true);
chordChoicesArray[6].optionArray[13] = new ChordChoice(10, false, false, true, true, true, true);

chordChoicesArray[7] = new chordChoices(5, true, 15);
chordChoicesArray[7].optionArray[0] = new ChordChoice(0, false, false, true, true, true, true);
chordChoicesArray[7].optionArray[1] = new ChordChoice(0, true, false, true, true, true, true);
chordChoicesArray[7].optionArray[2] = new ChordChoice(1, false, true, true, true, true, true);
chordChoicesArray[7].optionArray[3] = new ChordChoice(2, true, false, true, true, true, true);
chordChoicesArray[7].optionArray[4] = new ChordChoice(2, false, false, true, true, true, true);
chordChoicesArray[7].optionArray[5] = new ChordChoice(3, false, false, true, true, true, true);
chordChoicesArray[7].optionArray[6] = new ChordChoice(4, false, false, true, true, true, true);
chordChoicesArray[7].optionArray[7] = new ChordChoice(6, true, false, true, true, true, true);
chordChoicesArray[7].optionArray[8] = new ChordChoice(7, true, false, true, true, true, true);
chordChoicesArray[7].optionArray[9] = new ChordChoice(7, false, false, true, true, true, true);
chordChoicesArray[7].optionArray[10] = new ChordChoice(8, true, false, true, true, true, true);
chordChoicesArray[7].optionArray[11] = new ChordChoice(8, false, false, true, true, true, true);
chordChoicesArray[7].optionArray[12] = new ChordChoice(10, false, false, true, true, true, true);
chordChoicesArray[7].optionArray[13] = new ChordChoice(11, false, false, true, true, true, true);
chordChoicesArray[7].optionArray[14] = new ChordChoice(11, true, false, true, true, true, true);

chordChoicesArray[8] = new chordChoices(7, true, 14);
chordChoicesArray[8].optionArray[0] = new ChordChoice(0, false, false, true, true, true, true);
chordChoicesArray[8].optionArray[1] = new ChordChoice(0, true, false, true, true, true, true);
chordChoicesArray[8].optionArray[2] = new ChordChoice(1, false, true, true, true, true, true);
chordChoicesArray[8].optionArray[3] = new ChordChoice(2, false, false, true, true, true, true);
chordChoicesArray[8].optionArray[4] = new ChordChoice(2, true, false, true, true, true, true);
chordChoicesArray[8].optionArray[5] = new ChordChoice(3, false, false, true, true, true, true);
chordChoicesArray[8].optionArray[6] = new ChordChoice(3, true, false, true, true, true, true);
chordChoicesArray[8].optionArray[7] = new ChordChoice(5, false, false, true, true, true, true);
chordChoicesArray[8].optionArray[8] = new ChordChoice(5, true, false, true, true, true, true);
chordChoicesArray[8].optionArray[9] = new ChordChoice(6, false, false, true, true, true, true);
chordChoicesArray[8].optionArray[10] = new ChordChoice(8, true, false, true, true, true, true);
chordChoicesArray[8].optionArray[11] = new ChordChoice(8, false, false, true, true, true, true);
chordChoicesArray[8].optionArray[12] = new ChordChoice(10, false, false, true, true, true, true);
chordChoicesArray[8].optionArray[13] = new ChordChoice(10, true, false, true, true, true, true);

chordChoicesArray[9] = new chordChoices(7, false, 10);
chordChoicesArray[9].optionArray[0] = new ChordChoice(0, false, false, true, true, true, true);
chordChoicesArray[9].optionArray[1] = new ChordChoice(0, true, false, true, true, true, true);
chordChoicesArray[9].optionArray[2] = new ChordChoice(2, false, false, true, true, true, true);
chordChoicesArray[9].optionArray[3] = new ChordChoice(2, true, false, true, true, true, true);
chordChoicesArray[9].optionArray[4] = new ChordChoice(4, true, false, true, true, true, true);
chordChoicesArray[9].optionArray[5] = new ChordChoice(5, false, false, true, true, true, true);
chordChoicesArray[9].optionArray[6] = new ChordChoice(5, true, false, true, true, true, true);
chordChoicesArray[9].optionArray[7] = new ChordChoice(8, false, false, true, true, true, true);
chordChoicesArray[9].optionArray[8] = new ChordChoice(8, true, false, true, true, true, true);
chordChoicesArray[9].optionArray[9] = new ChordChoice(9, true, false, true, true, true, true);

chordChoicesArray[10] = new chordChoices(9, true, 13);
chordChoicesArray[10].optionArray[0] = new ChordChoice(0, false, false, true, true, true, true);
chordChoicesArray[10].optionArray[1] = new ChordChoice(0, true, false, true, true, true, true);
chordChoicesArray[10].optionArray[2] = new ChordChoice(1, false, true, true, true, true, true);
chordChoicesArray[10].optionArray[3] = new ChordChoice(2, true, false, true, true, true, true);
chordChoicesArray[10].optionArray[4] = new ChordChoice(2, false, false, true, true, true, true);
chordChoicesArray[10].optionArray[5] = new ChordChoice(3, false, false, true, true, true, true);
chordChoicesArray[10].optionArray[6] = new ChordChoice(4, true, false, true, true, true, true);
chordChoicesArray[10].optionArray[7] = new ChordChoice(5, false, false, true, true, true, true);
chordChoicesArray[10].optionArray[8] = new ChordChoice(5, true, false, true, true, true, true);
chordChoicesArray[10].optionArray[9] = new ChordChoice(7, true, false, true, true, true, true);
chordChoicesArray[10].optionArray[10] = new ChordChoice(7, false, false, true, true, true, true);
chordChoicesArray[10].optionArray[11] = new ChordChoice(8, false, false, true, true, true, true);
chordChoicesArray[10].optionArray[12] = new ChordChoice(10, false, false, true, true, true, true);

chordChoicesArray[11] = new chordChoices(11, false, 6);
chordChoicesArray[11].optionArray[0] = new ChordChoice(0, true, false, true, true, true, true);
chordChoicesArray[11].optionArray[1] = new ChordChoice(1, false, true, true, true, true, true);
chordChoicesArray[11].optionArray[2] = new ChordChoice(1, true, false, true, true, true, true);
chordChoicesArray[11].optionArray[3] = new ChordChoice(1, false, false, true, true, true, true);
chordChoicesArray[11].optionArray[4] = new ChordChoice(7, false, false, true, true, true, true);
chordChoicesArray[11].optionArray[5] = new ChordChoice(7, true, false, true, true, true, true);

chordChoicesArray[12] = new chordChoices(11, true, 5);
chordChoicesArray[12].optionArray[0] = new ChordChoice(1, false, true, true, true, true, true);
chordChoicesArray[12].optionArray[1] = new ChordChoice(2, true, false, true, true, true, true);
chordChoicesArray[12].optionArray[2] = new ChordChoice(5, false, true, true, true, true, true);
chordChoicesArray[12].optionArray[3] = new ChordChoice(5, true, false, true, true, true, true);
chordChoicesArray[12].optionArray[4] = new ChordChoice(8, false, false, true, true, true, true);

chordChoicesArray[13] = new chordChoices(1, false, 2);
chordChoicesArray[13].optionArray[0] = new ChordChoice(0, false, false, true, true, true, true);
chordChoicesArray[13].optionArray[1] = new ChordChoice(0, true, false, true, true, true, true);

chordChoicesArray[14] = new chordChoices(1, true, 2);
chordChoicesArray[14].optionArray[0] = new ChordChoice(0, true, false, true, true, true, true);
chordChoicesArray[14].optionArray[1] = new ChordChoice(0, true, false, true, true, true, true);

chordChoicesArray[15] = new chordChoices(3, false, 12);
chordChoicesArray[15].optionArray[0] = new ChordChoice(0, false, false, true, true, true, true);
chordChoicesArray[15].optionArray[1] = new ChordChoice(0, true, false, true, true, true, true);
chordChoicesArray[15].optionArray[2] = new ChordChoice(1, false, true, true, true, true, true);
chordChoicesArray[15].optionArray[3] = new ChordChoice(5, false, false, true, true, true, true);
chordChoicesArray[15].optionArray[4] = new ChordChoice(7, false, false, true, true, true, true);
chordChoicesArray[15].optionArray[5] = new ChordChoice(7, true, false, true, true, true, true);
chordChoicesArray[15].optionArray[6] = new ChordChoice(8, true, false, true, true, true, true);
chordChoicesArray[15].optionArray[7] = new ChordChoice(8, false, false, true, true, true, true);
chordChoicesArray[15].optionArray[8] = new ChordChoice(10, true, false, true, true, true, true);
chordChoicesArray[15].optionArray[9] = new ChordChoice(10, false, false, true, true, true, true);
chordChoicesArray[15].optionArray[10] = new ChordChoice(11, false, false, true, true, true, true);
chordChoicesArray[15].optionArray[11] = new ChordChoice(11, true, false, true, true, true, true);

chordChoicesArray[16] = new chordChoices(111, false, 2);
chordChoicesArray[16].optionArray[0] = new ChordChoice(0, false, false, true, true, true, true);
chordChoicesArray[16].optionArray[1] = new ChordChoice(0, true, false, true, true, true, true);

chordChoicesArray[17] = new chordChoices(6, false, 10);
chordChoicesArray[17].optionArray[0] = new ChordChoice(1, false, false, true, true, true, true);
chordChoicesArray[17].optionArray[1] = new ChordChoice(1, true, false, true, true, true, true);
chordChoicesArray[17].optionArray[2] = new ChordChoice(2, false, false, true, true, true, true);
chordChoicesArray[17].optionArray[3] = new ChordChoice(3, false, false, true, true, true, true);
chordChoicesArray[17].optionArray[4] = new ChordChoice(3, true, false, true, true, true, true);
chordChoicesArray[17].optionArray[5] = new ChordChoice(8, false, false, true, true, true, true);
chordChoicesArray[17].optionArray[6] = new ChordChoice(9, false, false, true, true, true, true);
chordChoicesArray[17].optionArray[7] = new ChordChoice(9, true, false, true, true, true, true);
chordChoicesArray[17].optionArray[8] = new ChordChoice(10, true, false, true, true, true, true);
chordChoicesArray[17].optionArray[9] = new ChordChoice(10, false, false, true, true, true, true);

chordChoicesArray[18] = new chordChoices(8, false, 17);
chordChoicesArray[18].optionArray[0] = new ChordChoice(0, false, false, true, true, true, true);
chordChoicesArray[18].optionArray[1] = new ChordChoice(0, true, false, true, true, true, true);
chordChoicesArray[18].optionArray[2] = new ChordChoice(1, false, true, true, true, true, true);
chordChoicesArray[18].optionArray[3] = new ChordChoice(1, true, false, true, true, true, true);
chordChoicesArray[18].optionArray[4] = new ChordChoice(1, false, false, true, true, true, true);
chordChoicesArray[18].optionArray[5] = new ChordChoice(3, false, false, true, true, true, true);
chordChoicesArray[18].optionArray[6] = new ChordChoice(3, true, false, true, true, true, true);
chordChoicesArray[18].optionArray[7] = new ChordChoice(4, false, false, true, true, true, true);
chordChoicesArray[18].optionArray[8] = new ChordChoice(4, true, false, true, true, true, true);
chordChoicesArray[18].optionArray[9] = new ChordChoice(5, true, false, true, true, true, true);
chordChoicesArray[18].optionArray[10] = new ChordChoice(5, false, false, true, true, true, true);
chordChoicesArray[18].optionArray[11] = new ChordChoice(7, false, false, true, true, true, true);
chordChoicesArray[18].optionArray[12] = new ChordChoice(7, true, false, true, true, true, true);
chordChoicesArray[18].optionArray[13] = new ChordChoice(9, true, false, true, true, true, true);
chordChoicesArray[18].optionArray[14] = new ChordChoice(10, false, false, true, true, true, true);
chordChoicesArray[18].optionArray[15] = new ChordChoice(11, false, false, true, true, true, true);
chordChoicesArray[18].optionArray[16] = new ChordChoice(11, true, false, true, true, true, true);

chordChoicesArray[19] = new chordChoices(8, true, 10);
chordChoicesArray[19].optionArray[0] = new ChordChoice(0, false, false, true, true, true, true);
chordChoicesArray[19].optionArray[1] = new ChordChoice(0, true, false, true, true, true, true);
chordChoicesArray[19].optionArray[2] = new ChordChoice(1, false, true, true, true, true, true);
chordChoicesArray[19].optionArray[3] = new ChordChoice(1, false, false, true, true, true, true);
chordChoicesArray[19].optionArray[4] = new ChordChoice(3, false, false, true, true, true, true);
chordChoicesArray[19].optionArray[5] = new ChordChoice(3, true, false, true, true, true, true);
chordChoicesArray[19].optionArray[6] = new ChordChoice(4, false, false, true, true, true, true);
chordChoicesArray[19].optionArray[7] = new ChordChoice(4, true, false, true, true, true, true);
chordChoicesArray[19].optionArray[8] = new ChordChoice(5, true, false, true, true, true, true);
chordChoicesArray[19].optionArray[9] = new ChordChoice(5, false, false, true, true, true, true);

chordChoicesArray[20] = new chordChoices(3, true, 19);
chordChoicesArray[20].optionArray[0] = new ChordChoice(0, false, false, true, true, true, true);
chordChoicesArray[20].optionArray[1] = new ChordChoice(0, true, false, true, true, true, true);
chordChoicesArray[20].optionArray[2] = new ChordChoice(1, false, true, true, true, true, true);
chordChoicesArray[20].optionArray[3] = new ChordChoice(2, false, false, true, true, true, true);
chordChoicesArray[20].optionArray[4] = new ChordChoice(4, false, false, true, true, true, true);
chordChoicesArray[20].optionArray[5] = new ChordChoice(4, true, false, true, true, true, true);
chordChoicesArray[20].optionArray[6] = new ChordChoice(5, true, false, true, true, true, true);
chordChoicesArray[20].optionArray[7] = new ChordChoice(5, false, false, true, true, true, true);
chordChoicesArray[20].optionArray[8] = new ChordChoice(6, true, false, true, true, true, true);
chordChoicesArray[20].optionArray[9] = new ChordChoice(6, false, false, true, true, true, true);
chordChoicesArray[20].optionArray[10] = new ChordChoice(7, true, false, true, true, true, true);
chordChoicesArray[20].optionArray[11] = new ChordChoice(8, false, false, true, true, true, true);
chordChoicesArray[20].optionArray[12] = new ChordChoice(8, true, false, true, true, true, true);
chordChoicesArray[20].optionArray[13] = new ChordChoice(9, true, false, true, true, true, true);
chordChoicesArray[20].optionArray[14] = new ChordChoice(9, false, false, true, true, true, true);
chordChoicesArray[20].optionArray[15] = new ChordChoice(10, false, false, true, true, true, true);
chordChoicesArray[20].optionArray[16] = new ChordChoice(10, true, false, true, true, true, true);
chordChoicesArray[20].optionArray[17] = new ChordChoice(11, false, false, true, true, true, true);
chordChoicesArray[20].optionArray[18] = new ChordChoice(11, true, false, true, true, true, true);

chordChoicesArray[21] = new chordChoices(6, true, 9);
chordChoicesArray[21].optionArray[0] = new ChordChoice(1, false, false, true, true, true, true);
chordChoicesArray[21].optionArray[1] = new ChordChoice(1, true, false, true, true, true, true);
chordChoicesArray[21].optionArray[2] = new ChordChoice(2, false, false, true, true, true, true);
chordChoicesArray[21].optionArray[3] = new ChordChoice(3, false, false, true, true, true, true);
chordChoicesArray[21].optionArray[4] = new ChordChoice(3, true, false, true, true, true, true);
chordChoicesArray[21].optionArray[5] = new ChordChoice(4, false, false, true, true, true, true);
chordChoicesArray[21].optionArray[6] = new ChordChoice(5, false, false, true, true, true, true);
chordChoicesArray[21].optionArray[7] = new ChordChoice(8, false, false, true, true, true, true);
chordChoicesArray[21].optionArray[8] = new ChordChoice(11, true, false, true, true, true, true);

chordChoicesArray[22] = new chordChoices(10, false, 13);
chordChoicesArray[22].optionArray[0] = new ChordChoice(0, false, false, true, true, true, true);
chordChoicesArray[22].optionArray[1] = new ChordChoice(0, true, false, true, true, true, true);
chordChoicesArray[22].optionArray[2] = new ChordChoice(1, false, true, true, true, true, true);
chordChoicesArray[22].optionArray[3] = new ChordChoice(3, false, false, true, true, true, true);
chordChoicesArray[22].optionArray[4] = new ChordChoice(3, true, false, true, true, true, true);
chordChoicesArray[22].optionArray[5] = new ChordChoice(5, true, false, true, true, true, true);
chordChoicesArray[22].optionArray[6] = new ChordChoice(5, false, false, true, true, true, true);
chordChoicesArray[22].optionArray[7] = new ChordChoice(6, false, false, true, true, true, true);
chordChoicesArray[22].optionArray[8] = new ChordChoice(7, true, false, true, true, true, true);
chordChoicesArray[22].optionArray[9] = new ChordChoice(7, false, false, true, true, true, true);
chordChoicesArray[22].optionArray[10] = new ChordChoice(8, true, false, true, true, true, true);
chordChoicesArray[22].optionArray[11] = new ChordChoice(8, false, false, true, true, true, true);
chordChoicesArray[22].optionArray[12] = new ChordChoice(11, true, false, true, true, true, true);

chordChoicesArray[23] = new chordChoices(10, true, 12);
chordChoicesArray[23].optionArray[0] = new ChordChoice(0, false, false, true, true, true, true);
chordChoicesArray[23].optionArray[1] = new ChordChoice(1, false, true, true, true, true, true);
chordChoicesArray[23].optionArray[2] = new ChordChoice(3, false, false, true, true, true, true);
chordChoicesArray[23].optionArray[3] = new ChordChoice(3, true, false, true, true, true, true);
chordChoicesArray[23].optionArray[4] = new ChordChoice(5, false, false, true, true, true, true);
chordChoicesArray[23].optionArray[5] = new ChordChoice(6, true, false, true, true, true, true);
chordChoicesArray[23].optionArray[6] = new ChordChoice(6, false, false, true, true, true, true);
chordChoicesArray[23].optionArray[7] = new ChordChoice(7, false, false, true, true, true, true);
chordChoicesArray[23].optionArray[8] = new ChordChoice(7, true, false, true, true, true, true);
chordChoicesArray[23].optionArray[9] = new ChordChoice(9, false, false, true, true, true, true);
chordChoicesArray[23].optionArray[10] = new ChordChoice(9, true, false, true, true, true, true);
chordChoicesArray[23].optionArray[11] = new ChordChoice(11, true, false, true, true, true, true);


}
public void loadSequences(){
  
    ArrayList<NoteEvent> sequenceBass = new ArrayList<NoteEvent>();
    sequenceBass.add(new NoteEvent(15, 2,   1,  1,  1,  1,    0,  3,  3,  0));
 // sequenceBass.add(new NoteEvent(15, 2,   1,  1,  2,  1,    0,  0,  0,  5));
 // sequenceBass.add(new NoteEvent(15, 2,   1,  2,  3,  1,    0,  0,  0,  5));
 // sequenceBass.add(new NoteEvent(15, 2,   1,  2,  4,  1,    0,  0,  0,  5));
 // sequenceBass.add(new NoteEvent(15, 2,   1,  3,  2,  1,    0,  0,  0,  5));
 // sequenceBass.add(new NoteEvent(15, 2,   1,  3,  3,  1,    0,  0,  0,  5));
 // sequenceBass.add(new NoteEvent(15, 2,   1,  4,  1,  1,    0,  0,  0,  5));
 // sequenceBass.add(new NoteEvent(15, 2,   1,  4,  2,  1,    0,  0,  0,  5));
    seedSequencer(sequenceBass, 2);
    
    ArrayList<NoteEvent> sequencePizz = new ArrayList<NoteEvent>();
    sequencePizz.add(new NoteEvent(13, 2,   1,  1,  3,  1,    0,  0,  1,  0));
    sequencePizz.add(new NoteEvent(12, 2,   1,  1,  3,  1,    0,  0,  1,  0));
    sequencePizz.add(new NoteEvent(11, 2,   1,  1,  3,  1,    0,  0,  1,  0));
    sequencePizz.add(new NoteEvent(10, 2,   1,  1,  3,  1,    0,  0,  1,  0));
    sequencePizz.add(new NoteEvent(9,  2,   1,  1,  3,  1,    0,  0,  1,  0));
//  sequencePizz.add(new NoteEvent(8,  2,   1,  1,  3,  1,    0,  0,  1,  0));
//  sequencePizz.add(new NoteEvent(7,  2,   1,  1,  3,  1,    0,  0,  1,  0));
//  sequencePizz.add(new NoteEvent(6,  2,   1,  1,  3,  1,    0,  0,  1,  0));
    sequencePizz.add(new NoteEvent(0,  2,   1,  2,  3,  1,    0,  0,  1,  0));
    sequencePizz.add(new NoteEvent(1,  2,   1,  2,  3,  1,    0,  0,  1,  0));
    sequencePizz.add(new NoteEvent(2,  2,   1,  2,  3,  1,    0,  0,  1,  0));
    sequencePizz.add(new NoteEvent(3,  2,   1,  2,  3,  1,    0,  0,  1,  0));
    sequencePizz.add(new NoteEvent(4,  2,   1,  2,  3,  1,    0,  0,  1,  0));
//  sequencePizz.add(new NoteEvent(8,  2,   1,  2,  3,  1,    0,  0,  1,  0));
//  sequencePizz.add(new NoteEvent(7,  2,   1,  2,  3,  1,    0,  0,  1,  0));
//  sequencePizz.add(new NoteEvent(6,  2,   1,  2,  3,  1,    0,  0,  1,  0));
    sequencePizz.add(new NoteEvent(13, 2,   1,  3,  3,  1,    0,  0,  1,  0));
    sequencePizz.add(new NoteEvent(12, 2,   1,  3,  3,  1,    0,  0,  1,  0));
    sequencePizz.add(new NoteEvent(11, 2,   1,  3,  3,  1,    0,  0,  1,  0));
    sequencePizz.add(new NoteEvent(10, 2,   1,  3,  3,  1,    0,  0,  1,  0));
    sequencePizz.add(new NoteEvent(9,  2,   1,  3,  3,  1,    0,  0,  1,  0));
//  sequencePizz.add(new NoteEvent(8,  2,   1,  3,  3,  1,    0,  0,  1,  0));
//  sequencePizz.add(new NoteEvent(7,  2,   1,  3,  3,  1,    0,  0,  1,  0));
//  sequencePizz.add(new NoteEvent(6,  2,   1,  3,  3,  1,    0,  0,  1,  0));
    sequencePizz.add(new NoteEvent(0,  2,   1,  4,  1,  1,    0,  0,  1,  0));
    sequencePizz.add(new NoteEvent(1,  2,   1,  4,  1,  1,    0,  0,  1,  0));
    sequencePizz.add(new NoteEvent(2,  2,   1,  4,  1,  1,    0,  0,  1,  0));
    sequencePizz.add(new NoteEvent(3,  2,   1,  4,  1,  1,    0,  0,  1,  0));
    sequencePizz.add(new NoteEvent(4,  2,   1,  4,  1,  1,    0,  0,  1,  0));
//  sequencePizz.add(new NoteEvent(8,  2,   1,  4,  3,  1,    0,  0,  1,  0));
//  sequencePizz.add(new NoteEvent(7,  2,   1,  4,  3,  1,    0,  0,  1,  0));
//  sequencePizz.add(new NoteEvent(6,  2,   1,  4,  3,  1,    0,  0,  1,  0));
    seedSequencer(sequencePizz, 3);
/*    
    ArrayList<NoteEvent> sequenceStrings = new ArrayList<NoteEvent>();
    sequenceStrings.add(new NoteEvent(13, 2,   1,  1,  1,  1,    0,  1,  3,  0));
    sequenceStrings.add(new NoteEvent(12, 2,   1,  1,  1,  1,    0,  1,  3,  0));
    sequenceStrings.add(new NoteEvent(11, 2,   1,  1,  1,  1,    0,  1,  3,  0));
    sequenceStrings.add(new NoteEvent(10, 2,   1,  1,  1,  1,    0,  1,  3,  0));
    sequenceStrings.add(new NoteEvent(9,  2,   1,  1,  1,  1,    0,  1,  3,  0));
    sequenceStrings.add(new NoteEvent(8,  2,   1,  1,  1,  1,    0,  1,  3,  0));
    sequenceStrings.add(new NoteEvent(7,  2,   1,  1,  1,  1,    0,  1,  3,  0));
    sequenceStrings.add(new NoteEvent(6,  2,   1,  1,  1,  1,    0,  1,  3,  0));
    seedSequencer(sequenceStrings, 4);
*/
    
}

public void seedSequencer(ArrayList<NoteEvent> sIn, int track){
    for (int i = 0; i < sIn.size(); i++){
      NoteEvent s = sIn.get(i);
  //  println("info stuff : " + s[i].notePitch);
        tracks[track].sequence[s.notePitch][(s.notePosition[0]-1)*pulsesPerBar + (s.notePosition[1]-1)*grid + (s.notePosition[2]-1)*(grid/fractions) + s.notePosition[3]] = new NoteEvent (s.notePitch, s.channel, bar,beat,fraction,pulse);
        tracks[track].sequence[s.notePitch][(s.notePosition[0]-1)*pulsesPerBar + (s.notePosition[1]-1)*grid + (s.notePosition[2]-1)*(grid/fractions) + s.notePosition[3] + s.noteLength[0]*pulsesPerBar + s.noteLength[1]*grid + s.noteLength[2]*grid/fractions + s.noteLength[3]] = new NoteEvent (s.notePitch, s.channel, bar,beat,fraction,pulse, true);
    }
}
  static public void main(String args[]) {
    PApplet.main(new String[] { "--bgcolor=#FFFFFF", "HeresyBigBangDone" });
  }
}