classNoteClip
Source: waax.
new NoteClip()
NoteClip abstraction. A collection of Note objects. Instantiated by WX.NoteClip.
Methods
staticdelete(id) → (Note or null)
Deletes and returns a note from clip. Returns null when not found.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
id |
String |
|
Note ID. |
- Returns
-
(Note or null)
staticempty()
Flush out noteclip content.
staticfindNoteIdAtPosition(pitch, tick) → (String or null)
Find a note that contains a point specified by pitch and tick. Then returns note ID. Returns null when not found. Note that this impl might produce an undesirable result since it simply catches the first note detected in the iteration. There is no perfect solution over this problem, so I chose to make it robust instead.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
pitch |
Number |
|
MIDI pitch |
tick |
Number |
|
Position in tick. |
- Returns
-
(String or null)
staticfindNotesIdInArea(minPitch, maxPitch, startTick, endTick) → (Array or null)
Find notes in a area specified by pitch and tick. Then returns an array of notes. Returns null when nothing in target area. Note that this method only care for start time of note. If a note starts before than the area, it will not be included in the selection.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
minPitch |
Number |
|
Lower bound pitch. |
maxPitch |
Number |
|
Upper bound pitch. |
startTick |
Number |
|
Start time in tick. |
endTick |
Number |
|
End time in tick. |
- Returns
-
(Array or null)
staticget(id) → Object
Returns note from clip with id.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
id |
String |
|
Note ID. |
- Returns
-
Object
staticgetAllId() → Array
Retunrs an array with all the ID of notes.
- Returns
-
Array
staticgetSize() → Number
Returns clip size.
- Returns
-
Number
statichasId(id) → Boolean
Probes clip with note id.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
id |
String |
|
Note id. |
- Returns
-
Boolean
True if clip contains the note.
staticiterate(callback)
Iterates all the notes with callback function.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
callback |
|
Process for iteration. |
staticpush(note) → String
Pushes a new note into clip. Returns ID of the new note.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
note |
|
- Returns
-
String
Note ID.
staticscanNotesInTimeSpan(start, end) → (Array or null)
Returns an array of notes within a timespan. Returns null when not found. Note that this method actually returns Note objects, not IDs.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
start |
Number |
|
Start time in tick. |
end |
Number |
|
End time in tick. |
- Returns
-
(Array or null)
staticset(id, note)
Set a note with a specific ID. If the same ID found, update properties of the note. Otherwise, create a new note with a specified ID. Usually this method is used in the collaborative context.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
id |
String |
|
Note ID. |
note |
|
Note object. |