Package org.jfugue.theory
Class Note
java.lang.Object
org.jfugue.theory.Note
- All Implemented Interfaces:
PatternProducer
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionchangeValue
(int delta) static Note
createRest
(double duration) boolean
Returns the "decorators" to the base note, which includes the duration if one is explicitly specified, and velocity dynamics if providedstatic 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.double
static String
getDurationString
(double decimalDuration) Returns a MusicString representation of a decimal duration.static String
getDurationStringForBeat
(int beat) static double
getFrequencyForNote
(int noteValue) Returns the frequency, in Hertz, for the given note value.static double
getFrequencyForNote
(String note) Returns the frequency, in Hertz, for the given note.double
getMicrosecondDuration
(double mpq) byte
byte
byte
Returns a pattern representing this note.static String
getPercussionString
(byte noteValue) Returns a MusicString representation of the given MIDI note value using the name of a percussion instrument.byte
static String
getToneString
(byte noteValue) Returns a MusicString representation of the given MIDI note value, which indicates a note and an octave.static String
getToneStringWithoutOctave
(byte noteValue) Returns a MusicString representation of the given MIDI note value, but just the note - not the octave.byte
getValue()
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
isRest()
static boolean
isSameNote
(String note1, String note2) boolean
static boolean
isValidNote
(String candidateNote) static boolean
isValidQualifier
(String candidateQualifier) setDuration
(double d) setDuration
(String duration) setEndOfTie
(boolean isEndOfTie) setFirstNote
(boolean isFirstNote) setHarmonicNote
(boolean isHarmonicNote) setImplicitDurationForTestingOnly
(double d) FOR TESTING PURPOSES ONLY - avoids setting "isDurationExplicitlySet" - Please use setDuration instead!setMelodicNote
(boolean isMelodicNote) setOctaveExplicitlySet
(boolean set) setOffVelocity
(byte velocity) setOnVelocity
(byte velocity) setOriginalString
(String originalString) setPercussionNote
(boolean perc) setRest
(boolean rest) setStartOfTie
(boolean isStartOfTie) setValue
(byte value) 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.toString()
useSameDurationAs
(Note note2)
-
Field Details
-
originalString
-
NOTE_NAMES_COMMON
-
NOTE_NAMES_SHARP
-
NOTE_NAMES_FLAT
-
PERCUSSION_NAMES
-
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
-
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
-
getValue
public byte getValue() -
changeValue
-
setOctaveExplicitlySet
-
getOctave
public byte getOctave() -
getDuration
public double getDuration() -
setDuration
-
useDefaultDuration
-
useSameDurationAs
-
useSameExplicitOctaveSettingAs
-
setDuration
-
isDurationExplicitlySet
public boolean isDurationExplicitlySet() -
isOctaveExplicitlySet
public boolean isOctaveExplicitlySet() -
setImplicitDurationForTestingOnly
FOR TESTING PURPOSES ONLY - avoids setting "isDurationExplicitlySet" - Please use setDuration instead! -
setRest
-
isRest
public boolean isRest() -
setPercussionNote
-
isPercussionNote
public boolean isPercussionNote() -
setOnVelocity
-
getOnVelocity
public byte getOnVelocity() -
setOffVelocity
-
getOffVelocity
public byte getOffVelocity() -
setStartOfTie
-
setEndOfTie
-
isStartOfTie
public boolean isStartOfTie() -
isEndOfTie
public boolean isEndOfTie() -
setFirstNote
-
isFirstNote
public boolean isFirstNote() -
setMelodicNote
-
isMelodicNote
public boolean isMelodicNote() -
setHarmonicNote
-
isHarmonicNote
public boolean isHarmonicNote() -
setOriginalString
-
getOriginalString
-
getMicrosecondDuration
public double getMicrosecondDuration(double mpq) -
getPositionInOctave
public byte getPositionInOctave() -
isSameNote
-
sortNotesBy
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
-
getToneString
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
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
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 valuenoteValue
- this MIDI note value, like 61- Returns:
- a MusicString value, like Db if -1 or C# if +1
-
getPercussionString
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
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
-
isValidQualifier
-
getDurationString
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
-
getVelocityString
-
getPattern
Returns a pattern representing this note. Does not return indicators of whether the note is harmonic or melodic.- Specified by:
getPattern
in interfacePatternProducer
-
getPercussionPattern
-
toString
-
toStringWithoutDuration
-
getToneString
-
getDecoratorString
Returns the "decorators" to the base note, which includes the duration if one is explicitly specified, and velocity dynamics if provided -
equals
-
toDebugString
-