1
0
Fork 0

midi on planck

This commit is contained in:
Jack Humbert 2015-08-25 17:06:38 -04:00
parent e6dd47db45
commit 9b46f4021e
6 changed files with 47 additions and 13 deletions

View file

@ -124,7 +124,7 @@ COMMAND_ENABLE = yes # Commands for debug and configuration
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
# NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
# MIDI_ENABLE = YES # MIDI controls
MIDI_ENABLE = YES # MIDI controls
BACKLIGHT_ENABLE = yes
ifdef MIDI_ENABLE

View file

@ -19,11 +19,38 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "keymap_midi.h"
#include <lufa.h>
uint8_t starting_note = 0x0C;
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
{
if (id != 0) {
if (record->event.pressed) {
midi_send_noteon(&midi_device, opt, (id & 0xFF), 127);
} else {
midi_send_noteoff(&midi_device, opt, (id & 0xFF), 127);
}
}
if (record->event.key.col == (MATRIX_COLS - 1) && record->event.key.row == (MATRIX_ROWS - 1) && record->event.pressed) {
starting_note++;
midi_send_cc(&midi_device, 0, 0x7B, 0);
midi_send_cc(&midi_device, 1, 0x7B, 0);
midi_send_cc(&midi_device, 2, 0x7B, 0);
midi_send_cc(&midi_device, 3, 0x7B, 0);
midi_send_cc(&midi_device, 4, 0x7B, 0);
}
if (record->event.key.col == (MATRIX_COLS - 2) && record->event.key.row == (MATRIX_ROWS - 1) && record->event.pressed) {
starting_note--;
midi_send_cc(&midi_device, 0, 0x7B, 0);
midi_send_cc(&midi_device, 1, 0x7B, 0);
midi_send_cc(&midi_device, 2, 0x7B, 0);
midi_send_cc(&midi_device, 3, 0x7B, 0);
midi_send_cc(&midi_device, 4, 0x7B, 0);
}
if (record->event.pressed) {
midi_send_noteon(&midi_device, opt, (id & 0xFF), 127);
midi_send_noteon(&midi_device, record->event.key.row, starting_note + SCALE[record->event.key.col], 127);
} else {
midi_send_noteoff(&midi_device, opt, (id & 0xFF), 127);
midi_send_noteoff(&midi_device, record->event.key.row, starting_note + SCALE[record->event.key.col], 127);
}
}

View file

@ -18,8 +18,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef KEYMAP_MIDI_H
#define KEYMAP_MIDI_H
#define MIDI 0x6000
#define MIDI12 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000
#define CHNL(note, channel) (note + (channel << 8))
#define SCALE (int []){ 0, 2, 4, 5, 7, 9, 11, 12, 14, 16, 17, 19, 21, 23, 24, 26, 28, 29, 31, 33, 35, 36}
#define N_CN1 (0x600C + (12 * -1) + 0 )
#define N_CN1S (0x600C + (12 * -1) + 1 )
#define N_DN1F (0x600C + (12 * -1) + 1 )

View file

@ -35,11 +35,11 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
{KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_KP_1, KC_KP_2, KC_KP_3, KC_SLSH, KC_ENT},
{KC_TRNS, KC_LCTL, KC_LALT, KC_LGUI, KC_TRNS, KC_SPC, KC_SPC, KC_KP_0, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
},
[5] = { /* MIDI */
{CHNL(N_C5, 0), CHNL(N_D5, 0),CHNL(N_E5, 0),CHNL(N_F5, 0),CHNL(N_G5, 0),CHNL(N_A5, 0),CHNL(N_B5, 0),CHNL(N_C6, 0), CHNL(N_D6, 0), CHNL(N_E6, 0), CHNL(N_F6, 0),CHNL(N_G6, 0)},
{CHNL(N_C5, 2), CHNL(N_D5, 2),CHNL(N_E5, 2),CHNL(N_F5, 2),CHNL(N_G5, 2),CHNL(N_A5, 2),CHNL(N_B5, 2),CHNL(N_C6, 2), CHNL(N_D6, 2), CHNL(N_E6, 2), CHNL(N_F6, 2),CHNL(N_G6, 2)},
{CHNL(N_C5, 4), CHNL(N_D5, 4),CHNL(N_E5, 4),CHNL(N_F5, 4),CHNL(N_G5, 4),CHNL(N_A5, 4),CHNL(N_B5, 4),CHNL(N_C6, 4), CHNL(N_D6, 4), CHNL(N_E6, 4), CHNL(N_F6, 4),CHNL(N_G6, 4)},
{KC_TRNS, KC_LCTL, KC_LALT, KC_LGUI, KC_TRNS, KC_SPC, KC_SPC, KC_KP_0, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
[5] = {
{ MIDI12 },
{ MIDI12 },
{ MIDI12 },
{M(0), KC_LCTL, KC_LALT, KC_LGUI, FUNC(2), KC_SPC, KC_SPC, FUNC(1), MIDI, MIDI, MIDI, MIDI}
}
};
@ -60,11 +60,13 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
if (record->event.pressed) {
// register_code(KC_RSFT);
backlight_set(BACKLIGHT_LEVELS);
layer_on(5);
default_layer_and(0);
default_layer_or((1<<5));
} else {
// unregister_code(KC_RSFT);
backlight_set(0);
layer_clear();
default_layer_and(0);
default_layer_or(0);
}
break;
}

View file

@ -46,7 +46,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
{ MIDI12 },
{ MIDI12 },
{ MIDI12 },
{M(0), KC_LCTL, KC_LALT, KC_LGUI, FUNC(2), KC_SPC, KC_SPC, FUNC(1), KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
{M(0), KC_LCTL, KC_LALT, KC_LGUI, FUNC(2), KC_SPC, KC_SPC, FUNC(1), MIDI, MIDI, MIDI, MIDI}
}
};

View file

@ -31,7 +31,7 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
}
}
if (record->event.key.col == 11 && record->event.key.row == 4) {
if (record->event.key.col == 11 && record->event.key.row == 4 && record->event.pressed) {
starting_note++;
midi_send_cc(&midi_device, 0, 0x7B, 0);
midi_send_cc(&midi_device, 1, 0x7B, 0);
@ -39,7 +39,7 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
midi_send_cc(&midi_device, 3, 0x7B, 0);
midi_send_cc(&midi_device, 4, 0x7B, 0);
}
if (record->event.key.col == 8 && record->event.key.row == 4) {
if (record->event.key.col == 8 && record->event.key.row == 4 && record->event.pressed) {
starting_note--;
midi_send_cc(&midi_device, 0, 0x7B, 0);
midi_send_cc(&midi_device, 1, 0x7B, 0);