Example #1
0
 public boolean[] getCurrentEnharmonics(int index) {
   Polylist tones = new Polylist();
   Chord currentChord = chordProg.getCurrentChord(index);
   if (currentChord != null && !currentChord.getName().equals(NOCHORD)) {
     try {
       tones = chordProg.getCurrentChord(index).getPriority();
     } catch (NullPointerException e) {
       tones = new Polylist();
       Trace.log(2, "Null pointer exception should be fixed in Score.getCurrentEnharmonics.");
       Trace.log(2, e.getStackTrace().toString());
     }
   }
   return getCurrentEnharmonics(index, tones);
 }
Example #2
0
  // Determine whether '#' or 'b' is visible in the lick triage utility, based on
  // whatever the current chord is.
  public boolean[] getCurrentEnharmonics(int index, Polylist tones) {
    boolean[] enh = new boolean[5];

    // We set the default visible accidental to '#' if we're in a sharp key; otherwise, set
    // the default to 'b'.
    if (keySig >= 0) {
      enh[CSHARP] = true;
      enh[DSHARP] = true;
      enh[FSHARP] = true;
      enh[GSHARP] = true;
      enh[ASHARP] = true;
    } else {
      enh[CSHARP] = false;
      enh[DSHARP] = false;
      enh[FSHARP] = false;
      enh[GSHARP] = false;
      enh[ASHARP] = false;
    }

    // Get the current chord if there is one.
    Chord current = chordProg.getCurrentChord(index);

    if (current == null || current.getName().equals(NOCHORD)) {
      return enh;
    }

    if (tones == null || tones.isEmpty()) {
      return enh;
    }

    // Look at all the chord tones in the list and determine whether we need to change
    // any accidental labels from '#' to 'b'
    while (tones.nonEmpty()) {
      NoteSymbol first = (NoteSymbol) tones.first();
      tones = tones.rest();

      if (first.getPitchString().length() > 1) {
        switch (first.getPitchString().charAt(0)) {
          case 'c':
            if (first.getPitchString().charAt(1) == '#') {
              enh[CSHARP] = true;
            }
            break;
          case 'd':
            if (first.getPitchString().charAt(1) == 'b') {
              enh[CSHARP] = false;
            } else if (first.getPitchString().charAt(1) == '#') {
              enh[DSHARP] = true;
            }
            break;
          case 'e':
            if (first.getPitchString().charAt(1) == 'b') {
              enh[DSHARP] = false;
            }
            break;
          case 'f':
            if (first.getPitchString().charAt(1) == '#') {
              enh[FSHARP] = true;
            }
          case 'g':
            if (first.getPitchString().charAt(1) == 'b') {
              enh[FSHARP] = false;
            } else if (first.getPitchString().charAt(1) == '#') {
              enh[GSHARP] = true;
            }
            break;
          case 'a':
            if (first.getPitchString().charAt(1) == 'b') {
              enh[GSHARP] = false;
            } else if (first.getPitchString().charAt(1) == '#') {
              enh[ASHARP] = true;
            }
            break;
          case 'b':
            if (first.getPitchString().charAt(1) == 'b') {
              enh[ASHARP] = false;
            }
            break;
        }
      }
    }
    return enh;
  }