sky.monome.util.scale
Class MidiNote


java.lang.Object

  extended by sky.monome.util.scale.MidiNote

All Implemented Interfaces:
java.lang.Comparable<MidiNote>

public final class MidiNote
extends java.lang.Object
implements java.lang.Comparable<MidiNote>

Midi note. This kind of note can return its Midi number. Note that Midi notes are immutable.

Since:
SkyMonome v1.1
Author:
PJ Skyman

Nested Class Summary
static class MidiNote.Note
          Octave note.
 
Field Summary
static MidiNote C_1
          Constant for the minimum possible note with the Midi protocol.
static MidiNote C4
          Constant for the default note with the Midi protocol.
static MidiNote G9
          Constant for the maximum possible note with the Midi protocol.
 
Constructor Summary
MidiNote(MidiNote.Note note, int octave)
          Constructs a Midi note with the specified octave note and the specified octave number.
 
Method Summary
 int compareTo(MidiNote o)
          Compares this Midi note to the specified Midi note.
 boolean equals(java.lang.Object o)
          Says if this Midi note is equal to the specified object.
 int getMidiNoteNumber()
          Returns the note number of this Midi note in the Midi protocol.
 MidiNote.Note getNote()
          Returns the octave note of this Midi note.
 int getOctave()
          Returns the number of the octave of this Midi note.
 MidiNote getOffsettedNote(int offset)
          Returns the Midi note which is the result of the specified offset applied on this Midi note.
 int hashCode()
          Returns the hashcode of this Midi note.
 java.lang.String toString()
          Returns a string representation of this Midi note.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

C_1


public static final MidiNote C_1
Constant for the minimum possible note with the Midi protocol. Its Midi number is 0.


C4


public static final MidiNote C4
Constant for the default note with the Midi protocol.


G9


public static final MidiNote G9
Constant for the maximum possible note with the Midi protocol. Its Midi number is 127.

Constructor Detail

MidiNote


public MidiNote(MidiNote.Note note,

                int octave)
Constructs a Midi note with the specified octave note and the specified octave number.

Parameters:
note - Octave note.
octave - Number of the octave.
Method Detail

getNote


public MidiNote.Note getNote()
Returns the octave note of this Midi note.

Returns:
The octave note of this Midi note.

getOctave


public int getOctave()
Returns the number of the octave of this Midi note.

Returns:
The number of the octave of this Midi note.

getMidiNoteNumber


public int getMidiNoteNumber()
Returns the note number of this Midi note in the Midi protocol.

Returns:
The note number of this Midi note in the Midi protocol.

getOffsettedNote


public MidiNote getOffsettedNote(int offset)
Returns the Midi note which is the result of the specified offset applied on this Midi note.

Parameters:
offset - Offset to apply to this Midi note.
Returns:
The Midi note which is the result of the specified offset applied on this Midi note.

toString


public java.lang.String toString()
Returns a string representation of this Midi note.

Overrides:
toString in class java.lang.Object
Returns:
A string representation of this Midi note.

compareTo


public int compareTo(MidiNote o)
Compares this Midi note to the specified Midi note.

Specified by:
compareTo in interface java.lang.Comparable<MidiNote>
Parameters:
o - Midi note to compare with.
Returns:
A negative integer when this Midi note is inferior to the specified Midi note, a positive integer when this Midi note is superior to the specified Midi note, 0 when this Midi note is equivalent to the specified Midi note.

equals


public boolean equals(java.lang.Object o)
Says if this Midi note is equal to the specified object.

Overrides:
equals in class java.lang.Object
Parameters:
o - Object to compare with.
Returns:
Always false if the specified object is in a wrong type. Otherwise, returns true if and only if the two Midi notes have the same octave note and the same octave number.

hashCode


public int hashCode()
Returns the hashcode of this Midi note.

Overrides:
hashCode in class java.lang.Object
Returns:
The hashcode of this Midi note.