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?
Renaming ALSA midi ports for aseqnet
Moderators: MattKingUSA, khz
- lucidbeaming
- Established Member
- Posts: 34
- Joined: Tue Mar 21, 2017 8:44 am
- Location: San Jose, CA
- Contact:
- SpotlightKid
- Established Member
- Posts: 250
- Joined: Sun Jul 02, 2017 1:24 pm
- Has thanked: 48 times
- Been thanked: 54 times
Re: Renaming ALSA midi ports for aseqnet
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.
- lucidbeaming
- Established Member
- Posts: 34
- Joined: Tue Mar 21, 2017 8:44 am
- Location: San Jose, CA
- Contact:
Re: Renaming ALSA midi ports for aseqnet
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.
- SpotlightKid
- Established Member
- Posts: 250
- Joined: Sun Jul 02, 2017 1:24 pm
- Has thanked: 48 times
- Been thanked: 54 times
Re: Renaming ALSA midi ports for aseqnet
I'm not sure you can rename ALSA ports, which your program hasn't opened itself.lucidbeaming wrote:I was hoping to rename the ports before the python script launches.
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.
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).lucidbeaming wrote:Your library is superior for direct calls, but I admit to getting use out of Mido helper functions.
And, just out of interest, which of Mido's helper functions do you find particularly useful?
Maybe you could use the Python binding for libsmf for that? https://github.com/dsacre/pysmflucidbeaming 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.
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