Skip to content

usb_midi Device Name #4191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1st-BrainStormer opened this issue Feb 12, 2021 · 20 comments · Fixed by #9146
Closed

usb_midi Device Name #4191

1st-BrainStormer opened this issue Feb 12, 2021 · 20 comments · Fixed by #9146

Comments

@1st-BrainStormer
Copy link

Device name should be "CircuitPython Midi" not "CircuitPython Audio" as this is a midi interface.
It would also be useful if this could be overridden with a custom device name.

@ToxicTiger901
Copy link

Sorry I know I'm a bit late to this conversation, but I thought I would add this in case it helps anyone else.
It's really easy to change the device name if you want to. Just download the Circuit Python .UF2 file and using a Hex file editor (I used PSPad) search for "CircuitPython Audio". You can then edit the Text, save the changes and install your modified version of the .UF2 file.
The Pi Pico should then appear with the new name you gave it.

@jwktje
Copy link

jwktje commented Jul 19, 2022

I also wanna change the midi device name but it seems like this approach doesn't work anymore. Any tips?

@ToxicTiger901
Copy link

ToxicTiger901 commented Jul 19, 2022

It should still work.

  1. Download CircuitPython (I’m currently using 7.3.1)
    image

  2. Open the .UF2 with a HEX editor (I use PSPAD which is a free text editor)

  3. Go to line 151100 (or search for “CircuitPython Audio”):
    image

  4. Change the text for example to “MIDI Pedalboard”. I haven’t experimented but my guess is that you will be limited to 19 characters. Fill any unused characters with 00Hex :
    image

  5. Save the changes to the .UF2 file

  6. Holding in the BOOT button on your Pi Pico and plug in the USB cable, then copy the edited .UF2 file to the Raspberry Pi Pico as you would normally to install CircuitPyton.

As a basic example I then put the following code in the code.py file:

import board
import digitalio
import usb_midi
import time
import adafruit_midi
from adafruit_midi.note_off import NoteOff
from adafruit_midi.note_on import NoteOn

led = digitalio.DigitalInOut(board.GP25)
led.direction = digitalio.Direction.OUTPUT
usb_midi = adafruit_midi.MIDI(
midi_out=usb_midi.ports[1],
out_channel=0
)

while True:
usb_midi.send(NoteOn(48,127))
led.value = True
time.sleep(1)
usb_midi.send(NoteOff(48,0))
led.value = False
time.sleep(1)

Using MIDI-OX you can then open the midi device with the new name you created and it will send a single note on a 2 second loop (on/off)

@ToxicTiger901
Copy link

I also wanna change the midi device name but it seems like this approach doesn't work anymore. Any tips?

I've added some more instructions. Hopefully they should help. Let me know if you get stuck!

@jwktje
Copy link

jwktje commented Jul 19, 2022

@ToxicTiger901 Tried again and it worked. Thanks a bunch for the detailed update! Still would love a way to just define a name in the Python code, but I don't know if that is even possible without help from Adafruit. Maybe something worth to consider @ladyada ? Totally understand if it's too hard

@tannewt
Copy link
Member

tannewt commented Jul 25, 2022

Overall USB names will be configurable with: #6247 (Testing would be helpful.)

You may also be able to provide a new USB descriptor for the MIDI with: https://learn.adafruit.com/customizing-usb-devices-in-circuitpython

@ToxicTiger901
Copy link

Overall USB names will be configurable with: #6247 (Testing would be helpful.)

Is this now included in 8.0.0 Beta 6?
If so how do I get it to work?

@dhalbert
Copy link
Collaborator

dhalbert commented Jan 3, 2023

@ToxicTiger901 #6247 allows setting the name of the whole device, but not individual interface descriptor names. So it will not help for what you want. We haven't yet added the ability to modify the interface names. You can do a custom build and change this:

static const char midi_streaming_interface_name[] = USB_INTERFACE_NAME " MIDI";
static const char midi_audio_control_interface_name[] = USB_INTERFACE_NAME " Audio";

@ToxicTiger901
Copy link

Thanks. I think I understand now.

@ToxicTiger901
Copy link

My only slight confusion here is when I configure a Midi Device using standard CircuitPython firmware (see my example Python code above) it comes up as CircuitPyton Audio,not CircuitPython MIDI?

