Constructor
new CodedEventCanvas(query, trackName, cells, beatsPerCell)
Construct a coded event 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. |
cells |
number | The number of horizontal 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:
controlPressed
Indicates whether we are in delete mode or not.
- Source:
coord
The coords of the mouse.
- 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
Width of lines for drawing.
- 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
Indicates whether or not we are in the middle of a mouse click.
- Source:
name
The name of the instrument this widget is a parameter for.
- Source:
rectangleList
The array of created events (as rectangles).
- Source:
scaleAmtX
Amount X scaling changes by.
- Source:
scaleAmtY
Amount Y scaling changes by.
- 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 in progress event (as a rectangle).
- Source:
workingText
The input text for the next event.
- 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:
controlLeftClickDown()
Handle when mouse left click is pressed down after control mode switch.
- 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.
draw()
Draw the current state of the widget to the screen.
- Source:
drawRectangle(rect)
Draw the given rectangle to the screen.
Parameters:
| Name | Type | Description |
|---|---|---|
rect |
object | The rectangle (as an array of coords) to draw. |
- Source:
drawRectangleOutline(c1, c2)
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. |
- 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:
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:
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: