-
Hola, gracias por tan fabulosa libreria. APPLEMIDI_CREATE_INSTANCE (EthernetUDP, MIDI1, " Arduino1 " , DEFAULT_CONTROL_PORT); Pero no se si se pueda, y que habria que colocar en lugar de EthernetUDP. Muchas gracias, un saludo |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Hola @Veroledez Taken from the ESP32_wifi example and Arduino-AppleMIDI-Library/src/AppleMIDI.h Lines 350 to 352 in 7c96535 Your code could something like this: #include <WiFi.h>
#include <WiFiClient.h>
#include <WiFiUdp.h>
APPLEMIDI_CREATE_INSTANCE(WiFiUDP, MIDI1, "AppleMIDI-ESP32-1", DEFAULT_CONTROL_PORT);
APPLEMIDI_CREATE_INSTANCE(WiFiUDP, MIDI2, "AppleMIDI-ESP32-2", DEFAULT_CONTROL_PORT+2);
Let me know if this works |
Beta Was this translation helpful? Give feedback.
-
Hola @Veroledez. At first glace nothing wrong with your code, good job! I copied into the Arduino IDE and compiled for ESP32 DevKit, tweaked the code left and right (kept the essentials) and got good results. Can you try the below. I noticed you did not show the IP address - how did you know the IP address of the ESP32? (Bonjour is not enabled in the code below) In any case, try the below: #include <WiFi.h>
#include <WiFiClient.h>
#include <WiFiUdp.h>
#define SerialMon Serial
#define APPLEMIDI_DEBUG SerialMon
#include <AppleMIDI.h>
char ssid[] = "xxx"; // your network SSID (name)
char pass[] = "yyy"; // your network password (use for WPA, or use as key for WEP)
unsigned long t0 = millis();
int8_t isConnected = 0;
APPLEMIDI_CREATE_INSTANCE(WiFiUDP, MIDI1, " ESP-1", DEFAULT_CONTROL_PORT);
APPLEMIDI_CREATE_INSTANCE(WiFiUDP, MIDI2, " ESP-2", DEFAULT_CONTROL_PORT + 2);
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void setup()
{
DBG_SETUP(115200);
DBG("Booting");
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
DBG("Establishing connection to WiFi..");
}
DBG("Connected to network");
DBG(F("OK, now make sure you an rtpMIDI session that is Enabled"));
DBG(F("Add device named Arduino with Host"), WiFi.localIP(), "Port", AppleMIDI1.getPort(), "and Port", AppleMIDI2.getPort());
DBG(F("Select and then press the Connect button"));
DBG(F("Then open a MIDI listener and monitor incoming notes"));
DBG(F("Listen to incoming MIDI commands"));
AppleMIDI1.setHandleConnected([](const APPLEMIDI_NAMESPACE::ssrc_t & ssrc, const char* name) {
isConnected++;
DBG(F("MIDI 1 Connected to session"), ssrc, name);
});
AppleMIDI1.setHandleDisconnected([](const APPLEMIDI_NAMESPACE::ssrc_t & ssrc) {
isConnected--;
DBG(F("MIDI 1 Disconnected"), ssrc);
});
AppleMIDI2.setHandleConnected([](const APPLEMIDI_NAMESPACE::ssrc_t & ssrc, const char* name) {
isConnected++;
DBG(F("MIDI 2 Connected to session"), ssrc, name);
});
AppleMIDI2.setHandleDisconnected([](const APPLEMIDI_NAMESPACE::ssrc_t & ssrc) {
isConnected--;
DBG(F("MIDI 2 Disconnected"), ssrc);
});
MIDI1.begin();
MIDI2.begin();
MIDI1.setHandleNoteOn([](byte channel, byte note, byte velocity) {
DBG(F("MIDI 1 NoteOn"), note);
});
MIDI2.setHandleNoteOn([](byte channel, byte note, byte velocity) {
DBG(F("MIDI 2 NoteOff"), note);
});
DBG(F("Sending NoteOn/Off of note 45, every second"));
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void loop()
{
// Listen to incoming notes
MIDI1.read();
MIDI2.read();
// send a note every second
// (dont cáll delay(1000) as it will stall the pipeline)
if (isConnected >= 2 && (millis() - t0) > 1000)
{
t0 = millis();
MIDI1.sendNoteOn(40, 64, 1);
MIDI2.sendNoteOn(40, 64, 1);
}
} |
Beta Was this translation helpful? Give feedback.
Hola @Veroledez. At first glace nothing wrong with your code, good job!
I copied into the Arduino IDE and compiled for ESP32 DevKit, tweaked the code left and right (kept the essentials) and got good results. Can you try the below.
I noticed you did not show the IP address - how did you know the IP address of the ESP32? (Bonjour is not enabled in the code below)
In any case, try the below: