public static ArrayList<PitchCandidate> harmonicChecksSuperBasic(
      ArrayList<PitchCandidate> pitch_candidates,
      MelodicNote CF_note,
      Boolean CFnoteRoot,
      MelodicNote CP_note) {
    // begin Harmonic checks
    // Will need to evaluate each CP pitch candidate against the counterpoint notes
    // in each previously built voice

    // Evaluate Pitch Candidates Against these checke
    for (PitchCandidate myPC : pitch_candidates) {
      int this_interval = abs(myPC.getPitch() - CF_note.getPitch()) % 12;
      System.out.println("this interval  = " + this_interval);

      // compute interval whether consonant
      boolean this_interval_consonant = false;
      boolean root_interval_consonant = false;
      for (Integer consonance : consonances) {
        if (this_interval == consonance) this_interval_consonant = true;
      }
      if (this_interval_consonant) {
        System.out.println("this interval consonant");
      } else {
        if (CP_note.getAccent()) {
          // if (CP_note.getAccent() && CP_note.getStartTime() <= CF_note.getStartTime()) {
          myPC.decrementRank(Decrements.accented_dissonance);
          System.out.println("dissonant accent2");
        }
      }
    }
    return pitch_candidates;
  }
  public static ArrayList<PitchCandidate> harmonicChecks(
      ArrayList<PitchCandidate> pitch_candidates,
      MelodicNote CF_note,
      Boolean CFnoteRoot,
      Integer previous_cf_pitch,
      Integer previous_cp_pitch,
      MelodicNote CP_note,
      int voice_pitch_count,
      int cf_voice_index) {
    // begin Harmonic checks
    boolean cand_prev_cf_diss = true;
    // Will need to evaluate each CP pitch candidate against the counterpoint notes
    // in each previously built voice

    // Evaluate Pitch Candidates Against these checke
    for (PitchCandidate myPC : pitch_candidates) {
      Integer cand_pitch = myPC.getPitch();
      Integer cf_pitch = CF_note.getPitch();
      if (previous_cp_pitch == 9999)
        previous_cp_pitch = cand_pitch; // 9999 means the CP is held over to multiple cfs
      Integer melody_motion_to_cand = cand_pitch - previous_cp_pitch;
      int this_interval = abs(myPC.getPitch() - CF_note.getPitch()) % 12;
      // if (myPC.getLatestInterval(cf_voice_index) != null) previous_cf_pitch =
      // myPC.getLatestInterval(cf_voice_index); //NEW
      System.out.println("this interval  = " + this_interval);
      Integer melodic_motion_to_ = cf_pitch - previous_cf_pitch;
      Integer previous_interval = abs(previous_cp_pitch - previous_cf_pitch) % 12;
      System.out.println("previous interval  = " + previous_interval);
      Double cp_start_time = CP_note.getStartTime();
      Double cf_start_time = CF_note.getStartTime();

      // compute interval whether consonant
      boolean this_interval_consonant = false;
      for (Integer consonance : consonances) {
        if (this_interval == consonance) {
          this_interval_consonant = true;
          System.out.println(
              "this_interval == "
                  + consonance
                  + " means this_interval_consonant == "
                  + this_interval_consonant);
          break;
        }
      }

      if (this_interval_consonant) {
        System.out.println("this interval consonant");
        if (this_interval == 0) {
          myPC.decrementRank(Decrements.octave);
          System.out.println("octave");
        }
      } else {
        if (this_interval == 1
            && (abs(myPC.getPitch() - CF_note.getPitch()) < 14 || large_dissonance_bad)) {
          myPC.decrementRank(Decrements.minor_9th);
          System.out.println("minor 9th");
        }
        if (CP_note.getAccent()
            && (abs(myPC.getPitch() - CF_note.getPitch()) < 36 || large_dissonance_bad)) {
          // if (CP_note.getAccent() && CP_note.getStartTime()<= CF_note.getStartTime() ) {
          myPC.decrementRank(Decrements.accented_dissonance);
          System.out.println("dissonant accent");
        }
      }

      // compute previous_interval consonant
      boolean previous_interval_consonant = false;
      for (Integer consonance : consonances) {
        if (previous_interval == consonance) previous_interval_consonant = true;
      }
      if (previous_interval_consonant) System.out.println("previous interval consonant");

      if (cp_start_time > cf_start_time) {
        System.out.println("CP starts after CF");
        if (melody_motion_to_cand == 0) {
          myPC.decrementRank(Decrements.seq_of_same_cons);
        }
        if (previous_interval_consonant) {
          if (!this_interval_consonant && abs(melody_motion_to_cand) > 2) {
            myPC.decrementRank(Decrements.bad_diss_approach_from_cons);
          }
        } else if (this_interval_consonant) {
          if (abs(melody_motion_to_cand) > 2) {
            myPC.decrementRank(Decrements.bad_cons_approach_from_diss);
          }

        } else {
          if (abs(melody_motion_to_cand) > 4) { // New_Interval is dissonant
            myPC.decrementRank(Decrements.bad_diss_approach_from_diss);
          }
        }
      } else if (cp_start_time < cf_start_time) {
        System.out.println("CP starts before CF");
        if (previous_interval_consonant) {
          if (previous_interval == this_interval) {
            myPC.decrementRank(Decrements.seq_same_type_cons);
          }
        } else { // ie Previous_Interval is dissonant
          if (this_interval_consonant) {
            if (abs(melodic_motion_to_) > 2)
              myPC.decrementRank(Decrements.bad_cons_approach_from_diss);
          } else // New_Interval is dissonant
          if (abs(melodic_motion_to_) > 4)
            myPC.decrementRank(Decrements.bad_diss_approach_from_diss);
        }
      } else {
        System.out.println("CP and CF start at the same time");
        if (previous_interval_consonant) {
          if (this_interval_consonant) {
            for (Integer consonance : consonances) {
              if ((cand_pitch - previous_cf_pitch) % 12 == consonance) {
                cand_prev_cf_diss = false;
              }
            }

            if (cand_prev_cf_diss == true) myPC.decrementRank(Decrements.diss_cp_previous_cf);

            if (previous_interval == this_interval) {
              same_consonant_count++;
              if (same_consonant_count > same_consonant_threshold)
                myPC.decrementRank(Decrements.seq_of_same_cons);
            }
            // Too many of same type of interval
            for (Integer perfect_consonance : perfect_consonances) {
              if (this_interval == perfect_consonance) {
                if (this_interval == previous_interval) {
                  myPC.decrementRank(Decrements.seq_same_type_cons);
                  if (melody_motion_to_cand > 0)
                    if (melodic_motion_to_ > 0)
                      myPC.decrementRank(Decrements.parallel_perf_consonance);
                  if (melody_motion_to_cand < 0)
                    if (melodic_motion_to_ < 0)
                      myPC.decrementRank(Decrements.parallel_perf_consonance);
                }
              } else {
                if (melody_motion_to_cand > 0)
                  if (melodic_motion_to_ > 0)
                    myPC.decrementRank(Decrements.direct_motion_perf_cons);
                if (melody_motion_to_cand < 0)
                  if (melodic_motion_to_ < 0)
                    myPC.decrementRank(Decrements.direct_motion_perf_cons);
              }
            }
            // If dissonance between CP1 and CF2 is this resolved?
          } else // New_Interval is dissonant
          myPC.decrementRank(Decrements.motion_into_diss_both_voices_change);
        } else // ie Previous_Interval is dissonant
        if (this_interval_consonant) {

          for (Integer consonance : consonances) {
            if ((cand_pitch - previous_cp_pitch) % 12 == consonance) {
              cand_prev_cf_diss = false;
            }
          }

          if (cand_prev_cf_diss == true) myPC.decrementRank(Decrements.diss_cp_previous_cf);
          if (melody_motion_to_cand > 0)
            if (melodic_motion_to_ > 0) myPC.decrementRank(Decrements.direct_motion_perf_cons);
          if (melody_motion_to_cand < 0)
            if (melodic_motion_to_ < 0) myPC.decrementRank(Decrements.direct_motion_perf_cons);
        } else { // this interval is dissonant
          myPC.decrementRank(Decrements.motion_into_diss_both_voices_change);
          myPC.decrementRank(Decrements.seq_of_diss);
          if (this_interval == previous_interval) {
            myPC.decrementRank(Decrements.seq_same_type_diss);
            if (melody_motion_to_cand > 0)
              if (melodic_motion_to_ > 0) myPC.decrementRank(Decrements.direct_motion_into_diss);
            if (melody_motion_to_cand < 0)
              if (melodic_motion_to_ < 0) myPC.decrementRank(Decrements.direct_motion_into_diss);
          }
        }
      }
      myPC.setLatestInterval(cf_pitch, cf_voice_index);
    }
    return pitch_candidates;
  }
  public static void main(String[] args) {

    int number_of_voices = voice_array.length;
    Random my_roll = new Random();

    Pattern[] rhythm_patterns = james.generate(piece_length, number_of_voices);
    for (int i = 0; i < number_of_voices; i++) {
      MelodicVoice this_voice = new MelodicVoice();
      this_voice.setRange(voice_array[i]);
      AccentListener my_accent_listener = new AccentListener();
      this_voice.setNoteArray(my_accent_listener.listen(rhythm_patterns[i]));
      System.out.println("adding voice " + i + " to unbuiltvoices");
      unbuilt_voices.add(this_voice);
    }
    int ub_size = unbuilt_voices.size();
    for (int i = 0; i < number_of_voices; i++) {
      // int voice_index = my_roll.nextInt(unbuilt_voices.size());
      int voice_index = i;
      System.out.println(" about to build voice pitches for " + voice_index);
      MelodicVoice nextVoice =
          buildVoicePitches(unbuilt_voices.get(voice_index), number_of_voices, my_mode_module);
      ArrayList<MelodicNote> verify_array = nextVoice.getNoteArray();
      System.out.println("Return Me: ");
      for (MelodicNote verify : verify_array) {
        if (verify.getRest()) System.out.println("rest " + verify.getDuration() + "  ");
        else System.out.println(verify.getPitch() + " " + verify.getDuration() + "   ");
      }
      if (i == 0) {
        harmonic_prog = nextVoice;
        harmonic_prog_built = true;
      } else built_voices.add(nextVoice);
      // unbuilt_voices.remove(voice_index);
    }
    unbuilt_voices.clear();
    Pattern music_output = new Pattern();
    music_output.addElement(new Tempo(tempo_bpm));

    for (byte i = 0; i < built_voices.size(); i++) {
      // create a jfugue musicstring from the built voice
      MelodicVoice final_voice = built_voices.get(i);
      ArrayList<MelodicNote> final_note_array = final_voice.getNoteArray();
      Voice jf_voice = new Voice(i);
      music_output.addElement(jf_voice);
      for (MelodicNote final_note : final_note_array) {
        int jf_int = 0;
        Note jf_note = new Note();
        jf_note.setDecimalDuration(final_note.getDuration());
        if (final_note.getPitch() != null && final_note.getRest() == false) {
          jf_int = final_note.getPitch();
          byte jf_note_byte = (byte) jf_int;
          jf_note.setValue(jf_note_byte);
          if (!final_note.getAccent()) jf_note.setAttackVelocity((byte) 40);
        } else {
          // System.out.println("setting jf note to rest");
          jf_note.setRest(true);
          jf_note.setAttackVelocity((byte) 0);
          jf_note.setDecayVelocity((byte) 0);
        }

        music_output.addElement(jf_note);
      } // add the musicstring to a pattern
    }

    // save and play the pattern
    System.out.println(music_output.getMusicString());
    Player my_player = new Player();
    my_player.play(music_output);
    Date today = new Date(System.currentTimeMillis());
    // Date format: "yyyy-MM-dd_HH:mm:ss"
    SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("MM-dd-yyyy-HH-mm");
    String dateString = DATE_FORMAT.format(today);
    try {
      my_player.saveMidi(
          music_output,
          new File(
              "C:\\Documents and Settings\\alyssa\\Desktop\\Species Midi\\species-"
                  + tempo_bpm
                  + "-"
                  + dateString
                  + ".mid"));
    } catch (IOException ex) {
    }
  }