You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the midi_multi_ports example, a new USB MIDI object is created with 3 ports. I was able to run this successfully and all the ports are showing on my PC when I connect my device (I am using Raspberry Pi Pico) via USB.
However, I am not able to know from which port/cable a MIDI message sent from my PC to the Pico came from, as I don't have any information about which MidiInterface object is mapped to which MIDI cable index (or so I think that's how it should work).
Is this already supported in the library? Here's my code sample:
#include <Arduino.h>
#include <Adafruit_TinyUSB.h>
#include <MIDI.h>
// USB MIDI object with 3 ports
Adafruit_USBD_MIDI usb_midi(3);
typedef midi::SerialMIDI<Adafruit_USBD_MIDI> MidiType;
// Create a new instance of the Arduino MIDI Library,
// and attach usb_midi as the transport.
MidiType serialMidi(usb_midi);
midi::MidiInterface<MidiType> midi_interface(serialMidi);
void handleControlChange(midi::Channel channel, byte code, byte value)
{
// Log when a control change is received.
Serial.print("Control change: channel = ");
Serial.print(channel);
Serial.print(" code = ");
Serial.print(code);
Serial.print(" value = ");
Serial.println(value);
}
void setup()
{
#if defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_RP2040)
// Manual begin() is required on core without built-in support for TinyUSB such as mbed rp2040
TinyUSB_Device_Init(0);
#endif
USBDevice.setManufacturerDescriptor("Raspberry Pi Pico");
USBDevice.setProductDescriptor("Master Pico");
// Set name for each cable, must be done before usb_midi.begin()
usb_midi.setCableName(1, "Port 1");
usb_midi.setCableName(2, "Port 2");
usb_midi.setCableName(3, "Port 3");
// Initialize MIDI, and listen to all MIDI channels
// This will also call usb_midi's begin()
midi_interface.begin(MIDI_CHANNEL_OMNI);
midi_interface.setHandleControlChange(handleControlChange);
// wait until device mounted
while (!TinyUSBDevice.mounted()) delay(1);
}
void loop()
{
// read any new MIDI messages
midi_interface.read();
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
In the
midi_multi_ports
example, a new USB MIDI object is created with 3 ports. I was able to run this successfully and all the ports are showing on my PC when I connect my device (I am using Raspberry Pi Pico) via USB.However, I am not able to know from which port/cable a MIDI message sent from my PC to the Pico came from, as I don't have any information about which
MidiInterface
object is mapped to which MIDI cable index (or so I think that's how it should work).Is this already supported in the library? Here's my code sample:
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions