summaryrefslogtreecommitdiff
path: root/protocol/lufa
diff options
context:
space:
mode:
authorJack Humbert <jack.humb@gmail.com>2015-08-29 11:54:38 -0400
committerJack Humbert <jack.humb@gmail.com>2015-08-29 11:54:38 -0400
commit91176d854b8c9e49e88d494ba02c8e9c54fec914 (patch)
treee21a68fbcd4e1d2c9d1b0d0d74d8ab47140d4847 /protocol/lufa
parentd63c2e3995ae464c4266a7bd348ffb2f43cf7377 (diff)
speaker working, midi out
Diffstat (limited to 'protocol/lufa')
-rw-r--r--protocol/lufa/lufa.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c
index e9f335a632..3ec476928c 100644
--- a/protocol/lufa/lufa.c
+++ b/protocol/lufa/lufa.c
@@ -51,6 +51,7 @@
#include "descriptor.h"
#include "lufa.h"
+#include <beeps.h>
// #include <LUFA/Version.h>
// #include <LUFA/Drivers/USB/USB.h>
@@ -877,11 +878,21 @@ int main(void)
}
#ifdef MIDI_ENABLE
-//echo data back
void fallthrough_callback(MidiDevice * device,
uint16_t cnt, uint8_t byte0, uint8_t byte1, uint8_t byte2){
- //pass the data back to the device, using the general purpose send data
- //function, any bytes after cnt are ignored
+ if (cnt == 3) {
+ switch (byte0 & 0xF0) {
+ case MIDI_NOTEON:
+ play_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(byte1 & 0x7F)/12.0), (byte2 & 0x7F) / 8);
+ break;
+ case MIDI_NOTEOFF:
+ stop_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(byte1 & 0x7F)/12.0));
+ break;
+ }
+ }
+ if (byte0 == MIDI_STOP) {
+ stop_all_notes();
+ }
}
void cc_callback(MidiDevice * device,