music
Class Note

java.lang.Object
  extended by 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 = {-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}
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)
          Executes (accepts) the visitor, calling the case associated with this host's index value.
 int getAccidental()
           
 double getDuration()
           
 boolean getIsNatural()
          Accessor for isNatural flag
 char getName()
           
 int getOctave()
           
 void setAccidental(int accidental)
           
 void setDuration(double duration)
           
 void setIsNatural(boolean isNatural)
          Settor for isNatural flag.
 void setName(char name)
           
 void setOctave(int octave)
           
 java.lang.String toString()
           
 
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}


octave

private int octave
Octave value


accidental

private int accidental
Accidental = {-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. False is to stay with key signature setting for note.
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
string representation of the Note

execute

public java.lang.Object execute(IPhraseVisitor algo,
                                java.lang.Object... params)
Description copied from interface: IPhrase
Executes (accepts) the visitor, calling the case associated with this host's index value.

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)
Parameters:
name - - the name to set

getName

public char getName()
Returns:
the name

setOctave

public void setOctave(int octave)
Parameters:
octave - - the octave to set

getOctave

public int getOctave()
Returns:
the octave

setAccidental

public void setAccidental(int accidental)
Parameters:
accidental - - the accidental to set

getAccidental

public int getAccidental()
Returns:
the accidental

setDuration

public void setDuration(double duration)
Parameters:
duration - - the duration to set

getDuration

public double getDuration()
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