Added README.md from upstream.

Added MIDI channel support.
master
Holger Wirtz 4 years ago
parent 15449c78ab
commit 90f8157b9d
  1. 11
      OSC2Midi.cpp
  2. 1
      OSC2Midi.h
  3. 14
      OSC2MidiGateway.ino
  4. 52
      README.md

@ -3,9 +3,9 @@
#include <stdlib.h>
/*
* TODO: this will return rather unpredictable numbers when
* given strings with numbers > 255.
*/
TODO: this will return rather unpredictable numbers when
given strings with numbers > 255.
*/
uint8_t getCC(const char *str, int index)
{
const char *offset = str;
@ -37,6 +37,11 @@ uint8_t getCC(const char *str, int index)
}
uint8_t getCC(const char *str)
{
return getCC(str, 1);
}
uint8_t getMIDIChannel(const char *str)
{
return getCC(str, -1);
}

@ -5,5 +5,6 @@
uint8_t getCC(const char *str, int index);
uint8_t getCC(const char *str);
uint8_t getMIDIChannel(const char *str);
#endif

@ -48,8 +48,10 @@ void setup() {
void OSCToMidiCC(OSCMessage &msg, int offset) {
char address[100] = { 0 };
uint8_t cc, value;
uint8_t midichannel;
msg.getAddress(address, offset, sizeof(address));
midichannel = getMIDIChannel(address);
if (msg.size() == 1 && msg.isFloat(0)) {
// Single or multi control with sending one value
@ -57,20 +59,20 @@ void OSCToMidiCC(OSCMessage &msg, int offset) {
value = round(msg.getFloat(0));
value = value > 127 ? 127 : value;
DEBUG_MSG("MSG: %s\tCC: %u\tValue: %u\n", address, cc, value);
MIDI.sendControlChange(cc, value, 1);
MIDI.sendControlChange(cc, value, midichannel);
} else if (msg.size() == 2 && msg.isFloat(0) && msg.isFloat(1)) {
// XY pad, two values
cc = getCC(address, 0);
cc = getCC(address, 1);
value = round(msg.getFloat(0));
value = value > 127 ? 127 : value;
DEBUG_MSG("MSG: %s\tCC: %u\tValue: %u\n", address, cc, value);
MIDI.sendControlChange(cc, value, 1);
MIDI.sendControlChange(cc, value, midichannel);
cc = getCC(address, 1);
cc = getCC(address, 2);
value = round(msg.getFloat(1));
value = value > 127 ? 127 : value;
DEBUG_MSG("MSG: %s\tCC: %u\tValue: %u\n", address, cc, value);
MIDI.sendControlChange(cc, value, 1);
MIDI.sendControlChange(cc, value, midichannel);
} else {
DEBUG_MSG("Cannot handle: %s\n", address);
}
@ -78,7 +80,7 @@ void OSCToMidiCC(OSCMessage &msg, int offset) {
void MidiCCToOSC(uint8_t channel, uint8_t number, uint8_t value) {
char buffer[1024];
snprintf(buffer, sizeof(buffer), "/midi/cc/%u", number);
snprintf(buffer, sizeof(buffer), "/midi/cc/%u/%u", channel, number);
OSCMessage msg = OSCMessage(buffer);
msg.add(value * 1.0);

@ -1,2 +1,54 @@
# OSC2MidiGateway
(Fork of https://github.com/tadas-s/OSC2Midi with extensions)
ESP8266 based OSC <-> Midi wireless bridge.
It is mostly meant to be used with [TouchOSC][1] but it will work with
any [OSC message source][2].
## Library dependencies
Project uses:
* https://github.com/FortySevenEffects/arduino_midi_library/
* https://github.com/CNMAT/OSC
## Hardware
Based on a generic ESP8266-01 board using both GPIO pins as MIDI-I/O.
## OSC message formats
All messages are expected to have payload of 1 or 2 floats with range
from 0 to 127.
### /midi/cc/channel/{cc} + 1 float
Will send control change message for `{cc}` number.
### /midi/cc/channel/{ccA}/{ccB}/.../{index} + 1 float
Will send control change message for CC specified by `{index}`. For
example:
* /midi/cc/1/10/12/15/1 -> CC to 10 on channel 1
* /midi/cc/1/10/12/15/3 -> CC to 15 on channel 1
This is meant to be used with TouchOSC groups of faders. For example,
my [MicroKORG][6] preset includes a fader group of 4 to control
amp ADSR: `/midi/cc/1/73/75/70/72`
### /midi/cc/channel/{ccA}/{ccB} + 2 floats
This sends two control change messages to `{ccA}` and `{ccB}`. This is
meant to be used with TouchOSC XY pads.
[1]: http://hexler.net/software/touchosc
[2]: https://en.wikipedia.org/wiki/Open_Sound_Control
[3]: https://www.arduino.cc/en/Tutorial/Midi
[4]: http://libremusicproduction.com/tutorials/arduino-and-midi-in
[5]: https://www.arduino.cc/en/Reference/SoftwareSerial
[6]: http://www.korg.com/us/products/synthesizers/microkorg/
[7]: https://www.microchip.com/wwwproducts/en/en027785
[8]: https://github.com/tadas-s/esp8266-autoreset

Loading…
Cancel
Save