andrew@50: boolean heresyMinor, oldHeresyMinor, heresy7th, oldHeresy7th, heresy9th, oldHeresy9th, heresy11th, oldHeresy11th, heresy13th, oldHeresy13th, heresyDom; andrew@50: boolean heresyMinorChanged, heresyChordChanged, heresy7thChanged, heresy9thChanged, heresy11thChanged, heresy13thChanged, heresyChange, dontRevoice; andrew@50: int currentChord, lastChord; andrew@50: VPArray[] VPA = new VPArray[16]; andrew@50: int[] notesOnArray = new int[16]; andrew@50: int no1s = 0; int no3s = 0; int no5s = 0; int no7s = 0; int no9s = 0; int no11s = 0; int no13s = 0; andrew@50: int tonic = 0; andrew@50: andrew@50: andrew@50: andrew@50: andrew@50: andrew@50: //------------------------------------------------------------------------------------------------------------------------------- andrew@50: andrew@50: /* public int getHeresyPitch(int extension, int notePosition){ // delivers heresy pitches andrew@50: int value = getExtentionPitch(extension) % 12; andrew@50: if (notePosition == 15) value += 24; andrew@50: if (notePosition == 14) value += 36; andrew@50: if (notePosition == 13) value += 36; andrew@50: if (notePosition == 12) value += 48; andrew@50: if (notePosition == 11) value += 48; andrew@50: if (notePosition == 10) value += 48; andrew@50: if (notePosition == 9) value += 48; andrew@50: if (notePosition == 8) value += 60; andrew@50: if (notePosition == 7) value += 60; andrew@50: if (notePosition == 6) value += 60; andrew@50: if (notePosition == 5) value += 60; andrew@50: if (notePosition == 4) value += 72; andrew@50: if (notePosition == 3) value += 72; andrew@50: if (notePosition == 2) value += 72; andrew@50: if (notePosition == 1) value += 72; andrew@50: if (notePosition == 0) value += 84; andrew@50: return value; andrew@50: }*/ andrew@50: andrew@50: andrew@50: public int heresyPitchInfo(int arrayPosition){ // returns a value for checking if note required is currently playing andrew@50: int value = 0; andrew@50: if (heresyMinor && heresy7th && heresy9th && heresy11th && !heresy13th){ andrew@50: if (arrayPosition == 15) value = (15-currentChord) + 24; andrew@50: if (arrayPosition == 14) value = (15-currentChord) + 36; andrew@50: if (arrayPosition == 13) value = (15-currentChord) + 43; andrew@50: if (arrayPosition == 12) value = (15-currentChord) + 50; andrew@50: if (arrayPosition == 11) value = (15-currentChord) + 51; andrew@50: if (arrayPosition == 10) value = (15-currentChord) + 58; andrew@50: if (arrayPosition == 9) value = (15-currentChord) + 65; andrew@50: if (arrayPosition == 8) value = (15-currentChord) + 67; andrew@50: if (arrayPosition == 7) value = (15-currentChord) + 70; andrew@50: if (arrayPosition == 6) value = (15-currentChord) + 72; andrew@50: if (arrayPosition == 5) value = (15-currentChord) + 74; andrew@50: if (arrayPosition == 4) value = (15-currentChord) + 75; andrew@50: if (arrayPosition == 3) value = (15-currentChord) + 77; andrew@50: if (arrayPosition == 2) value = (15-currentChord) + 79; andrew@50: if (arrayPosition == 1) value = (15-currentChord) + 82; andrew@50: if (arrayPosition == 0) value = (15-currentChord) + 84; andrew@50: } andrew@50: if (!heresyMinor && heresy7th && heresy9th && heresy11th && !heresy13th){ andrew@50: if (arrayPosition == 15) value = (15-currentChord) + 24; andrew@50: if (arrayPosition == 14) value = (15-currentChord) + 36; andrew@50: if (arrayPosition == 13) value = (15-currentChord) + 43; andrew@50: if (arrayPosition == 12) value = (15-currentChord) + 50; andrew@50: if (arrayPosition == 11) value = (15-currentChord) + 52; andrew@50: if (arrayPosition == 10) value = (15-currentChord) + 59; andrew@50: if (arrayPosition == 9) value = (15-currentChord) + 66; andrew@50: if (arrayPosition == 8) value = (15-currentChord) + 71; andrew@50: if (arrayPosition == 7) value = (15-currentChord) + 74; andrew@50: if (arrayPosition == 6) value = (15-currentChord) + 78; andrew@50: if (arrayPosition == 5) value = (15-currentChord) + 83; andrew@50: if (arrayPosition == 4) value = (15-currentChord) + 75; andrew@50: if (arrayPosition == 3) value = (15-currentChord) + 77; andrew@50: if (arrayPosition == 2) value = (15-currentChord) + 79; andrew@50: if (arrayPosition == 1) value = (15-currentChord) + 82; andrew@50: if (arrayPosition == 0) value = (15-currentChord) + 84; andrew@50: } andrew@50: return value; andrew@50: } andrew@50: andrew@50: andrew@50: //------------------------------------------------------------------------------------------------------------------------------- andrew@50: andrew@50: public void playTrackEvents(){ // initiates the playing Heresy AI logic andrew@50: andrew@50: workOutExtensions(); andrew@50: //workOutChord(); andrew@50: heresyChangeHistory(); andrew@50: VpaNoteStater(); andrew@50: // heresyVoicingArray(); andrew@50: countNoteOns(); andrew@50: andrew@50: andrew@50: } andrew@50: andrew@50: andrew@50: //------------------------------------------------------------------------------------------------------------------------------- andrew@50: andrew@50: public void sendNoteEvents(){ // sends sequencer evernts to the IO section for out put to max andrew@50: for(int i = 1; i < Track.currentNumberOfTracks; i++){ andrew@50: if (tracks[i] != null ){ andrew@50: for (int ii = 0; ii < 16; ii++) { andrew@50: if (!VPA[i].VPArrayNotes[ii].played){ andrew@50: outputToMax (VPA[i].VPArrayNotes[ii].VPNotePitch, VPA[i].VPArrayNotes[ii].VPNoteVelocity, i); andrew@50: VPA[i].VPArrayNotes[ii].played = true; andrew@50: } andrew@50: } andrew@50: } andrew@50: } andrew@50: } andrew@50: andrew@50: andrew@50: //------------------------------------------------------------------------------------------------------------------------------- andrew@50: andrew@50: public void VpaNoteStater(){ // calculates pitches based on Heresy AI voice leading and voicing tables. andrew@50: for(int i = 1; i < Track.currentNumberOfTracks; i++){ andrew@50: if (tracks[i] != null){ andrew@50: for (int ii = 0; ii < 16; ii++) { andrew@50: if (tracks[i].sequence[ii][currentPulse%(tracks[i].loopLength)] != null){ andrew@50: if (tracks[i].sequence[ii][currentPulse%(tracks[i].loopLength)].noteVelocity != 0){ andrew@50: if (VPA[i].VPArrayNotes[ii].VPNoteOn && heresyPitchInfo(ii) != VPA[i].VPArrayNotes[ii].VPNotePitch){ andrew@50: // println("in..."); andrew@50: VPA[i].VPArrayNotes[ii].VPNoteVelocity = 0; andrew@50: sendNote(VPA[i].VPArrayNotes[ii], i); andrew@50: if (i != 1 && i != 5) andrew@50: VPA[i].VPArrayNotes[ii].VPNotePitch = heresyPitch(ii, 3); andrew@50: else andrew@50: VPA[i].VPArrayNotes[ii].VPNotePitch = heresyPitch(ii, 1); andrew@50: VPA[i].VPArrayNotes[ii].VPNoteVelocity = tracks[i].sequence[ii][currentPulse%(tracks[i].loopLength)].noteVelocity; andrew@50: sendNote(VPA[i].VPArrayNotes[ii], i); andrew@50: }else{ andrew@50: // println("in2..."); andrew@50: if (i != 1 && i != 5) andrew@50: VPA[i].VPArrayNotes[ii].VPNotePitch = heresyPitch(ii, 3); andrew@50: else andrew@50: VPA[i].VPArrayNotes[ii].VPNotePitch = heresyPitch(ii, 1); andrew@50: VPA[i].VPArrayNotes[ii].VPNoteVelocity = tracks[i].sequence[ii][currentPulse%(tracks[i].loopLength)].noteVelocity; andrew@50: sendNote(VPA[i].VPArrayNotes[ii], i); andrew@50: } andrew@50: } andrew@50: if (tracks[i].sequence[ii][currentPulse%(tracks[i].loopLength)].noteVelocity == 0){ andrew@50: VPA[i].VPArrayNotes[ii].VPNoteVelocity = 0; andrew@50: sendNote(VPA[i].VPArrayNotes[ii], i); andrew@50: } andrew@50: } andrew@50: } andrew@50: } andrew@50: } andrew@50: } andrew@50: andrew@50: andrew@50: //------------------------------------------------------------------------------------------------------------------------------- andrew@50: andrew@50: /* public void heresyVoicingArray(){ // sets the voicing array to be used for note ons andrew@50: if (!heresy7th && !heresy9th && !heresy11th && !heresy13th) hvArray = hchoice135; andrew@50: if (heresy7th && !heresy9th && !heresy11th && !heresy13th) hvArray = hchoice7; andrew@50: if (!heresy7th && heresy9th && !heresy11th && !heresy13th) hvArray = hchoice9; andrew@50: if (!heresy7th && !heresy9th && heresy11th && !heresy13th) hvArray = hchoice11; andrew@50: if (!heresy7th && !heresy9th && !heresy11th && heresy13th) hvArray = hchoice13; andrew@50: if (heresy7th && heresy9th && !heresy11th && !heresy13th) hvArray = hchoice79; andrew@50: if (heresy7th && !heresy9th && heresy11th && !heresy13th) hvArray = hchoice711; andrew@50: if (heresy7th && !heresy9th && !heresy11th && heresy13th) hvArray = hchoice713; andrew@50: if (!heresy7th && heresy9th && heresy11th && !heresy13th) hvArray = hchoice911; andrew@50: if (!heresy7th && heresy9th && !heresy11th && heresy13th) hvArray = hchoice913; andrew@50: if (!heresy7th && !heresy9th && heresy11th && heresy13th) hvArray = hchoice1113; andrew@50: if (heresy7th && heresy9th && heresy11th && !heresy13th) hvArray = hchoice7911; andrew@50: if (heresy7th && heresy9th && !heresy11th && heresy13th) hvArray = hchoice7913; andrew@50: if (heresy7th && !heresy9th && !heresy11th && heresy13th) hvArray = hchoice71113; andrew@50: if (!heresy7th && heresy9th && heresy11th && heresy13th) hvArray = hchoice91113; andrew@50: } andrew@50: andrew@50: */ andrew@50: andrew@50: andrew@50: //------------------------------------------------------------------------------------------------------------------------------- andrew@50: andrew@50: public void countNoteOns(){ // counts the note ons for all tracks andrew@50: for (int ii = 0; ii < 16; ii++){ andrew@50: notesOnArray[ii] = 0;} andrew@50: for(int i = 1; i < Track.currentNumberOfTracks; i++){ andrew@50: for (int ii = 0; ii < 16; ii++){ andrew@50: if (VPA[i].VPArrayNotes[ii].VPNoteOn == true) andrew@50: notesOnArray[i]++; andrew@50: } andrew@50: } andrew@50: } andrew@50: andrew@50: andrew@50: //------------------------------------------------------------------------------------------------------------------------------- andrew@50: andrew@50: /* public void calculateHeresyNoteExtensions(){ andrew@50: for(int tracki = 1; tracki < Track.currentNumberOfTracks; tracki++){ andrew@50: no1s = 0; no3s = 0; no5s = 0; no7s = 0; no9s = 0; no11s = 0; no13s = 0; andrew@50: andrew@50: checkIfNotesAlreadyFit(tracki); andrew@50: andrew@50: calcRemainingNotes(tracki); andrew@50: andrew@50: for (int t = 0; t < 16; t++){ andrew@50: VPA[tracki].VPArrayNotes[t].done = false; andrew@50: } andrew@50: } andrew@50: } andrew@50: andrew@50: */ andrew@50: andrew@50: andrew@50: //------------------------------------------------------------------------------------------------------------------------------- andrew@50: andrew@50: /* public void calcRemainingNotes(int tracki){ andrew@50: int counter = -1; andrew@50: int looped = 0; andrew@50: while (no1s + no3s + no5s + no7s + no9s + no11s + no13s != 0){ andrew@50: counter++; andrew@50: if (counter >= notesOnArray[tracki]){ andrew@50: counter = 0; andrew@50: looped++; andrew@50: } andrew@50: int nextExtension = hvArray[counter]; andrew@50: if(extensionNeeded(nextExtension)){ andrew@50: for (int playingNotesi = 0; playingNotesi < 16; playingNotesi++){ andrew@50: if (VPA[tracki].VPArrayNotes[playingNotesi].VPNoteOn == true && !VPA[tracki].VPArrayNotes[playingNotesi].done){ andrew@50: if (extensionPossible(playingNotesi, nextExtension)){ andrew@50: VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch = getHeresyPitch(nextExtension, playingNotesi); andrew@50: VPA[tracki].VPArrayNotes[playingNotesi].done = true; andrew@50: println("got pitch " + VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch); andrew@50: // correctIfNeeded(tracki, playingNotesi, nextExtension); andrew@50: }else println("wasn't possible"); andrew@50: } andrew@50: } andrew@50: } andrew@50: if (looped > 3) { andrew@50: for (int playingNotesi = 0; playingNotesi < 16; playingNotesi++){ andrew@50: if (VPA[tracki].VPArrayNotes[playingNotesi].VPNoteOn == true && !VPA[tracki].VPArrayNotes[playingNotesi].done){ andrew@50: VPA[tracki].VPArrayNotes[playingNotesi].VPNoteOn = false; andrew@50: VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch = -1; andrew@50: } andrew@50: } andrew@50: System.out.println("Had to break_________________"); andrew@50: break; andrew@50: } andrew@50: } andrew@50: } andrew@50: andrew@50: */ andrew@50: andrew@50: andrew@50: //------------------------------------------------------------------------------------------------------------------------------- andrew@50: andrew@50: /* 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 andrew@50: boolean alreadyGotNote = false; boolean alreadyGotNotePlus12 = false; boolean alreadyGotNoteMinus12 = false; andrew@50: int pitchAverage = 0; andrew@50: for (int i = 0; i < 16; i++) andrew@50: if (i != playingNotesi){ andrew@50: if (VPA[tracki].VPArrayNotes[i].done) andrew@50: pitchAverage += VPA[tracki].VPArrayNotes[i].VPNotePitch; andrew@50: if (VPA[tracki].VPArrayNotes[i].VPNotePitch == VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch) andrew@50: alreadyGotNote = true; andrew@50: if (VPA[tracki].VPArrayNotes[i].VPNotePitch == VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch + 12) andrew@50: alreadyGotNotePlus12 = true; andrew@50: if (VPA[tracki].VPArrayNotes[i].VPNotePitch == VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch - 12) andrew@50: alreadyGotNoteMinus12 = true; andrew@50: } andrew@50: if (notesOnArray[tracki]-1 > 0) andrew@50: pitchAverage = pitchAverage / (notesOnArray[tracki]-1); andrew@50: else andrew@50: pitchAverage = VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch; andrew@50: boolean correctedIt = false; andrew@50: if (alreadyGotNote){ andrew@50: println("correcting note.........."); andrew@50: if (!alreadyGotNotePlus12 && pitchAverage > VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch){ andrew@50: VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch = VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch + 12; andrew@50: correctedIt = true; andrew@50: }else andrew@50: if (!alreadyGotNoteMinus12){ andrew@50: VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch = VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch - 12; andrew@50: correctedIt = true; andrew@50: } andrew@50: if (!alreadyGotNoteMinus12 && pitchAverage < VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch){ andrew@50: VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch = VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch - 12; andrew@50: correctedIt = true; andrew@50: }else andrew@50: if (!alreadyGotNotePlus12){ andrew@50: VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch = VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch + 12; andrew@50: correctedIt = true; andrew@50: } andrew@50: } andrew@50: if (alreadyGotNote && !correctedIt) andrew@50: VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch = -2; andrew@50: if (!alreadyGotNote || correctedIt){ andrew@50: VPA[tracki].VPArrayNotes[playingNotesi].VPNoteVelocity = 80; andrew@50: VPA[tracki].VPArrayNotes[playingNotesi].done = true; andrew@50: VPA[tracki].VPArrayNotes[playingNotesi].played = false; andrew@50: extensionCounter(false, nextExtension); andrew@50: }else{ andrew@50: VPA[tracki].VPArrayNotes[playingNotesi].VPNoteVelocity = 80; andrew@50: VPA[tracki].VPArrayNotes[playingNotesi].done = true; andrew@50: } andrew@50: } andrew@50: andrew@50: */ andrew@50: andrew@50: andrew@50: //------------------------------------------------------------------------------------------------------------------------------- andrew@50: andrew@50: andrew@50: andrew@50: /* public void checkIfNotesAlreadyFit(int tracki){ andrew@50: for (int extensioni = 0; extensioni < notesOnArray[tracki]; extensioni++){ andrew@50: boolean extensionFound = false; andrew@50: for (int playingNotesi = 0; playingNotesi < 16; playingNotesi++){ andrew@50: if (VPA[tracki].VPArrayNotes[playingNotesi].VPNoteOn && !VPA[tracki].VPArrayNotes[playingNotesi].done && !extensionFound && VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch >= 24){ andrew@50: if (disiredPitch(VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch, hvArray[extensioni])){ andrew@50: VPA[tracki].VPArrayNotes[playingNotesi].done = true; andrew@50: extensionFound = true; andrew@50: } andrew@50: } andrew@50: } andrew@50: if (!extensionFound){ andrew@50: extensionCounter(true, hvArray[extensioni]); andrew@50: } andrew@50: } andrew@50: } andrew@50: andrew@50: */ andrew@50: andrew@50: andrew@50: //------------------------------------------------------------------------------------------------------------------------------- andrew@50: andrew@50: /* public boolean pitchInChord(int currentPitch){ andrew@50: boolean returnValue = false; andrew@50: for (int i = 0; i < 16; i++){ andrew@50: // println("currentPitch " + currentPitch + " getHeresyPitch(hvArray[i], 5) % 12) " + (getHeresyPitch(hvArray[i], 5))); andrew@50: if (currentPitch % 12 == (getHeresyPitch(hvArray[i], 5) % 12)); andrew@50: returnValue = true; andrew@50: } andrew@50: return returnValue; andrew@50: } andrew@50: */ andrew@50: andrew@50: //------------------------------------------------------------------------------------------------------------------------------- andrew@50: andrew@50: /* public boolean extensionNeeded(int extension){ andrew@50: boolean needed = false; andrew@50: if (extension == 1 && no1s > 0) needed = true; andrew@50: if (extension == 3 && no3s > 0) needed = true; andrew@50: if (extension == 5 && no5s > 0) needed = true; andrew@50: if (extension == 7 && no7s > 0) needed = true; andrew@50: if (extension == 9 && no9s > 0) needed = true; andrew@50: if (extension == 11 && no11s > 0) needed = true; andrew@50: if (extension == 13 && no13s > 0) needed = true; andrew@50: return needed; andrew@50: } andrew@50: */ andrew@50: andrew@50: andrew@50: //------------------------------------------------------------------------------------------------------------------------------- andrew@50: andrew@50: /* public int extensionMatch(){ andrew@50: int returnValue = -1; andrew@50: for (int i = 0; i < 16; i++){ andrew@50: if( hvArray[i] == 1 && no1s > 0){ andrew@50: returnValue = hvArray[i]; andrew@50: break; andrew@50: } andrew@50: if( hvArray[i] == 3 && no3s > 0){ andrew@50: returnValue = hvArray[i]; andrew@50: break; andrew@50: } andrew@50: if( hvArray[i] == 5 && no5s > 0){ andrew@50: returnValue = hvArray[i]; andrew@50: break; andrew@50: } andrew@50: if( hvArray[i] == 7 && no7s > 0){ andrew@50: returnValue = hvArray[i]; andrew@50: break; andrew@50: } andrew@50: if( hvArray[i] == 9 && no9s > 0){ andrew@50: returnValue = hvArray[i]; andrew@50: break; andrew@50: } andrew@50: if( hvArray[i] == 11 && no11s > 0){ andrew@50: returnValue = hvArray[i]; andrew@50: break; andrew@50: } andrew@50: if( hvArray[i] == 13 && no13s > 0){ andrew@50: returnValue = hvArray[i]; andrew@50: break; andrew@50: } andrew@50: } andrew@50: return returnValue; andrew@50: } andrew@50: andrew@50: */ andrew@50: andrew@50: andrew@50: andrew@50: andrew@50: //------------------------------------------------------------------------------------------------------------------------------- andrew@50: andrew@50: /* public boolean extensionPossible(int playingNotesi, int extentionNeeded){ andrew@50: Boolean returnValue = true; andrew@50: if (extentionNeeded != 1 && playingNotesi < 2) returnValue = false; andrew@50: if ((extentionNeeded == 5 || extentionNeeded == 7 || extentionNeeded == 1) && playingNotesi == 3) returnValue = false; andrew@50: if (!returnValue) println ("returning no on playingNotesi = " + playingNotesi + " and " + extentionNeeded); andrew@50: return returnValue; andrew@50: } andrew@50: */ andrew@50: andrew@50: //------------------------------------------------------------------------------------------------------------------------------- andrew@50: andrew@50: /* public boolean disiredPitch(int pitch, int extension){ // returns a value for voice leading purposes. If true then pitch is already in current chord andrew@50: if (pitch % 12 == getExtentionPitch(extension) % 12) andrew@50: return true; andrew@50: else return false; andrew@50: } andrew@50: */ andrew@50: andrew@50: //------------------------------------------------------------------------------------------------------------------------------- andrew@50: andrew@50: /* public int getExtentionPitch(int extension){ // andrew@50: if (!heresyMinor){ andrew@50: if (currentChord-tonic == 1) return tritoneSystem[extension/2]+currentChord; andrew@50: if (currentChord-tonic == 7) return dom7System[extension/2]+currentChord; andrew@50: if (currentChord-tonic != 1 || currentChord-tonic != 7) return major7System[extension/2]+currentChord; andrew@50: } andrew@50: if (heresyMinor) andrew@50: return minorSystem[extension/2]+currentChord; andrew@50: else andrew@50: return -1; andrew@50: } andrew@50: */ andrew@50: andrew@50: andrew@50: //------------------------------------------------------------------------------------------------------------------------------- andrew@50: andrew@50: /* public void extensionCounter(boolean positive, int currentDesiredExtention){ andrew@50: if (currentDesiredExtention == 1) if (positive) no1s++; else no1s--; andrew@50: if (currentDesiredExtention == 3) if (positive) no3s++; else no3s--; andrew@50: if (currentDesiredExtention == 5) if (positive) no5s++; else no5s--; andrew@50: if (currentDesiredExtention == 7) if (positive) no7s++; else no7s--; andrew@50: if (currentDesiredExtention == 9) if (positive) no9s++; else no9s--; andrew@50: if (currentDesiredExtention == 11) if (positive) no11s++; else no11s--; andrew@50: if (currentDesiredExtention == 13) if (positive) no13s++; else no13s--; andrew@50: } andrew@50: */ andrew@50: andrew@50: //------------------------------------------------------------------------------------------------------------------------------- andrew@50: andrew@50: public void workOutExtensions(){ // calculates whether the performer wants chord extensions andrew@50: if (tracks[0].sequence[3][currentPulse%(tracks[0].loopLength)] != null && tracks[0].sequence[3][currentPulse%(tracks[0].loopLength)].noteVelocity == 0 && trSelected == 0 && noteOnArray[3]) andrew@50: tracks[0].sequence[3][currentPulse%(tracks[0].loopLength)] = null; andrew@50: if (tracks[0].sequence[2][currentPulse%(tracks[0].loopLength)] != null && tracks[0].sequence[2][currentPulse%(tracks[0].loopLength)].noteVelocity == 0 && trSelected == 0 && noteOnArray[2]) andrew@50: tracks[0].sequence[2][currentPulse%(tracks[0].loopLength)] = null; andrew@50: if (tracks[0].sequence[1][currentPulse%(tracks[0].loopLength)] != null && tracks[0].sequence[1][currentPulse%(tracks[0].loopLength)].noteVelocity == 0 && trSelected == 0 && noteOnArray[1]) andrew@50: tracks[0].sequence[1][currentPulse%(tracks[0].loopLength)] = null; andrew@50: if (tracks[0].sequence[0][currentPulse%(tracks[0].loopLength)] != null && tracks[0].sequence[0][currentPulse%(tracks[0].loopLength)].noteVelocity == 0 && trSelected == 0 && noteOnArray[0]) andrew@50: tracks[0].sequence[0][currentPulse%(tracks[0].loopLength)] = null; andrew@50: andrew@50: if (tracks[0].sequence[3][currentPulse%(tracks[0].loopLength)] != null && tracks[0].sequence[3][currentPulse%(tracks[0].loopLength)].noteVelocity > 0) andrew@50: heresy7th = true; andrew@50: if (tracks[0].sequence[3][currentPulse%(tracks[0].loopLength)] != null && tracks[0].sequence[3][currentPulse%(tracks[0].loopLength)].noteVelocity == 0) andrew@50: heresy7th = false; andrew@50: if (tracks[0].sequence[2][currentPulse%(tracks[0].loopLength)] != null && tracks[0].sequence[2][currentPulse%(tracks[0].loopLength)].noteVelocity > 0) andrew@50: heresy9th = true; andrew@50: if (tracks[0].sequence[2][currentPulse%(tracks[0].loopLength)] != null && tracks[0].sequence[2][currentPulse%(tracks[0].loopLength)].noteVelocity == 0) andrew@50: heresy9th = false; andrew@50: if (tracks[0].sequence[1][currentPulse%(tracks[0].loopLength)] != null && tracks[0].sequence[1][currentPulse%(tracks[0].loopLength)].noteVelocity > 0) andrew@50: heresy11th = true; andrew@50: if (tracks[0].sequence[1][currentPulse%(tracks[0].loopLength)] != null && tracks[0].sequence[1][currentPulse%(tracks[0].loopLength)].noteVelocity == 0) andrew@50: heresy11th = false; andrew@50: if (tracks[0].sequence[0][currentPulse%(tracks[0].loopLength)] != null && tracks[0].sequence[0][currentPulse%(tracks[0].loopLength)].noteVelocity > 0) andrew@50: heresy13th = true; andrew@50: if (tracks[0].sequence[0][currentPulse%(tracks[0].loopLength)] != null && tracks[0].sequence[0][currentPulse%(tracks[0].loopLength)].noteVelocity == 0) andrew@50: heresy13th = false; andrew@50: //--- andrew@50: if (chordsTemp.sequence[3][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[3][currentPulse%(chordsTemp.loopLength)].noteVelocity == 0 && trSelected == 0 && noteOnArray[3]) andrew@50: chordsTemp.sequence[3][currentPulse%(chordsTemp.loopLength)] = null; andrew@50: if (chordsTemp.sequence[2][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[2][currentPulse%(chordsTemp.loopLength)].noteVelocity == 0 && trSelected == 0 && noteOnArray[2]) andrew@50: chordsTemp.sequence[2][currentPulse%(chordsTemp.loopLength)] = null; andrew@50: if (chordsTemp.sequence[1][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[1][currentPulse%(chordsTemp.loopLength)].noteVelocity == 0 && trSelected == 0 && noteOnArray[1]) andrew@50: chordsTemp.sequence[1][currentPulse%(chordsTemp.loopLength)] = null; andrew@50: if (chordsTemp.sequence[0][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[0][currentPulse%(chordsTemp.loopLength)].noteVelocity == 0 && trSelected == 0 && noteOnArray[0]) andrew@50: chordsTemp.sequence[0][currentPulse%(chordsTemp.loopLength)] = null; andrew@50: andrew@50: if (chordsTemp.sequence[3][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[3][currentPulse%(chordsTemp.loopLength)].noteVelocity > 0) andrew@50: heresy7th = true; andrew@50: if (chordsTemp.sequence[3][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[3][currentPulse%(chordsTemp.loopLength)].noteVelocity == 0) andrew@50: heresy7th = false; andrew@50: if (chordsTemp.sequence[2][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[2][currentPulse%(chordsTemp.loopLength)].noteVelocity > 0) andrew@50: heresy9th = true; andrew@50: if (chordsTemp.sequence[2][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[2][currentPulse%(chordsTemp.loopLength)].noteVelocity == 0) andrew@50: heresy9th = false; andrew@50: if (chordsTemp.sequence[1][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[1][currentPulse%(chordsTemp.loopLength)].noteVelocity > 0) andrew@50: heresy11th = true; andrew@50: if (chordsTemp.sequence[1][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[1][currentPulse%(chordsTemp.loopLength)].noteVelocity == 0) andrew@50: heresy11th = false; andrew@50: if (chordsTemp.sequence[0][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[0][currentPulse%(chordsTemp.loopLength)].noteVelocity > 0) andrew@50: heresy13th = true; andrew@50: if (chordsTemp.sequence[0][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[0][currentPulse%(chordsTemp.loopLength)].noteVelocity == 0) andrew@50: heresy13th = false; andrew@50: andrew@50: } andrew@50: andrew@50: andrew@50: //------------------------------------------------------------------------------------------------------------------------------- andrew@50: andrew@50: public void workOutChord(){ // calculates current chord and major minor tonality andrew@50: for (int i = 4; i < 16; i++) { andrew@50: if (tracks[0] != null){ andrew@50: if ((tracks[0].sequence[i][currentPulse%(tracks[0].loopLength)] != null && tracks[0].sequence[i][currentPulse%(tracks[0].loopLength)].noteVelocity > 0 )|| andrew@50: (chordsTemp.sequence[i][currentPulse%(tracks[0].loopLength)] != null && chordsTemp.sequence[i][currentPulse%(chordsTemp.loopLength)].noteVelocity > 0 )){ andrew@50: currentChord = 15 - i; andrew@50: boolean iiDone = false; andrew@50: for (int ii = 0;; ii--){ andrew@50: if (ii == 0 && iiDone) andrew@50: break; andrew@50: if (currentPulse%(tracks[0].loopLength)+ii == 0) andrew@50: ii = tracks[0].loopLength+ii-1; andrew@50: if (i > 3){ andrew@50: if ((tracks[0].sequence[i-1][currentPulse%(tracks[0].loopLength)+ii] != null && tracks[0].sequence[i-1][currentPulse%(tracks[0].loopLength)+ii].noteVelocity == 0 ) || andrew@50: (chordsTemp.sequence[i-1][currentPulse%(chordsTemp.loopLength)+ii] != null && chordsTemp.sequence[i-1][currentPulse%(chordsTemp.loopLength)+ii].noteVelocity == 0 )) andrew@50: break; andrew@50: if ((tracks[0].sequence[i-1][currentPulse%(tracks[0].loopLength)+ii] != null && tracks[0].sequence[i-1][currentPulse%(tracks[0].loopLength)+ii].noteVelocity != 0 ) || andrew@50: (chordsTemp.sequence[i-1][currentPulse%(chordsTemp.loopLength)+ii] != null && chordsTemp.sequence[i-1][currentPulse%(chordsTemp.loopLength)+ii].noteVelocity != 0 )){ andrew@50: heresyMinor = true; andrew@50: break; andrew@50: }else andrew@50: heresyMinor = false; andrew@50: } andrew@50: iiDone = true; andrew@50: } andrew@50: } andrew@50: } andrew@50: } andrew@50: } andrew@50: andrew@50: andrew@50: //------------------------------------------------------------------------------------------------------------------------------- andrew@50: andrew@50: public void heresyChangeHistory(){ // remembers whether the chords or extensions have changed andrew@50: if (currentChord != lastChord){ andrew@50: heresyChordChanged = true; andrew@50: lastChord = currentChord; andrew@50: heresyChange = true; andrew@50: } andrew@50: if (heresyMinor != oldHeresyMinor){ andrew@50: heresyMinorChanged = true; andrew@50: oldHeresyMinor = heresyMinor; andrew@50: heresyChange = true; andrew@50: } andrew@50: if (heresy7th != oldHeresy7th){ andrew@50: heresy7thChanged = true; andrew@50: oldHeresy7th = heresy7th; andrew@50: heresyChange = true; andrew@50: } andrew@50: if (heresy9th != oldHeresy9th){ andrew@50: heresy9thChanged = true; andrew@50: oldHeresy9th = heresy9th; andrew@50: heresyChange = true; andrew@50: } andrew@50: if (heresy11th != oldHeresy11th){ andrew@50: heresy11thChanged = true; andrew@50: oldHeresy11th = heresy11th; andrew@50: heresyChange = true; andrew@50: } andrew@50: if (heresy13th != oldHeresy13th){ andrew@50: heresy13thChanged = true; andrew@50: oldHeresy13th = heresy13th; andrew@50: heresyChange = true; andrew@50: } andrew@50: } andrew@50: andrew@50: andrew@50: andrew@50: andrew@50: