annotate HeresyBigBangDone/HeresyAl.pde @ 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 e4b08c578349
children
rev   line source
rebecca@26 1 boolean heresyMinor, oldHeresyMinor, heresy7th, oldHeresy7th, heresy9th, oldHeresy9th, heresy11th, oldHeresy11th, heresy13th, oldHeresy13th, heresyDom;
rebecca@26 2 boolean heresyMinorChanged, heresyChordChanged, heresy7thChanged, heresy9thChanged, heresy11thChanged, heresy13thChanged, heresyChange, dontRevoice;
rebecca@26 3 int currentChord, lastChord;
rebecca@26 4 VPArray[] VPA = new VPArray[16];
rebecca@26 5 int[] notesOnArray = new int[16];
rebecca@26 6 int no1s = 0; int no3s = 0; int no5s = 0; int no7s = 0; int no9s = 0; int no11s = 0; int no13s = 0;
rebecca@26 7 int tonic = 0;
rebecca@26 8
rebecca@26 9
rebecca@26 10
rebecca@26 11
rebecca@26 12
rebecca@26 13 //-------------------------------------------------------------------------------------------------------------------------------
rebecca@26 14
rebecca@26 15 /* public int getHeresyPitch(int extension, int notePosition){ // delivers heresy pitches
rebecca@26 16 int value = getExtentionPitch(extension) % 12;
rebecca@26 17 if (notePosition == 15) value += 24;
rebecca@26 18 if (notePosition == 14) value += 36;
rebecca@26 19 if (notePosition == 13) value += 36;
rebecca@26 20 if (notePosition == 12) value += 48;
rebecca@26 21 if (notePosition == 11) value += 48;
rebecca@26 22 if (notePosition == 10) value += 48;
rebecca@26 23 if (notePosition == 9) value += 48;
rebecca@26 24 if (notePosition == 8) value += 60;
rebecca@26 25 if (notePosition == 7) value += 60;
rebecca@26 26 if (notePosition == 6) value += 60;
rebecca@26 27 if (notePosition == 5) value += 60;
rebecca@26 28 if (notePosition == 4) value += 72;
rebecca@26 29 if (notePosition == 3) value += 72;
rebecca@26 30 if (notePosition == 2) value += 72;
rebecca@26 31 if (notePosition == 1) value += 72;
rebecca@26 32 if (notePosition == 0) value += 84;
rebecca@26 33 return value;
rebecca@26 34 }*/
rebecca@26 35
rebecca@26 36
rebecca@26 37 public int heresyPitchInfo(int arrayPosition){ // returns a value for checking if note required is currently playing
rebecca@26 38 int value = 0;
rebecca@26 39 if (heresyMinor && heresy7th && heresy9th && heresy11th && !heresy13th){
rebecca@26 40 if (arrayPosition == 15) value = (15-currentChord) + 24;
rebecca@26 41 if (arrayPosition == 14) value = (15-currentChord) + 36;
rebecca@26 42 if (arrayPosition == 13) value = (15-currentChord) + 43;
rebecca@26 43 if (arrayPosition == 12) value = (15-currentChord) + 50;
rebecca@26 44 if (arrayPosition == 11) value = (15-currentChord) + 51;
rebecca@26 45 if (arrayPosition == 10) value = (15-currentChord) + 58;
rebecca@26 46 if (arrayPosition == 9) value = (15-currentChord) + 65;
rebecca@26 47 if (arrayPosition == 8) value = (15-currentChord) + 67;
rebecca@26 48 if (arrayPosition == 7) value = (15-currentChord) + 70;
rebecca@26 49 if (arrayPosition == 6) value = (15-currentChord) + 72;
rebecca@26 50 if (arrayPosition == 5) value = (15-currentChord) + 74;
rebecca@26 51 if (arrayPosition == 4) value = (15-currentChord) + 75;
rebecca@26 52 if (arrayPosition == 3) value = (15-currentChord) + 77;
rebecca@26 53 if (arrayPosition == 2) value = (15-currentChord) + 79;
rebecca@26 54 if (arrayPosition == 1) value = (15-currentChord) + 82;
rebecca@26 55 if (arrayPosition == 0) value = (15-currentChord) + 84;
rebecca@26 56 }
rebecca@26 57 if (!heresyMinor && heresy7th && heresy9th && heresy11th && !heresy13th){
rebecca@26 58 if (arrayPosition == 15) value = (15-currentChord) + 24;
rebecca@26 59 if (arrayPosition == 14) value = (15-currentChord) + 36;
rebecca@26 60 if (arrayPosition == 13) value = (15-currentChord) + 43;
rebecca@26 61 if (arrayPosition == 12) value = (15-currentChord) + 50;
rebecca@26 62 if (arrayPosition == 11) value = (15-currentChord) + 52;
rebecca@26 63 if (arrayPosition == 10) value = (15-currentChord) + 59;
rebecca@26 64 if (arrayPosition == 9) value = (15-currentChord) + 66;
rebecca@26 65 if (arrayPosition == 8) value = (15-currentChord) + 71;
rebecca@26 66 if (arrayPosition == 7) value = (15-currentChord) + 74;
rebecca@26 67 if (arrayPosition == 6) value = (15-currentChord) + 78;
rebecca@26 68 if (arrayPosition == 5) value = (15-currentChord) + 83;
rebecca@26 69 if (arrayPosition == 4) value = (15-currentChord) + 75;
rebecca@26 70 if (arrayPosition == 3) value = (15-currentChord) + 77;
rebecca@26 71 if (arrayPosition == 2) value = (15-currentChord) + 79;
rebecca@26 72 if (arrayPosition == 1) value = (15-currentChord) + 82;
rebecca@26 73 if (arrayPosition == 0) value = (15-currentChord) + 84;
rebecca@26 74 }
rebecca@26 75 return value;
rebecca@26 76 }
rebecca@26 77
rebecca@26 78
rebecca@26 79 //-------------------------------------------------------------------------------------------------------------------------------
rebecca@26 80
rebecca@26 81 public void playTrackEvents(){ // initiates the playing Heresy AI logic
rebecca@26 82
rebecca@26 83 workOutExtensions();
rebecca@26 84 //workOutChord();
rebecca@26 85 heresyChangeHistory();
rebecca@26 86 VpaNoteStater();
rebecca@26 87 // heresyVoicingArray();
rebecca@26 88 countNoteOns();
rebecca@26 89
rebecca@26 90
rebecca@26 91 }
rebecca@26 92
rebecca@26 93
rebecca@26 94 //-------------------------------------------------------------------------------------------------------------------------------
rebecca@26 95
rebecca@26 96 public void sendNoteEvents(){ // sends sequencer evernts to the IO section for out put to max
rebecca@26 97 for(int i = 1; i < Track.currentNumberOfTracks; i++){
rebecca@26 98 if (tracks[i] != null ){
rebecca@26 99 for (int ii = 0; ii < 16; ii++) {
rebecca@26 100 if (!VPA[i].VPArrayNotes[ii].played){
rebecca@26 101 outputToMax (VPA[i].VPArrayNotes[ii].VPNotePitch, VPA[i].VPArrayNotes[ii].VPNoteVelocity, i);
rebecca@26 102 VPA[i].VPArrayNotes[ii].played = true;
rebecca@26 103 }
rebecca@26 104 }
rebecca@26 105 }
rebecca@26 106 }
rebecca@26 107 }
rebecca@26 108
rebecca@26 109
rebecca@26 110 //-------------------------------------------------------------------------------------------------------------------------------
rebecca@26 111
rebecca@26 112 public void VpaNoteStater(){ // calculates pitches based on Heresy AI voice leading and voicing tables.
rebecca@26 113 for(int i = 1; i < Track.currentNumberOfTracks; i++){
rebecca@26 114 if (tracks[i] != null){
rebecca@26 115 for (int ii = 0; ii < 16; ii++) {
rebecca@26 116 if (tracks[i].sequence[ii][currentPulse%(tracks[i].loopLength)] != null){
rebecca@26 117 if (tracks[i].sequence[ii][currentPulse%(tracks[i].loopLength)].noteVelocity != 0){
rebecca@26 118 if (VPA[i].VPArrayNotes[ii].VPNoteOn && heresyPitchInfo(ii) != VPA[i].VPArrayNotes[ii].VPNotePitch){
rebecca@26 119 // println("in...");
rebecca@26 120 VPA[i].VPArrayNotes[ii].VPNoteVelocity = 0;
rebecca@26 121 sendNote(VPA[i].VPArrayNotes[ii], i);
rebecca@26 122 if (i != 1 && i != 5)
rebecca@26 123 VPA[i].VPArrayNotes[ii].VPNotePitch = heresyPitch(ii, 3);
rebecca@26 124 else
rebecca@26 125 VPA[i].VPArrayNotes[ii].VPNotePitch = heresyPitch(ii, 1);
rebecca@36 126 VPA[i].VPArrayNotes[ii].VPNoteVelocity = tracks[i].sequence[ii][currentPulse%(tracks[i].loopLength)].noteVelocity;
rebecca@26 127 sendNote(VPA[i].VPArrayNotes[ii], i);
rebecca@26 128 }else{
rebecca@26 129 // println("in2...");
rebecca@26 130 if (i != 1 && i != 5)
rebecca@26 131 VPA[i].VPArrayNotes[ii].VPNotePitch = heresyPitch(ii, 3);
rebecca@26 132 else
rebecca@26 133 VPA[i].VPArrayNotes[ii].VPNotePitch = heresyPitch(ii, 1);
rebecca@36 134 VPA[i].VPArrayNotes[ii].VPNoteVelocity = tracks[i].sequence[ii][currentPulse%(tracks[i].loopLength)].noteVelocity;
rebecca@26 135 sendNote(VPA[i].VPArrayNotes[ii], i);
rebecca@26 136 }
rebecca@26 137 }
rebecca@26 138 if (tracks[i].sequence[ii][currentPulse%(tracks[i].loopLength)].noteVelocity == 0){
rebecca@26 139 VPA[i].VPArrayNotes[ii].VPNoteVelocity = 0;
rebecca@26 140 sendNote(VPA[i].VPArrayNotes[ii], i);
rebecca@26 141 }
rebecca@26 142 }
rebecca@26 143 }
rebecca@26 144 }
rebecca@26 145 }
rebecca@26 146 }
rebecca@26 147
rebecca@26 148
rebecca@26 149 //-------------------------------------------------------------------------------------------------------------------------------
rebecca@26 150
rebecca@26 151 /* public void heresyVoicingArray(){ // sets the voicing array to be used for note ons
rebecca@26 152 if (!heresy7th && !heresy9th && !heresy11th && !heresy13th) hvArray = hchoice135;
rebecca@26 153 if (heresy7th && !heresy9th && !heresy11th && !heresy13th) hvArray = hchoice7;
rebecca@26 154 if (!heresy7th && heresy9th && !heresy11th && !heresy13th) hvArray = hchoice9;
rebecca@26 155 if (!heresy7th && !heresy9th && heresy11th && !heresy13th) hvArray = hchoice11;
rebecca@26 156 if (!heresy7th && !heresy9th && !heresy11th && heresy13th) hvArray = hchoice13;
rebecca@26 157 if (heresy7th && heresy9th && !heresy11th && !heresy13th) hvArray = hchoice79;
rebecca@26 158 if (heresy7th && !heresy9th && heresy11th && !heresy13th) hvArray = hchoice711;
rebecca@26 159 if (heresy7th && !heresy9th && !heresy11th && heresy13th) hvArray = hchoice713;
rebecca@26 160 if (!heresy7th && heresy9th && heresy11th && !heresy13th) hvArray = hchoice911;
rebecca@26 161 if (!heresy7th && heresy9th && !heresy11th && heresy13th) hvArray = hchoice913;
rebecca@26 162 if (!heresy7th && !heresy9th && heresy11th && heresy13th) hvArray = hchoice1113;
rebecca@26 163 if (heresy7th && heresy9th && heresy11th && !heresy13th) hvArray = hchoice7911;
rebecca@26 164 if (heresy7th && heresy9th && !heresy11th && heresy13th) hvArray = hchoice7913;
rebecca@26 165 if (heresy7th && !heresy9th && !heresy11th && heresy13th) hvArray = hchoice71113;
rebecca@26 166 if (!heresy7th && heresy9th && heresy11th && heresy13th) hvArray = hchoice91113;
rebecca@26 167 }
rebecca@26 168
rebecca@26 169 */
rebecca@26 170
rebecca@26 171
rebecca@26 172 //-------------------------------------------------------------------------------------------------------------------------------
rebecca@26 173
rebecca@26 174 public void countNoteOns(){ // counts the note ons for all tracks
rebecca@26 175 for (int ii = 0; ii < 16; ii++){
rebecca@26 176 notesOnArray[ii] = 0;}
rebecca@26 177 for(int i = 1; i < Track.currentNumberOfTracks; i++){
rebecca@26 178 for (int ii = 0; ii < 16; ii++){
rebecca@26 179 if (VPA[i].VPArrayNotes[ii].VPNoteOn == true)
rebecca@26 180 notesOnArray[i]++;
rebecca@26 181 }
rebecca@26 182 }
rebecca@26 183 }
rebecca@26 184
rebecca@26 185
rebecca@26 186 //-------------------------------------------------------------------------------------------------------------------------------
rebecca@26 187
rebecca@26 188 /* public void calculateHeresyNoteExtensions(){
rebecca@26 189 for(int tracki = 1; tracki < Track.currentNumberOfTracks; tracki++){
rebecca@26 190 no1s = 0; no3s = 0; no5s = 0; no7s = 0; no9s = 0; no11s = 0; no13s = 0;
rebecca@26 191
rebecca@26 192 checkIfNotesAlreadyFit(tracki);
rebecca@26 193
rebecca@26 194 calcRemainingNotes(tracki);
rebecca@26 195
rebecca@26 196 for (int t = 0; t < 16; t++){
rebecca@26 197 VPA[tracki].VPArrayNotes[t].done = false;
rebecca@26 198 }
rebecca@26 199 }
rebecca@26 200 }
rebecca@26 201
rebecca@26 202 */
rebecca@26 203
rebecca@26 204
rebecca@26 205 //-------------------------------------------------------------------------------------------------------------------------------
rebecca@26 206
rebecca@26 207 /* public void calcRemainingNotes(int tracki){
rebecca@26 208 int counter = -1;
rebecca@26 209 int looped = 0;
rebecca@26 210 while (no1s + no3s + no5s + no7s + no9s + no11s + no13s != 0){
rebecca@26 211 counter++;
rebecca@26 212 if (counter >= notesOnArray[tracki]){
rebecca@26 213 counter = 0;
rebecca@26 214 looped++;
rebecca@26 215 }
rebecca@26 216 int nextExtension = hvArray[counter];
rebecca@26 217 if(extensionNeeded(nextExtension)){
rebecca@26 218 for (int playingNotesi = 0; playingNotesi < 16; playingNotesi++){
rebecca@26 219 if (VPA[tracki].VPArrayNotes[playingNotesi].VPNoteOn == true && !VPA[tracki].VPArrayNotes[playingNotesi].done){
rebecca@26 220 if (extensionPossible(playingNotesi, nextExtension)){
rebecca@26 221 VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch = getHeresyPitch(nextExtension, playingNotesi);
rebecca@26 222 VPA[tracki].VPArrayNotes[playingNotesi].done = true;
rebecca@26 223 println("got pitch " + VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch);
rebecca@26 224 // correctIfNeeded(tracki, playingNotesi, nextExtension);
rebecca@26 225 }else println("wasn't possible");
rebecca@26 226 }
rebecca@26 227 }
rebecca@26 228 }
rebecca@26 229 if (looped > 3) {
rebecca@26 230 for (int playingNotesi = 0; playingNotesi < 16; playingNotesi++){
rebecca@26 231 if (VPA[tracki].VPArrayNotes[playingNotesi].VPNoteOn == true && !VPA[tracki].VPArrayNotes[playingNotesi].done){
rebecca@26 232 VPA[tracki].VPArrayNotes[playingNotesi].VPNoteOn = false;
rebecca@26 233 VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch = -1;
rebecca@26 234 }
rebecca@26 235 }
rebecca@26 236 System.out.println("Had to break_________________");
rebecca@26 237 break;
rebecca@26 238 }
rebecca@26 239 }
rebecca@26 240 }
rebecca@26 241
rebecca@26 242 */
rebecca@26 243
rebecca@26 244
rebecca@26 245 //-------------------------------------------------------------------------------------------------------------------------------
rebecca@26 246
rebecca@26 247 /* 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 248 boolean alreadyGotNote = false; boolean alreadyGotNotePlus12 = false; boolean alreadyGotNoteMinus12 = false;
rebecca@26 249 int pitchAverage = 0;
rebecca@26 250 for (int i = 0; i < 16; i++)
rebecca@26 251 if (i != playingNotesi){
rebecca@26 252 if (VPA[tracki].VPArrayNotes[i].done)
rebecca@26 253 pitchAverage += VPA[tracki].VPArrayNotes[i].VPNotePitch;
rebecca@26 254 if (VPA[tracki].VPArrayNotes[i].VPNotePitch == VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch)
rebecca@26 255 alreadyGotNote = true;
rebecca@26 256 if (VPA[tracki].VPArrayNotes[i].VPNotePitch == VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch + 12)
rebecca@26 257 alreadyGotNotePlus12 = true;
rebecca@26 258 if (VPA[tracki].VPArrayNotes[i].VPNotePitch == VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch - 12)
rebecca@26 259 alreadyGotNoteMinus12 = true;
rebecca@26 260 }
rebecca@26 261 if (notesOnArray[tracki]-1 > 0)
rebecca@26 262 pitchAverage = pitchAverage / (notesOnArray[tracki]-1);
rebecca@26 263 else
rebecca@26 264 pitchAverage = VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch;
rebecca@26 265 boolean correctedIt = false;
rebecca@26 266 if (alreadyGotNote){
rebecca@26 267 println("correcting note..........");
rebecca@26 268 if (!alreadyGotNotePlus12 && pitchAverage > VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch){
rebecca@26 269 VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch = VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch + 12;
rebecca@26 270 correctedIt = true;
rebecca@26 271 }else
rebecca@26 272 if (!alreadyGotNoteMinus12){
rebecca@26 273 VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch = VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch - 12;
rebecca@26 274 correctedIt = true;
rebecca@26 275 }
rebecca@26 276 if (!alreadyGotNoteMinus12 && pitchAverage < VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch){
rebecca@26 277 VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch = VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch - 12;
rebecca@26 278 correctedIt = true;
rebecca@26 279 }else
rebecca@26 280 if (!alreadyGotNotePlus12){
rebecca@26 281 VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch = VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch + 12;
rebecca@26 282 correctedIt = true;
rebecca@26 283 }
rebecca@26 284 }
rebecca@26 285 if (alreadyGotNote && !correctedIt)
rebecca@26 286 VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch = -2;
rebecca@26 287 if (!alreadyGotNote || correctedIt){
rebecca@26 288 VPA[tracki].VPArrayNotes[playingNotesi].VPNoteVelocity = 80;
rebecca@26 289 VPA[tracki].VPArrayNotes[playingNotesi].done = true;
rebecca@26 290 VPA[tracki].VPArrayNotes[playingNotesi].played = false;
rebecca@26 291 extensionCounter(false, nextExtension);
rebecca@26 292 }else{
rebecca@26 293 VPA[tracki].VPArrayNotes[playingNotesi].VPNoteVelocity = 80;
rebecca@26 294 VPA[tracki].VPArrayNotes[playingNotesi].done = true;
rebecca@26 295 }
rebecca@26 296 }
rebecca@26 297
rebecca@26 298 */
rebecca@26 299
rebecca@26 300
rebecca@26 301 //-------------------------------------------------------------------------------------------------------------------------------
rebecca@26 302
rebecca@26 303
rebecca@26 304
rebecca@26 305 /* public void checkIfNotesAlreadyFit(int tracki){
rebecca@26 306 for (int extensioni = 0; extensioni < notesOnArray[tracki]; extensioni++){
rebecca@26 307 boolean extensionFound = false;
rebecca@26 308 for (int playingNotesi = 0; playingNotesi < 16; playingNotesi++){
rebecca@26 309 if (VPA[tracki].VPArrayNotes[playingNotesi].VPNoteOn && !VPA[tracki].VPArrayNotes[playingNotesi].done && !extensionFound && VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch >= 24){
rebecca@26 310 if (disiredPitch(VPA[tracki].VPArrayNotes[playingNotesi].VPNotePitch, hvArray[extensioni])){
rebecca@26 311 VPA[tracki].VPArrayNotes[playingNotesi].done = true;
rebecca@26 312 extensionFound = true;
rebecca@26 313 }
rebecca@26 314 }
rebecca@26 315 }
rebecca@26 316 if (!extensionFound){
rebecca@26 317 extensionCounter(true, hvArray[extensioni]);
rebecca@26 318 }
rebecca@26 319 }
rebecca@26 320 }
rebecca@26 321
rebecca@26 322 */
rebecca@26 323
rebecca@26 324
rebecca@26 325 //-------------------------------------------------------------------------------------------------------------------------------
rebecca@26 326
rebecca@26 327 /* public boolean pitchInChord(int currentPitch){
rebecca@26 328 boolean returnValue = false;
rebecca@26 329 for (int i = 0; i < 16; i++){
rebecca@26 330 // println("currentPitch " + currentPitch + " getHeresyPitch(hvArray[i], 5) % 12) " + (getHeresyPitch(hvArray[i], 5)));
rebecca@26 331 if (currentPitch % 12 == (getHeresyPitch(hvArray[i], 5) % 12));
rebecca@26 332 returnValue = true;
rebecca@26 333 }
rebecca@26 334 return returnValue;
rebecca@26 335 }
rebecca@26 336 */
rebecca@26 337
rebecca@26 338 //-------------------------------------------------------------------------------------------------------------------------------
rebecca@26 339
rebecca@26 340 /* public boolean extensionNeeded(int extension){
rebecca@26 341 boolean needed = false;
rebecca@26 342 if (extension == 1 && no1s > 0) needed = true;
rebecca@26 343 if (extension == 3 && no3s > 0) needed = true;
rebecca@26 344 if (extension == 5 && no5s > 0) needed = true;
rebecca@26 345 if (extension == 7 && no7s > 0) needed = true;
rebecca@26 346 if (extension == 9 && no9s > 0) needed = true;
rebecca@26 347 if (extension == 11 && no11s > 0) needed = true;
rebecca@26 348 if (extension == 13 && no13s > 0) needed = true;
rebecca@26 349 return needed;
rebecca@26 350 }
rebecca@26 351 */
rebecca@26 352
rebecca@26 353
rebecca@26 354 //-------------------------------------------------------------------------------------------------------------------------------
rebecca@26 355
rebecca@26 356 /* public int extensionMatch(){
rebecca@26 357 int returnValue = -1;
rebecca@26 358 for (int i = 0; i < 16; i++){
rebecca@26 359 if( hvArray[i] == 1 && no1s > 0){
rebecca@26 360 returnValue = hvArray[i];
rebecca@26 361 break;
rebecca@26 362 }
rebecca@26 363 if( hvArray[i] == 3 && no3s > 0){
rebecca@26 364 returnValue = hvArray[i];
rebecca@26 365 break;
rebecca@26 366 }
rebecca@26 367 if( hvArray[i] == 5 && no5s > 0){
rebecca@26 368 returnValue = hvArray[i];
rebecca@26 369 break;
rebecca@26 370 }
rebecca@26 371 if( hvArray[i] == 7 && no7s > 0){
rebecca@26 372 returnValue = hvArray[i];
rebecca@26 373 break;
rebecca@26 374 }
rebecca@26 375 if( hvArray[i] == 9 && no9s > 0){
rebecca@26 376 returnValue = hvArray[i];
rebecca@26 377 break;
rebecca@26 378 }
rebecca@26 379 if( hvArray[i] == 11 && no11s > 0){
rebecca@26 380 returnValue = hvArray[i];
rebecca@26 381 break;
rebecca@26 382 }
rebecca@26 383 if( hvArray[i] == 13 && no13s > 0){
rebecca@26 384 returnValue = hvArray[i];
rebecca@26 385 break;
rebecca@26 386 }
rebecca@26 387 }
rebecca@26 388 return returnValue;
rebecca@26 389 }
rebecca@26 390
rebecca@26 391 */
rebecca@26 392
rebecca@26 393
rebecca@26 394
rebecca@26 395
rebecca@26 396 //-------------------------------------------------------------------------------------------------------------------------------
rebecca@26 397
rebecca@26 398 /* public boolean extensionPossible(int playingNotesi, int extentionNeeded){
rebecca@26 399 Boolean returnValue = true;
rebecca@26 400 if (extentionNeeded != 1 && playingNotesi < 2) returnValue = false;
rebecca@26 401 if ((extentionNeeded == 5 || extentionNeeded == 7 || extentionNeeded == 1) && playingNotesi == 3) returnValue = false;
rebecca@26 402 if (!returnValue) println ("returning no on playingNotesi = " + playingNotesi + " and " + extentionNeeded);
rebecca@26 403 return returnValue;
rebecca@26 404 }
rebecca@26 405 */
rebecca@26 406
rebecca@26 407 //-------------------------------------------------------------------------------------------------------------------------------
rebecca@26 408
rebecca@26 409 /* 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 410 if (pitch % 12 == getExtentionPitch(extension) % 12)
rebecca@26 411 return true;
rebecca@26 412 else return false;
rebecca@26 413 }
rebecca@26 414 */
rebecca@26 415
rebecca@26 416 //-------------------------------------------------------------------------------------------------------------------------------
rebecca@26 417
rebecca@26 418 /* public int getExtentionPitch(int extension){ //
rebecca@26 419 if (!heresyMinor){
rebecca@26 420 if (currentChord-tonic == 1) return tritoneSystem[extension/2]+currentChord;
rebecca@26 421 if (currentChord-tonic == 7) return dom7System[extension/2]+currentChord;
rebecca@26 422 if (currentChord-tonic != 1 || currentChord-tonic != 7) return major7System[extension/2]+currentChord;
rebecca@26 423 }
rebecca@26 424 if (heresyMinor)
rebecca@26 425 return minorSystem[extension/2]+currentChord;
rebecca@26 426 else
rebecca@26 427 return -1;
rebecca@26 428 }
rebecca@26 429 */
rebecca@26 430
rebecca@26 431
rebecca@26 432 //-------------------------------------------------------------------------------------------------------------------------------
rebecca@26 433
rebecca@26 434 /* public void extensionCounter(boolean positive, int currentDesiredExtention){
rebecca@26 435 if (currentDesiredExtention == 1) if (positive) no1s++; else no1s--;
rebecca@26 436 if (currentDesiredExtention == 3) if (positive) no3s++; else no3s--;
rebecca@26 437 if (currentDesiredExtention == 5) if (positive) no5s++; else no5s--;
rebecca@26 438 if (currentDesiredExtention == 7) if (positive) no7s++; else no7s--;
rebecca@26 439 if (currentDesiredExtention == 9) if (positive) no9s++; else no9s--;
rebecca@26 440 if (currentDesiredExtention == 11) if (positive) no11s++; else no11s--;
rebecca@26 441 if (currentDesiredExtention == 13) if (positive) no13s++; else no13s--;
rebecca@26 442 }
rebecca@26 443 */
rebecca@26 444
rebecca@26 445 //-------------------------------------------------------------------------------------------------------------------------------
rebecca@26 446
rebecca@26 447 public void workOutExtensions(){ // calculates whether the performer wants chord extensions
rebecca@26 448 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 449 tracks[0].sequence[3][currentPulse%(tracks[0].loopLength)] = null;
rebecca@26 450 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 451 tracks[0].sequence[2][currentPulse%(tracks[0].loopLength)] = null;
rebecca@26 452 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 453 tracks[0].sequence[1][currentPulse%(tracks[0].loopLength)] = null;
rebecca@26 454 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 455 tracks[0].sequence[0][currentPulse%(tracks[0].loopLength)] = null;
rebecca@26 456
rebecca@26 457 if (tracks[0].sequence[3][currentPulse%(tracks[0].loopLength)] != null && tracks[0].sequence[3][currentPulse%(tracks[0].loopLength)].noteVelocity > 0)
rebecca@26 458 heresy7th = true;
rebecca@26 459 if (tracks[0].sequence[3][currentPulse%(tracks[0].loopLength)] != null && tracks[0].sequence[3][currentPulse%(tracks[0].loopLength)].noteVelocity == 0)
rebecca@26 460 heresy7th = false;
rebecca@26 461 if (tracks[0].sequence[2][currentPulse%(tracks[0].loopLength)] != null && tracks[0].sequence[2][currentPulse%(tracks[0].loopLength)].noteVelocity > 0)
rebecca@26 462 heresy9th = true;
rebecca@26 463 if (tracks[0].sequence[2][currentPulse%(tracks[0].loopLength)] != null && tracks[0].sequence[2][currentPulse%(tracks[0].loopLength)].noteVelocity == 0)
rebecca@26 464 heresy9th = false;
rebecca@26 465 if (tracks[0].sequence[1][currentPulse%(tracks[0].loopLength)] != null && tracks[0].sequence[1][currentPulse%(tracks[0].loopLength)].noteVelocity > 0)
rebecca@26 466 heresy11th = true;
rebecca@26 467 if (tracks[0].sequence[1][currentPulse%(tracks[0].loopLength)] != null && tracks[0].sequence[1][currentPulse%(tracks[0].loopLength)].noteVelocity == 0)
rebecca@26 468 heresy11th = false;
rebecca@26 469 if (tracks[0].sequence[0][currentPulse%(tracks[0].loopLength)] != null && tracks[0].sequence[0][currentPulse%(tracks[0].loopLength)].noteVelocity > 0)
rebecca@26 470 heresy13th = true;
rebecca@26 471 if (tracks[0].sequence[0][currentPulse%(tracks[0].loopLength)] != null && tracks[0].sequence[0][currentPulse%(tracks[0].loopLength)].noteVelocity == 0)
rebecca@26 472 heresy13th = false;
rebecca@26 473 //---
rebecca@26 474 if (chordsTemp.sequence[3][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[3][currentPulse%(chordsTemp.loopLength)].noteVelocity == 0 && trSelected == 0 && noteOnArray[3])
rebecca@26 475 chordsTemp.sequence[3][currentPulse%(chordsTemp.loopLength)] = null;
rebecca@26 476 if (chordsTemp.sequence[2][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[2][currentPulse%(chordsTemp.loopLength)].noteVelocity == 0 && trSelected == 0 && noteOnArray[2])
rebecca@26 477 chordsTemp.sequence[2][currentPulse%(chordsTemp.loopLength)] = null;
rebecca@26 478 if (chordsTemp.sequence[1][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[1][currentPulse%(chordsTemp.loopLength)].noteVelocity == 0 && trSelected == 0 && noteOnArray[1])
rebecca@26 479 chordsTemp.sequence[1][currentPulse%(chordsTemp.loopLength)] = null;
rebecca@26 480 if (chordsTemp.sequence[0][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[0][currentPulse%(chordsTemp.loopLength)].noteVelocity == 0 && trSelected == 0 && noteOnArray[0])
rebecca@26 481 chordsTemp.sequence[0][currentPulse%(chordsTemp.loopLength)] = null;
rebecca@26 482
rebecca@26 483 if (chordsTemp.sequence[3][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[3][currentPulse%(chordsTemp.loopLength)].noteVelocity > 0)
rebecca@26 484 heresy7th = true;
rebecca@26 485 if (chordsTemp.sequence[3][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[3][currentPulse%(chordsTemp.loopLength)].noteVelocity == 0)
rebecca@26 486 heresy7th = false;
rebecca@26 487 if (chordsTemp.sequence[2][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[2][currentPulse%(chordsTemp.loopLength)].noteVelocity > 0)
rebecca@26 488 heresy9th = true;
rebecca@26 489 if (chordsTemp.sequence[2][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[2][currentPulse%(chordsTemp.loopLength)].noteVelocity == 0)
rebecca@26 490 heresy9th = false;
rebecca@26 491 if (chordsTemp.sequence[1][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[1][currentPulse%(chordsTemp.loopLength)].noteVelocity > 0)
rebecca@26 492 heresy11th = true;
rebecca@26 493 if (chordsTemp.sequence[1][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[1][currentPulse%(chordsTemp.loopLength)].noteVelocity == 0)
rebecca@26 494 heresy11th = false;
rebecca@26 495 if (chordsTemp.sequence[0][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[0][currentPulse%(chordsTemp.loopLength)].noteVelocity > 0)
rebecca@26 496 heresy13th = true;
rebecca@26 497 if (chordsTemp.sequence[0][currentPulse%(chordsTemp.loopLength)] != null && chordsTemp.sequence[0][currentPulse%(chordsTemp.loopLength)].noteVelocity == 0)
rebecca@26 498 heresy13th = false;
rebecca@26 499
rebecca@26 500 }
rebecca@26 501
rebecca@26 502
rebecca@26 503 //-------------------------------------------------------------------------------------------------------------------------------
rebecca@26 504
rebecca@26 505 public void workOutChord(){ // calculates current chord and major minor tonality
rebecca@26 506 for (int i = 4; i < 16; i++) {
rebecca@26 507 if (tracks[0] != null){
rebecca@26 508 if ((tracks[0].sequence[i][currentPulse%(tracks[0].loopLength)] != null && tracks[0].sequence[i][currentPulse%(tracks[0].loopLength)].noteVelocity > 0 )||
rebecca@26 509 (chordsTemp.sequence[i][currentPulse%(tracks[0].loopLength)] != null && chordsTemp.sequence[i][currentPulse%(chordsTemp.loopLength)].noteVelocity > 0 )){
rebecca@26 510 currentChord = 15 - i;
rebecca@26 511 boolean iiDone = false;
rebecca@26 512 for (int ii = 0;; ii--){
rebecca@26 513 if (ii == 0 && iiDone)
rebecca@26 514 break;
rebecca@26 515 if (currentPulse%(tracks[0].loopLength)+ii == 0)
rebecca@26 516 ii = tracks[0].loopLength+ii-1;
rebecca@26 517 if (i > 3){
rebecca@26 518 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 519 (chordsTemp.sequence[i-1][currentPulse%(chordsTemp.loopLength)+ii] != null && chordsTemp.sequence[i-1][currentPulse%(chordsTemp.loopLength)+ii].noteVelocity == 0 ))
rebecca@26 520 break;
rebecca@26 521 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 522 (chordsTemp.sequence[i-1][currentPulse%(chordsTemp.loopLength)+ii] != null && chordsTemp.sequence[i-1][currentPulse%(chordsTemp.loopLength)+ii].noteVelocity != 0 )){
rebecca@26 523 heresyMinor = true;
rebecca@26 524 break;
rebecca@26 525 }else
rebecca@26 526 heresyMinor = false;
rebecca@26 527 }
rebecca@26 528 iiDone = true;
rebecca@26 529 }
rebecca@26 530 }
rebecca@26 531 }
rebecca@26 532 }
rebecca@26 533 }
rebecca@26 534
rebecca@26 535
rebecca@26 536 //-------------------------------------------------------------------------------------------------------------------------------
rebecca@26 537
rebecca@26 538 public void heresyChangeHistory(){ // remembers whether the chords or extensions have changed
rebecca@26 539 if (currentChord != lastChord){
rebecca@26 540 heresyChordChanged = true;
rebecca@26 541 lastChord = currentChord;
rebecca@26 542 heresyChange = true;
rebecca@26 543 }
rebecca@26 544 if (heresyMinor != oldHeresyMinor){
rebecca@26 545 heresyMinorChanged = true;
rebecca@26 546 oldHeresyMinor = heresyMinor;
rebecca@26 547 heresyChange = true;
rebecca@26 548 }
rebecca@26 549 if (heresy7th != oldHeresy7th){
rebecca@26 550 heresy7thChanged = true;
rebecca@26 551 oldHeresy7th = heresy7th;
rebecca@26 552 heresyChange = true;
rebecca@26 553 }
rebecca@26 554 if (heresy9th != oldHeresy9th){
rebecca@26 555 heresy9thChanged = true;
rebecca@26 556 oldHeresy9th = heresy9th;
rebecca@26 557 heresyChange = true;
rebecca@26 558 }
rebecca@26 559 if (heresy11th != oldHeresy11th){
rebecca@26 560 heresy11thChanged = true;
rebecca@26 561 oldHeresy11th = heresy11th;
rebecca@26 562 heresyChange = true;
rebecca@26 563 }
rebecca@26 564 if (heresy13th != oldHeresy13th){
rebecca@26 565 heresy13thChanged = true;
rebecca@26 566 oldHeresy13th = heresy13th;
rebecca@26 567 heresyChange = true;
rebecca@26 568 }
rebecca@26 569 }
rebecca@26 570
rebecca@26 571
rebecca@26 572
rebecca@26 573
rebecca@26 574