From 91176d854b8c9e49e88d494ba02c8e9c54fec914 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Sat, 29 Aug 2015 11:54:38 -0400 Subject: speaker working, midi out --- protocol/lufa/lufa.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'protocol') 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 // #include // #include @@ -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, -- cgit v1.2.3