org.jfugue
Class Note

java.lang.Object
  |
  +--org.jfugue.Note
All Implemented Interfaces:
JFugueElement

public 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
Author:
David Koelle

Field Summary
static byte DEFAULT_VELOCITY
          Default value for attack and decay velocity.
static byte FIRST
          Indicates that this note is the first note in the token.
static byte PARALLEL
          Indicates that this note is played at the same time as a previous note in the same token.
static byte SEQUENTIAL
          Indicates that this note immediately follows a previous note in the same token.
 
Constructor Summary
Note()
          Instantiates a new Note object.
Note(byte value, long duration)
          Instantiates a new Note object with the given note value and duration.
 
Method Summary
 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.
 long getDuration()
          Returns the duration of this note.
 byte getType()
          Returns the note type - either First, Sequential, or Parallel.
 byte getValue()
          Returns the numeric value of this note.
 boolean isRest()
          Returns whether this Note object actually represents a rest.
 java.lang.String musicString()
          Returns the Music String representing this element and all of its settings.
 void setAttackVelocty(byte velocity)
          Sets the attack velocity for this note.
 void setDecayVelocty(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 setRest(boolean rest)
          Indicates whether this Note object actually represents a rest.
 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
clone, equals, finalize, 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.

SEQUENTIAL

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

PARALLEL

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

DEFAULT_VELOCITY

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

Note

public Note()
Instantiates a new Note object.

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.
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

setAttackVelocty

public void setAttackVelocty(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

setDecayVelocty

public void setDecayVelocty(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

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

musicString

public java.lang.String musicString()
Returns the Music String representing this element and all of its settings. For a Note object, the Music String is [note-value]/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:
musicString in interface JFugueElement
Returns:
the Music String for this element