Piano ctrl
piano-ctrl.js Many operations on clip events involve all or many events of a clip, e.g. select-all, move. Clips can potentially have many events (e.g. hundreds or thausands of notes), the time needed for IPC calls to modify events increases linearly with the number of events involved (change_batch() call arguments and fetching updates via list_all_notes()). Using 'await' for an IPC call at every pointermove with several thausand events on a clip takes too long to maintain good interactive behaviour. So we use a transactional programming model for note modifications, that allows to combine many note updates (e.g. selection rectangle changes) into a single IPC call, but not all (e.g. note creation needs await-synchronisation for note.id creation). Consequently operations are applied to a local cache of clip events and only a limited number of functions may be used to modify notes.
queue_change_selection(): modify cached selection of notes according to a predicate queue_modify_notes(): modify local event cache with a callback
The predicate or callback will be executed after the queue_*() call, so external objects should not be referenced, copy needed objects into locals first.
Note that IPC notifications are delivered before the reply value of a modifying call, so proper notification handling with immediate reload requests will produce a consistent remote cache. Commits are diffing the modified events against the cached state. While these comparisons take extra time, significant savings can be accomplished by reducing the IPC traffic.
Constants
[list_actions
]{#list_actions data-4search="ui/b/piano-ctrl.js:list_actions;export"}
: List menu actions for PianoRoll.
Functions
[ntool
]{#ntool data-4search="ui/b/piano-ctrl.js:ntool;func"} (
toolmode, drag_event, cursor, predicate)
: Add/register piano-roll canvas tool
[notes_canvas_drag_select
]{#notes_canvas_drag_select data-4search="ui/b/piano-ctrl.js:notes_canvas_drag_select;func"} (
event, MODE)
: ### Select Tool
The Select Tool allows selection of single notes or groups of notes. Modifier keys can be used to modify the selection behavior.
### Horizontal Select
[notes_canvas_drag_paint
]{#notes_canvas_drag_paint data-4search="ui/b/piano-ctrl.js:notes_canvas_drag_paint;func"} (
event, MODE)
: ### Paint Tool
With the note Paint Tool, notes can be placed everywhere in the grid by clicking mouse button 1 and possibly keeping it held during drags.
[notes_canvas_drag_move
]{#notes_canvas_drag_move data-4search="ui/b/piano-ctrl.js:notes_canvas_drag_move;func"} (
event, MODE)
: ### Move Tool
With the note Move Tool, selected notes can be moved clicking mouse button 1
and keeping it held during drags. A copy will be made instead of moving
the selected notes if the ctrl key is pressed during drag.
[notes_canvas_drag_resize
]{#notes_canvas_drag_resize data-4search="ui/b/piano-ctrl.js:notes_canvas_drag_resize;func"} (
event, MODE)
: #### Resizing Notes
When the Paint Tool is selected, the right edge of a note can be draged to make notes shorter or longer in duration.
[notes_canvas_drag_erase
]{#notes_canvas_drag_erase data-4search="ui/b/piano-ctrl.js:notes_canvas_drag_erase;func"} (
event, MODE)
: ### Erase Tool
The Erase Tool allows deletion of all notes selected during a mouse button 1 drag. The deletion can be aborted by the Escape key.
[note_hover_body
]{#note_hover_body data-4search="ui/b/piano-ctrl.js:note_hover_body;func"} (
coords, tick, key, notes)
: Detect note if hovering over its body
[note_hover_tail
]{#note_hover_tail data-4search="ui/b/piano-ctrl.js:note_hover_tail;func"} (
coords, tick, key, notes)
: Detect note if hovering over its tail
[note_hover_head
]{#note_hover_head data-4search="ui/b/piano-ctrl.js:note_hover_head;func"} (
coords, tick, key, notes)
: Detect note if hovering over its head
[notes_canvas_tool_from_hover
]{#notes_canvas_tool_from_hover data-4search="ui/b/piano-ctrl.js:notes_canvas_tool_from_hover;func"} (
piano_roll, pointerevent)
: Get drag tool and cursor from hover position
[target_coords
]{#target_coords data-4search="ui/b/piano-ctrl.js:target_coords;func"} (
event, target)
: Translate event offsetX,offsetY into taret element