R0Wi / Arduino-ESP32-Midi-BLE-Proxy

GNU General Public License v3.0
8 stars 1 forks source link

newbie questions #1

Closed Maitresinh closed 1 month ago

Maitresinh commented 2 years ago

1/ Is that device work with two of them (in and out) ? For exemple as Midi BLE out on the first device (a keyboard) and as Midi BLE in in other (hardware synth module) ?

2/ "You can compile the source code like any other Arduino sketch by using the Arduino IDE." Assuming i'm using windows, i can just use Arduino IDE and throw the code as usual ?

I already used this code https://forum.arduino.cc/t/easiest-esp32-din5-serial-midi-to-ble/650534

To make a Midi BLE out but did not managed tomake the DIN works yet.

thanks for posting

R0Wi commented 2 years ago

1) Indeed it's not important what's the MIDI BLE source device. As long as you can connect to your ESP32 everything should be fine and the ESP32 just puts the received signal onto the wire.

2) Generally speaking: yes. Please follow the steps described in https://github.com/R0Wi/Arduino-ESP32-Midi-BLE-Proxy#compile. What you need is the code hosted inside this repo and the appropriate libraries. You can either copy them from the lib folder into your Arduino library path or use the board manager to download them. This is independent of your OS so Windows should work, too.

Maitresinh commented 2 years ago

Thanks robin

Juste to be sure regarding (1), this is what i have in mind

Keyboard -MIDI OUT- DIN5 connected into /din5 MIDI IN ESP32- BLE din 5 /

TOWARDS

/ESP32 BLE midi din out / connected to synth module

...and your module has only a midi out....?

R0Wi commented 2 years ago

Ok your target looks like the following, right?

ESP32

Of course you're right then: only the red component is tackled by this repo. So basically we're talking about a receiver for MIDI BLE signals, who brings that signals onto a wire. The lefthand side has to be a client oder sender, which works the other way around. Currently my use case is a bit different, because i already have a MIDI BLE client (my tablet) which just sends control commands to my synth, letting him change his currently configured patch or tone for example.

I think you need to implement the client side on your own. Maybe https://github.com/lathoub/Arduino-BLE-MIDI/blob/master/examples/MidiBle_Client/MidiBle_Client.ino could help. But to be honest: i don't know if that works regarding the MIDI BLE delay i have no experience with that. But i'd really like to know your results. Let me know if i can provide further information 👍

Maitresinh commented 2 years ago

Thanks Robin. Now it's all clear (nice diagram by the way, it's exactly that). I have no idea (and very, very few skills, if any) about how to do a BLE client. I'm not even sure of what a client is (i see it as a server here - i mean the left part)

Could that be the "client" we are talking about :

https://www.youtube.com/watch?v=JCnHo92WUXY&ab_channel=RyoKosaka

R0Wi commented 2 years ago

Not completely sure if that's your usecase.

But for the lefthand side i'd take https://github.com/lathoub/Arduino-BLE-MIDI/blob/master/examples/MidiBle_Client/MidiBle_Client.ino as a reference and combine it with the code you have inside this repo. What you'll have to lookup is how to wire the MIDI IN connection but the code should basically look like this (not tested and incomplete):

// Connect to our receiver on the righthand side by using it's populated name.
// We act as kind of "client" because we connect to a BLE server here.
// Note that this call will not only provide the BLE_MIDI_OUTPUT  object but also the BLEBLE_MIDI_OUTPUT  object
// (see https://github.com/R0Wi/Arduino-ESP32-Midi-BLE-Proxy/blob/53f5eb5f746508f00a18f18692dc93a1dc737207/lib/BLE-MIDI/src/hardware/BLEMIDI_ArduinoBLE.h#L216).
#define BLE_NAME "BLE Midi Proxy"
BLEMIDI_CREATE_INSTANCE(BLE_NAME, BLE_MIDI_OUTPUT)

// Setup the wired MIDI input serial (please lookup exact hardware setup)
// https://github.com/FortySevenEffects/arduino_midi_library might help
MIDI_CREATE_INSTANCE(HardwareSerial, Serial2, SERIAL_MIDI_INPUT);

// Example of a callback which is triggered if we received a MIDI NoteOn message on the wire.
// You'll have to catch all kinds of MIDI-messages (like NoteOff, ControlChange, ...) that way.
// see also
//    - https://github.com/FortySevenEffects/arduino_midi_library/blob/master/examples/Callbacks/Callbacks.ino
//    - https://github.com/R0Wi/Arduino-ESP32-Midi-BLE-Proxy/blob/53f5eb5f746508f00a18f18692dc93a1dc737207/MIDI_BLE_PROXY.ino#L63
void handleNoteOn(byte channel, byte pitch, byte velocity)
{
    // Send the midi message we received via wired connection over to the BLE server
   BLE_MIDI_OUTPUT.sendNoteOn(note, velocity, channel);
}

void setup()
{
     // Listen to all incoming messages on our wired connection
     SERIAL_MIDI_INPUT.begin(MIDI_CHANNEL_OMNI); 

    // Setup the basic BLE interface? Not sure if this is needed if we only send messages.
    // BLE_MIDI_OUTPUT.begin();
}

void loop()
{
    // Read incoming messages on the wire
    SERIAL_MIDI_INPUT.read();
}

Hope this helps!

Maitresinh commented 2 years ago

Thanks Robin. I wll try and let you know.

R0Wi commented 2 years ago

Thanks Robin. I wll try and let you know.

If you get thinks to work i'd be really interested in the code and the wiring setup. Maybe we could add it here so that we have both "client" and "server" parts to also support your mentioned usecase 🚀