summaryrefslogtreecommitdiff
path: root/quantum/process_keycode
diff options
context:
space:
mode:
authorGabriel Young <gabeplaysdrums@live.com>2017-02-25 15:02:43 -0800
committerGabriel Young <gabeplaysdrums@live.com>2017-02-25 15:02:43 -0800
commit525be99ee938aa6e48448d7dd6ea6e6fe50bb36d (patch)
tree8842033e455e5a2546894d03b701ae8fe2f565a7 /quantum/process_keycode
parent64eecfc5303788bd82bf2fb466ec4a6f1bd0c028 (diff)
downloadqmk_firmware-525be99ee938aa6e48448d7dd6ea6e6fe50bb36d.tar.gz
qmk_firmware-525be99ee938aa6e48448d7dd6ea6e6fe50bb36d.zip
Split MIDI functionality into MIDI_BASIC and MIDI_ADVANCED
MIDI_ENABLE = no text data bss dec hex filename 0 17080 0 17080 42b8 satan_midi.hex MIDI_ENABLE = yes MIDI_BASIC undefined MIDI_ADVANCED undefined text data bss dec hex filename 0 19494 0 19494 4c26 satan_midi.hex MIDI_ENABLE = yes #define MIDI_BASIC MIDI_ADVANCED undefined text data bss dec hex filename 0 19788 0 19788 4d4c satan_midi.hex MIDI_ENABLE = yes MIDI_BASIC undefined #define MIDI_ADVANCED text data bss dec hex filename 0 20846 0 20846 516e satan_midi.hex MIDI_ENABLE = yes #define MIDI_BASIC #define MIDI_ADVANCED text data bss dec hex filename 0 21140 0 21140 5294 satan_midi.hex
Diffstat (limited to 'quantum/process_keycode')
-rw-r--r--quantum/process_keycode/process_midi.c9
-rw-r--r--quantum/process_keycode/process_music.c22
2 files changed, 28 insertions, 3 deletions
diff --git a/quantum/process_keycode/process_midi.c b/quantum/process_keycode/process_midi.c
index 5530ea97c4..161f04a245 100644
--- a/quantum/process_keycode/process_midi.c
+++ b/quantum/process_keycode/process_midi.c
@@ -1,6 +1,7 @@
-#define MIDI_TONE_KEYCODE_OCTAVES 2
-
#include "process_midi.h"
+
+#if defined(MIDI_ENABLE) && defined(MIDI_ADVANCED)
+
#include "timer.h"
static uint8_t tone_status[MIDI_TONE_COUNT];
@@ -161,7 +162,7 @@ bool process_midi(uint16_t keycode, keyrecord_t *record)
dprintf("midi channel %d\n", midi_config.channel);
}
return false;
- case MI_OFF:
+ case MI_ALLOFF:
if (record->event.pressed) {
midi_send_cc(&midi_device, midi_config.channel, 0x7B, 0);
dprintf("midi off\n");
@@ -209,3 +210,5 @@ bool process_midi(uint16_t keycode, keyrecord_t *record)
return true;
}
+
+#endif // MIDI_ADVANCED
diff --git a/quantum/process_keycode/process_music.c b/quantum/process_keycode/process_music.c
index 1e2648bff5..ac906b6281 100644
--- a/quantum/process_keycode/process_music.c
+++ b/quantum/process_keycode/process_music.c
@@ -17,6 +17,7 @@ static uint16_t music_sequence_interval = 100;
bool process_music(uint16_t keycode, keyrecord_t *record) {
+ #ifdef AUDIO_ENABLE
if (keycode == AU_ON && record->event.pressed) {
audio_on();
return false;
@@ -38,6 +39,7 @@ bool process_music(uint16_t keycode, keyrecord_t *record) {
}
return false;
}
+ #endif // AUDIO_ENABLE
if (keycode == MU_ON && record->event.pressed) {
music_on();
@@ -61,6 +63,7 @@ bool process_music(uint16_t keycode, keyrecord_t *record) {
return false;
}
+ #ifdef AUDIO_ENABLE
if (keycode == MUV_IN && record->event.pressed) {
voice_iterate();
music_scale_user();
@@ -72,11 +75,14 @@ bool process_music(uint16_t keycode, keyrecord_t *record) {
music_scale_user();
return false;
}
+ #endif // AUDIO_ENABLE
if (music_activated) {
if (keycode == KC_LCTL && record->event.pressed) { // Start recording
+ #ifdef AUDIO_ENABLE
stop_all_notes();
+ #endif
music_sequence_recording = true;
music_sequence_recorded = false;
music_sequence_playing = false;
@@ -85,7 +91,9 @@ bool process_music(uint16_t keycode, keyrecord_t *record) {
}
if (keycode == KC_LALT && record->event.pressed) { // Stop recording/playing
+ #ifdef AUDIO_ENABLE
stop_all_notes();
+ #endif
if (music_sequence_recording) { // was recording
music_sequence_recorded = true;
}
@@ -95,7 +103,9 @@ bool process_music(uint16_t keycode, keyrecord_t *record) {
}
if (keycode == KC_LGUI && record->event.pressed && music_sequence_recorded) { // Start playing
+ #ifdef AUDIO_ENABLE
stop_all_notes();
+ #endif
music_sequence_recording = false;
music_sequence_playing = true;
music_sequence_position = 0;
@@ -116,6 +126,7 @@ bool process_music(uint16_t keycode, keyrecord_t *record) {
}
#define MUSIC_MODE_GUITAR
+ #ifdef AUDIO_ENABLE
#ifdef MUSIC_MODE_CHROMATIC
float freq = ((float)220.0)*pow(2.0, -5.0)*pow(2.0,(music_starting_note + record->event.key.col + music_offset)/12.0+(MATRIX_ROWS - record->event.key.row));
#elif defined(MUSIC_MODE_GUITAR)
@@ -125,15 +136,20 @@ bool process_music(uint16_t keycode, keyrecord_t *record) {
#else
float freq = ((float)220.0)*pow(2.0, -5.0)*pow(2.0,(music_starting_note + SCALE[record->event.key.col + music_offset])/12.0+(MATRIX_ROWS - record->event.key.row));
#endif
+ #endif // AUDIO_ENABLE
if (record->event.pressed) {
+ #ifdef AUDIO_ENABLE
play_note(freq, 0xF);
if (music_sequence_recording) {
music_sequence[music_sequence_count] = freq;
music_sequence_count++;
}
+ #endif
} else {
+ #ifdef AUDIO_ENABLE
stop_note(freq);
+ #endif
}
if (keycode < 0xFF) // ignores all normal keycodes, but lets RAISE, LOWER, etc through
@@ -161,15 +177,19 @@ void music_on(void) {
void music_off(void) {
music_activated = 0;
+ #ifdef AUDIO_ENABLE
stop_all_notes();
+ #endif
}
__attribute__ ((weak))
void music_on_user() {}
+#ifdef AUDIO_ENABLE
__attribute__ ((weak))
void audio_on_user() {}
+#endif
__attribute__ ((weak))
void music_scale_user() {}
@@ -178,8 +198,10 @@ void matrix_scan_music(void) {
if (music_sequence_playing) {
if ((music_sequence_timer == 0) || (timer_elapsed(music_sequence_timer) > music_sequence_interval)) {
music_sequence_timer = timer_read();
+ #ifdef AUDIO_ENABLE
stop_note(music_sequence[(music_sequence_position - 1 < 0)?(music_sequence_position - 1 + music_sequence_count):(music_sequence_position - 1)]);
play_note(music_sequence[music_sequence_position], 0xF);
+ #endif
music_sequence_position = (music_sequence_position + 1) % music_sequence_count;
}
}