Constructor
new SliderCanvas(query, trackName, horizontalCells, verticalCells, beatsPerCell, rectangleStyle)
Construct a slider 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. |
rectangleStyle |
string | The style of slider canvas to construct. |
- 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:
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:
maxOut
The maximum value a slider can take.
- Source:
minOut
The minimum value a slider can take.
- 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:
scaleAmtX
Amount X scaling changes by.
- Source:
scaleAmtY
Amount Y scaling changes by.
- Source:
sliderList
The array of created sliders.
- Source:
snapAmount
Configures the fraction of cell that snapping occurs on.
- Source:
styles
The possible display styles for this widget.
Lollipop mode displays values as vertical bars with a circle drawn at the top.
Solid mode displays amplitudes as rectangular blocks.
- 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:
workingSlider
The in progress slider.
- 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.
circleCoord(c)
Draw a circle around the input coord.
Parameters:
| Name | Type | Description |
|---|---|---|
c |
number | Coordinate to draw a circle around. |
- Source:
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.
distance(a, b)
Calculates the distance between the input points.
Parameters:
| Name | Type | Description |
|---|---|---|
a |
object | The first input point. |
b |
object | The second input point. |
- Source:
Returns:
The distance between the two input points.
draw()
Draw the current state of the widget to the screen.
- 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:
drawSlider(slider)
Draw the input slider.
Parameters:
| Name | Type | Description |
|---|---|---|
slider |
object | The input slider to draw. |
- 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:
lollipopCollision(c, slider)
Checks for collision between the input point and the input slider in lollipop mode.
Parameters:
| Name | Type | Description |
|---|---|---|
c |
object | The point to check for collision against. |
slider |
object | The slider to check for collision against. |
- Source:
Returns:
True if collision occured false otherwise.
lollipopStyle()
Draws the lollipop specified by the points c1 and c2.
- 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:
rectangleXAxisCollision1(pt, rect-)
Check if input pt lies in division/snapAmount of left point of rectangle along x axis.
Parameters:
| Name | Type | Description |
|---|---|---|
pt |
object | The point to check collisions against. |
rect- |
object | The rectangle to check collisions against. |
- Source:
Returns:
True if pt collides with rectangle false otherwise.
rectangleXAxisCollision2(pt, rect-)
Check if pt lies in x bounds of the given rectangle.
Parameters:
| Name | Type | Description |
|---|---|---|
pt |
object | The point to check collisions against. |
rect- |
object | The rectangle to check collisions against. |
- Source:
Returns:
True if pt collides with rectangle false otherwise.
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:
setMax(n)
Setter for maxOut parameter.
Parameters:
| Name | Type | Description |
|---|---|---|
n |
number | The new value for maxOut. |
- Source:
setMin(n)
Setter for maxIn parameter.
Parameters:
| Name | Type | Description |
|---|---|---|
n |
number | The new value for maxIn. |
- 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.
solidCollision(c, slider)
Checks for collision between the input point and the input slider in solid mode.
Parameters:
| Name | Type | Description |
|---|---|---|
c |
object | The point to check for collision against. |
slider |
object | The slider to check for collision against. |
- Source:
Returns:
True if collision occured false otherwise.
solidStyle()
Draws the rectangle specified by the points c1 and c2.
- Source:
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: