projectgus / hairless-midiserial

Lightweight cross-platform GUI-based MIDI/Serial bridge
https://projectgus.github.io/hairless-midiserial
Other
213 stars 72 forks source link

ESP32 usage #79

Open highway11 opened 2 years ago

highway11 commented 2 years ago

Has anyone successfully used hairless-midi with an ESP32 on Windows 10? I'm not having luck with either the old ardumidi library or the new ArduinoMidi library.

In the older ardumidi.h library it throws a compile error: ardumidi.cpp:60:30: error: 'BYTE' was not declared in this scope I was able to fix this by removing the last 'BYTE' parameter from the Serial.print call. However I just get Error: got unexpected data byte 0x30. over and over in Hairless Midi image

If I use the newer Arduino Midi library I'm getting absolutely no serial output at all, I feel like I may be missing something here:

#include <MIDI.h>

// Create and bind the MIDI interface to the default hardware Serial port
//MIDI_CREATE_DEFAULT_INSTANCE();
MIDI_CREATE_INSTANCE(HardwareSerial, Serial, MIDI);

void setup() {
  MIDI.begin(MIDI_CHANNEL_OMNI);  // Listen to all incoming messages
  Serial.begin(115200);
}

void loop() {

    MIDI.sendNoteOn(1, 127, 1);
    //MIDI.read();
    delay(1000);

}
highway11 commented 2 years ago

I have made progress with the old ardumidi library. To fix compile errors in ardumidi.cpp replace the Serial.print() with Serial.write() and remove the BYTE parameter

void midi_command(byte command, byte channel, byte param1, byte param2)
{
    Serial.write(command | (channel & 0x0F));
    Serial.write(param1 & 0x7F);
    Serial.write(param2 & 0x7F);
}

void midi_command_short(byte command, byte channel, byte param1)
{
    Serial.write(command | (channel & 0x0F));
    Serial.write(param1 & 0x7F);
}

void midi_print(char* msg, int len)
{
    Serial.write(0xFF);
    Serial.write(0x00);
    Serial.write(0x00);
    Serial.write(len );
    Serial.write(msg);
}
highway11 commented 2 years ago

I was going to make a pull request to fix this, but I realized its already fixed in the github repository. I must have used ardumidi that came bundled with the download from https://projectgus.github.io/hairless-midiserial/

Maybe its a good idea to update the downloadable zip files with the fixed ardumidi library