The MIDI channels that the tracker will accept notes from.
The list of currently active notes, sorted by MIDI value.
Returns the amount of time (in milleseconds) that has passed since the last note was added to the tracker.
Creates a new instance of NoteTracker
An array representing the MIDI channel values that NoteTracker accepts. Default value is an empty array, meaning all MIDI notes will be accepted.
Gets the timestamp of when a note was last added. If there has not been an instance of the provided note being added, this method will return 0.
Gets the timestamp of when a note was last removed. If there has not been an instance of the provided note being removed, this method will return 0.
Removes all notes from the tracker.
Removes a note from the tracker.
If the note provided doesn't exist, this method does nothing.
The note to remove.
Attempts to store a note within the tracker. If the channel argument matches a number in the filter, it is accepted. If the filter is an empty array, the note will always be accepted.
If a note could not be added, this method returns nothing.
True if the note was added, false if rejected by the filter, or if the note already exists in the tracker.
OptionalonCallback that is invoked when a note is successfully added. Acts as an event.
Override this property to handle this event.
const tracker = new NoteTracker();
tracker.onNoteAdded = () => {
console.log("new note added");
};
The implementation of this property means that there can only ever be one
callback for onNoteAdded events, as reassigning this value means that
the old callback will be deleted. As a general workaround, each
DynamicGraphic instance should be given it's own NoteTracker when
creating a new layout.
OptionalonCallback that is invoked when a note is deleted. Acts as an event.
Override this property to handle this event.
const tracker = new NoteTracker();
tracker.onNoteDeleted = () => {
console.log("note deleted");
};
The implementation of this property means that there can only ever be one
callback for onNoteDeleted events, as reassigning this value means that
the old callback will be deleted. As a general workaround, each
DynamicGraphic instance should be given it's own NoteTracker when
creating a new layout.
NoteTracker logs data regarding MIDI note data. It is used to keep track of the currently active notes, and record the timestamps of when notes were last added/removed.
NoteTracker comes with a filtering system to prevent notes from being added if their channel number doesn't match a list of accepted numbers. Additionally, it cannot store multiple instances of the same note. If a note already exists within the tracker, it is ignored.
Remarks
Note timestamps are generated using Date.now(), meaning that the timestamp is in milliseconds, relative to the epoch (12:00 AM, January 1, 1970, UTC).
Notes are stored as the actual MIDI note value, meaning that the note value range is 0 to 127, rather than 1 to 128.