Example #1
0
  public static void populateContext(StaccatoParserContext context) {
    for (int i = 0; i < Note.PERCUSSION_NAMES.length; i++) {
      context.getDictionary().put(Note.PERCUSSION_NAMES[i], (byte) (i + 35));
    }

    // Also give a hand to Chord!

    for (String key : Chord.chordMap.keySet()) {
      context.getDictionary().put(key, Chord.chordMap.get(key));
    }
  }
Example #2
0
    /**
     * Creates a Note based on the settings in this NoteContext
     *
     * @return Note
     */
    public Note createNote(StaccatoParserContext parserContext) {
      try {
        if (noteValueAsString != null) {
          noteNumber = (Byte) parserContext.getDictionary().get(noteValueAsString);
        }
      } catch (NullPointerException e) {
        throw new RuntimeException(
            "JFugue NoteSubparser: Could not find '" + noteValueAsString + "' in dictionary.");
      }

      try {
        if (durationValueAsString != null) {
          decimalDuration = (Byte) parserContext.getDictionary().get(durationValueAsString);
        }
      } catch (NullPointerException e) {
        throw new RuntimeException(
            "JFugue NoteSubparser: Could not find '" + durationValueAsString + "' in dictionary.");
      }

      Note note = new Note(noteNumber);
      note.setOctaveExplicitlySet(isOctaveExplicitlySet);
      if (isDurationExplicitlySet) {
        note.setDuration(decimalDuration);
      }
      note.setOriginalString(originalString);
      note.setRest(isRest);

      if (hasNoteOnVelocity) {
        if (noteOnVelocityValueAsString != null) {
          noteOnVelocity = (Byte) parserContext.getDictionary().get(noteOnVelocityValueAsString);
        }
        note.setOnVelocity(noteOnVelocity);
      }

      if (hasNoteOffVelocity) {
        if (noteOffVelocityValueAsString != null) {
          noteOffVelocity = (Byte) parserContext.getDictionary().get(noteOffVelocityValueAsString);
        }
        note.setOffVelocity(noteOffVelocity);
      }

      note.setEndOfTie(isEndOfTie);
      note.setStartOfTie(isStartOfTie);
      note.setFirstNote(isFirstNote);
      note.setHarmonicNote(isHarmonicNote);
      note.setMelodicNote(isMelodicNote);

      return note;
    }
Example #3
0
    /**
     * Creates a Note based on the settings in this NoteContext
     *
     * @return Note
     */
    public Chord createChord(StaccatoParserContext parserContext) {
      if (noteValueAsString != null) {
        noteNumber = (Byte) parserContext.getDictionary().get(noteValueAsString);
      }
      if (durationValueAsString != null) {
        decimalDuration = (Byte) parserContext.getDictionary().get(durationValueAsString);
      }

      Note rootNote = createNote(parserContext);
      if (isChord) {
        Chord chord = new Chord(rootNote, intervals);
        if (!(inversionBassNote == null)) {
          chord.setBassNote(inversionBassNote);
        } else if (inversionCount > 0) {
          chord.setInversion(inversionCount);
        }
        return chord;
      }
      return null;
    }