Fixed midi_devices for hopefully woring MIDI-THRU.

master
Holger Wirtz 6 years ago
parent ee3cf1b92e
commit 967edf9f87
  1. 90
      MicroMDAEPiano.ino
  2. 319
      midi_devices.cpp
  3. 44
      midi_devices.h
  4. 1602
      midi_devices.hpp

@ -34,11 +34,11 @@
#else
#include "mdaEPianoData.h"
#endif
#include <Bounce.h>
#include "Encoder4.h"
#include "midi_devices.h"
#include "LiquidCrystalPlus_I2C.h"
#include "UI.h"
//#include <Bounce.h>
//#include "Encoder4.h"
//#include "LiquidCrystalPlus_I2C.h"
//#include "UI.h"
#include "midi_devices.hpp"
//*************************************************************************************************
//* GLOBAL VARIABLES
@ -303,6 +303,86 @@ void handleControlChange(byte inChannel, byte inData1, byte inData2)
}
}
void handleAfterTouch(byte inChannel, byte inPressure)
{
;
}
void handlePitchBend(byte inChannel, int inPitch)
{
;
}
void handleProgramChange(byte inChannel, byte inProgram)
{
;
}
void handleSystemExclusive(byte *data, uint len)
{
;
}
void handleSystemExclusiveChunk(const byte *data, uint16_t len, bool last)
{
;
}
void handleTimeCodeQuarterFrame(byte data)
{
;
}
void handleAfterTouchPoly(byte inChannel, byte inNumber, byte inVelocity)
{
;
}
void handleSongSelect(byte inSong)
{
;
}
void handleTuneRequest(void)
{
;
}
void handleClock(void)
{
;
}
void handleStart(void)
{
;
}
void handleContinue(void)
{
;
}
void handleStop(void)
{
;
}
void handleActiveSensing(void)
{
;
}
void handleSystemReset(void)
{
;
}
void handleRealTimeSystem(void)
{
;
}
bool checkMidiChannel(byte inChannel)
{
// check for MIDI channel

@ -1,319 +0,0 @@
/*
MicroMDAEPiano
MicroMDAEPiano is a port of the MDA-EPiano sound engine
(https://sourceforge.net/projects/mda-vst/) for the Teensy-3.5/3.6 with audio shield.
(c)2019 H. Wirtz <wirtz@parasitstudio.de>
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 3 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, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if defined(MIDI_DEVICE_USB)
#include <midi_UsbTransport.h>
#endif
#ifdef MIDI_DEVICE_USB_HOST
#include <USBHost_t36.h>
#endif
#ifdef MIDI_DEVICE_DIN
MIDI_CREATE_INSTANCE(HardwareSerial, MIDI_DEVICE_DIN, midi_serial);
#endif
#ifdef MIDI_DEVICE_USB_HOST
USBHost usb_host;
MIDIDevice midi_usb(usb_host);
#endif
#ifdef MIDI_DEVICE_USB
static const unsigned sUsbTransportBufferSize = 16;
typedef midi::UsbTransport<sUsbTransportBufferSize> UsbTransport;
UsbTransport sUsbTransport;
MIDI_CREATE_INSTANCE(UsbTransport, sUsbTransport, midi_onboard_usb);
#endif
void setup_midi_devices(void)
{
#ifdef MIDI_DEVICE_DIN
// Start serial MIDI
midi_serial.begin(DEFAULT_MIDI_CHANNEL);
midi_serial.setHandleNoteOn(handleNoteOn_MIDI_DEVICE_DIN);
midi_serial.setHandleNoteOff(handleNoteOff_MIDI_DEVICE_DIN);
midi_serial.setHandleControlChange(handleControlChange_MIDI_DEVICE_DIN);
Serial.println(F("MIDI_DEVICE_DIN enabled"));
#endif
// start up USB host
#ifdef MIDI_DEVICE_USB_HOST
usb_host.begin();
midi_usb.setHandleNoteOn(handleNoteOn_MIDI_DEVICE_USB_HOST);
midi_usb.setHandleNoteOff(handleNoteOff_MIDI_DEVICE_USB_HOST);
midi_usb.setHandleControlChange(handleControlChange_MIDI_DEVICE_USB_HOST);
Serial.println(F("MIDI_DEVICE_USB_HOST enabled."));
#endif
// check for onboard USB-MIDI
#ifdef MIDI_DEVICE_USB
midi_onboard_usb.begin();
midi_onboard_usb.setHandleNoteOn(handleNoteOn_MIDI_DEVICE_USB);
midi_onboard_usb.setHandleNoteOff(handleNoteOff_MIDI_DEVICE_USB);
midi_onboard_usb.setHandleControlChange(handleControlChange_MIDI_DEVICE_USB);
Serial.println(F("MIDI_DEVICE_USB enabled."));
#endif
}
void check_midi_devices(void)
{
#ifdef MIDI_DEVICE_DIN
midi_serial.read();
#endif
#ifdef MIDI_DEVICE_USB_HOST
usb_host.Task();
midi_usb.read();
#endif
#ifdef MIDI_DEVICE_USB
midi_onboard_usb.read();
#endif
}
#ifdef MIDI_DEVICE_DIN
void handleNoteOn_MIDI_DEVICE_DIN(byte inChannel, byte inNumber, byte inVelocity)
{
handleNoteOn(byte inChannel, byte inNumber, byte inVelocity);
#ifdef DEBUG
Serial.print(F("[MIDI_DIN] NoteOn"));
#endif
#ifdef MIDI_MERGE_THRU
#ifdef MIDI_DEVICE_USB_HOST
midi_usb.send(midi::NoteOn, inNumber, inVelocity, inChannel);
#ifdef DEBUG
Serial.print(F(" THRU->MIDI_USB_HOST"));
#endif
#endif
#ifdef MIDI_DEVICE_USB
midi_onboard_usb.send(midi::NoteOn, inNumber, inVelocity, inChannel);
#ifdef DEBUG
Serial.print(F(" THRU->MIDI_USB"));
#endif
#endif
#ifdef DEBUG
Serial.println();
#endif
#endif
}
void handleNoteOff_MIDI_DEVICE_DIN(byte inChannel, byte inNumber, byte inVelocity)
{
handleNoteOff(byte inChannel, byte inNumber, byte inVelocity);
#ifdef DEBUG
Serial.print(F("[MIDI_DIN] NoteOff"));
#endif
#ifdef MIDI_MERGE_THRU
#ifdef MIDI_DEVICE_USB_HOST
midi_usb.send(midi::NoteOff, inNumber, inVelocity, inChannel);
#ifdef DEBUG
Serial.print(F(" THRU->MIDI_USB_HOST"));
#endif
#endif
#ifdef MIDI_DEVICE_USB
midi_onboard_usb.send(midi::NoteOff, inNumber, inVelocity, inChannel);
#ifdef DEBUG
Serial.print(F(" THRU->MIDI_USB"));
#endif
#endif
#ifdef DEBUG
Serial.println();
#endif
#endif
}
void handleControlChange_MIDI_DEVICE_DIN(byte inChannel, byte inData1, byte inData2)
{
handleControlChange(byte inChannel, byte inData1, byte inData2);
#ifdef DEBUG
Serial.print(F("[MIDI_DIN] CC"));
#endif
#ifdef MIDI_MERGE_THRU
#ifdef MIDI_DEVICE_USB_HOST
midi_usb.send(midi::ControlChange, inData1, inData2, inChannel);
#ifdef DEBUG
Serial.print(F(" THRU->MIDI_USB_HOST"));
#endif
#endif
#ifdef MIDI_DEVICE_USB
midi_onboard_usb.send(midi::ControlChange, inData1, inData2, inChannel);
#ifdef DEBUG
Serial.print(F( "THRU->MIDI_USB"));
#endif
#endif
#ifdef DEBUG
Serial.println();
#endif
#endif
}
#endif
#ifdef MIDI_DEVICE_USB_HOST
void handleNoteOn_MIDI_DEVICE_USB_HOST(byte inChannel, byte inNumber, byte inVelocity)
{
handleNoteOn(inChannel, inNumber, inVelocity);
#ifdef DEBUG
Serial.print(F("[MIDI_USB_HOST] NoteOn"));
#endif
#ifdef MIDI_MERGE_THRU
#ifdef MIDI_DEVICE_DIN
midi_serial.send(midi::NoteOn, inNumber, inVelocity, inChannel);
#ifdef DEBUG
Serial.print(F(" THRU->MIDI_DIN"));
#endif
#endif
#ifdef MIDI_DEVICE_USB
midi_onboard_usb.send(midi::NoteOn, inNumber, inVelocity, inChannel);
#ifdef DEBUG
Serial.print(F(" THRU->MIDI_USB"));
#endif
#endif
#ifdef DEBUG
Serial.println();
#endif
#endif
}
void handleNoteOff_MIDI_DEVICE_USB_HOST(byte inChannel, byte inNumber, byte inVelocity)
{
handleNoteOff(inChannel, inNumber, inVelocity);
#ifdef DEBUG
Serial.print(F("[MIDI_USB_HOST] NoteOff"));
#endif
#ifdef MIDI_MERGE_THRU
#ifdef MIDI_DEVICE_DIN
midi_serial.send(midi::NoteOff, inNumber, inVelocity, inChannel);
#ifdef DEBUG
Serial.print(F(" THRU->MIDI_DIN"));
#endif
#endif
#ifdef MIDI_DEVICE_USB
midi_onboard_usb.send(midi::NoteOff, inNumber, inVelocity, inChannel);
#ifdef DEBUG
Serial.print(F(" THRU->MIDI_USB"));
#endif
#endif
#ifdef DEBUG
Serial.println();
#endif
#endif
}
void handleControlChange_MIDI_DEVICE_USB_HOST(byte inChannel, byte inData1, byte inData2)
{
handleControlChange(inChannel, inData1, inData2);
#ifdef DEBUG
Serial.print(F("[MIDI_USB_HOST] CC"));
#endif
#ifdef MIDI_MERGE_THRU
#ifdef MIDI_DEVICE_DIN
midi_serial.send(midi::ControlChange, inData1, inData2, inChannel);
#ifdef DEBUG
Serial.print(F(" THRU->MIDI_DIN"));
#endif
#endif
#ifdef MIDI_DEVICE_USB
midi_onboard_usb.send(midi::ControlChange, inData1, inData2, inChannel);
#ifdef DEBUG
Serial.print(F(" THRU->MIDI_USB"));
#endif
#endif
#ifdef DEBUG
Serial.println();
#endif
#endif
}
#endif
#ifdef MIDI_DEVICE_USB
void handleNoteOn_MIDI_DEVICE_USB(byte inChannel, byte inNumber, byte inVelocity)
{
handleNoteOn(inChannel, inNumber, inVelocity);
#ifdef DEBUG
Serial.print(F("[MIDI_USB] NoteOn"));
#endif
#ifdef MIDI_MERGE_THRU
#ifdef MIDI_DEVICE_DIN
midi_serial.send(midi::NoteOn, inNumber, inVelocity, inChannel);
#ifdef DEBUG
Serial.print(F(" THRU->MIDI_DIN"));
#endif
#endif
#ifdef MIDI_DEVICE_USB_HOST
midi_usb.send(midi::NoteOn, inNumber, inVelocity, inChannel);
#ifdef DEBUG
Serial.print(F(" THRU->MIDI_USB_HOST"));
#endif
#endif
#ifdef DEBUG
Serial.println();
#endif
#endif
}
void handleNoteOff_MIDI_DEVICE_USB(byte inChannel, byte inNumber, byte inVelocity)
{
handleNoteOff(inChannel, inNumber, inVelocity);
#ifdef DEBUG
Serial.print(F("[MIDI_USB] NoteOff"));
#endif
#ifdef MIDI_MERGE_THRU
#ifdef MIDI_DEVICE_DIN
midi_serial.send(midi::NoteOff, inNumber, inVelocity, inChannel);
#ifdef DEBUG
Serial.print(F(" THRU->MIDI_DIN"));
#endif
#endif
#ifdef MIDI_DEVICE_USB_HOST
midi_usb.send(midi::NoteOff, inNumber, inVelocity, inChannel);
#ifdef DEBUG
Serial.print(F(" THRU->MIDI_USB_HOST"));
#endif
#endif
#ifdef DEBUG
Serial.println();
#endif
#endif
}
void handleControlChange_MIDI_DEVICE_USB(byte inChannel, byte inData1, byte inData2)
{
handleControlChange(inChannel, inData1, inData2);
#ifdef DEBUG
Serial.print(F("[MIDI_USB] CC"));
#endif
#ifdef MIDI_MERGE_THRU
#ifdef MIDI_DEVICE_DIN
midi_serial.send(midi::ControlChange, inData1, inData2, inChannel);
#ifdef DEBUG
Serial.print(F(" THRU->MIDI_DIN"));
#endif
#endif
#ifdef MIDI_DEVICE_USB_HOST
midi_usb.send(midi::ControlChange, inData1, inData2, inChannel);
#ifdef DEBUG
Serial.print(F(" THRU->MIDI_USB_HOST"));
#endif
#endif
#ifdef DEBUG
Serial.println();
#endif
#endif
}
#endif

@ -1,44 +0,0 @@
/*
MicroMDAEPiano
MicroMDAEPiano is a port of the MDA-EPiano sound engine
(https://sourceforge.net/projects/mda-vst/) for the Teensy-3.5/3.6 with audio shield.
(c)2019 H. Wirtz <wirtz@parasitstudio.de>
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 3 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, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MIDI_DEVICES_H
#define MIDI_DEVICES_H
void setup_midi_devices(void);
void check_midi_devices(void);
#ifdef MIDI_DEVICE_DIN
void handleNoteOn_MIDI_DEVICE_DIN(byte inChannel, byte inNumber, byte inVelocity);
void handleNoteOff_MIDI_DEVICE_DIN(byte inChannel, byte inNumber, byte inVelocity);
void handleControlChange_MIDI_DEVICE_DIN(byte inChannel, byte inData1, byte inData2);
#endif
#ifdef MIDI_DEVICE_USB_HOST
void handleNoteOn_MIDI_DEVICE_USB_HOST(byte inChannel, byte inNumber, byte inVelocity);
void handleNoteOff_MIDI_DEVICE_USB_HOST(byte inChannel, byte inNumber, byte inVelocity);
void handleControlChange_MIDI_DEVICE_USB_HOST(byte inChannel, byte inData1, byte inData2);
#endif
#ifdef MIDI_DEVICE_USB
void handleNoteOn_MIDI_DEVICE_USB(byte inChannel, byte inNumber, byte inVelocity);
void handleNoteOff_MIDI_DEVICE_USB(byte inChannel, byte inNumber, byte inVelocity);
void handleControlChange_MIDI_DEVICE_USB(byte inChannel, byte inData1, byte inData2);
#endif
#endif

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save