Constructor
new PianoRollCanvas(query, trackName, horizontalCells, verticalCells, beatsPerCell)
Construct a pianoroll canvas widget instance and draw it to the screen.
Parameters:
| Name | Type | Description |
|---|---|---|
query |
string | String containing html id of the canvas we are constructing for. |
trackName |
string | String containing the track name that this widget corresponds to. |
horizontalCells |
number | The number of horizontal cells to draw. |
verticalCells |
number | The number of vertical cells to draw. |
beatsPerCell |
number | The number of beats each cell containg. |
- Source:
Members
beatsPerCell
The number of beats per cell of our piano roll grid.
- Source:
coord
The coords of the mouse.
- Source:
inputMode
The current input mode.
- Source:
inputModes
The various input modes of this widget. Select mode is used for selecting several notes at once. Note mode
is used for entering notes via mouse clicks. Delete mode is used to remove notes by individually clicking on
them. Paste mode copies notes currently selected from using the select mode to the current cursor position.
Remove mode deletes collections of notes which were selected via the select mode.
- Source:
instrument
The instrument this widget is a parameter for (as a list of widgets).
- Source:
leftClickEnd
The coords of the mouse at the release of a click.
- Source:
leftClickStart
the coords of the mouse at the start of a click.
- Source:
lineWidth
Used for setting width of lines.
- Source:
localHeight
Height of a cell in local, i.e., not screen coords.
- Source:
localWidth
Width of a cell in local, i.e., not screen coords.
- Source:
mousePressed
Tracks if mouse has been pressed or not.
- Source:
name
The name of the instrument this widget is a parameter for.
- Source:
rectangleList
The list of rectangles created so far.
- Source:
scaleAmtX
Amount X scaling changes by.
- Source:
scaleAmtY
Amount Y scaling changes by.
- Source:
selectedRectangles
The collection of rectangles (notes) selected while in select mode.
- Source:
selectionOutlineWidth
The outline width of the selection rectangle for drawing it to the screen.
- Source:
selectionRectangle
The rectangle used for select mode. All notes within this rectangle's bounds are selected.
- Source:
snapAmount
Configures the fraction of cell that snapping occurs on.
- Source:
trackName
The name of the track this widget is assigned to.
- Source:
translateAmt
Amount translate changes by.
- Source:
triggerMode
Controls whether the widget triggers notes or controls parameters.
- Source:
widgetType
On file save/load denotes the type of widget that this widget is.
- Source:
workingRectangle
The rectangle being created this mouse click.
- Source:
Methods
addRectangle(rect)
Add rectangle to the rectangle list of this object.
Parameters:
| Name | Type | Description |
|---|---|---|
rect |
object | The rectangle to add to the list. |
- Source:
applyScale(x, y)
Apply a scaling to the current instrument.
Parameters:
| Name | Type | Description |
|---|---|---|
x |
number | Scale factor in x direction. |
y |
number | Scale factor in y direction. |
- Source:
applyTranslate(x, y)
Apply a translation to the current instrument.
Parameters:
| Name | Type | Description |
|---|---|---|
x |
number | Translation amount in x direction. |
y |
number | Translation amount in y direction. |
- Source:
buttonClick(ev)
Handles button clicks from the user.
Parameters:
| Name | Type | Description |
|---|---|---|
ev |
event | The event containing the button click we are handling. |
- Source:
cellsToSeconds(c, bpm)
Convert a raw cell number to a value in seconds.
Parameters:
| Name | Type | Description |
|---|---|---|
c |
number | The cell number to convert. |
bpm |
number | Beats per minute, required to do unit conversion of times. |
- Source:
Returns:
Converted value described above.
clickHelper()
Helper that sets up leftClickEnd and leftClickStarts coordinates.
- Source:
convertRectToNote(rect, bpm)
Converts the input rectangle to a quadruple [start time, duration, note].
Parameters:
| Name | Type | Description |
|---|---|---|
rect |
object | The input rectangle to convert. |
bpm |
number | Beats per minute, required to do unit conversion of times. |
- Source:
Returns:
Tuple containing tuple in form [start, time, duration, note] for input note with bpm.
deleteModeLeftClick()
Handle left clicks while in delete mode.
- Source:
draw()
Draw the current state of the widget to the screen.
- Source:
drawRectangle(c1, c2, color)
Draw a rectangle with the given points and color.
Parameters:
| Name | Type | Description |
|---|---|---|
c1 |
object | Object denoting top left coord of rectangle. |
c2 |
object | Object denoting bottom right coord of rectangle. |
color |
string | String containing the color of the rectangle. |
- Source:
drawRectangleOutline(c1, c2, width)
Draw a rectangle outline with the given points.
Parameters:
| Name | Type | Description |
|---|---|---|
c1 |
object | Object denoting top left coord of rectangle. |
c2 |
object | Object denoting bottom right coord of rectangle. |
width |
number | Number denoting the width of the rectangle outline. |
- Source:
drawSelectionRectangle(c1, c2, width)
Draw a rectangle denoting selection of notes.
Parameters:
| Name | Type | Description |
|---|---|---|
c1 |
object | Object denoting top left coord of rectangle. |
c2 |
object | Object denoting bottom right coord of rectangle. |
width |
number | Number denoting the width of the rectangle outline. |
- Source:
getBeatsPerCell()
Getter for the number of beats per cell.
- Source:
Returns:
The number of beats per cell.
getName()
Get the name of the instrument associated with this parameter widget.
- Source:
Returns:
The above mentioned name.
getNoteOutput(bpm)
Creates array of note quadruples in [start, time, duration, note] format from rectangle list.
Parameters:
| Name | Type | Description |
|---|---|---|
bpm |
number | Beats per minute, required to do unit conversion of times. |
- Source:
Returns:
Array containing list of tuples in the above form.
getNotes()
Getter for the number of notes displayed vertically by this widget.
- Source:
Returns:
The number of cells per beat.
getTrack()
Get the trackname associated to the instrument this parameter widget is assigned to.
- Source:
Returns:
The above mentioned name.
getTriggerMode()
Gets the trigger mode for this parameter widget.
- Source:
Returns:
The trigger mode of this parameter widget.
helperText()
Prints helper text to the top right corner of the widget.
- Source:
inSelectionBounds(rect)
Checks if the given rectangle overlaps with the selection rectangle.
Parameters:
| Name | Type | Description |
|---|---|---|
rect |
object | Rectangle (array containing topleft/bottom right coords) to test intersection against. |
- Source:
Returns:
true or false depending on if rect intersects with the selection rectangle.
leftClickDown()
Handle when mouse left click is pressed down.
- Source:
leftClickUp()
Handle release of mouse left click.
- Source:
nonTriggerModeClick()
Handle when mouse left click is pressed down while not in trigger mode.
- Source:
noteToPitchClass(n)
Converts a note to a pitch class value.
Parameters:
| Name | Type | Description |
|---|---|---|
n |
number | The note number to convert. |
- Source:
Returns:
String containing pitch class and octave information of the note n.
reconfigure(state)
Set up the state of the widget based on the input argument.
Parameters:
| Name | Type | Description |
|---|---|---|
state |
object | The state used to configure the widget. |
- Source:
rectangleCollision(pt, rect)
Checks if point pt lies inside rectangle rect.
Parameters:
| Name | Type | Description |
|---|---|---|
pt |
object | Point to test for inclusion. |
rect |
object | Rectangle (array containing topleft/bottom right coords) to test inclusion of pt against. |
- Source:
Returns:
true or false depending on if pt lies in rect.
rectangleXAxisCollision(pt, rect)
Checks if point pt's x coordinate lies inside rectangle rect's x axis bounds.
Parameters:
| Name | Type | Description |
|---|---|---|
pt |
object | Point to test with. |
rect |
object | Rectangle (array containing topleft/bottom right coords) to test against. |
- Source:
Returns:
true or false depending on if the x coord of pt lies within the x axis bounds of rect.
registerInstrument(inst, name)
Stores the instrument array corresponding to this parameter widget.
Parameters:
| Name | Type | Description |
|---|---|---|
inst |
object | The instrument array. |
name |
string | The name of the instrument containing this parameter widget. |
- Source:
scaleAll(x, y)
Scale all params in the instrument array (including this one).
Parameters:
| Name | Type | Description |
|---|---|---|
x |
number | Scale factor in x direction. |
y |
number | Scale factor in y direction. |
- Source:
scaleAmountAll(x, y)
Set scale amount for all params in the instrument array (including this one).
Parameters:
| Name | Type | Description |
|---|---|---|
x |
number | Scale factor in x direction. |
y |
number | Scale factor in y direction. |
- Source:
screenToWorldCoords(p)
Converts the coordinates of the input point in screen coordinates to local/world coordinates.
Parameters:
| Name | Type | Description |
|---|---|---|
p |
object | Point to convert. |
- Source:
Returns:
A new point with transformed x and y coords.
setInstrument(inst)
Sets the instrument array corresponding to this parameter widget.
Parameters:
| Name | Type | Description |
|---|---|---|
inst |
object | The instrument array. |
- Source:
setName(name)
Sets the name of the instrument associated with this parameter widget.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | The name to set. |
- Source:
setScaleAmount(x, y)
Set the scaling amount for the current instrument.
Parameters:
| Name | Type | Description |
|---|---|---|
x |
number | Scale factor in x direction. |
y |
number | Scale factor in y direction. |
- Source:
setSnapAmount(n)
Setter for the fraction of a cell that snapping occurs to.
Parameters:
| Name | Type | Description |
|---|---|---|
n |
number | Fraction of a cell to snap to. |
- Source:
setTranslateAmount(x, y)
Set the translation amount for the current instrument
Parameters:
| Name | Type | Description |
|---|---|---|
x |
number | Translation amount in x direction. |
y |
number | Translation amount in y direction. |
- Source:
setTriggerMode(t)
Sets the trigger mode for this parameter widget.
Parameters:
| Name | Type | Description |
|---|---|---|
t |
boolean | True if this parameter widget is in trigger mode else false. |
- Source:
snapToGrid(c)
Snap input coordinates to grid and return the resulting coord
Parameters:
| Name | Type | Description |
|---|---|---|
c |
number | the coordinate to snap to the grid. |
- Source:
Returns:
The coordinate resulting from snapping c to the grid.
splice(i, j)
Splice the rectangle list. See javascript array splice() method documentation.
Parameters:
| Name | Type | Description |
|---|---|---|
i |
number | The index to remove items from. |
j |
number | The number of items to be removed. |
- Source:
translateAll(x, y)
Translate all params in the instrument array (including this one).
Parameters:
| Name | Type | Description |
|---|---|---|
x |
number | Translation amount in x direction. |
y |
number | Translation amount in y direction. |
- Source:
translateAmountAll(x, y)
Set translate amount for all params in the instrument array (including this one).
Parameters:
| Name | Type | Description |
|---|---|---|
x |
number | Translate amount in x direction. |
y |
number | Translate amount in y direction. |
- Source:
updateMouseCoordinates()
Update the current coordinates of the mouse.
- Source: