provided.music
Class Note

java.lang.Object
  extended by provided.music.Note
All Implemented Interfaces:
INote, IPhrase

public class Note
extends java.lang.Object
implements INote

Basic class representing musical Notes.


Field Summary
private  int accidental
          Accidental (normally in {-1, 0, +1})
private  double duration
          Duration
private  boolean isNatural
          Flag to override key signature
private  char name
          Note name: {A, B, C, D, E, F, G, Z} (Z = rest)
private  int octave
          Octave value
 
Constructor Summary
Note(char name, int octave, int accidental, double duration, boolean isNatural)
          Constructor for the class
 
Method Summary
 java.lang.Object execute(IPhraseVisitor algo, java.lang.Object... params)
          Calls the "Note" case of the visitor.
 int getAccidental()
          Accessor to get the value of the accidental
 double getDuration()
          Accessor to get the note duraton
 boolean getIsNatural()
          Accessor for isNatural flag
 char getName()
          Accessor to get the name of the note
 int getOctave()
          Accessor to get the octave
 void setAccidental(int accidental)
          Accessor to set the accidental value
 void setDuration(double duration)
          Accessor to set the note duration
 void setIsNatural(boolean isNatural)
          Settor for isNatural flag.
 void setName(char name)
          Accessor to set the name of the note
 void setOctave(int octave)
          Accessor to set the octave of the note
 java.lang.String toString()
          Returns a string representation of the Note
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

private char name
Note name: {A, B, C, D, E, F, G, Z} (Z = rest)


octave

private int octave
Octave value


accidental

private int accidental
Accidental (normally in {-1, 0, +1})


duration

private double duration
Duration


isNatural

private boolean isNatural
Flag to override key signature

Constructor Detail

Note

public Note(char name,
            int octave,
            int accidental,
            double duration,
            boolean isNatural)
Constructor for the class

Parameters:
name - The name of the note
octave - The octave of the note w.r.t. middle C. Zero = same octave as middle C.
accidental - accidental setting sharp > 0, flat < 0
duration - duration of note
isNatural - flag to override key signature. True if note should be natural, overriding key signature.
Method Detail

toString

public java.lang.String toString()
Returns a string representation of the Note

Overrides:
toString in class java.lang.Object
Returns:
"(name, octave, duration)"

execute

public java.lang.Object execute(IPhraseVisitor algo,
                                java.lang.Object... params)
Calls the "Note" case of the visitor.

Specified by:
execute in interface IPhrase
Parameters:
algo - The visitor to execute
params - The input parameters supplied to the algo when its appropriate case is called.
Returns:
The return value from executing the appropriate case on 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