Arduino r4 midiusb

Will the arduino uno r4 support the midiusb library? I get an error message that the Uno is not compatible, but on the Arduino website it says that the Uno is compatible with the MidiUSB library

Hi @RianDeRous

Despite the similar names, the Uno and UNO R4 Minima/UNO R4 WiFi boards have significant differences in the context of library compatibility. You should not assume that a library will be compatible with the UNO R4 just because it indicates compatibility with the classic Uno board.

A word of advice when using the Arduino library reference, please keep in mind the "compatibility note" shown on the page:

Note: while the library is supposed to compile correctly on these architectures, it might require specific hardware features that may be available only on some boards.

If you read the documentation of the MIDIUSB library, you'll see that it is actually not compatible with the classic Arduino Uno board at all:

microcontroller with native USB capabilities (atmega32u4 based boards or ARM boards)

In this respect, there is actually a better chance of eventual compatibility with the UNO R4 than the classic Arduino Uno, which does not have the native USB capability that is fundamental to this library.

You can check out what people have found compatable on the R4 on this page:-
Compatibility Library list.

No it doesn't. It mentions the Uno and the Nano in the list of compatible devices but it adds the caveat.

Compatibility Note

Note: while the library is supposed to compile correctly on these architectures, it might require specific hardware features that may be available only on some boards.

The Uno and Nano do not have these features that will allow it to function.

It is very misleading to put the Arduino Uno on that list, especially when you know that the R4 does indeed have the USB functionality. I bought an 'R4 minima' to try this - because it's advertised with it's USB functionality - and was disappointed to see that I need another board.

(Fortunately I have not yet sent my pcb design to be manufactured for this project)

No I have been experimenting and you can do it with what you have, providing you install on your computer an app called 'hairless'. This takes the normal serial data coming into the computer and converts it to MIDI data.
Then the simple #include <MIDI.h> will work. Here is a sketch I modified from the simple example. It sends one note in response to a MIDI read and another note along with a blinking LED at 2 second intervals if nothing is sent.

#include <MIDI.h>

// Simple tutorial on how to receive and send MIDI messages.
// Here, when receiving any message on channel 4, the Arduino
// will blink a led and play back a note for 1 second.

MIDI_CREATE_DEFAULT_INSTANCE();

void setup()
{
    pinMode(LED_BUILTIN, OUTPUT);
    MIDI.begin(4);                      // Launch MIDI and listen to channel 4
}

void loop()
{
    if (MIDI.read())                    // If we have received a message
    {
        sendNote();
    }
    else{
      sendNote2();
    }
}

void sendNote(){
        //digitalWrite(LED_BUILTIN, HIGH);
        MIDI.sendNoteOn(61, 127, 1);    // Send a Note (pitch 61, velo 127 on channel 1)
        delay(1000);                // Wait for a second
        MIDI.sendNoteOff(61, 0, 1);     // Stop the note
        //digitalWrite(LED_BUILTIN, LOW);

}

void sendNote2(){
        digitalWrite(LED_BUILTIN, HIGH);
        MIDI.sendNoteOn(42, 127, 1);    // Send a Note (pitch 42, velo 127 on channel 1)
        delay(1000);                // Wait for a second
        MIDI.sendNoteOff(42, 0, 1);     // Stop the note
        digitalWrite(LED_BUILTIN, LOW);
        delay(1000);

}

I have tested this on both the R4 Minima and the R4 W-Fi. You need to set the baud rate on hairless to 115200 bauds.

here is a screen dump of this working with the Minima.

on the left is hairless, and on the right is the same thing being picked up on Bus 1. All you need to do is to point your MIDI device towards this bus.

1 Like

Thank you! I didn't know such a program exists. I'll try this out. Thank you!

(and hope they'll adapt the midusb library to use the R4's USB functionality in the near future)

I tried the Hairless implementation, but seems to work very unreliable. Despite many attempts, only a few times was I able to have sound as output on Windows.

Have you tried a Serial.begin to set the baud rate, followed by a two second delay.

Yes I agree that the R4 is not very stable when using serial ports. Especially on the 1.xx IDE.

This example did not work for me on the r4 wifi.
Hairless doesn't pick up any messages from the serial port.
I'm not sure what I'm missing here..

You are missing any detail about your project.
So for a start :-
What OS is your computer using?

I am on Windows 11. I have used Hairless before on a similar project (used an arduino mega for that one).
Apart from that, I'm trying to run the code you provided above to test if I'm able to send midi messages to hairless via USB using the r4 wifi.

I've set the baud rate on hariless to 115200 but still nothing..

Sorry I know nothing about Microsoft I was using a Mac.

All I know is that Windows running some kinds of virus protection can sometimes stop the WI-Fi from working. Try a forum search for this, especially ones complaining about very long compile times.

But there's a whole thread you were active on talking about issues with the r4 wifi's serial communication. MIDI-library works on Minima but not on WIFI

So I'm finding it hard to understand how you got around that and got this code to work.

I am on a Mackintosh computer
I have always been on a. Macintosh computer, also I run IDE 1.8.19.

Understand now why you might be having problems that I do not have?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.