Naming Midi Interfaces on Pisound

Hello all! I am in the process of setting up an audio installation based on Pd with the Pisound at the heart controlling 4 Arduino Pro Micro operating as Midi interfaces. I’m now trying to understand how to make sure that these Arduino Midi Interfaces are assigned in ALSA in a specific order, so that I can address the correct one from the Pd Patch using channels 1-16, 17-33 etc. Is there a way to change the generic Midi interface name on the RPi? And how could I make sure that these Midi interfaces are connected every startup in the same way? Many thanks for your help in advance!

Hi, it should be possible to write an udev rule to assign some consistent name, see here: Changing card IDs with udev - AlsaProject

It depends on how the Pro Micro devices are programmed too - do each of them have a different USB VID and PID values, or are they all the same? Can you change the product name string on each of the device?

Ideally, you’d want to have unique product name strings on each device, then you could just use their names as part of the aconnect command to connect the hardware to virtual PD ports.

Otherwise, having a different ‘serial string’ on each of the devices would be helpful too, so you could write udev rules for those devices based on the serial.

If none of that can be changed, you may have to look into writing udev rules for naming the devices based on which USB port they’re physically connected to, this could be tricky and not as reliable.

I’ve looked into this a little bit in the AVR core of Arduino - looks like it’s not meant for easy customization, but it should still be doable, see this place in USBCore.cpp:

You may do this to let yourself customize the name of the device, first find USBCore.cpp used by SparkFun Pro Micro somewhere in the boards description directory of Arduino, then comment out this line:

const u8 STRING_MANUFACTURER[] PROGMEM = USB_MANUFACTURER;

also change this line:

return USB_SendStringDescriptor(STRING_MANUFACTURER, strlen(USB_MANUFACTURER), TRANSFER_PGM);

into:

return USB_SendStringDescriptor(STRING_MANUFACTURER, strlen_P(STRING_MANUFACTURER), TRANSFER_PGM);

Place this line into your main sketch:

const u8 STRING_MANUFACTURER[] PROGMEM = "iamkabuki";

You may want to do the same changes with STRING_PRODUCT.

After the names are changed, connect the devices to RPi and check the output of aconnect -l.

1 Like

Thank you so much for the detailed reply! I will give this a shot and report back my findings.

1 Like

Hello Giedrius!

I tried to follow the instructions in your post but only have limited success.
I’m able to identify the two midi interfaces, and then created a new set of rules as outlined in the link “Changing card IDs with udev”, but I couldn’t find a way to address them reliable.
I intend to look further into this at a later stage and post my findings.

In the meantime I used the following workaround: I applied a Midi filter on the Arduino Midi interfaces, so that each only listens to one specific channel. This way I only have to adapt my Pd script on the RPi.
Turns out there is always a solution if you only look long enough :slight_smile:

Thanks again for the awesome platform that you created!

If you managed to rename the USB devices by changing the product id string, you should be able to realiably address them by using strings like “your_product_name:0”, as long as the names are unique for each device. Check ‘aconnect -l’ to see how the strings could look like. Also see snd_seq_parse_address function of ALSA API for insight on how the string is matched up to the ALSA port.

In that case, no udev rules would be necessary.