public class MidiNote extends java.lang.Object implements java.lang.Comparable<MidiNote>
MidiNote represents a single instance of a played midi note. It contains
information on the note's pitch, onset, offset, and velocity, as well as which MidiChord
it is assigned to.
MidiNotes are Comparable, and their natural ordering is determined strictly by each note's
onsetTime. That means that the compareTo(MidiNote) method will return 0
if two notes are compared which have the same onset time. For this reason, MidiNotes should
not be used in any SortedSets, since they test for equality based soleley on the compareTo
method, and will therefore not be able to hold multiple notes with the same onset time.
| Modifier and Type | Field and Description |
|---|---|
private int |
correctVoice
The gold standard voice which this note came from.
|
private int |
guessedVoice
The index of the guessed voice of this note.
|
private long |
offsetTick
The offset tick of this note, or 0 if it is still active.
|
private long |
offsetTime
The offset time of this note, measured in microseconds, or 0 if it is still active.
|
private long |
onsetTick
The onset tick of this note.
|
private long |
onsetTime
The onset time of this note, measured in microseconds.
|
private int |
pitch
The key number of this note.
|
private int |
velocity
The velocity of this note.
|
| Constructor and Description |
|---|
MidiNote(int key,
int velocity,
long onsetTime,
long onsetTick,
int correctVoice,
int guessedVoice)
Constructor for a new note.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close(long offsetTime,
long offsetTick)
Turns off this note at the given time and tick.
|
int |
compareTo(MidiNote o) |
boolean |
equals(java.lang.Object o) |
private java.util.List<Beat> |
getBeatsAroundTime(long time,
java.util.List<Beat> beats) |
int |
getCorrectVoice()
Get the gold standard voice of this note.
|
long |
getDurationTime()
Get the duration of this MidiNote in microseconds.
|
int |
getGuessedVoice()
Get the guessed voice of this note.
|
static java.lang.String |
getNoteName(int pitch)
Get the note name of the given MIDI pitch value.
|
Beat |
getOffsetBeat(java.util.List<Beat> beats) |
long |
getOffsetTick()
Gets the offset tick of this note.
|
long |
getOffsetTime()
Gets the offset time of this note.
|
Beat |
getOnsetBeat(java.util.List<Beat> beats) |
long |
getOnsetTick()
Gets the onset tick of this note.
|
long |
getOnsetTime()
Gets the onset time of this note.
|
int |
getPitch()
Gets the key number of this note.
|
int |
getVelocity()
Get the velocity of this note.
|
boolean |
isActive()
Returns whether this note is active (still on) or not.
|
boolean |
overlaps(MidiNote other)
Return whether this note overlaps another MidiNote in time.
|
void |
setCorrectVoice(int correctVoice)
Set the correctVoice of this note to a new value.
|
void |
setGuessedVoice(int voice)
Set the guessed voice of this note to the given value.
|
void |
setOffset(long offsetTime,
long offsetTick)
Move this note's offset to the given location.
|
void |
setOnset(long onsetTime,
long onsetTick)
Move this note's onset to the given location.
|
java.lang.String |
toString() |
private int correctVoice
private long onsetTime
private long onsetTick
private long offsetTime
private long offsetTick
private int velocity
private int pitch
private int guessedVoice
public MidiNote(int key,
int velocity,
long onsetTime,
long onsetTick,
int correctVoice,
int guessedVoice)
key - pitchvelocity - velocityonsetTime - onsetTimeonsetTick - onsetTickcorrectVoice - correctVoiceguessedVoice - guessedVoicepublic void setOnset(long onsetTime,
long onsetTick)
public void setOffset(long offsetTime,
long offsetTick)
offsetTime - offsetTimeoffsetTick - offsetTickpublic boolean isActive()
public void close(long offsetTime,
long offsetTick)
offsetTime - offsetTimeoffsetTick - offsetTickpublic boolean overlaps(MidiNote other)
other - The note we want to check for overlap. This can be null, in which case
we will return false.public long getOnsetTime()
onsetTimepublic long getOnsetTick()
onsetTickpublic long getOffsetTime()
offsetTimepublic long getOffsetTick()
offsetTickpublic long getDurationTime()
public int getPitch()
pitchpublic int getVelocity()
velocitypublic int getCorrectVoice()
correctVoicepublic void setCorrectVoice(int correctVoice)
correctVoice - correctVoicepublic void setGuessedVoice(int voice)
voice - guessedVoicepublic int getGuessedVoice()
guessedVoiceprivate java.util.List<Beat> getBeatsAroundTime(long time, java.util.List<Beat> beats)
public java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int compareTo(MidiNote o)
compareTo in interface java.lang.Comparable<MidiNote>public static java.lang.String getNoteName(int pitch)
pitch - The MIDI pitch value whose note name we want, on the range 0-127