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