afterglow.controllers.color

Provides support for adjusting components of a show variable containing a color using any MIDI controller.

add-midi-control-to-color-mapping

(add-midi-control-to-color-mapping device-filter channel control-number variable component & {:keys [min max transform-fn]})

Cause specified component of the color value stored in the specified variable in *show* to be updated by any MIDI controller-change messages from the specified device sent on the specified channel and control-number.

The first MIDI input source whose device matches the device-filter (using filter-devices) will be chosen.

The values you can pass for component include :red, :green, :blue, :hue, :saturation, and :lightness.

As control changes come in, they will be mapped from the MIDI range (of 0 to 127) to the legal range for the chosen color component. If :min and/or :max are specified, the values will be scaled to the supplied range instead, but will still be clamped to fit within legal values for the chosen color component (RGB values can range from 0 to 255, hues from 0 to 360, and saturation and lightness from 0 to 100).

If :transform-fn is specified, it will be called with the scaled color component value, and its return value will be assigned to the color, although once again the value will be clamped to within the legal range for the component.

Returns a MIDI mapping function, which can be passed to remove-control-mapping if you later want to stop the MIDI control affecting the color variable.