java.lang.Object
provided.abcMusic.musicFW.Note
Basic class representing musical Notes.
----------------------------------------------
A playable note or rest.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
Accidental (normally in {-1, 0, +1})private double
Durationstatic String
The ID value of this classprivate boolean
Flag to override key signatureprivate char
Note name: {A, B, C, D, E, F, G, Z} (Z = rest)private int
Octave value -
Constructor Summary
ConstructorsConstructorDescriptionNote(char name, int octave, int accidental, double duration, boolean isNatural)
Constructor for the class -
Method Summary
Modifier and TypeMethodDescriptionexecute(IPhraseVisitor algo, Object... params)
Calls the Note.ID case of the visitor.int
Accessor to get the value of the accidentaldouble
Accessor to get the note duratonboolean
Accessor for isNatural flagchar
getName()
Accessor to get the name of the noteint
Accessor to get the octavevoid
setAccidental(int accidental)
Accessor to set the accidental valuevoid
setDuration(double duration)
Accessor to set the note durationvoid
setIsNatural(boolean isNatural)
Settor for isNatural flag.void
setName(char name)
Accessor to set the name of the notevoid
setOctave(int octave)
Accessor to set the octave of the notetoString()
Returns a string representation of the Note
-
Field Details
-
ID
The ID value of this class- See Also:
- Constant Field Values
-
name
private char nameNote name: {A, B, C, D, E, F, G, Z} (Z = rest) -
octave
private int octaveOctave value -
accidental
private int accidentalAccidental (normally in {-1, 0, +1}) -
duration
private double durationDuration -
isNatural
private boolean isNaturalFlag to override key signature
-
-
Constructor Details
-
Note
public Note(char name, int octave, int accidental, double duration, boolean isNatural)Constructor for the class- Parameters:
name
- The name of the noteoctave
- The octave of the note w.r.t. middle C. Zero = same octave as middle C.accidental
- accidental setting sharp > 0, flat < 0duration
- duration of noteisNatural
- flag to override key signature. True if note should be natural, overriding key signature.
-
-
Method Details
-
toString
Returns a string representation of the Note -
execute
Calls the Note.ID case of the visitor. -
setName
public void setName(char name)Accessor to set the name of the note- Parameters:
name
- - the name to set
-
getName
public char getName()Accessor to get the name of the note- Returns:
- the name
-
setOctave
public void setOctave(int octave)Accessor to set the octave of the note- Parameters:
octave
- - the octave to set
-
getOctave
public int getOctave()Accessor to get the octave- Returns:
- the octave
-
setAccidental
public void setAccidental(int accidental)Accessor to set the accidental value- Parameters:
accidental
- - the accidental to set
-
getAccidental
public int getAccidental()Accessor to get the value of the accidental- Returns:
- the accidental
-
setDuration
public void setDuration(double duration)Accessor to set the note duration- Parameters:
duration
- - the duration to set
-
getDuration
public double getDuration()Accessor to get the note duraton- Returns:
- the duration
-
getIsNatural
public boolean getIsNatural()Accessor for isNatural flag- Returns:
- isNatural flag setting
-
setIsNatural
public void setIsNatural(boolean isNatural)Settor for isNatural flag. Accidentals will be set to zero if isNatural is true.- Parameters:
isNatural
- New isNatural setting
-