Class NoteEvent
- All Implemented Interfaces:
Cloneable,Comparable<Note>
This is an immutable class EXCEPT for the client properties.
Two different NoteEvent instances can not be equal. If you need NoteEvent map keys to be considered equal when they share the same Note attributes, use the AsNoteKey inner class.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA NoteEvent wrapper to be used as hash/map key when 2 different NoteEvent instances need to be considered as equal when their attributes are equal (except client properties).Nested classes/interfaces inherited from class org.jjazz.harmony.api.Note
Note.Alteration -
Field Summary
Fields inherited from class org.jjazz.harmony.api.Note
notesFlat, notesSharp, OCTAVE_MAX, OCTAVE_MIN, OCTAVE_STD, PITCH_MAX, PITCH_MIN, PITCH_STD, VELOCITY_MAX, VELOCITY_MIN, VELOCITY_STD -
Constructor Summary
ConstructorsConstructorDescriptionNoteEvent(int pitch, float duration, int velocity, float posInBeats) Create a new NoteEvent.Create a new NoteEvent from a Note at specified position.Create a new NoteEvent from another NoteEvent. -
Method Summary
Modifier and TypeMethodDescriptionvoidclone()Also clone the client properties.intCompare this NoteEvent to a Note or NoteEvent.intCompare using only position.booleanReturn false unless o is the same object.booleanequalsAsNoteNearPosition(NoteEvent ne, float nearWindow) Check for equality as a Note tolerating slight differences in position and duration.Get the "as Note" key for this instance.Get the client properties.getCopyDur(float durationInBeats) Get a copy with one parameter modified.getCopyDurPos(float durationInBeats, float posInBeats) Get a copy with the specified parameters modified.getCopyPitch(int pitch) Get a copy with one parameter modified.getCopyPitchPos(int pitch, float posInBeats) Get a copy with the specified parameters modified.getCopyPitchVel(int pitch, int velocity) Get a copy with the specified parameters modified.getCopyPos(float posInBeats) Get a copy with one parameter modified.getCopyVel(int velocity) Get a copy with one parameter modified.floatinthashCode()Return the identify hash code.booleanbooleanisNear(float posInBeats, float nearWindow) Test if this note is near the specified position.static NoteEventCreate a NoteEvent from the specified string.voidstatic StringSave the specified NoteEvent as a string.toMidiEvents(int channel) Convert a note into 2 MidiEvents (NoteON and NoteOFF).toNote()Get a new Note instance built from this object's pitch, duration, velocity and alteration.toString()Same as toPianoOctaveString().Methods inherited from class org.jjazz.harmony.api.Note
checkOctave, checkPitch, checkVelocity, equalsRelativePitch, getAlterationDisplay, getCentered, getChromaticNotesArray, getClosestPitch, getDurationInBeats, getGStaffLineNumber, getLowerPitch, getNormalizedRelPitch, getOctave, getPitch, getRelativeAscInterval, getRelativeDescInterval, getRelativePitch, getRelativePitchDelta, getSymbolicDuration, getTransposed, getTransposed, getTransposedWithinOctave, getUpperPitch, getVelocity, isFlat, isWhiteKey, limitPitch, parsePianoOctaveString, saveAsString, toPianoOctaveBeatString, toPianoOctaveString, toRelativeNoteString, toRelativeNoteString
-
Constructor Details
-
NoteEvent
public NoteEvent(int pitch, float duration, int velocity, float posInBeats) Create a new NoteEvent.- Parameters:
pitch-duration-velocity-posInBeats-
-
NoteEvent
Create a new NoteEvent from a Note at specified position.- Parameters:
n-posInBeats-
-
NoteEvent
Create a new NoteEvent from another NoteEvent.Client properties are also copied.
- Parameters:
ne-pitch- if < 0 reuse ne's pitch, otherwise use this valueduration- if < 0 reuse ne's duration, otherwise use this valuevelocity- if < 0 reuse ne's velocity, otherwise use this valueposInBeats- if < 0 reuse ne's position, otherwise use this value
-
-
Method Details
-
getCopyPitch
Get a copy with one parameter modified.Client properties are also copied.
- Parameters:
pitch-- Returns:
-
getCopyDur
Get a copy with one parameter modified.Client properties are also copied.
- Parameters:
durationInBeats-- Returns:
-
getCopyVel
Get a copy with one parameter modified.Client properties are also copied.
- Parameters:
velocity-- Returns:
-
getCopyPos
Get a copy with one parameter modified.Client properties are also copied.
- Parameters:
posInBeats-- Returns:
-
getCopyDurPos
Get a copy with the specified parameters modified.Client properties are also copied.
- Parameters:
durationInBeats-posInBeats-- Returns:
-
getCopyPitchVel
Get a copy with the specified parameters modified.Client properties are also copied.
- Parameters:
pitch-velocity-- Returns:
-
getCopyPitchPos
Get a copy with the specified parameters modified.Client properties are also copied.
- Parameters:
pitch-posInBeats-- Returns:
-
getClientProperties
Get the client properties.- Returns:
-
toMidiEvents
Convert a note into 2 MidiEvents (NoteON and NoteOFF).- Parameters:
channel-- Returns:
-
isBefore
-
getPositionInBeats
public float getPositionInBeats() -
getBeatRange
-
isNear
public boolean isNear(float posInBeats, float nearWindow) Test if this note is near the specified position.A "near" position is in the interval [posInBeats-nearWindow;posInBeats+nearWindow[.
- Parameters:
posInBeats-nearWindow-- Returns:
-
equalsAsNoteNearPosition
Check for equality as a Note tolerating slight differences in position and duration.If the positions are equals +/- beatWindow, positions are considered equal. If the durations are equals +/- 2*beatWindow, durations are considered equal.
ClientProperties are ignored.
- Parameters:
ne-nearWindow- Must be > 0- Returns:
-
compareTo
Compare this NoteEvent to a Note or NoteEvent.- Specified by:
compareToin interfaceComparable<Note>- Overrides:
compareToin classNote- Parameters:
n-- Returns:
- 0 only if this == n.
-
compareToAsPosition
Compare using only position.- Parameters:
n-- Returns:
-
toNote
Get a new Note instance built from this object's pitch, duration, velocity and alteration.- Returns:
-
getAsNoteKey
Get the "as Note" key for this instance.- Returns:
-
equals
Return false unless o is the same object. -
hashCode
public int hashCode()Return the identify hash code. -
clone
Also clone the client properties. -
toString
Description copied from class:NoteSame as toPianoOctaveString(). -
addClientPropertyChangeListener
-
removeClientPropertyChangeListener
-
saveAsString
Save the specified NoteEvent as a string.NOTE: client properties are NOT saved.
- Parameters:
ne-- Returns:
- See Also:
-
loadAsString
Create a NoteEvent from the specified string.Example "60,FLAT,102,2.5:1.25" means pitch=60, AlterationDisplay=FLAT, velocity=102, duration=2.5 beats, and position=1.25 beats
- Parameters:
s-- Returns:
- Throws:
ParseException- If s is not a valid string.- See Also:
-