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 note attributes are equal (except client properties).Nested classes/interfaces inherited from class org.jjazz.harmony.api.Note
Note.Accidental -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringIf true this note is an "adjusting note".static final StringSystem property used to customize NoteEvent.toString().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 with Accidental.FLAT.NoteEvent(int pitch, float duration, int velocity, float posInBeats, Note.Accidental acc) Create a new NoteEvent.Create a new NoteEvent from a Note at specified position. -
Method Summary
Modifier and TypeMethodDescriptionvoidclone()Clone this instance, including 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" map key for this instance.Get the client properties.floatinthashCode()Return the identify hash code.static booleanCheck if note is marked isAdjusting.booleanbooleanisNear(float posInBeats, float nearWindow) Test if this note is near the specified position.static NoteEventCreate a NoteEvent from the specified string.static voidmarkIsAdjustingNote(NoteEvent note, boolean b) Set or reset the note as isAdjusting.voidstatic StringSave the specified NoteEvent as a string.setAccidental(Note.Accidental newAccidental, boolean copyProperties) Get a copy with the alteration parameter modified.setAll(int pitch, float duration, int velocity, float posInBeats, Note.Accidental acc, boolean copyProperties) Create a new and possibly modified NoteEvent from this instance.setDuration(float newDurationInBeats, boolean copyProperties) Get a copy with the duration parameter modified.setPitch(int newPitch, boolean copyProperties) Get a copy with the pitch parameter modified.setPosition(float newPositionInBeats, boolean copyProperties) Get a copy with the position parameter modified.setVelocity(int newVelocity, boolean copyProperties) Get a copy with the velocity parameter modified.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 accidental.toString()Same as toPianoOctaveString().Methods inherited from class org.jjazz.harmony.api.Note
checkOctave, checkPitch, checkVelocity, equalsRelativePitch, getAccidental, getCentered, getChromaticNotesArray, getClosestPitch, getDurationInBeats, getFStaffLineNumber, getGStaffLineNumber, getLowerPitch, getNormalizedRelPitch, getOctave, getPitch, getRelativeAscInterval, getRelativeDescInterval, getRelativePitch, getRelativePitchDelta, getSymbolicDuration, getTransposed, getTransposed, getTransposedWithinOctave, getUpperPitch, getVelocity, getWhiteKeyPitch, isFlat, isWhiteKey, isWhiteKey, limitPitch, parsePianoOctaveBeatString, parsePianoOctaveString, saveAsString, toPianoOctaveBeatString, toPianoOctaveString, toRelativeNoteString, toRelativeNoteString
-
Field Details
-
SYSTEM_PROP_NOTEEVENT_TOSTRING_FORMAT
System property used to customize NoteEvent.toString().Used as String.format() parameter with arguments 1=toPianoOctaveString(), 2=position, 3=durationInBeats, 4=velocity, 5=identityHashCode
Example: "[%1$s, dur=%3$.2f]"
- See Also:
-
PROP_IS_ADJUSTING
If true this note is an "adjusting note"."Adjusting" means it's a temporary note used by an action which will eventually replace the temporary note by a non-adjusting note. For example if user is mouse-dragging a note in an editor, editor might generate "adjusting notes" until drag operation is complete.
Note that this property is not directly used by the NoteEvent class.
- See Also:
-
-
Constructor Details
-
NoteEvent
Create a new NoteEvent.- Parameters:
pitch-duration-velocity-posInBeats-acc-
-
NoteEvent
public NoteEvent(int pitch, float duration, int velocity, float posInBeats) Create a new NoteEvent with Accidental.FLAT.- Parameters:
pitch-duration-velocity-posInBeats-
-
NoteEvent
Create a new NoteEvent from a Note at specified position.- Parameters:
n-posInBeats-
-
-
Method Details
-
markIsAdjustingNote
Set or reset the note as isAdjusting.- Parameters:
note-b- If true note is marked isAdjusting.- See Also:
-
isAdjustingNote
Check if note is marked isAdjusting.- Parameters:
ne-- Returns:
-
setAll
public NoteEvent setAll(int pitch, float duration, int velocity, float posInBeats, Note.Accidental acc, boolean copyProperties) Create a new and possibly modified NoteEvent from this instance.- Parameters:
pitch- if < 0 reuse this instance's pitch, otherwise use the parameter valueduration- if < 0 reuse this instance's duration, otherwise use the parameter valuevelocity- if < 0 reuse this instance's velocity, otherwise use the parameter valueposInBeats- if < 0 reuse this instance's position, otherwise use the parameter valueacc- if null reuse this instance's accidental, otherwise use the parameter valuecopyProperties- if true copy the properties- Returns:
-
setPitch
Get a copy with the pitch parameter modified.Client properties are copied.
- Parameters:
newPitch- The new pitchcopyProperties-- Returns:
-
setDuration
Get a copy with the duration parameter modified.- Parameters:
newDurationInBeats-copyProperties- If true copy the properties- Returns:
-
setVelocity
Get a copy with the velocity parameter modified.- Parameters:
newVelocity-copyProperties- If true copy the properties- Returns:
-
setPosition
Get a copy with the position parameter modified.- Parameters:
newPositionInBeats-copyProperties- If true copy the properties- Returns:
-
setAccidental
Get a copy with the alteration parameter modified.- Parameters:
newAccidental-copyProperties- If true copy the properties- Returns:
-
getClientProperties
-
toMidiEvents
-
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- Must be >= 0- 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
-
compareToAsPosition
-
toNote
Get a new Note instance built from this object's pitch, duration, velocity and accidental.- Returns:
-
getAsNoteKey
Get the "as Note" map key for this instance.- Returns:
- See Also:
-
equals
-
hashCode
-
clone
-
toString
-
addClientPropertyChangeListener
-
removeClientPropertyChangeListener
-
saveAsString
-
loadAsString
Create a NoteEvent from the specified string.Example "60,FLAT,102,2.5:1.25" means pitch=60, AccidentalDisplay=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:
-