-
Hello, I'm currently developing over the DualMerger.ino example. Works perfect with UNO Board, but not working under Sparkfun Pro Micro. Guess has to do with interrupts for Serial input. ProMicro needs any special request? is it compatible with this lib? #include <MIDI.h>
#include "Controller.h"
#include <SoftwareSerial.h>
SoftwareSerial softSerial(2,3); // Software Serial Port Pins (2,3) (Rx,Tx)
MIDI_CREATE_INSTANCE(HardwareSerial, Serial, midiA);
MIDI_CREATE_INSTANCE(SoftwareSerial, softSerial, midiB);
MIDI_CREATE_DEFAULT_INSTANCE();
void setup() {
attachInterrupt(digitalPinToInterrupt(2), loop, CHANGE);
// Initiate MIDI communications, listen to all channels
midiA.begin(MIDI_CHANNEL_OMNI);
midiB.begin(MIDI_CHANNEL_OMNI);
MIDI.begin (MIDI_CHANNEL_OFF);
}
void loop()
{
if (midiA.read())
{
// Thru on A has already pushed the input message to out A.
// Forward the message to out B as well.
midiB.send(midiA.getType(),
midiA.getData1(),
midiA.getData2(),
midiA.getChannel());
}
if (midiB.read())
{
// Thru on B has already pushed the input message to out B.
// Forward the message to out A as well.
midiA.send(midiB.getType(),
midiB.getData1(),
midiB.getData2(),
midiB.getChannel());
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 13 replies
-
Hello, I'm not familiar with the Sparkfun Pro Micro. But looking at the code, you instantiate 3 MIDI ports: midiA, midiB and MIDI. Yet you only use 2 in your code: midiA and midiB. I also have a suspicion that midiA (using hardware serial) overlaps with MIDI (also using hardware serial, yet hidden by the MACRO So: delete Note: i can't see in your code why you need the interrupt. |
Beta Was this translation helpful? Give feedback.
-
Do you have another ProMicro to test this on? |
Beta Was this translation helpful? Give feedback.
-
Just to rule some things out, could you test the following things?
|
Beta Was this translation helpful? Give feedback.
-
More R&D..... a genuine Leonardo with a 32U4 also doesn't work.... same as ProMicro 32U4 issue. |
Beta Was this translation helpful? Give feedback.
-
I didn't really understand your response concerning USB MIDI, but if you want to use the 32U4 to act as a USB MIDI device and talk with a USB host, you'll really have to use the USBMIDI library made by @lathoub in addition to this one, check the examples there. It has worked on the Uno as it talks using HardwareSerial to the USB transceiver chip that deals with USB device enumeration (as a MIDI device in your case as you patched it to behave like so). But this transceiver bridge does not exist on the 32U4, which has a built-in USB interface. |
Beta Was this translation helpful? Give feedback.
-
Finally got it! well almost there. The clue is a limitation of the SoftwareSerial library: |
Beta Was this translation helpful? Give feedback.
-
And finally, still need how to add midi over usb (merged with midiA+midiB) both to Serial1. Can you help here? #include <USB-MIDI.h>
#include <SoftwareSerial.h>
SoftwareSerial softSerial(8,9); // Software Serial Port Pins (8,9) (Rx,Tx)
MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, midiA); //Atmega32U4 uses Serial1 . Uno Serial.
MIDI_CREATE_INSTANCE(SoftwareSerial, softSerial, midiB);
void setup(){
// Initiate MIDI communications, listen to all channels
midiA.begin(MIDI_CHANNEL_OMNI);
midiB.begin(MIDI_CHANNEL_OMNI);
}
void loop(){
if (midiA.read()) {
// Thru on A has already pushed the input message to out A.
// Forward the message to out B as well.
midiB.send(midiA.getType(),
midiA.getData1(),
midiA.getData2(),
midiA.getChannel());
}
if (midiB.read()) {
// Thru on B has already pushed the input message to out B.
// Forward the message to out A as well.
midiA.send(midiB.getType(),
midiB.getData1(),
midiB.getData2(),
midiB.getChannel());
}
} |
Beta Was this translation helpful? Give feedback.
-
@Petrus125 apart from the USB-MIDI include, I don't see any reference to a USB MIDI instance as described on https://github.com/lathoub/Arduino-USBMIDI. The above code only references serial MIDI. Have you looked at the example franky47 pointed you to (example) |
Beta Was this translation helpful? Give feedback.
Finally got it! well almost there. The clue is a limitation of the SoftwareSerial library:
"Not all pins on the Leonardo and Micro boards support change interrupts, so only the following can be used for RX: 8, 9, 10, 11, 14
(MISO), 15 (SCK), 16 (MOSI)."
So using pin 8, instead of pin 2, works fine.