org.jfugue
Class Note

java.lang.Object
  extended by org.jfugue.Note
All Implemented Interfaces:
JFugueElement

public final class Note
extends java.lang.Object
implements JFugueElement

Contains all information necessary for a musical note, including pitch, duration, attack velocity, and decay velocity.

Most of these settings have defaults. The default octave is 5. The default duration is a quarter note. The default attack and decay velocities are 64.

Version:
2.0.1
Author:
David Koelle

Field Summary
static byte ACOUSTIC_BASS_DRUM
           
static byte ACOUSTIC_SNARE
           
static byte BASS_DRUM
           
static byte CABASA
           
static byte CHINESE_CYMBAL
           
static byte CLAVES
           
static byte CLOSED_HI_HAT
           
static byte COWBELL
           
static byte CRASH_CYMBAL_1
           
static byte CRASH_CYMBAL_2
           
static byte DEFAULT_VELOCITY
          Default value for attack and decay velocity.
static byte ELECTRIC_SNARE
           
static byte FIRST
          Indicates that this note is the first note in the token.
static byte HAND_CLAP
           
static byte HI_BONGO
           
static byte HI_MID_TOM
           
static byte HI_WOOD_BLOCK
           
static byte HIGH_AGOGO
           
static byte HIGH_FLOOR_TOM
           
static byte HIGH_TIMBALE
           
static byte HIGH_TOM
           
static byte LONG_GUIRO
           
static byte LONG_WHISTLE
           
static byte LOW_AGOGO
           
static byte LOW_BONGO
           
static byte LOW_CONGA
           
static byte LOW_FLOOR_TOM
           
static byte LOW_MID_TOM
           
static byte LOW_TIMBALE
           
static byte LOW_TOM
           
static byte LOW_WOOD_BLOCK
           
static byte MARACAS
           
static byte MUTE_CUICA
           
static byte MUTE_HI_CONGA
           
static byte MUTE_TRIANGLE
           
static java.lang.String[] NOTES
           
static byte OPEN_CUICA
           
static byte OPEN_HI_CONGA
           
static byte OPEN_HI_HAT
           
static byte OPEN_TRIANGLE
           
static byte PARALLEL
          Indicates that this note is played at the same time as a previous note in the same token.
static byte PEDAL_HI_HAT
           
static byte RIDE_BELL
           
static byte RIDE_CYMBAL_1
           
static byte RIDE_CYMBAL_2
           
static byte SEQUENTIAL
          Indicates that this note immediately follows a previous note in the same token.
static byte SHORT_GUIRO
           
static byte SHORT_WHISTLE
           
static byte SIDE_STICK
           
static byte SPLASH_CYMBAL
           
static byte TAMBOURINE
           
static byte VIBRASLAP
           
 
Constructor Summary
Note()
          Instantiates a new Note object.
Note(byte value)
          Instantiates a new Note object with the given note value.
Note(byte value, double decimalDuration)
          Instantiates a new Note object with the given note value and duration.
Note(byte value, double decimalDuration, byte attackVelocity, byte decayVelocity)
          Instantiates a new Note object with the given note value, duration, and attack and decay velocities.
Note(byte value, long duration)
          Instantiates a new Note object with the given note value and duration.
Note(byte value, long duration, byte attackVelocity, byte decayVelocity)
          Instantiates a new Note object with the given note value, duration, and attack and decay velocities.
 
Method Summary
static java.lang.String createCompoundVerifyString(java.lang.String... strings)
          Easily create compound note verification strings, like: Note: value=60, duration=1.0, startTie=F, endTie=F, attack=64, decay=64, isFirst=T, isParallel=F, isSequential=F; Note: value=63, duration=0.0, startTie=F, endTie=F, attack=64, decay=64, isFirst=F, isParallel=T, isSequential=F
static java.lang.String createVerifyString(int value, double duration)
           
static java.lang.String createVerifyString(int value, double duration, boolean startTie, boolean endTie)
           
static java.lang.String createVerifyString(int value, double duration, boolean isFirst, boolean isParallel, boolean isSequential)
           
static java.lang.String createVerifyString(int value, double duration, boolean startTie, boolean endTie, int attack, int decay, boolean isFirst, boolean isParallel, boolean isSequential)
           
static java.lang.String createVerifyString(int value, double duration, int attack, int decay)
           
 byte getAttackVelocity()
          Returns the attack velocity for this note.
 byte getDecayVelocity()
          Returns the decay velocity for this note.
 double getDecimalDuration()
          Returns the decimal fraction value for the duration.
static double getDecimalForDuration(java.lang.String stringDuration)
          Returns the decimal duration that is equal to the given MusicString representation.
 long getDuration()
          Returns the duration of this note.
static double getFrequencyForNote(int noteValue)
          Returns the frequency, in Hertz, for the given note value.
 java.lang.String getMusicString()
          Returns the Music String representing this element and all of its settings.
static java.lang.String getStringForDuration(double decimalDuration)
          Returns a MusicString representation of a decimal duration.
static java.lang.String getStringForNote(byte noteValue)
          Returns a MusicString representation of the given MIDI note value -- which indicates a note and an octave.
static java.lang.String getStringForNote(byte noteValue, double decimalDuration)
          Returns a MusicString representation of the given MIDI note value and duration -- which indicates a note and an octave.
 byte getType()
          Returns the note type - either First, Sequential, or Parallel.
 byte getValue()
          Returns the numeric value of this note.
 java.lang.String getVerifyString()
          Returns verification string in this format: Note: value={#}, duration={#}, startTie={T|F}, endTie={T|F}, attack={#}, decay={#}, isFirst={T|F}, isParallel={T|F}, isSequential={T|F}
 boolean hasAccompanyingNotes()
          Returns whether this Note will have other Notes (sequential or parallel) associated with it.
 boolean isEndOfTie()
          Returns whether this note is tied to some past note.
 boolean isRest()
          Returns whether this Note object actually represents a rest.
 boolean isStartOfTie()
          Returns whether this note has a tie to some future note.
 void setAttackVelocity(byte velocity)
          Sets the attack velocity for this note.
 void setDecayVelocity(byte velocity)
          Sets the decay velocity for this note.
 void setDecimalDuration(double duration)
          Sets the decimal fraction value for the duration.
 void setDuration(long duration)
          Sets the duration of this note.
 void setEndOfTie(boolean endOfTie)
          Indicates whether this note is tied to some past note.
 void setHasAccompanyingNotes(boolean accompanying)
          Sets whether this Note will have other Notes (sequential or parallel) associated with it.
 void setRest(boolean rest)
          Indicates whether this Note object actually represents a rest.
 void setStartOfTie(boolean startOfTie)
          Indicates whether this note has a tie to some future note.
 void setType(byte type)
          Sets the note type - either First, Sequential, or Parallel.
 void setValue(byte value)
          Sets the numeric value of this note.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FIRST

public static final byte FIRST
Indicates that this note is the first note in the token.

See Also:
Constant Field Values

SEQUENTIAL

public static final byte SEQUENTIAL
Indicates that this note immediately follows a previous note in the same token.

See Also:
Constant Field Values

PARALLEL

public static final byte PARALLEL
Indicates that this note is played at the same time as a previous note in the same token.

See Also:
Constant Field Values

DEFAULT_VELOCITY

public static final byte DEFAULT_VELOCITY
Default value for attack and decay velocity.

See Also:
Constant Field Values

NOTES

public static final java.lang.String[] NOTES

ACOUSTIC_BASS_DRUM

public static final byte ACOUSTIC_BASS_DRUM
See Also:
Constant Field Values

BASS_DRUM

public static final byte BASS_DRUM
See Also:
Constant Field Values

SIDE_STICK

public static final byte SIDE_STICK
See Also:
Constant Field Values

ACOUSTIC_SNARE

public static final byte ACOUSTIC_SNARE
See Also:
Constant Field Values

HAND_CLAP

public static final byte HAND_CLAP
See Also:
Constant Field Values

ELECTRIC_SNARE

public static final byte ELECTRIC_SNARE
See Also:
Constant Field Values

LOW_FLOOR_TOM

public static final byte LOW_FLOOR_TOM
See Also:
Constant Field Values

CLOSED_HI_HAT

public static final byte CLOSED_HI_HAT
See Also:
Constant Field Values

HIGH_FLOOR_TOM

public static final byte HIGH_FLOOR_TOM
See Also:
Constant Field Values

PEDAL_HI_HAT

public static final byte PEDAL_HI_HAT
See Also:
Constant Field Values

LOW_TOM

public static final byte LOW_TOM
See Also:
Constant Field Values

OPEN_HI_HAT

public static final byte OPEN_HI_HAT
See Also:
Constant Field Values

LOW_MID_TOM

public static final byte LOW_MID_TOM
See Also:
Constant Field Values

HI_MID_TOM

public static final byte HI_MID_TOM
See Also:
Constant Field Values

CRASH_CYMBAL_1

public static final byte CRASH_CYMBAL_1
See Also:
Constant Field Values

HIGH_TOM

public static final byte HIGH_TOM
See Also:
Constant Field Values

RIDE_CYMBAL_1

public static final byte RIDE_CYMBAL_1
See Also:
Constant Field Values

CHINESE_CYMBAL

public static final byte CHINESE_CYMBAL
See Also:
Constant Field Values

RIDE_BELL

public static final byte RIDE_BELL
See Also:
Constant Field Values

TAMBOURINE

public static final byte TAMBOURINE
See Also:
Constant Field Values

SPLASH_CYMBAL

public static final byte SPLASH_CYMBAL
See Also:
Constant Field Values

COWBELL

public static final byte COWBELL
See Also:
Constant Field Values

CRASH_CYMBAL_2

public static final byte CRASH_CYMBAL_2
See Also:
Constant Field Values

VIBRASLAP

public static final byte VIBRASLAP
See Also:
Constant Field Values

RIDE_CYMBAL_2

public static final byte RIDE_CYMBAL_2
See Also:
Constant Field Values

HI_BONGO

public static final byte HI_BONGO
See Also:
Constant Field Values

LOW_BONGO

public static final byte LOW_BONGO
See Also:
Constant Field Values

MUTE_HI_CONGA

public static final byte MUTE_HI_CONGA
See Also:
Constant Field Values

OPEN_HI_CONGA

public static final byte OPEN_HI_CONGA
See Also:
Constant Field Values

LOW_CONGA

public static final byte LOW_CONGA
See Also:
Constant Field Values

HIGH_TIMBALE

public static final byte HIGH_TIMBALE
See Also:
Constant Field Values

LOW_TIMBALE

public static final byte LOW_TIMBALE
See Also:
Constant Field Values

HIGH_AGOGO

public static final byte HIGH_AGOGO
See Also:
Constant Field Values

LOW_AGOGO

public static final byte LOW_AGOGO
See Also:
Constant Field Values

CABASA

public static final byte CABASA
See Also:
Constant Field Values

MARACAS

public static final byte MARACAS
See Also:
Constant Field Values

SHORT_WHISTLE

public static final byte SHORT_WHISTLE
See Also:
Constant Field Values

LONG_WHISTLE

public static final byte LONG_WHISTLE
See Also:
Constant Field Values

SHORT_GUIRO

public static final byte SHORT_GUIRO
See Also:
Constant Field Values

LONG_GUIRO

public static final byte LONG_GUIRO
See Also:
Constant Field Values

CLAVES

public static final byte CLAVES
See Also:
Constant Field Values

HI_WOOD_BLOCK

public static final byte HI_WOOD_BLOCK
See Also:
Constant Field Values

LOW_WOOD_BLOCK

public static final byte LOW_WOOD_BLOCK
See Also:
Constant Field Values

MUTE_CUICA

public static final byte MUTE_CUICA
See Also:
Constant Field Values

OPEN_CUICA

public static final byte OPEN_CUICA
See Also:
Constant Field Values

MUTE_TRIANGLE

public static final byte MUTE_TRIANGLE
See Also:
Constant Field Values

OPEN_TRIANGLE

public static final byte OPEN_TRIANGLE
See Also:
Constant Field Values
Constructor Detail

Note

public Note()
Instantiates a new Note object.


Note

public Note(byte value)
Instantiates a new Note object with the given note value. This constructor should only be called in cases where the duration of the note is not important (for example, when specifying a root note for a IntervalNotation)

Parameters:
value - the numeric value of the note. C5 is 60.

Note

public Note(byte value,
            long duration)
Instantiates a new Note object with the given note value and duration.

Parameters:
value - the numeric value of the note. C5 is 60.
duration - the duration of the note, as milliseconds.

Note

public Note(byte value,
            double decimalDuration)
Instantiates a new Note object with the given note value and duration.

Parameters:
value - the numeric value of the note. C5 is 60.
duration - the duration of the note, as a decimal fraction of a whole note.

Note

public Note(byte value,
            long duration,
            byte attackVelocity,
            byte decayVelocity)
Instantiates a new Note object with the given note value, duration, and attack and decay velocities.

Parameters:
value - the numeric value of the note. C5 is 60.
duration - the duration of the note.

Note

public Note(byte value,
            double decimalDuration,
            byte attackVelocity,
            byte decayVelocity)
Instantiates a new Note object with the given note value, duration, and attack and decay velocities.

Parameters:
value - the numeric value of the note. C5 is 60.
duration - the duration of the note.
Method Detail

setRest

public void setRest(boolean rest)
Indicates whether this Note object actually represents a rest.

Parameters:
rest - indicates whether this note is rest

isRest

public boolean isRest()
Returns whether this Note object actually represents a rest.

Returns:
whether this note is a rest

setValue

public void setValue(byte value)
Sets the numeric value of this note. C5 is 60.

Parameters:
value - the value of the note

getValue

public byte getValue()
Returns the numeric value of this note. C5 is 60.

Returns:
the value of this note

setDuration

public void setDuration(long duration)
Sets the duration of this note.

Parameters:
duration - the duration of this note

getDuration

public long getDuration()
Returns the duration of this note.

Returns:
the duration of this note

setDecimalDuration

public void setDecimalDuration(double duration)
Sets the decimal fraction value for the duration.

Parameters:
number - the decimal fraction for the duration

getDecimalDuration

public double getDecimalDuration()
Returns the decimal fraction value for the duration.

Returns:
the decimal fraction value for the duration

setStartOfTie

public void setStartOfTie(boolean startOfTie)
Indicates whether this note has a tie to some future note.

Parameters:
tied - true if the note is tied, false if not

isStartOfTie

public boolean isStartOfTie()
Returns whether this note has a tie to some future note.

Returns:
true is the note is tied, false if not

setEndOfTie

public void setEndOfTie(boolean endOfTie)
Indicates whether this note is tied to some past note.

Parameters:
tied - true if the note is tied, false if not

isEndOfTie

public boolean isEndOfTie()
Returns whether this note is tied to some past note.

Returns:
true is the note is tied, false if not

setAttackVelocity

public void setAttackVelocity(byte velocity)
Sets the attack velocity for this note.

Parameters:
velocity - the attack velocity

getAttackVelocity

public byte getAttackVelocity()
Returns the attack velocity for this note.

Returns:
the attack velocity

setDecayVelocity

public void setDecayVelocity(byte velocity)
Sets the decay velocity for this note.

Parameters:
velocity - the decay velocity

getDecayVelocity

public byte getDecayVelocity()
Returns the decay velocity for this note.

Returns:
the decay velocity

setHasAccompanyingNotes

public void setHasAccompanyingNotes(boolean accompanying)
Sets whether this Note will have other Notes (sequential or parallel) associated with it.

Parameters:
accompanying -

hasAccompanyingNotes

public boolean hasAccompanyingNotes()
Returns whether this Note will have other Notes (sequential or parallel) associated with it.


setType

public void setType(byte type)
Sets the note type - either First, Sequential, or Parallel.

Parameters:
type - the note type

getType

public byte getType()
Returns the note type - either First, Sequential, or Parallel.

Returns:
the note type

getMusicString

public java.lang.String getMusicString()
Returns the Music String representing this element and all of its settings. For a Note object, the Music String is a note, expressed as either a letter, note, or a bracketed number, [note-value], and a duration, expressed as either a letter, duration, or a slash followed by a numeric duration, /decimal-duration
If either the attack or decay velocity is set to a value besides the default, avelocity and/or dvelocity will be added to the string. If this note is to be played in sequence or in parallel to another note, a + or _ character will be added as appropriate.

Specified by:
getMusicString in interface JFugueElement
Returns:
the Music String for this element

getVerifyString

public java.lang.String getVerifyString()
Returns verification string in this format: Note: value={#}, duration={#}, startTie={T|F}, endTie={T|F}, attack={#}, decay={#}, isFirst={T|F}, isParallel={T|F}, isSequential={T|F}

Specified by:
getVerifyString in interface JFugueElement

createVerifyString

public static java.lang.String createVerifyString(int value,
                                                  double duration)

createVerifyString

public static java.lang.String createVerifyString(int value,
                                                  double duration,
                                                  boolean startTie,
                                                  boolean endTie)

createVerifyString

public static java.lang.String createVerifyString(int value,
                                                  double duration,
                                                  int attack,
                                                  int decay)

createVerifyString

public static java.lang.String createVerifyString(int value,
                                                  double duration,
                                                  boolean isFirst,
                                                  boolean isParallel,
                                                  boolean isSequential)

createVerifyString

public static java.lang.String createVerifyString(int value,
                                                  double duration,
                                                  boolean startTie,
                                                  boolean endTie,
                                                  int attack,
                                                  int decay,
                                                  boolean isFirst,
                                                  boolean isParallel,
                                                  boolean isSequential)

createCompoundVerifyString

public static java.lang.String createCompoundVerifyString(java.lang.String... strings)
Easily create compound note verification strings, like: Note: value=60, duration=1.0, startTie=F, endTie=F, attack=64, decay=64, isFirst=T, isParallel=F, isSequential=F; Note: value=63, duration=0.0, startTie=F, endTie=F, attack=64, decay=64, isFirst=F, isParallel=T, isSequential=F


getStringForNote

public static java.lang.String getStringForNote(byte noteValue,
                                                double decimalDuration)
Returns a MusicString representation of the given MIDI note value and duration -- which indicates a note and an octave.

Parameters:
noteValue - this MIDI note value, like 60
decimalDuration - the duration of this note, like 0.5
Returns:
a MusicString value, like C5h

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 -
Returns:

getStringForNote

public static java.lang.String getStringForNote(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

getStringForDuration

public static java.lang.String getStringForDuration(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) or anything greater than a duration of 1.0 (for example, "wwww" for 4.0). 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.

Parameters:
decimalDuration - The decimal value of the duration to convert
Returns:
a MusicString fragment representing the duration

getDecimalForDuration

public static double getDecimalForDuration(java.lang.String stringDuration)
Returns the decimal duration that is equal to the given MusicString representation. 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) or anything greater than a duration of 1.0 (for example, "wwww" for 4.0). 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.

Parameters:
stringDuration - The MusicString duration character (or dotted character)
Returns:
a decimal value representing the duration, expressed as a fraction of a whole note