world.sound.tunes
Class Note

java.lang.Object
  extended by world.sound.tunes.Note

public class Note
extends java.lang.Object

Represents a single note which includes a pitch and duration. Notes may be created/converted to and from a String representation that includes the name, octave, modifier, and duration, where:

As an example, "C6n4" represents a C natural, in the 6th octave (Note 72), that will play for 4 beats

Based in part on a class originally designed by Viera K. Proulx.


Constructor Summary
Note(int pitch)
          Create a Note with the given MIDI pitch, with a default duration of 1 and a default velocity.
Note(int pitch, int duration)
          Create a Note with the given MIDI pitch and duration, and the default velocity.
Note(int pitch, int duration, int velocity)
          Create a Note with the given MIDI pitch, duration, and velocity.
Note(java.lang.String snote)
          Create a Note from the description given as a String, and the default velocity.
Note(java.lang.String snote, int velocity)
          Create a Note from the description given as a String.
 
Method Summary
static int computePitch(char noteName, int octave, char modifier)
          Compute the MIDI pitch of the given note name, octave, and modifier.
 Note copy()
          Make a copy of this Note.
 int getDuration()
          Get the Duration of this Note.
 int getPitch()
          Get the Pitch of this Note.
 int getVelocity()
          Get the Velocity of this Note.
 boolean isSilent()
          Has this note completed its duration?
 void nextBeat()
          Decrement the duration of this Note.
 boolean sameNote(Note that)
          Does the given Note represent the same Note as this one?
 void skipBeat()
          Increment the duration of this Note.
 java.lang.String toString()
          Produce a Human readable String representation of this Note.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Note

public Note(int pitch)
Create a Note with the given MIDI pitch, with a default duration of 1 and a default velocity.


Note

public Note(int pitch,
            int duration)
Create a Note with the given MIDI pitch and duration, and the default velocity.


Note

public Note(int pitch,
            int duration,
            int velocity)
Create a Note with the given MIDI pitch, duration, and velocity.


Note

public Note(java.lang.String snote)
Create a Note from the description given as a String, and the default velocity.


Note

public Note(java.lang.String snote,
            int velocity)
Create a Note from the description given as a String. The encoding is either 4 or 5 characters long and includes the name, octave, modifier, and duration, where:

As an example, "C6n4" represents a C natural, in the 6th octave (Note 72), that will play for 4 beats

Method Detail

copy

public Note copy()
Make a copy of this Note.


getPitch

public int getPitch()
Get the Pitch of this Note.


getDuration

public int getDuration()
Get the Duration of this Note.


getVelocity

public int getVelocity()
Get the Velocity of this Note.


sameNote

public boolean sameNote(Note that)
Does the given Note represent the same Note as this one?


isSilent

public boolean isSilent()
Has this note completed its duration?


nextBeat

public void nextBeat()
Decrement the duration of this Note.


skipBeat

public void skipBeat()
Increment the duration of this Note.


toString

public java.lang.String toString()
Produce a Human readable String representation of this Note.

Overrides:
toString in class java.lang.Object

computePitch

public static int computePitch(char noteName,
                               int octave,
                               char modifier)
Compute the MIDI pitch of the given note name, octave, and modifier.