Add deeper simulation of USB midi
This commit is contained in:
parent
2d034b6369
commit
3d38f50d98
6 changed files with 96 additions and 59 deletions
|
@ -12,7 +12,7 @@ else
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
CXXFLAGS= $(CFLAGS) -std=c++14
|
CXXFLAGS= $(CFLAGS) -std=c++14 -Wno-unused-parameter
|
||||||
|
|
||||||
LIBS=-framework SDL2 -lc++ -lc -framework OpenGL
|
LIBS=-framework SDL2 -lc++ -lc -framework OpenGL
|
||||||
LDFLAGS=-macosx_version_min 10.9 -rpath @executable_path/../Frameworks
|
LDFLAGS=-macosx_version_min 10.9 -rpath @executable_path/../Frameworks
|
||||||
|
@ -32,8 +32,9 @@ CXXFILES= ../NuEVI/menu.cpp \
|
||||||
src/Print.cpp \
|
src/Print.cpp \
|
||||||
src/simserial.cpp \
|
src/simserial.cpp \
|
||||||
src/simwire.cpp \
|
src/simwire.cpp \
|
||||||
src/simmidi.cpp \
|
src/simusbmidi.cpp \
|
||||||
src/filters.cpp \
|
src/filters.cpp \
|
||||||
|
../NuEVI/midi.cpp \
|
||||||
src/Adafruit_GFX_sim.cpp \
|
src/Adafruit_GFX_sim.cpp \
|
||||||
src/Adafruit_SSD1306_sim.cpp \
|
src/Adafruit_SSD1306_sim.cpp \
|
||||||
src/Adafruit_MPR121_sim.cpp \
|
src/Adafruit_MPR121_sim.cpp \
|
||||||
|
|
|
@ -67,9 +67,29 @@ public:
|
||||||
void println(const char* str);
|
void println(const char* str);
|
||||||
void print(const char* str);
|
void print(const char* str);
|
||||||
void print(uint32_t intValue);
|
void print(uint32_t intValue);
|
||||||
|
void write(const uint8_t str);
|
||||||
|
void flush();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class SimUsbMidi
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void sendNoteOff(uint8_t note, uint8_t velocity, uint8_t channel, uint8_t cable=0);
|
||||||
|
void sendNoteOn(uint8_t note, uint8_t velocity, uint8_t channel, uint8_t cable=0);
|
||||||
|
void sendPolyPressure(uint8_t note, uint8_t pressure, uint8_t channel, uint8_t cable=0);
|
||||||
|
void sendAfterTouchPoly(uint8_t note, uint8_t pressure, uint8_t channel, uint8_t cable=0);
|
||||||
|
void sendControlChange(uint8_t control, uint8_t value, uint8_t channel, uint8_t cable=0);
|
||||||
|
void sendProgramChange(uint8_t program, uint8_t channel, uint8_t cable=0);
|
||||||
|
void sendAfterTouch(uint8_t pressure, uint8_t channel, uint8_t cable=0);
|
||||||
|
void sendPitchBend(int value, uint8_t channel, uint8_t cable=0);
|
||||||
|
void sendSysEx(uint16_t length, const uint8_t *data, bool hasTerm=false, uint8_t cable=0);
|
||||||
|
bool read(uint8_t channel=0);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern SimSerial Serial;
|
extern SimSerial Serial;
|
||||||
|
extern SimSerial Serial3; //Used for MIDI serial putput with default hardware
|
||||||
|
extern SimUsbMidi usbMIDI;
|
||||||
|
|
||||||
//extern void putString(int row, int col, int color, const char* msg, const FONT_INFO fontInfo);
|
//extern void putString(int row, int col, int color, const char* msg, const FONT_INFO fontInfo);
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,8 @@ extern Adafruit_SSD1306 display;
|
||||||
extern Adafruit_MPR121 touchSensor;
|
extern Adafruit_MPR121 touchSensor;
|
||||||
SimWire Wire;
|
SimWire Wire;
|
||||||
SimSerial Serial;
|
SimSerial Serial;
|
||||||
|
SimSerial Serial3; //Midi
|
||||||
|
SimUsbMidi usbMIDI;
|
||||||
|
|
||||||
static const int scale = 3;
|
static const int scale = 3;
|
||||||
|
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
#include <Arduino.h>
|
|
||||||
#include "midi.h"
|
|
||||||
|
|
||||||
void midiSetChannel(byte __attribute__((unused)) channel){}
|
|
||||||
|
|
||||||
byte midiGetChannel(){ return 1; }
|
|
||||||
|
|
||||||
void midiSendProgramChange(int __attribute__((unused)) patch)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void midiSendControlChange(int __attribute__((unused)) ccParam, int __attribute__((unused)) ccValue)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void midiSendNoteOn(byte __attribute__((unused)) note, int __attribute__((unused)) velocity)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void midiSendNoteOff(byte __attribute__((unused)) note)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void midiSendAfterTouch(byte __attribute__((unused)) value)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void midiSendPitchBend(int __attribute__((unused)) value)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void midiDiscardInput()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void midiReset()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void midiPanic()
|
|
||||||
{
|
|
||||||
// turn all notes off
|
|
||||||
}
|
|
||||||
|
|
||||||
void midiInitialize(byte __attribute__((unused)) channel)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
|
@ -41,3 +41,15 @@ void SimSerial::println(const char *str)
|
||||||
printf( "[Serial::println] %s\n", str );
|
printf( "[Serial::println] %s\n", str );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Used to send serial midi
|
||||||
|
void SimSerial::write(const uint8_t str)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SimSerial::flush()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
59
simulation/src/simusbmidi.cpp
Normal file
59
simulation/src/simusbmidi.cpp
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
#include <cstdint>
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
|
|
||||||
|
#include "Arduino.h"
|
||||||
|
|
||||||
|
/*************************************
|
||||||
|
* Stub simulation of Teensy usbMidi
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
void SimUsbMidi::sendNoteOff(uint8_t note, uint8_t velocity, uint8_t channel, uint8_t cable)
|
||||||
|
{
|
||||||
|
printf( "[usbMIDI::noteOff] note %03d vel %03d ch %02d\n", note, velocity, channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SimUsbMidi::sendNoteOn(uint8_t note, uint8_t velocity, uint8_t channel, uint8_t cable)
|
||||||
|
{
|
||||||
|
printf( "[usbMIDI::noteOn] note %03d vel %03d ch %02d\n", note, velocity, channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SimUsbMidi::sendPolyPressure(uint8_t note, uint8_t pressure, uint8_t channel, uint8_t cable)
|
||||||
|
{
|
||||||
|
printf( "[usbMIDI::polyPressure] note %03d p %03d ch %02d\n", note, pressure, channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SimUsbMidi::sendAfterTouchPoly(uint8_t note, uint8_t pressure, uint8_t channel, uint8_t cable)
|
||||||
|
{
|
||||||
|
printf( "[usbMIDI::afterTouchPoly] note %03d p %03d ch %02d\n", note, pressure, channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SimUsbMidi::sendControlChange(uint8_t control, uint8_t value, uint8_t channel, uint8_t cable)
|
||||||
|
{
|
||||||
|
printf( "[usbMIDI::controlChange] cc %03d val %03d ch %02d\n", control, value, channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SimUsbMidi::sendProgramChange(uint8_t program, uint8_t channel, uint8_t cable)
|
||||||
|
{
|
||||||
|
printf( "[usbMIDI::programChange] prg %03d ch %02d\n", program, channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SimUsbMidi::sendAfterTouch(uint8_t pressure, uint8_t channel, uint8_t cable)
|
||||||
|
{
|
||||||
|
printf( "[usbMIDI::afterTouch] p %03d ch %02d\n", pressure, channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SimUsbMidi::sendPitchBend(int value, uint8_t channel, uint8_t cable)
|
||||||
|
{
|
||||||
|
printf( "[usbMIDI::pitchBend] pb %05d ch %02d\n", value, channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SimUsbMidi::sendSysEx(uint16_t length, const uint8_t *data, bool hasTerm, uint8_t cable)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SimUsbMidi::read(uint8_t channel) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue