tttapa / Control-Surface

Arduino library for creating MIDI controllers and other MIDI devices.
GNU General Public License v3.0
1.27k stars 140 forks source link

AppleMIDI example: Questions #197

Open ciapamusche opened 4 years ago

ciapamusche commented 4 years ago

Hi im tryng to get work AppleMIDI example.

i have an error

Arduino:1.8.12 (Windows 10), Scheda:"DOIT ESP32 DEVKIT V1, 80MHz, 921600, None"

In file included from C:\Users\Damiano\Documents\Arduino\libraries\Control-Surface-master\examples\3. MIDI Interfaces\AppleMIDI\AppleMIDI.ino:99:0:

C:\Users\Damiano\Documents\Arduino\libraries\Control-Surface-master\src/MIDI_Interfaces/Wrappers/FortySevenEffects.hpp:9:18: fatal error: MIDI.h: No such file or directory

compilation terminated.

exit status 1

Any advices?

I have other questions.

1)Is possible to use the AppleMIDI on ESP8266? Is a wifi communication so i think is possible.

2) an off topic but i dont want to open new unuseful issues: I have a roland EV-5 pedal. How can i connect? thank you very much for help

tttapa commented 4 years ago

C:\Users\Damiano\Documents\Arduino\libraries\Control-Surface-master\src/MIDI_Interfaces/Wrappers/FortySevenEffects.hpp:9:18: fatal error: MIDI.h: No such file or directory

The AppleMIDI library depends on the FortySevenEffects MIDI library. You have to install that first.

  1. Is possible to use the AppleMIDI on ESP8266? Is a wifi communication so i think is possible.

That's a question for the AppleMIDI developers, I've never tried it on an ESP8266, but it seems to work fine on an ESP32, and although there are no examples for the ESP8266 specifically, their GitHub page claims that it's compatible.

  1. an off topic but i dont want to open new unuseful issues: I have a roland EV-5 pedal. How can i connect?

A quick Google search brings up this schematic:

EV-5

If it's correct, you can connect the shield to ground, the ring to Vcc (3.3V), and the tip to the analog input.

An ESP8266 doesn't have a 3.3V ADC. Some boards have a voltage divider on-board to account for that, but it's not ideal for measuring potentiometers.
If your board doesn't have a voltage divider, connecting the pedal directly to the ESP8266's ADC pin will destroy it.

ciapamusche commented 4 years ago

Sorry for imprecision I have a NodeMCU which have internal voltage divider and can manage until 3.3v

I will try the AppleMIDI on it

ciapamusche commented 4 years ago

Update. The library didnt work with ESP8266. in contact with developer he adapt a branch for solve the problem. https://github.com/lathoub/Arduino-AppleMIDI-Library/issues/85

So if you want use NodeMCU or ESP8266 you have to download the branch feat/2.1.0

ciapamusche commented 4 years ago

Pasting working code for ESP8266 Boards. Modified the Wifi libraries.

/**
 * This example demonstrates how to use the AppleMIDI library to use Control
 * Surface over the network.
 * 
 * This example requires the 
 * [AppleMIDI](https://github.com/lathoub/Arduino-AppleMIDI-Library) and 
 * [MIDI](https://github.com/FortySevenEffects/arduino_midi_library) libraries.
 * 
 * @boards  ESP8266
 * 
 * Connections
 * -----------
 * 
 * The on-board LED will be used, as well as the push button on GPIO0. These 
 * should be present on most ESP8266 boards, if this is not the case for your 
 * board, connect an LED (+ series resistor) and a push button to the relevant
 * pins (in the "MIDI Elements" section below). For more details, see the 
 * @ref NoteButton.ino and @ref 1.Note-LED.ino examples.
 * 
 * WiFi Credentials
 * ----------------
 * 
 * Open the tab `WiFi-Credentials.example.h`, enter your WiFi credentials, and
 * rename the file to `WiFi-Credentials.h`.
 * 
 * Behavior
 * --------
 * 
 * Upload the code to the ESP8266, and open the Serial monitor. You should see
 * output like this
 * 
 * ~~~
 * Connecting to Your WiFi Network ...
 * Connected!
 * IP address: 192.168.1.35
 * mDNS responder started (ESP8266.local)
 * ~~~
 * 
 * Next, connect to the device using your DAW or other MIDI software. If the 
 * software supports mDNS (Apple Bonjour), you can use `ESP32.local`, 
 * otherwise, you'll have to use the IP address.
 * 
 * When the connection is successful, you'll see the following message in the
 * Serial monitor:
 * 
 * ~~~
 * Connected to session Your Session Name
 * ~~~
 * 
 * When the button is pushed, a MIDI note on message for note C4 (middle C) is
 * sent.  
 * When the ESP32 receives a MIDI note message for that note, it turn on/off the
 * LED accordingly.
 * 
 * RTP MIDI Bridge (Linux)
 * -----------------------
 * 
 * If you're on Linux, you can use the rtpmidi-bridge application in the example
 * folder. You'll need to install Node.js and NPM.
 * 
 * First, install the necessary dependencies and build tools:
 * 
 * ~~~sh
 * sudo apt install build-essential libasound2-dev libavahi-compat-libdnssd-dev
 * ~~~
 * 
 * Then install the dependencies using NPM:
 * 
 * ~~~sh
 * npm install
 * ~~~
 * You might get a compilation error for the `avahi_pub` module. This is not an
 * issue, it's an optional dependency of the `rtpmidi` module.
 * 
 * Finally, run the application:
 * 
 * ~~~sh
 * node rtpmidi-bridge.js
 * ~~~
 * 
 * The application will initiate a RTP MIDI connection with the ESP32, create
 * virtual MIDI ports, and bridge the MIDI traffic between the RTP MIDI 
 * connection and the virtual MIDI ports.  
 * You can then connect your DAW or other MIDI application to the virtual MIDI 
 * ports.
 * 
 * When the ESP32 is connected, you should see the following in the serial 
 * monitor and the rtpmidi-bridge output respectively:
 * 
 * ~~~
 * Connected to session Node RTPMidi
 * ~~~
 * 
 * ~~~
 * 2020-05-06T15:50:42.956Z info:  Invitation accepted by ESP32
 * 2020-05-06T15:50:42.962Z info:  Data channel to ESP32 established
 * ~~~
 * 
 * Mapping
 * -------
 * 
 * Connect the virtual MIDI ports or the AppleMIDI connection to a device or 
 * application that can send and receive MIDI notes.
 * 
 * Written by PieterP, 2020-05-06  
 * https://github.com/tttapa/Control-Surface
 */
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <WiFiUdp.h>

#include <AppleMIDI.h>
USING_NAMESPACE_APPLEMIDI

#include <Control_Surface.h>
#include <MIDI_Interfaces/Wrappers/FortySevenEffects.hpp>

#include <ESP8266mDNS.h>
//#include <WiFi.h>
#include <WiFiUdp.h>

#include "WiFi-Credentials.h" // See instructions above

// ----------------------------- MIDI Interface ----------------------------- //
// First create the AppleMIDI instance
APPLEMIDI_CREATE_INSTANCE(WiFiUDP, MIDI, "ESP8266", 5004);
//                           │       │      │       └──── Local port number
//                           │       │      └──────────── Name
//                           │       └─────────────────── MIDI instance name
//                           └─────────────────────────── Network socket class

// Then wrap it in a Control Surface-compatible MIDI interface
FortySevenEffectsMIDI_Interface<decltype(MIDI) &> AppleMIDI_interface = MIDI;

// ------------------------------ MIDI Elements ----------------------------- //

// Add some MIDI elements for testing
using namespace MIDI_Notes;
NoteButton button = {
    0, note(C, 4),  // GPIO0 has a push button connected on most boards
};
NoteValueLED led = {
    LED_BUILTIN, note(C, 4),
};

// --------------------------- AppleMIDI callbacks -------------------------- //

void onAppleMidiConnected(const ssrc_t &ssrc, const char *name) {
  Serial << F("Connected to session ") << name << endl;
}
void onAppleMidiDisconnected(const ssrc_t &ssrc) {
  Serial << F("Disconnected") << endl;
}
void onAppleMidiError(const ssrc_t &ssrc, int32_t err) {
  Serial << F("Exception ") << err << F(" from ssrc 0x") << hex << ssrc << dec
         << endl;
}

// ---------------------------------- Setup --------------------------------- //

void setup() {
  Serial.begin(115200);

  // Connect to the WiFi network
  Serial << endl << F("Connecting to ") << ssid << ' ';
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED)
    Serial.print("."), delay(250);
  Serial << endl
         << F("Connected!") << endl
         << F("IP address: ") << WiFi.localIP() << endl;

  // Set up mDNS responder:
  if (!MDNS.begin(AppleMIDI.getName()))
    FATAL_ERROR(F("Error setting up MDNS responder!"), 0x0032);
  Serial << F("mDNS responder started (") << AppleMIDI.getName() << ".local)" 
         << endl;
  MDNS.addService("apple-midi", "udp", AppleMIDI.getPort());

  // Set up some AppleMIDI callback handles
  AppleMIDI.setHandleConnected(onAppleMidiConnected);
  AppleMIDI.setHandleDisconnected(onAppleMidiDisconnected);
  AppleMIDI.setHandleError(onAppleMidiError);

  // Initialize Control Surface (also calls MIDI.begin())
  Control_Surface.begin();
}

// ---------------------------------- Loop ---------------------------------- //

void loop() {
  // Update all MIDI elements and handle incoming MIDI
  Control_Surface.loop();
}
alomdj00 commented 3 years ago

Hola @ciapamusche he estado tratando de usar el esp8266, y no he logrado compilar, instale el ide nuevamente, descargue todo lo que se me ocurrio y no compilo, veo que nombras una rama FEAT, la he buscado en el repositorio de applemidi, de fortyseveneffects y de controlsurface y no la encuentro, podrias indicarme a que libreria pertenece esta rama o como lograste compilar para esp8266, agradezco mucho tu ayuda. Un saludo

ciapamusche commented 3 years ago

Hi Which error you get?

have you try the branch indicated?

alomdj00 commented 3 years ago

Hola, este es el error que obtengo

https://github.com/tttapa/Control-Surface/issues/372

He usado la version master y la new input de controlsurface. AppleMidi ya no tiene ramas. Fortyseveneffects tampoco tiene ramas.

No se cual es la rama feat, o a que libreria pertenece la rama feat para buscarla y probar