Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By oxxe
#96055 Hello,

i want to write a firmware for an ESP8266, which listens to Apple MIDI (RTP MIDI) over WIFI and controls LEDs, which are connected to the ESP.
I found the AppleMIDI-Library (https://github.com/lathoub/Arduino-AppleMIDI-Library) on the internet, but i don't understand, how i can read out Midi-Signals, which are sent to the ESP.
All the examples only show how to sent Midi. They write it is possible to receive midi, but its not written how.
There is always only the "MIDI.read" used, but noone is taking values out of it.

In the end i only need a function, which gives me the Midichannel, the Midinote and the velocity, if a signal was sent.
I'm not a coder. I remember a few things from university, but i learned it years ago....

Can someone help me?

Thanks in advance!

oxxe
User avatar
By rooppoorali
#96416 To receive MIDI signals on your ESP8266 using the AppleMIDI library, you need to define a callback function that will be called every time a MIDI message is received. Here is an example of how you can do this:

Code: Select all#include <AppleMIDI.h>

void MyMidiCallback(uint8_t channel, uint8_t note, uint8_t velocity)
{
    // Do something with the received MIDI message here
}

void setup()
{
    // Initialize the AppleMIDI library
    AppleMIDI.begin("ESP8266", "AppleMIDI");

    // Set the MIDI message receiver callback function
    AppleMIDI.OnReceive(MyMidiCallback);
}

void loop()
{
    // Handle any pending MIDI messages
    AppleMIDI.run();
}
 

In the MyMidiCallback function, you will have access to the channel, note, and velocity parameters of the received MIDI message. You can then use these values to control your LEDs.

Note that you will need to connect your ESP8266 to your WiFi network before it can receive MIDI messages over WiFi. You can use the WiFi.begin function to connect to your network.