abc4j API Specification

abc.notation
Class Note

java.lang.Object
  extended by abc.notation.NoteAbstract
      extended by abc.notation.Note
All Implemented Interfaces:
MusicElement
Direct Known Subclasses:
PositionableNote

public class Note
extends NoteAbstract

This class defines a (single) Note : height, rhythm, part of tuplet, rest etc... There can be some tricky representation of a duration for a note. For instance :
Tuplets

The first tuplet describes 3 quarter notes in the time of 2. So in that case, the representation of each note of tuplet as a Note object is :

The same applies to the second tuplet except that the strict duration of the notes composing the tuplet is Note.EIGHTH. Same for the third tuplet with a strict duration equals to Note.SIXTEENTH. Dots

When a note is dotted, its strict duration remains unchanged. The only difference between a non-dotted note and a dotted one can be retrieved from the method countDots() that returns the number of dots for a given Note instance. So in the example above :


Field Summary
static byte a
          The a note height type.
static byte A
          The A note height type : A440
static byte b
          The b note height type.
static byte B
          The B note height type.
static byte c
          The c note height type.
static byte C
          The C note height type.
static byte d
          The d note height type.
static byte D
          The D note height type.
static short DOTTED_EIGHTH
          The DOTTED_EIGHTH length type.
static short DOTTED_HALF
          The DOTTED_HALF length type.
static short DOTTED_QUARTER
          The DOTTED_QUARTER length type.
static short DOTTED_SIXTEENTH
          The DOTTED_SIXTEENTH length type.
static short DOTTED_SIXTY_FOURTH
          The DOTTED_SIXTY_FOURTH length type.
static short DOTTED_THIRTY_SECOND
          The DOTTED_THIRTY_SECOND length type.
static short DOTTED_WHOLE
          The DOTTED_WHOLE length type.
static byte e
          The e note height type.
static byte E
          The E note height type.
static short EIGHTH
          The EIGHTH length type.
static byte f
          The f note height type.
static byte F
          The F note height type.
static byte g
          The g note height type.
static byte G
          The G note height type.
static short HALF
          The HALF length type.
static short QUARTER
          The QUARTER length type.
static byte REST
          The REST height type.
static short SIXTEENTH
          The SIXTEENTH length type.
static short SIXTY_FOURTH
          The SIXTY_FOURTH length type.
static short THIRTY_SECOND
          The THIRTY_SECOND length type.
static short WHOLE
          The WHOLE length type.
 
Fields inherited from class abc.notation.NoteAbstract
DOWN, NONE, UP
 
Constructor Summary
Note(byte heightValue)
          Creates an abc note with the specified height.
Note(byte heightValue, byte accidentalValue)
          Creates an abc note with the specified heigth and accidental.
Note(byte heightValue, byte accidentalValue, byte octaveTranspositionValue)
          Creates an abc note with the specified heigth, accidental and octave transposition.
 
Method Summary
static byte convertToAccidentalType(java.lang.String accidental)
           
static short convertToNoteLengthStrict(int num, int denom)
           
static byte convertToNoteType(java.lang.String note)
           
 byte getAccidental()
          Returns accidental for this note if any.
 short getDuration()
          Returns the duration of this note.
 byte getHeight()
          Returns this note height.
 byte getHeigth()
          Deprecated. use getHeight() instead. Sorry for the typo....
static Note getHighestNote(Note[] notes)
           
static int getHighestNoteIndex(Note[] notes)
           
static Note getLowestNote(Note[] notes)
           
 byte getOctaveTransposition()
          Returns the octave transposition for this note.
static byte getOctaveTransposition(byte height)
          Returns the octave transposition for the specified height relative to its strict height.
 short getStrictDuration()
          Returns the strict duration of this note.
 byte getStrictHeight()
          Returns this note absolute height.
static byte getStrictHeight(byte height)
          Returns this note absolute height.
 TieDefinition getTieDefinition()
           
 boolean hasAccidental()
           
 boolean isBeginningTie()
          Returns true if this note is beginning a tie.
 boolean isEndingTie()
          Returns true if this note is ending a tie.
 boolean isHigherThan(Note aNote)
          Returns true if the given note is strictly higher than this one.
 boolean isLowerThan(Note aNote)
           
 boolean isRest()
          A convenient method that returns true if this note is a rest.
static boolean isStrictDuration(short noteDuration)
          Returns true if the duration of the note is one of the following : Note.WHOLE, Note.HALF, Note.QUARTER, Note.EIGHTH, Note.SIXTEENTH, Note.THIRTY_SECOND, Note.SIXTY_FOURTH.
 boolean isTied()
          Returns true if this note is tied.
 void setAccidental(byte accidentalValue)
          Sets the accidental for this note.
 void setDotted(byte dotsNb)
          Sets the number of dots for this note.
 void setDuration(short duration)
          Sets the length of this note.
 void setHeight(byte heightValue)
          Sets the height of this note.
 void setHeigth(byte heigthValue)
          Deprecated. use setHeight(byte heigthValue) instead. sorry for the typo...
 void setLength(short length)
          Deprecated. use setDuration(short duration) instead.
 void setOctaveTransposition(byte octaveTranspositionValue)
          Sets the octave transposition for this note.
 void setStrictDuration(short strictDuration)
          Sets the strict duration of this note.
 void setTieDefinition(TieDefinition tieDef)
          Sets the tie definition for this note.
 byte toRootOctaveHeigth()
          Deprecated. use getStrictHeight() instead
 java.lang.String toString()
          Returns a String representation of this Object.
 
Methods inherited from class abc.notation.NoteAbstract
countDots, getBow, getChordName, getDotted, getGracingNotes, getGracingNotesLength, getSlurDefinition, getTuplet, hasGeneralGracing, hasGracingNotes, hasStaccato, isBeginingSlur, isEndingSlur, isPartOfSlur, isPartOfTuplet, setBow, setChordName, setGeneralGracing, setGracingNotes, setPartOfSlur, setSlurDefinition, setStaccato
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

C

public static final byte C
The C note height type.

See Also:
Constant Field Values

D

public static final byte D
The D note height type.

See Also:
Constant Field Values

E

public static final byte E
The E note height type.

See Also:
Constant Field Values

F

public static final byte F
The F note height type.

See Also:
Constant Field Values

G

public static final byte G
The G note height type.

See Also:
Constant Field Values

A

public static final byte A
The A note height type : A440

See Also:
Constant Field Values

B

public static final byte B
The B note height type.

See Also:
Constant Field Values

c

public static final byte c
The c note height type.

See Also:
Constant Field Values

d

public static final byte d
The d note height type.

See Also:
Constant Field Values

e

public static final byte e
The e note height type.

See Also:
Constant Field Values

f

public static final byte f
The f note height type.

See Also:
Constant Field Values

g

public static final byte g
The g note height type.

See Also:
Constant Field Values

a

public static final byte a
The a note height type.

See Also:
Constant Field Values

b

public static final byte b
The b note height type.

See Also:
Constant Field Values

REST

public static final byte REST
The REST height type.

See Also:
Constant Field Values

DOTTED_WHOLE

public static final short DOTTED_WHOLE
The DOTTED_WHOLE length type.

See Also:
Constant Field Values

WHOLE

public static final short WHOLE
The WHOLE length type.

See Also:
Constant Field Values

DOTTED_HALF

public static final short DOTTED_HALF
The DOTTED_HALF length type.

See Also:
Constant Field Values

HALF

public static final short HALF
The HALF length type.

See Also:
Constant Field Values

DOTTED_QUARTER

public static final short DOTTED_QUARTER
The DOTTED_QUARTER length type.

See Also:
Constant Field Values

QUARTER

public static final short QUARTER
The QUARTER length type.

See Also:
Constant Field Values

DOTTED_EIGHTH

public static final short DOTTED_EIGHTH
The DOTTED_EIGHTH length type.

See Also:
Constant Field Values

EIGHTH

public static final short EIGHTH
The EIGHTH length type.

See Also:
Constant Field Values

DOTTED_SIXTEENTH

public static final short DOTTED_SIXTEENTH
The DOTTED_SIXTEENTH length type.

See Also:
Constant Field Values

SIXTEENTH

public static final short SIXTEENTH
The SIXTEENTH length type.

See Also:
Constant Field Values

DOTTED_THIRTY_SECOND

public static final short DOTTED_THIRTY_SECOND
The DOTTED_THIRTY_SECOND length type.

See Also:
Constant Field Values

THIRTY_SECOND

public static final short THIRTY_SECOND
The THIRTY_SECOND length type.

See Also:
Constant Field Values

DOTTED_SIXTY_FOURTH

public static final short DOTTED_SIXTY_FOURTH
The DOTTED_SIXTY_FOURTH length type.

See Also:
Constant Field Values

SIXTY_FOURTH

public static final short SIXTY_FOURTH
The SIXTY_FOURTH length type.

See Also:
Constant Field Values
Constructor Detail

Note

public Note(byte heightValue)
Creates an abc note with the specified height. Accidental will inherit its default value AccidentalType.NONE.

Parameters:
heightValue - The heigth of this note as a byte that respect the scale defined by constants such as C D E F G A B c d e ..... The heigth is REST if this note is a rest.
See Also:
setHeight(byte)

Note

public Note(byte heightValue,
            byte accidentalValue)
Creates an abc note with the specified heigth and accidental.

Parameters:
heightValue - The heigth of this note as a byte that respect the scale defined by constants such as C D E F G A B c d e ..... The heigth is REST if this note is a rest.
accidentalValue - Accidental for this note. Possible values are AccidentalType.NATURAL, AccidentalType.SHARP (#), AccidentalType.FLAT (b) or AccidentalType.NONE.
See Also:
setAccidental(byte), setHeight(byte)

Note

public Note(byte heightValue,
            byte accidentalValue,
            byte octaveTranspositionValue)
Creates an abc note with the specified heigth, accidental and octave transposition.

Parameters:
heightValue - The heigth of this note as a byte that respect the scale defined by constants such as C D E F G A B c d e ..... The heigth is REST if this note is a rest.
accidentalValue - Accidental for this note. Possible values are AccidentalType.NATURAL, AccidentalType.SHARP (#), AccidentalType.FLAT (b) or AccidentalType.NONE.
octaveTranspositionValue - The octave transposition for this note : 1, 2 or 3 means "1, 2 or 3 octave(s) higher than the reference octave" and -1, -2 or -3 means "1, 2 or 3 octave(s) less than the reference octave".
See Also:
setAccidental(byte), setOctaveTransposition(byte), setHeight(byte)
Method Detail

setHeigth

public void setHeigth(byte heigthValue)
Deprecated. use setHeight(byte heigthValue) instead. sorry for the typo...

Sets the height of this note.

Parameters:
heigthValue - The height of this note. The height is REST if this note is a rest.
See Also:
setHeight(byte)

setHeight

public void setHeight(byte heightValue)
               throws java.lang.IllegalArgumentException
Sets the height of this note. Accidentals are not taken into account in this value, Ex: using this method you will be able to specify that your note is a C but not a C#. To express the sharp, you'll have to use the setAccidental(byte) method.

Parameters:
heightValue - The height of this note as a byte that respect the scale defined by constants such as C D E F G A B c d e ..... The height is REST if this note is a rest.
Throws:
java.lang.IllegalArgumentException
See Also:
getHeight(), setAccidental(byte)

getHeigth

public byte getHeigth()
Deprecated. use getHeight() instead. Sorry for the typo....

Returns this note absolute height. This height doesn't take in account takes into account octave transposition.

Returns:
This note height.
See Also:
getHeight()

getHeight

public byte getHeight()
Returns this note height. This height doesn't take in account takes into account octave transposition. This height is not the height of the note itself (like how it would be played using midi for instance) but the height of its representation on a score. For instance 2 notes written C and C# would have the same value returned by getHeight(). They would only differ with their accidental value returned by getAccidental().

Returns:
The heigth of this note as a byte that respect the scale defined by constants such as C D E F G A B c d e ....
See Also:
getStrictHeight(), setHeight(byte)

isHigherThan

public boolean isHigherThan(Note aNote)
Returns true if the given note is strictly higher than this one.

Parameters:
aNote - A note instance.
Returns:
true if the given note is strictly higher than this one, false otherwise.
See Also:
isLowerThan(Note)

isLowerThan

public boolean isLowerThan(Note aNote)

getStrictHeight

public byte getStrictHeight()
Returns this note absolute height. This height doesn't take in account octave transposition.

Returns:
The height of this note on the first octave. Possible values are C, D, E, F, G, A(404), B or REST only.
See Also:
getHeight(), setHeight(byte)

getStrictHeight

public static byte getStrictHeight(byte height)
Returns this note absolute height. This height doesn't take in account octave transposition.

Parameters:
height - A height of a note as a byte that respect the scale defined by constants such as C D E F G A B c d e ....
Returns:
The height of this note on the first octave. Possible values are C, D, E, F, G, A(404) B or REST only.
See Also:
getHeight()

getOctaveTransposition

public static byte getOctaveTransposition(byte height)
Returns the octave transposition for the specified height relative to its strict height. For instance, the octave transposition of Note.c is 1 because it is one octave higher than its strict height Note.C.

Parameters:
height - A height as a byte that respect the scale defined by constants such as C D E F G A B c d e ....
Returns:
The number of octave(s), to reach the given height from the stric height. A positive value is returned if the height is higher than the strict height, negative otherwise.

toRootOctaveHeigth

public byte toRootOctaveHeigth()
Deprecated. use getStrictHeight() instead

Returns the heigth of this note on the first octave.

Returns:
the heigth of this note on the first octave. Possible values are C, D, E, F, G, A(404) or B.
See Also:
getStrictHeight()

setOctaveTransposition

public void setOctaveTransposition(byte octaveTranspositionValue)
Sets the octave transposition for this note.

Parameters:
octaveTranspositionValue - The octave transposition for this note : 1, 2 or 3 means "1, 2 or 3 octave(s) higher than the reference octave" and -1, -2 or -3 means "1, 2 or 3 octave(s) less than the reference octave".

getOctaveTransposition

public byte getOctaveTransposition()
Returns the octave transposition for this note.

Returns:
The octave transposition for this note. Default is 0.
See Also:
setOctaveTransposition(byte)

setLength

public void setLength(short length)
Deprecated. use setDuration(short duration) instead.

Sets the length of this note.

Parameters:
length - The length of this note as a value adjusted to the scale of constants such as Note.WHOLE, Note.HALF etc etc ...
See Also:
setDuration(short)

setDuration

public void setDuration(short duration)
Sets the length of this note. However, it is recommended to represent the note duration using methods such as setStrictDuration(short strictDuration), setDotted(byte dotted) etc etc as explained at the beginning of this class description.

Parameters:
duration - The length of this note as a value adjusted to the scale of constants such as Note.WHOLE, Note.HALF etc etc ...
See Also:
getDuration()

setStrictDuration

public void setStrictDuration(short strictDuration)
                       throws java.lang.IllegalArgumentException
Sets the strict duration of this note.

Parameters:
strictDuration - This note strict duration. Possible values are ONLY Note.WHOLE, Note.HALF, Note.QUARTER, Note.EIGHTH, Note.SIXTEENTH, Note.THIRTY_SECOND, Note.SIXTY_FOURTH.
Throws:
java.lang.IllegalArgumentException - Thrown if the given duration does not match the excepted ones.

getStrictDuration

public short getStrictDuration()
Returns the strict duration of this note.

Returns:
The strict duration of this note. The dot, tuplet whatever... are taken NOT into account for the duration returned by this function. The possible returned values are : Note.WHOLE, Note.HALF, Note.QUARTER, Note.EIGHTH, Note.SIXTEENTH, Note.THIRTY_SECOND, Note.SIXTY_FOURTH or -1 if this note duration is not expressed using (strict duration + dots + tuplet) but with an exotic duration (that can be retrieved using getDuration() in that case).
See Also:
getDuration()

getDuration

public short getDuration()
Returns the duration of this note. The duration returned here takes into account if the note is dotted, part of a tuplet and so on ... (as opposed to getStrictDuration() that only refers to the "pure" note)

Returns:
The duration of this note as a value adjusted to the scale of constants such as Note.WHOLE, Note.HALF etc etc ...
See Also:
setLength(short), getStrictDuration()

setAccidental

public void setAccidental(byte accidentalValue)
Sets the accidental for this note.

Parameters:
accidentalValue - Accidental for this note. Possible values are AccidentalType.NATURAL, AccidentalType.SHARP (#), AccidentalType.FLAT (b) or AccidentalType.NONE.

getAccidental

public byte getAccidental()
Returns accidental for this note if any.

Returns:
Accidental for this note if any. Possible values are AccidentalType.NATURAL, AccidentalType.FLAT, AccidentalType.SHARP or AccidentalType.NONE.
See Also:
setAccidental(byte)

hasAccidental

public boolean hasAccidental()

setTieDefinition

public void setTieDefinition(TieDefinition tieDef)
Sets the tie definition for this note.

Parameters:
tieDef - The definition of the tie if this note is tied. NULL if the note should not be tied.
See Also:
isTied()

getTieDefinition

public TieDefinition getTieDefinition()

isBeginningTie

public boolean isBeginningTie()
Returns true if this note is beginning a tie.

Returns:
true if this note is beginning a tie, false otherwise.

isEndingTie

public boolean isEndingTie()
Returns true if this note is ending a tie.

Returns:
true if this note is ending a tie, false otherwise.

isTied

public boolean isTied()
Returns true if this note is tied.

Returns:
true if this note is tied, false otherwise.
See Also:
setTieDefinition(TieDefinition)

isRest

public boolean isRest()
A convenient method that returns true if this note is a rest. A note is a rest if its height returned by getHeight() or getStrictHeight() is equals to Note.REST.

Returns:
true if this note is a rest, false otherwise.

setDotted

public void setDotted(byte dotsNb)
Sets the number of dots for this note.

Overrides:
setDotted in class NoteAbstract
Parameters:
dotsNb - The number of dots for this note.
See Also:
NoteAbstract.countDots()

convertToNoteType

public static byte convertToNoteType(java.lang.String note)

convertToNoteLengthStrict

public static short convertToNoteLengthStrict(int num,
                                              int denom)
                                       throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

convertToAccidentalType

public static byte convertToAccidentalType(java.lang.String accidental)
                                    throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

toString

public java.lang.String toString()
Description copied from class: NoteAbstract
Returns a String representation of this Object.

Overrides:
toString in class NoteAbstract
Returns:
a String representation of this Object.

isStrictDuration

public static boolean isStrictDuration(short noteDuration)
Returns true if the duration of the note is one of the following : Note.WHOLE, Note.HALF, Note.QUARTER, Note.EIGHTH, Note.SIXTEENTH, Note.THIRTY_SECOND, Note.SIXTY_FOURTH.

Parameters:
noteDuration - The note duration to be checked
Returns:
true if the duration of the note is one of the following : Note.WHOLE, Note.HALF, Note.QUARTER, Note.EIGHTH, Note.SIXTEENTH, Note.THIRTY_SECOND, Note.SIXTY_FOURTH. false otherwise.

getHighestNote

public static Note getHighestNote(Note[] notes)

getHighestNoteIndex

public static int getHighestNoteIndex(Note[] notes)

getLowestNote

public static Note getLowestNote(Note[] notes)

abc4j API Specification

Submit a bug or feature