Skip to content

usb_midi Device Name #4191

Closed
Closed

Description

@1st-BrainStormer

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.

Activity

  1. added this to the Long term milestone on Feb 12, 2021
  2. ToxicTiger901 commented on May 29, 2022

    @ToxicTiger901

    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.

  3. jwktje commented on Jul 19, 2022

    @jwktje

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

  4. ToxicTiger901 commented on Jul 19, 2022

    @ToxicTiger901

    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)

  5. ToxicTiger901 commented on Jul 19, 2022

    @ToxicTiger901

    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!

  6. jwktje commented on Jul 19, 2022

    @jwktje

    @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

  7. tannewt commented on Jul 25, 2022

    @tannewt
    Member

    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

  8. ToxicTiger901 commented on Jan 3, 2023

    @ToxicTiger901

    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?

  9. dhalbert commented on Jan 3, 2023

    @dhalbert
    Collaborator

    @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";

  10. ToxicTiger901 commented on Jan 4, 2023

    @ToxicTiger901

    Thanks. I think I understand now.

  11. ToxicTiger901 commented on Jan 4, 2023

    @ToxicTiger901

    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?

  12. dhalbert commented on Jun 29, 2023

    @dhalbert
    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.

  13. mrbbp commented on Sep 23, 2023

    @mrbbp

    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

  14. dhalbert commented on Sep 23, 2023

    @dhalbert
    Collaborator

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

  15. mrbbp commented on Sep 24, 2023

    @mrbbp

    @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

  16. dhalbert commented on Sep 24, 2023

    @dhalbert
    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]";
    .

  17. mrbbp commented on Sep 24, 2023

    @mrbbp

    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.

  18. dhalbert commented on Sep 24, 2023

    @dhalbert
    Collaborator

    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?

  19. dhalbert commented on Mar 3, 2024

    @dhalbert
    Collaborator

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

  20. dhalbert commented on Apr 6, 2024

    @dhalbert
    Collaborator

    Fixed by #9146.

  21. Antinote commented on Apr 8, 2025

    @Antinote

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions