afterglow.controllers.ableton-push-2
Allows the Ableton Push 2 to be used as a control surface for Afterglow. Its features are described in the Developer Guide.
add-button-held-feedback-overlay
(add-button-held-feedback-overlay controller button)
Adds a simple overlay which keeps a control button bright as long as the user is holding it down.
add-custom-control-button
(add-custom-control-button controller button press-fn release-fn)
Activates an otherwise-unused button which responds to a control message, causing it to run custom code when pressed and released.
build-touch-strip-mode
(build-touch-strip-mode & flags)
Calculate a touch strip mode byte based on a list of flags (keys in touch-strip-mode-flags
).
button-cell-margin
The number of pixels to keep blank between labels of adjacent buttons.
button-cell-width
The number of pixels allocated to each button above or below the graphical display.
calculate-text-width
(calculate-text-width graphics font text)
Figure out how many pixels wide some text will be in a given font.
clear-all-touch-strip-leds
(clear-all-touch-strip-leds controller)
Send a System Exclusive message which requests all touch strip LEDs be turned off.
clear-interface
(clear-interface controller)
Clears the graphical display and all illuminated buttons and pads.
create-graphics
(create-graphics controller)
Create the graphics object we will use to draw in the display, and configure its rendering hints properly.
cue-grid-updates
(cue-grid-updates controller)
See if any of the cue grid button states have changed, and list any required updates as tuples of the pad x and y coordinates, corresponding grid pad array index, and the new desired color.
deactivate
(deactivate controller & {:keys [disconnected], :or {disconnected false}})
Deactivates a controller interface, killing its update thread and removing its MIDI listeners. If :disconnected
is passed with a true
value, it means that the controller has already been removed from the MIDI environment, so no effort will be made to clear its display or take it out of User mode.
In general you will not need to call this function directly; it will be dispatched to via controllers/deactivate when that is called with a controller binding implementation from this namespace. It is also called automatically when one of the controllers being used disappears from the MIDI environment.
draw-attributed-variable-value
(draw-attributed-variable-value controller index encoder-count attributed-string color)
Draw a label under an encoder at the top of the graphical display, with an attributed string so the label can have mixed fonts, colors, etc. Assumes the value will fit in the allocated space.
draw-beat-mark
(draw-beat-mark graphics snapshot beat-position)
Draw one of the marks representing a beat on the beat grid.
draw-boolean-gauge
(draw-boolean-gauge controller index encoder-count value & {:keys [track-color active? fraction], :or {track-color default-track-color, fraction 1.0}})
Draw a graphical gauge with an indicator that covers the left or right half of an arc under a variable value, depending on if the value is true or false. The default color for the track is dim white. The color for the current value area is either red (for no) or green (for yes), and is dimmed when :active?
is false. To support animating state changes, a :fraction
parameter can be supplied which specifies how far from the opposite state the indicator should be drawn.
draw-bottom-button-label
(draw-bottom-button-label controller index text color & {:keys [background-color], :or {background-color off-color}})
Draw a label for a button below the graphical display.
draw-circular-gauge
(draw-circular-gauge controller index encoder-count value & {:keys [lowest highest track-color active-color], :or {lowest 0, highest 360, track-color default-track-color, active-color track-color}})
Draw a graphical gauge with an indicator that rides around an circle (starting at the bottom) under a variable value. The default range is from 0 to 360 (for hues), and the default color for both the track and active area is dim white.
draw-cue-variable-gauge
(draw-cue-variable-gauge controller index encoder-count cue cue-var effect-id)
Draw an appropriate gauge for a cue variable given its type and value.
draw-cue-variable-gauges
(draw-cue-variable-gauges controller x cue effect-id)
Displays the appropriate style of adjustment gauge for variables currently assigned to the encoders over an active cue.
draw-cue-variable-names
(draw-cue-variable-names controller x cue effect-id)
Draw the names of adjustable variables under the appropriate encoders for a cue.
draw-cue-variable-value
(draw-cue-variable-value controller index encoder-count text color)
(draw-cue-variable-value controller index encoder-count text color font)
Draw a label under an encoder at the top of the graphical display.
draw-cue-visualizer
(draw-cue-visualizer controller snapshot cell-x cue var-map)
Displays an animated visualization of the cue progress right above the name for cues which support this.
draw-encoder-button-label
(draw-encoder-button-label controller index encoder-count text color)
Draw a label under an encoder at the top of the graphical display.
draw-gauge
(draw-gauge controller index encoder-count value & {:keys [lowest highest track-color active-color], :or {lowest 0, highest 100, track-color default-track-color, active-color track-color}})
Draw a graphical gauge with an indicator that fills an arc under a variable value. The default range is from zero to a hundred, and the default color for both the track and active area is dim white.
draw-hue-gauge
(draw-hue-gauge controller index encoder-count value active?)
Draw a graphical gauge whose colors are the hues of the color circle, with an indicator that rides around an circle (starting at the bottom) under a variable value.
draw-null-gauge
(draw-null-gauge controller index encoder-count color)
Draw a mostly meaningless gauge simply to indicate that the encoder is doing something. Used for beat adjustments, for example, which have no reasonable range or location to show.
draw-pan-gauge
(draw-pan-gauge controller index encoder-count value & {:keys [lowest highest track-color active-color], :or {lowest 0, highest 100, track-color default-track-color, active-color track-color}})
Draw a graphical gauge with an indicator that extends from the top center of an arc under a variable value. The default range is from zero to a hundred, and the default color for both the track and active area is dim white.
draw-saturation-gauge
(draw-saturation-gauge controller index encoder-count hue value active?)
Draw a graphical gauge whose colors are the saturation levels of the specified hue circle, with an indicator like that of a level gauge, under a variable value.
encoder-label-underline-height
The height at which to draw the line under an encoder label.
fit-string
(fit-string text font render-context max-width)
Truncates a string (appending an ellipsis) enough to fit within a given pixel width.
get-display-font
(get-display-font k style size)
Find one of the fonts configured for use on the display by keyword, which should be one of :condensed
, :condensed-light
, :roboto
, or :roboto-medium
. The style
argument is a java.awt.Font
style constant, and size
is point size.
Roboto is available in all style variations, Roboto Medium in plain and italic, Condensed only in bold, and condensed light in plain and italic.
grid-update-chunk-size
The number of cue grid LED updates that can be sent before we need to wait and re-synch with the Push 2, to avoid overflowing buffers.
in-mode?
(in-mode? controller button)
Check whether the controller is in a particular mode, identified by a control button number or keyword.
light-custom-buttons
(light-custom-buttons controller)
Light any custom buttons that have been configured to make it clear they are active. (If the button already has a lightness value, it was not appropriate for it to have been configured as a custom button, so leave it alone.)
load-fonts
(load-fonts)
Load and register the fonts we will use to draw on the display, if they have not already been.
no-effects-active-color
The color to use for the text explaining that no effects are active.
port-filter
Because the Push registers multiple ports with the MIDI environment, we need to be sure to bind only to the User port. This filter is used with filter-devices to screen out any port that does not seem to be the User port. If port names are assigned differently on your operating system, you may need to change this (and please open a Pull Request); this filter seems to work for Mac OS X and Windows.
record-interface
(record-interface controller path & {:keys [loop], :or {loop true}})
Capture an animated GIF of the display for documentation purposes. Takes a filename to which the animation should be written. Returns a function which you must call to end the recording and close the file. Defaults to creating an animation which loops, but you can override that by passing false
with the optional keyword argument :loop
.
send-sysex
(send-sysex controller command)
Send a MIDI System Exclusive command to the Push 2 with the proper prefix. The command
argument begins with the Command ID of the desired command, as listed in Table 2.4.2 of the Ableton Push 2 MIDI and Display Interface Manual, followed by its parameter bytes. The SOX
byte, Ableton Sysex ID, device ID, and model ID will be prepended, and the EOX
byte appended, before sending the command.
set-button-color
(set-button-color controller button color)
Set one of the labeled buttons to a particular color (if it is a monochrome button, the lightness of the color is translated to a control value; otherwise, the palette entry assigned to the button is set to the specified color, and the corresponding velocity is sent.
set-cc-led-color
(set-cc-led-color controller control palette-index color)
Set one of the color LEDs that respond to control change values to a particular color. If the color is black, we send a control value of zero. Otherwise, we take over the color palette entry assigned to the LED, and set it to the desired RGB value, then send it a control change with the velocity corresponding to the palette entry we just adjusted.
Since we also have to set a white value, we pass along the white value that was present in the palette we found for this entry when initially binding to the Push 2.
set-encoder-pad-color
(set-encoder-pad-color controller x color)
Set one of the pads below the row of display encoders to a particular color.
set-graphics-color
(set-graphics-color graphics color)
Set the paint of the supplied graphics context to use the specified color.
set-pad-color
(set-pad-color controller x y color)
Set the color of one of the 64 touch pads to a specific RGB color. If the color is black, we send a note off to the pad. Otherwise, we take over the color palette entry whose velocity matches the note number of the pad, and set it to the desired RGB value, then send it a note with the velocity corresponding to the palette entry we just adjusted.
Since we also have to set a white value, we pass along the white value that was present in the palette we found for this velocity when initially binding to the Push 2.
set-top-pad-color
(set-top-pad-color controller x color)
Set one of the top-row pads (between the grid and the display) to a particular color.
set-touch-strip-mode
(set-touch-strip-mode controller mode)
Set the touch strip operating mode.
show-labels
(show-labels controller)
(show-labels controller color)
Illuminates all buttons with text labels, for development assistance.
sign-velocity
(sign-velocity val)
Convert a midi velocity to its signed equivalent, to translate encoder rotations, which are twos-complement seven bit numbers.
string-width
(string-width text font render-context)
Determines how many pixels wide a string will be in a given font and render context.
touch-strip-mode-default
The mode to which we should return the touch strip when we are shutting down.
touch-strip-mode-flags
The values which are combined to set the touch strip into particular modes.
touch-strip-mode-hue
The mode to which we should set the touch strip when the user is editing a hue.
touch-strip-mode-level
The mode to which we should set the touch strip when the user is editing a pan-style control.
touch-strip-mode-pan
The mode to which we should set the touch strip when the user is editing a level-style control.
touch-strip-mode-sysex
The mode to which we should set the touch strip when we want to be able to individually set LEDs, for example to turn them all off.
update-cue-grid-chunk
(update-cue-grid-chunk controller updates)
Given a list of needed cue grid updates, send at most grid-update-chunk-size
of them, and return the remaining list.