Skip to content

Commit

Permalink
Change MIDI velocity implementation to allow direct control of veloci…
Browse files Browse the repository at this point in the history
…ty value (qmk#9940)

* Initial changes to expose "real" MIDI velocity

* Change MI_VELU and MI_VELD to fit new logic

* Apply cleanups from fauxpark's review

my bad on the errant whitespace and else {} placements

* Slight changes to MI_VELD to match values when velocity is falling to when it is rising

* Add keycode MI_VEL_0

* Update compute_velocity() to handle MI_VEL_0

* Store velocity as 7 bits to hard cap value at 127
  • Loading branch information
jakobkg authored and jMavarez committed Oct 14, 2021
1 parent bbd1a52 commit e5f4001
Showing 1 changed file with 155 additions and 36 deletions.
191 changes: 155 additions & 36 deletions quantum/quantum_keycodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,42 +246,161 @@ enum quantum_keycodes {
MI_A_5, // 5C74
MI_As_5, // 5C75
MI_Bb_5 = MI_As_5,
MI_B_5, // 5C76

MI_OCT_N2, // 5C77
MI_OCT_N1, // 5C78
MI_OCT_0, // 5C79
MI_OCT_1, // 5C7A
MI_OCT_2, // 5C7B
MI_OCT_3, // 5C7C
MI_OCT_4, // 5C7D
MI_OCT_5, // 5C7E
MI_OCT_6, // 5C7F
MI_OCT_7, // 5C80
MI_OCTD, // 5C81
MI_OCTU, // 5C82

MI_TRNS_N6, // 5C83
MI_TRNS_N5, // 5C84
MI_TRNS_N4, // 5C85
MI_TRNS_N3, // 5C86
MI_TRNS_N2, // 5C87
MI_TRNS_N1, // 5C88
MI_TRNS_0, // 5C89
MI_TRNS_1, // 5C8A
MI_TRNS_2, // 5C8B
MI_TRNS_3, // 5C8C
MI_TRNS_4, // 5C8D
MI_TRNS_5, // 5C8E
MI_TRNS_6, // 5C8F
MI_TRNSD, // 5C90
MI_TRNSU, // 5C91

MI_VEL_0, // 5C92
#ifdef VIA_ENABLE
MI_VEL_1 = MI_VEL_0,
#else
MI_VEL_1, // 5C93
MI_B_5,
# endif

# if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 5
MIDI_TONE_MAX = MI_B_5,
# elif MIDI_TONE_KEYCODE_OCTAVES > 4
MIDI_TONE_MAX = MI_B_4,
# elif MIDI_TONE_KEYCODE_OCTAVES > 3
MIDI_TONE_MAX = MI_B_3,
# elif MIDI_TONE_KEYCODE_OCTAVES > 2
MIDI_TONE_MAX = MI_B_2,
# elif MIDI_TONE_KEYCODE_OCTAVES > 1
MIDI_TONE_MAX = MI_B_1,
# elif MIDI_TONE_KEYCODE_OCTAVES > 0
MIDI_TONE_MAX = MI_B,
# endif

MIDI_OCTAVE_MIN,
MI_OCT_N2 = MIDI_OCTAVE_MIN,
MI_OCT_N1,
MI_OCT_0,
MI_OCT_1,
MI_OCT_2,
MI_OCT_3,
MI_OCT_4,
MI_OCT_5,
MI_OCT_6,
MI_OCT_7,
MIDI_OCTAVE_MAX = MI_OCT_7,
MI_OCTD, // octave down
MI_OCTU, // octave up

MIDI_TRANSPOSE_MIN,
MI_TRNS_N6 = MIDI_TRANSPOSE_MIN,
MI_TRNS_N5,
MI_TRNS_N4,
MI_TRNS_N3,
MI_TRNS_N2,
MI_TRNS_N1,
MI_TRNS_0,
MI_TRNS_1,
MI_TRNS_2,
MI_TRNS_3,
MI_TRNS_4,
MI_TRNS_5,
MI_TRNS_6,
MIDI_TRANSPOSE_MAX = MI_TRNS_6,
MI_TRNSD, // transpose down
MI_TRNSU, // transpose up

MIDI_VELOCITY_MIN,
MI_VEL_0 = MIDI_VELOCITY_MIN,
MI_VEL_1,
MI_VEL_2,
MI_VEL_3,
MI_VEL_4,
MI_VEL_5,
MI_VEL_6,
MI_VEL_7,
MI_VEL_8,
MI_VEL_9,
MI_VEL_10,
MIDI_VELOCITY_MAX = MI_VEL_10,
MI_VELD, // velocity down
MI_VELU, // velocity up

MIDI_CHANNEL_MIN,
MI_CH1 = MIDI_CHANNEL_MIN,
MI_CH2,
MI_CH3,
MI_CH4,
MI_CH5,
MI_CH6,
MI_CH7,
MI_CH8,
MI_CH9,
MI_CH10,
MI_CH11,
MI_CH12,
MI_CH13,
MI_CH14,
MI_CH15,
MI_CH16,
MIDI_CHANNEL_MAX = MI_CH16,
MI_CHD, // previous channel
MI_CHU, // next channel

MI_ALLOFF, // all notes off

MI_SUS, // sustain
MI_PORT, // portamento
MI_SOST, // sostenuto
MI_SOFT, // soft pedal
MI_LEG, // legato

MI_MOD, // modulation
MI_MODSD, // decrease modulation speed
MI_MODSU, // increase modulation speed

MI_BENDD, // Bend down
MI_BENDU, // Bend up
#endif // MIDI_ADVANCED

// Backlight functionality
BL_ON,
BL_OFF,
BL_DEC,
BL_INC,
BL_TOGG,
BL_STEP,
BL_BRTG,

// RGB functionality
RGB_TOG,
RGB_MODE_FORWARD,
RGB_MODE_REVERSE,
RGB_HUI,
RGB_HUD,
RGB_SAI,
RGB_SAD,
RGB_VAI,
RGB_VAD,
RGB_SPI,
RGB_SPD,
RGB_MODE_PLAIN,
RGB_MODE_BREATHE,
RGB_MODE_RAINBOW,
RGB_MODE_SWIRL,
RGB_MODE_SNAKE,
RGB_MODE_KNIGHT,
RGB_MODE_XMAS,
RGB_MODE_GRADIENT,
RGB_MODE_RGBTEST,

// Momentum matching toggle
VLK_TOG,

// Left shift, open paren
KC_LSPO,

// Right shift, close paren
KC_RSPC,

// Shift, Enter
KC_SFTENT,

// Printing
PRINT_ON,
PRINT_OFF,

// output selection
OUT_AUTO,
OUT_USB,
#ifdef BLUETOOTH_ENABLE
OUT_BT,
#endif
MI_VEL_2, // 5C94
MI_VEL_3, // 5C95
Expand Down

0 comments on commit e5f4001

Please sign in to comment.