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