Using Serial MIDI instead of USB MIDI #464
Replies: 1 comment
-
Yes, that looks alright to me. For Control Surface to work, you need at least one MIDI Interface. Control Surface always uses the “default MIDI interface”. If the default MIDI interface was configured explicitly using Note that if you know that you'll always be using 5-pin DIN MIDI, you can use HardwareSerialMIDI_Interface midi = Serial; it's a bit cleaner than the more general version you posted above, but the result is exactly the same. |
Beta Was this translation helpful? Give feedback.
-
Hi.
First off, thank you very much for creating this wonderful library! I can imagine it has taken quite a bit of your time over the years and we all thank you for this labor of love, so to speak. I have a quick question that will make my use of the entire library much easier for me. So, I plan on using the majority of the examples with "Serial MIDI (5-Pin Din)". Understandably, all your examples includes USB MIDI. Being new to your MIDI implementation, I'm trying to figure out the easiest way to change this for my usage. Below is the code section from "AbsoluteRotaryEncoder.ino" as an example. I've commented out the "USBMIDI_Interface midi" line and added the Serial MIDI lines from the "Serial-Interface.ino" example. Would this be the correct solution for using Serial MIDI? Is there anything else I would need to add? Again, I really appreciate this and your time!
Thanks in advance.
`#include <Encoder.h> // Include the Encoder library.
// This must be done before the Control Surface library.
#include <Control_Surface.h> // Include the Control Surface library
// Instantiate a MIDI over USB interface.
// USBMIDI_Interface midi;
// Select the serial port to use.
auto &serial = Serial;
// Instantiate a Serial MIDI interface at the default MIDI baud rate.
SerialMIDI_Interface<decltype(serial)> midi = {serial, MIDI_BAUD};
// Instantiate a CCAbsoluteEncoder object
CCAbsoluteEncoder enc = {
{2, 3}, // pins
MIDI_CC::Pan, // MIDI address (CC number + optional channel)
1, // optional multiplier if the control isn't fast enough
};
// Similarly, for Pitch Bend
// PBAbsoluteEncoder enc = {
// {2, 3}, // pins
// CHANNEL_1, // MIDI channel
// 127, // large multiplier because Pitch Bend has high resolution
// };
void setup() {
Control_Surface.begin(); // Initialize Control Surface
}
void loop() {
Control_Surface.loop(); // Update the Control Surface
}`
Beta Was this translation helpful? Give feedback.
All reactions