Renaming ALSA midi ports for aseqnet

Programming applications for making music on Linux.

Moderators: MattKingUSA, khz

Post Reply
User avatar
lucidbeaming
Established Member
Posts: 33
Joined: Tue Mar 21, 2017 8:44 am
Location: San Jose, CA
Contact:

Renaming ALSA midi ports for aseqnet

Post by lucidbeaming »

I'm working on a Python project that controls multiple remote midi devices running on Raspberry Pis. I'm using a built-in ALSA utility called aseqnet to connect a common client to many midi servers. It works well enough, but names each port connection 'Net Device'. I'm using a Python midi library called mido and it requires a port name, not a port number like 128:0. Thus, namespace collisions and poor readablitiy.

I have built a small script that dumps the rtmidi label of the port, but would rather name the port in a custom way. I can't find any way to name midi ports in ALSA. Do you folks know of any CLI methods?

User avatar
SpotlightKid
Established Member
Posts: 123
Joined: Sun Jul 02, 2017 1:24 pm

Re: Renaming ALSA midi ports for aseqnet

Post by SpotlightKid »

mido is built on top of python-rtmidi (of which I am the auhor). The latest versions of python-rtmidi allow to rename ports. You can use python-rtmidi on its own instead of mido.

User avatar
lucidbeaming
Established Member
Posts: 33
Joined: Tue Mar 21, 2017 8:44 am
Location: San Jose, CA
Contact:

Re: Renaming ALSA midi ports for aseqnet

Post by lucidbeaming »

I was hoping to rename the ports before the python script launches. Your library is superior for direct calls, but I admit to getting use out of Mido helper functions. Mido also has basic methods for parsing external midi files, which I would need to either roll my own or use something like pygame.

User avatar
SpotlightKid
Established Member
Posts: 123
Joined: Sun Jul 02, 2017 1:24 pm

Re: Renaming ALSA midi ports for aseqnet

Post by SpotlightKid »

lucidbeaming wrote:I was hoping to rename the ports before the python script launches.
I'm not sure you can rename ALSA ports, which your program hasn't opened itself.

Maybe you could write a short Python script using the ALSA Python bindings and try? See the examples in the "test" directory of the alsa-python repo on how to open ALSA sequencer ports.
lucidbeaming wrote:Your library is superior for direct calls, but I admit to getting use out of Mido helper functions.
I'm sure Mido keeps references to the underlying rtmidi.MidiOut / rtmidi.MidiIn objects somewhere. You should be able to use these directly if any only when you need to. Just make sure, Mido uses the latest version of python-rtmidi (last time I looked it still required an older version in its setup.py).

And, just out of interest, which of Mido's helper functions do you find particularly useful?
lucidbeaming wrote:Mido also has basic methods for parsing external midi files, which I would need to either roll my own or use something like pygame.
Maybe you could use the Python binding for libsmf for that? https://github.com/dsacre/pysmf

I also have a library to parse SMFs, but it has it quirks, so I can't recommend it without reservations. https://github.com/SpotlightKid/miditk-smf

Post Reply