Add step sequencer feature (#9703)

* sequencer: create togglable feature

* sequencer: add support for steps

* sequencer: add support for tempo and resolutions

* sequencer: schedule a message print at the right frequency

* sequencer: send a hardcoded note

* sequencer: add support for 8 tracks

* sequencer: play several notes simultaneously

* sequencer: only play the active tracks for a given step

* sequencer: change the default behavior of the track toggler

* sequencer: make number of tracks and track notes customizable

* sequencer: move the keycodes down

Not adding them at the end of the list apparently risks breaking
compatibility with VIA.

Source: https://github.com/qmk/qmk_firmware/pull/9703#discussion_r459202733

* sequencer: add unit tests

* sequencer: add unit test for matrix_scan_sequencer

* sequencer: expose internal state for better unit-testability

* sequencer: add unit tests for matrix_scan_sequencer
This commit is contained in:
Rodolphe Belouin 2020-11-08 04:35:14 +01:00 committed by GitHub
parent 4cdd3005d6
commit 38527f9a3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 1280 additions and 0 deletions

View file

@ -16,6 +16,10 @@
#ifndef QUANTUM_KEYCODES_H
#define QUANTUM_KEYCODES_H
#if defined(SEQUENCER_ENABLE)
# include "sequencer.h"
#endif
#ifndef MIDI_ENABLE_STRICT
# define MIDI_ENABLE_STRICT 0
#endif
@ -550,6 +554,37 @@ enum quantum_keycodes {
JS_BUTTON31,
JS_BUTTON_MAX = JS_BUTTON31,
#if defined(SEQUENCER_ENABLE)
SQ_ON,
SQ_OFF,
SQ_TOG,
SQ_TMPD, // Decrease tempo
SQ_TMPU, // Increase tempo
SEQUENCER_RESOLUTION_MIN,
SEQUENCER_RESOLUTION_MAX = SEQUENCER_RESOLUTION_MIN + SEQUENCER_RESOLUTIONS,
SQ_RESD, // Decrease resolution
SQ_RESU, // Increase resolution
SQ_SALL, // All steps on
SQ_SCLR, // All steps off
SEQUENCER_STEP_MIN,
SEQUENCER_STEP_MAX = SEQUENCER_STEP_MIN + SEQUENCER_STEPS,
SEQUENCER_TRACK_MIN,
SEQUENCER_TRACK_MAX = SEQUENCER_TRACK_MIN + SEQUENCER_TRACKS,
/**
* Helpers to assign a keycode to a step, a resolution, or a track.
* Falls back to NOOP if n is out of range.
*/
# define SQ_S(n) (n < SEQUENCER_STEPS ? SEQUENCER_STEP_MIN + n : XXXXXXX)
# define SQ_R(n) (n < SEQUENCER_RESOLUTIONS ? SEQUENCER_RESOLUTION_MIN + n : XXXXXXX)
# define SQ_T(n) (n < SEQUENCER_TRACKS ? SEQUENCER_TRACK_MIN + n : XXXXXXX)
#endif
// always leave at the end
SAFE_RANGE
};