@dhalbert
Copy link
Collaborator

My only slight confusion here is when I configure a Midi Device using standard CircuitPython firmware (see my example Python code above) it comes up as CircuitPyton Audio,not CircuitPython MIDI?

MIDI is part of the USB Audio specification, which is confusing. It's a particular kind of "audio" device.

@mrbbp
Copy link

mrbbp commented Sep 23, 2023

sorry for my newb question.

Is there a "simple" way to rename the usb_midi device name?
by default it named CircuitPython usb_midi.ports[x]

i tried to modifing the .uf2 file with an hex editor:
i tried with a different length name and the uf2 is not working (no boot)
i tried a second time with the same number of char (13), the uf2 seems to work but the device has the same name CircuitPython....

i tried supervisor.set_usb_identification("Herve Bi", "Herve Bi") but no more result.
i'm not sure about my syntax

any help appreciate
regards

circuitPython : 8.2.6
board: waveshare zero

@dhalbert
Copy link
Collaborator

@mrbbp Which name exactly do you want to change? What is the current name and what do you want to change it to?

@mrbbp
Copy link

mrbbp commented Sep 24, 2023

@dhalbert
i build a small box with 2 rotatives pot on it and a rp2040 to send midi datas.
I use the pot to have a physical interface to manupulate things in Processing.org
in my sketch the device listed is CircuitPython usb_midi.ports[0]

Available MIDI Devices:

----------Input----------  
[0] "Real Time Sequencer"  
[1] "CircuitPython usb_midi.ports[0]"  
----------Output----------   
[0] "Gervill"  
[1] "Real Time Sequencer"  
[2] "CircuitPython usb_midi.ports[0]"

i would like to replace this name with a custom name, the name of the box ("Hervé Bi").

regards

@dhalbert
Copy link
Collaborator

Right now that name is not settable from CircuitPython, but you can make a custom build and change the name. The names that are fixed at compile time are here:

static const char midi_streaming_interface_name[] = USB_INTERFACE_NAME " MIDI";
static const char midi_audio_control_interface_name[] = USB_INTERFACE_NAME " Audio";
static const char midi_in_jack_name[] = USB_INTERFACE_NAME " usb_midi.ports[0]";
static const char midi_out_jack_name[] = USB_INTERFACE_NAME " usb_midi.ports[0]";
.

@mrbbp
Copy link

mrbbp commented Sep 24, 2023

hello, i retried with a new rp2040 and the custom (renamed) .uf2. Now the device show the new name. I retstart my mac and plug the old rp2040 with custom device but it don't show the good name.

@dhalbert
Copy link
Collaborator

dhalbert commented Sep 24, 2023

You may need to somehow "forget" the device on the Mac. macOS may have cached information about the device. Have you tried rebooting the Mac?

EDIT: I looked for a way to have macOS forget a USB device, but I couldn't find something a few minutes of searching. On Windows this is possible in the Device Manager.

Also could you look in BOOT_OUT.TXT on the "old" RP2040 to make sure you have the new custom build loaded?

@dhalbert
Copy link
Collaborator

dhalbert commented Mar 3, 2024

#8989, which allows renaming the HID interface, is a potential model for code to do this for MIDI.

@dhalbert
Copy link
Collaborator

dhalbert commented Apr 6, 2024

Fixed by #9146.

@dhalbert dhalbert closed this as completed Apr 6, 2024
@Antinote
Copy link

Antinote commented Apr 8, 2025

As mentioned above the Mac seems to cache the old name. To forget the old name on the Mac I seem to be able to:

  1. Run "Audio MIDI Setup"
  2. If the Pico is connected and powered on I can see it in Audio MIDI Setup
  3. Disconnect the Pico (You can't delete the device in Audio MIDI Setup unless you disconnect it)
  4. Select the Pico in Audio MIDI Setup
  5. Delete the Pico
  6. Reconnect the Pico and it will reappear in Audio MIDI Setup

I called usb_midi.set_names() from boot.py per the instructions on https://docs.circuitpython.org/en/latest/shared-bindings/usb_midi/ .

I had to use supervisor.set_usb_identification() in boot.py to change the USB Device name of the Pico per these instructions https://docs.circuitpython.org/en/latest/shared-bindings/supervisor/index.html#supervisor.set_usb_identification

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants