Class Note

java.lang.Object
  |
  +--Note

public class Note
extends java.lang.Object

Represents a musical Note and the operations that can be done on a Note.


Constructor Summary
Note(int midiValue)
          Constructs a Note from a MIDI value.
Note(Note toCopy)
          Copy constructor.
Note(java.lang.String stdDes)
          Constructs a Note from a string in standard designation.
 
Method Summary
 boolean after(Note comp)
          True if the standard designation value of caller is lower than that of comp; for Notes with modifications, version with the lower letter will be lower than its alternate.
 boolean before(Note comp)
          True if the standard designation value of caller is lower than that of comp; for Notes with modifications, version with the lower letter will be lower than its alternate.
 boolean canTranspose(int steps, Note min, Note max)
          True if the Note can be transposed without going out of the valid MIDI bounds.
 boolean equals(java.lang.Object comp)
          True if the two Notes have the same MIDI value; they may have different standard designation representations.
 char getLetter()
          Returns a char reprsenting the tone letter of the Note, .e.g.  'C' (even if the note is "C#").
 int getMIDI()
          Returns an integer representing the MIDI value of the Note.
 char getMod()
          Returns a char representing the modification on the Note, e.g.  '#'.
 int getOctave()
          Returns an integer representing the octave of the Note.
 java.lang.String getStdDes()
          Returns a string representing the Note in standard designation, e.g. , C#4.
 java.lang.String getTone()
          Returns a string representing the tone of the Note, e.g.  "C#".
 void toggle()
          Toggles a Note to its alternate MIDI representation.  If the Note does not have an alternate MIDI representation (D, G, A, or C-1) the standard designation value of the Note does not change.
 void transpose(int steps, Note min, Note max)
          Transposes a Note steps number of half steps.  If steps > 0, the Note is transposed up.  If steps < 0, the Note is transposed down.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Note

public Note(int midiValue)
Constructs a Note from a MIDI value.

Parameters:
midiValue - A valid MIDI number.
Throws:
java.lang.IllegalArgumentException - if the MIDI value is out of bounds.

Note

public Note(java.lang.String stdDes)
Constructs a Note from a string in standard designation.

Parameters:
stdDes - Note value in standard designation, e.g., C#4.
Throws:
java.lang.IllegalArgumentException - if the String is not a properly formatted in standard designation.

Note

public Note(Note toCopy)
Copy constructor.

Parameters:
toCopy - Note that is to be duplicated.
Method Detail

equals

public boolean equals(java.lang.Object comp)
True if the two Notes have the same MIDI value; they may have different standard designation representations.

Overrides:
equals in class java.lang.Object
Parameters:
comp - Note that is being compared to.

before

public boolean before(Note comp)
True if the standard designation value of caller is lower than that of comp; for Notes with modifications, version with the lower letter will be lower than its alternate.

Parameters:
comp - Note that is being compared to.

after

public boolean after(Note comp)
True if the standard designation value of caller is lower than that of comp; for Notes with modifications, version with the lower letter will be lower than its alternate.

Parameters:
comp - Note that is being compared to.

toggle

public void toggle()
Toggles a Note to its alternate MIDI representation.  If the Note does not have an alternate MIDI representation (D, G, A, or C-1) the standard designation value of the Note does not change.


canTranspose

public boolean canTranspose(int steps,
                            Note min,
                            Note max)
True if the Note can be transposed without going out of the valid MIDI bounds.

Parameters:
steps - Number of half steps for the transposition.  positive if the Note is being transposed up; negative if it is being transposed down.
min - The lowest value a Note is allowed to take on.
max - The highest value a Note is allowed to take on.

transpose

public void transpose(int steps,
                      Note min,
                      Note max)
Transposes a Note steps number of half steps.  If steps > 0, the Note is transposed up.  If steps < 0, the Note is transposed down.

Parameters:
steps - Number of half steps for the transposition.  positive if the Note is being transposed up; negative if it is being transposed down.
min - The lowest value a Note is allowed to take on.
max - The highest value a Note is allowed to take on.
Throws:
java.lang.IllegalArgumentException - if trying to tranpose Note out of allowable bounds

getStdDes

public java.lang.String getStdDes()
Returns a string representing the Note in standard designation, e.g. , C#4.


getTone

public java.lang.String getTone()
Returns a string representing the tone of the Note, e.g.  "C#".


getLetter

public char getLetter()
Returns a char reprsenting the tone letter of the Note, .e.g.  'C' (even if the note is "C#").


getMod

public char getMod()
Returns a char representing the modification on the Note, e.g.  '#'.


getOctave

public int getOctave()
Returns an integer representing the octave of the Note.


getMIDI

public int getMIDI()
Returns an integer representing the MIDI value of the Note.