Class Note

java.lang.Object
org.jfugue.theory.Note
All Implemented Interfaces:
PatternProducer

public class Note extends Object implements PatternProducer
  • Field Details

    • originalString

      public String originalString
    • NOTE_NAMES_COMMON

      public static final String[] NOTE_NAMES_COMMON
    • NOTE_NAMES_SHARP

      public static final String[] NOTE_NAMES_SHARP
    • NOTE_NAMES_FLAT

      public static final String[] NOTE_NAMES_FLAT
    • PERCUSSION_NAMES

      public static final String[] PERCUSSION_NAMES
    • REST

      public static final Note REST
    • OCTAVE

      public static final byte OCTAVE
      See Also:
    • MIN_OCTAVE

      public static final byte MIN_OCTAVE
      See Also:
    • MAX_OCTAVE

      public static final byte MAX_OCTAVE
      See Also:
  • Constructor Details

    • Note

      public Note()
    • Note

      public Note(String note)
    • Note

      public Note(Note note)
    • Note

      public Note(int value)
    • Note

      public Note(byte value)
    • Note

      public Note(int value, double duration)
    • Note

      public Note(byte value, double duration)
  • Method Details

    • setValue

      public Note setValue(byte value)
    • getValue

      public byte getValue()
    • changeValue

      public Note changeValue(int delta)
    • setOctaveExplicitlySet

      public Note setOctaveExplicitlySet(boolean set)
    • getOctave

      public byte getOctave()
    • getDuration

      public double getDuration()
    • setDuration

      public Note setDuration(double d)
    • useDefaultDuration

      public Note useDefaultDuration()
    • useSameDurationAs

      public Note useSameDurationAs(Note note2)
    • useSameExplicitOctaveSettingAs

      public Note useSameExplicitOctaveSettingAs(Note note2)
    • setDuration

      public Note setDuration(String duration)
    • isDurationExplicitlySet

      public boolean isDurationExplicitlySet()
    • isOctaveExplicitlySet

      public boolean isOctaveExplicitlySet()
    • setImplicitDurationForTestingOnly

      public Note setImplicitDurationForTestingOnly(double d)
      FOR TESTING PURPOSES ONLY - avoids setting "isDurationExplicitlySet" - Please use setDuration instead!
    • setRest

      public Note setRest(boolean rest)
    • isRest

      public boolean isRest()
    • setPercussionNote

      public Note setPercussionNote(boolean perc)
    • isPercussionNote

      public boolean isPercussionNote()
    • setOnVelocity

      public Note setOnVelocity(byte velocity)
    • getOnVelocity

      public byte getOnVelocity()
    • setOffVelocity

      public Note setOffVelocity(byte velocity)
    • getOffVelocity

      public byte getOffVelocity()
    • setStartOfTie

      public Note setStartOfTie(boolean isStartOfTie)
    • setEndOfTie

      public Note setEndOfTie(boolean isEndOfTie)
    • isStartOfTie

      public boolean isStartOfTie()
    • isEndOfTie

      public boolean isEndOfTie()
    • setFirstNote

      public Note setFirstNote(boolean isFirstNote)
    • isFirstNote

      public boolean isFirstNote()
    • setMelodicNote

      public Note setMelodicNote(boolean isMelodicNote)
    • isMelodicNote

      public boolean isMelodicNote()
    • setHarmonicNote

      public Note setHarmonicNote(boolean isHarmonicNote)
    • isHarmonicNote

      public boolean isHarmonicNote()
    • setOriginalString

      public Note setOriginalString(String originalString)
    • getOriginalString

      public String getOriginalString()
    • getMicrosecondDuration

      public double getMicrosecondDuration(double mpq)
    • getPositionInOctave

      public byte getPositionInOctave()
    • isSameNote

      public static boolean isSameNote(String note1, String note2)
    • sortNotesBy

      public static void sortNotesBy(Note[] notes, org.jfugue.theory.Note.SortingCallback callback)
      This is just Bubble Sort, but allows you to pass a Note.SortingCallback that returns a value that you want to sort for a note. For example, to sort based on position in octave, your SortingCallback would return note.getPositionInOctave(). This lets you sort by note value, octave, position in octave, duration, velocity, and so on.
    • createRest

      public static Note createRest(double duration)
    • getToneString

      public static String getToneString(byte noteValue)
      Returns a MusicString representation of the given MIDI note value, which indicates a note and an octave.
      Parameters:
      noteValue - this MIDI note value, like 60
      Returns:
      a MusicString value, like C5
    • getToneStringWithoutOctave

      public static String getToneStringWithoutOctave(byte noteValue)
      Returns a MusicString representation of the given MIDI note value, but just the note - not the octave. This means that the value returned can not be used to accurately recalculate the noteValue, since information will be missing. But this is useful for knowing what note within any octave the corresponding value belongs to.
      Parameters:
      noteValue - this MIDI note value, like 60
      Returns:
      a MusicString value, like C
    • getDispositionedToneStringWithoutOctave

      public static String getDispositionedToneStringWithoutOctave(int dispose, byte noteValue)
      Returns a MusicString representation of the given MIDI note value, just the note (not the octave), disposed to use either flats or sharps. Pass -1 to get a flat name and +1 to get a sharp name for any notes that are accidentals.
      Parameters:
      dispose - -1 to get a flat value, +1 to get a sharp value
      noteValue - this MIDI note value, like 61
      Returns:
      a MusicString value, like Db if -1 or C# if +1
    • getPercussionString

      public static String getPercussionString(byte noteValue)
      Returns a MusicString representation of the given MIDI note value using the name of a percussion instrument.
      Parameters:
      noteValue - this MIDI note value, like 60
      Returns:
      a MusicString value, like [AGOGO]
    • getFrequencyForNote

      public static double getFrequencyForNote(String note)
      Returns the frequency, in Hertz, for the given note. For example, the frequency for A5 (MIDI note 69) is 440.0
      Parameters:
      noteValue - the MIDI note value
      Returns:
      frequency in Hertz
    • getFrequencyForNote

      public static double getFrequencyForNote(int noteValue)
      Returns the frequency, in Hertz, for the given note value. For example, the frequency for A5 (MIDI note 69) is 440.0
      Parameters:
      noteValue - the MIDI note value
      Returns:
      frequency in Hertz
    • isValidNote

      public static boolean isValidNote(String candidateNote)
    • isValidQualifier

      public static boolean isValidQualifier(String candidateQualifier)
    • getDurationString

      public static String getDurationString(double decimalDuration)
      Returns a MusicString representation of a decimal duration. This code currently only converts single duration values representing whole, half, quarter, eighth, etc. durations; and dotted durations associated with those durations (such as "h.", equal to 0.75). This method does not convert combined durations (for example, "hi" for 0.625). For these values, the original decimal duration is returned in a string, prepended with a "/" to make the returned value a valid MusicString duration indicator. It does handle durations greater than 1.0 (for example, "wwww" for 4.0).
      Parameters:
      decimalDuration - The decimal value of the duration to convert
      Returns:
      a MusicString fragment representing the duration
    • getDurationStringForBeat

      public static String getDurationStringForBeat(int beat)
    • getVelocityString

      public String getVelocityString()
    • getPattern

      public Pattern getPattern()
      Returns a pattern representing this note. Does not return indicators of whether the note is harmonic or melodic.
      Specified by:
      getPattern in interface PatternProducer
    • getPercussionPattern

      public Pattern getPercussionPattern()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toStringWithoutDuration

      public String toStringWithoutDuration()
    • getToneString

      public String getToneString()
    • getDecoratorString

      public String getDecoratorString()
      Returns the "decorators" to the base note, which includes the duration if one is explicitly specified, and velocity dynamics if provided
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • toDebugString

      public String toDebugString()