X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=quantum%2Fprocess_keycode%2Fprocess_midi.c;h=9728076dfd3d58b063d14a339608b2a44d977a6c;hb=2b8a82fb9defa95ca679672322e7f43052fdc44f;hp=161f04a245d1e0317ec4676c36771b659e94fa40;hpb=525be99ee938aa6e48448d7dd6ea6e6fe50bb36d;p=qmk_firmware.git
diff --git a/quantum/process_keycode/process_midi.c b/quantum/process_keycode/process_midi.c
index 161f04a24..9728076df 100644
--- a/quantum/process_keycode/process_midi.c
+++ b/quantum/process_keycode/process_midi.c
@@ -1,6 +1,45 @@
+/* Copyright 2016 Jack Humbert
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
#include "process_midi.h"
-#if defined(MIDI_ENABLE) && defined(MIDI_ADVANCED)
+#ifdef MIDI_ENABLE
+#include
+#include "midi.h"
+#include "qmk_midi.h"
+
+#ifdef MIDI_BASIC
+
+void process_midi_basic_noteon(uint8_t note)
+{
+ midi_send_noteon(&midi_device, 0, note, 128);
+}
+
+void process_midi_basic_noteoff(uint8_t note)
+{
+ midi_send_noteoff(&midi_device, 0, note, 0);
+}
+
+void process_midi_all_notes_off(void)
+{
+ midi_send_cc(&midi_device, 0, 0x7B, 0);
+}
+
+#endif // MIDI_BASIC
+
+#ifdef MIDI_ADVANCED
#include "timer.h"
@@ -9,6 +48,7 @@ static uint8_t tone_status[MIDI_TONE_COUNT];
static uint8_t midi_modulation;
static int8_t midi_modulation_step;
static uint16_t midi_modulation_timer;
+midi_config_t midi_config;
inline uint8_t compute_velocity(uint8_t setting)
{
@@ -33,30 +73,6 @@ void midi_init(void)
midi_modulation_timer = 0;
}
-void midi_task(void)
-{
- if (timer_elapsed(midi_modulation_timer) < midi_config.modulation_interval)
- return;
- midi_modulation_timer = timer_read();
-
- if (midi_modulation_step != 0)
- {
- dprintf("midi modulation %d\n", midi_modulation);
- midi_send_cc(&midi_device, midi_config.channel, 0x1, midi_modulation);
-
- if (midi_modulation_step < 0 && midi_modulation < -midi_modulation_step) {
- midi_modulation = 0;
- midi_modulation_step = 0;
- return;
- }
-
- midi_modulation += midi_modulation_step;
-
- if (midi_modulation > 127)
- midi_modulation = 127;
- }
-}
-
uint8_t midi_compute_note(uint16_t keycode)
{
return 12 * midi_config.octave + (keycode - MIDI_TONE_MIN) + midi_config.transpose;
@@ -165,7 +181,7 @@ bool process_midi(uint16_t keycode, keyrecord_t *record)
case MI_ALLOFF:
if (record->event.pressed) {
midi_send_cc(&midi_device, midi_config.channel, 0x7B, 0);
- dprintf("midi off\n");
+ dprintf("midi all notes off\n");
}
return false;
case MI_SUS:
@@ -212,3 +228,34 @@ bool process_midi(uint16_t keycode, keyrecord_t *record)
}
#endif // MIDI_ADVANCED
+
+void midi_task(void)
+{
+ midi_device_process(&midi_device);
+#ifdef MIDI_ADVANCED
+ if (timer_elapsed(midi_modulation_timer) < midi_config.modulation_interval)
+ return;
+ midi_modulation_timer = timer_read();
+
+ if (midi_modulation_step != 0)
+ {
+ dprintf("midi modulation %d\n", midi_modulation);
+ midi_send_cc(&midi_device, midi_config.channel, 0x1, midi_modulation);
+
+ if (midi_modulation_step < 0 && midi_modulation < -midi_modulation_step) {
+ midi_modulation = 0;
+ midi_modulation_step = 0;
+ return;
+ }
+
+ midi_modulation += midi_modulation_step;
+
+ if (midi_modulation > 127)
+ midi_modulation = 127;
+ }
+#endif
+}
+
+
+
+#endif // MIDI_ENABLE