afterglow.controllers.tempo
Provides support for easily implementing tap-tempo and shift buttons on any MIDI controller.
add-midi-control-to-shift-mapping
(add-midi-control-to-shift-mapping device-filter channel kind note & {:keys [feedback-on feedback-off], :or {feedback-on 127, feedback-off 0}})
Sets up a controller pad or button to act as a shift button which can be used to modify other mappings. The shift state is entered whenever the specified note (when kind
is :note
) or controller-change (when kind
is :control
) message is received with a non-zero velocity (or control value) on the specified channel
. The shift state is ended whenever a matching note-off or controller-change message with velocity zero is received.
The device to be mapped is identified by device-filter
. The first input port which matches using filter-devices will be used.
Afterglow will attempt to provide feedback by lighting the pad or button when it is held down by sending note on/off or control-change values to the same controller. The note velocities or control values used can be changed by passing in different values with :feedback-on
and :feedback-off
, and this behavior can be suppressed entirely by passing false
with :feedback-on
.
Returns a map containing an entry :state
whose value is a function that can be called to check the state of the shift button, returning true
whenever it is held down. There are other entries in the map which are used for the mapping’s own purposes. Pass the entire map to remove-midi-control-to-shift-mapping if you ever want to stop the MIDI control or note from acting like a shift button.
add-midi-control-to-tempo-mapping
(add-midi-control-to-tempo-mapping device-filter channel kind note & {:keys [feedback-on feedback-off shift-fn], :or {feedback-on 127, feedback-off 0, shift-fn (constantly false)}})
Sets up a controller pad or button to act as a sync-aware Tap Tempo button for the default metronome in *show*. Whenever the specified note (when kind
is :note
) or controller-change (when kind
is :control
) message is received with a non-zero velocity (or control value), the appropriate tempo adjustment action is taken.
-
If the show’s sync mode is manual, this will invoke a low-level metronome tap-tempo handler to adjust the metronome tempo.
-
If the show’s sync mode is MIDI, calling the returned function will align the current beat to the tap.
-
If the show’s sync mode is DJ Link or Traktor Beat phase (so beats are already automatically aligned), calling the returned function will align the current beat to be a down beat (first beat of a bar).
The device to be mapped is identified by device-filter
. The first input port which matches using filter-devices will be used.
Afterglow will attempt to provide feedback by flashing the pad or button on each beat sending note on/off or control-change values to the same controller. The note velocities or control values used can be changed by passing in different values with :feedback-on
and :feedback-off
, and this behavior can be suppressed entirely by passing false
with :feedback-on
.
If you have set up a button on your controller to act like the shift button on one of the full-featured grid controllers, you can pass in a function with :shift-fn
that returns true
when that the shift button is held down. Whenever that function returns true
for a tempo tap, the returned tap handler function will synchronize at the next higher level. (In other words, if it was going to be a tempo tap, it would be treated as a beat tap; what would normally be a beat tap would be treated as a bar tap, and a bar tap would be promoted to start a phrase.) When you map a shift button using add-midi-control-to-shift-mapping, it gives you a function that is suitable for use with :shift-fn
as the value of the :state
key in the map it returns.
Returns the tempo-mapping function which can be passed to remove-midi-control-to-tempo-mapping if you ever want to stop the MIDI control or note from affecting the metronome in the future.
create-show-tempo-tap-handler
(create-show-tempo-tap-handler show & {:keys [shift-fn], :or {shift-fn (constantly false)}})
Returns a function that provides higher level tempo tap support for a show, based on the sync mode of the show metronome. Call the returned function whenever the user has tapped your tempo button.
-
If the show’s sync mode is manual, this will invoke a low-level metronome tap-tempo handler to align the beat to the tap, and (if three or more taps occur within two seconds of each other) adjust the metronome tempo.
-
If the show’s sync mode is MIDI, calling the returned function will align the current beat to the tap.
-
If the show’s sync mode is DJ Link or Traktor Beat phase (so beats are already automatically aligned), calling the returned function will align the current beat to be a down beat (first beat of a bar).
If you have set up a button on your controller to act like the shift button on one of the full-featured grid controllers, you can pass in a function with :shift-fn
that returns true
when that the shift button is held down. Whenever that function returns true
for a tempo tap, the returned tap handler function will synchronize at the next higher level. (In other words, if it was going to be a tempo or beat tap, it would be treated as a bar tap, and what would normally be a bar tap would be promoted to start a phrase.) If the metronome is not locked into a beat grid, when you set the position of a bar by shift-tapping, the beat is also aligned with the tap.
Returns a map describing the result of the current tempo tap.
remove-midi-control-to-shift-mapping
(remove-midi-control-to-shift-mapping device-filter channel kind note mapping)
Undoes the effect of add-midi-control-to-tempo-mapping. You must pass the value that was returned by that function as the argument mapping
.
remove-midi-control-to-tempo-mapping
(remove-midi-control-to-tempo-mapping device-filter channel kind note f)
Undoes the effect of add-midi-control-to-tempo-mapping. You must pass the value that was returned by that function as the argument f
.