Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/danieloneill/alsalist
Very basic tool to scan ALSA sequencer devices and list clients/sources in an easily parseable way.
https://github.com/danieloneill/alsalist
alsa midi sequencer
Last synced: 9 days ago
JSON representation
Very basic tool to scan ALSA sequencer devices and list clients/sources in an easily parseable way.
- Host: GitHub
- URL: https://github.com/danieloneill/alsalist
- Owner: danieloneill
- License: gpl-3.0
- Created: 2018-05-03T02:44:24.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-04-20T21:56:44.000Z (over 2 years ago)
- Last Synced: 2024-10-31T20:12:22.649Z (about 2 months ago)
- Topics: alsa, midi, sequencer
- Language: C
- Size: 14.6 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# alsalist
Very basic tool to scan ALSA sequencer devices and list clients/sources in an easily parseable way.I use this (instead of a BASH mess of "aconnect -l" and a pile of pipes) to automate connecting my DTX400k kit USB MIDI data to the output of a USB MIDI adapter.
## Build
You'll need make, gcc, libasound2-dev, and pkg-config```
$ cd alsalist
$ make
```## Usage
I mean... you just run it, and it lists your alsa sequencer clients/ports in a line-by-line fashion.The lines are in a "<client id>:<source id> <client name> : <source name>" format.
```
$ ./alsalist
0:0 System : Timer
0:1 System : Announce
14:0 Midi Through : Midi Through Port-0
$
```## Example
You could do fun things with the help of a few basic Unix utilites and udev to automate connections. I do it by first creating a udev rules file to trigger my script to run whenever one of two devices are plugged in. (Well, also when they're unplugged, but whatever):### /etc/udev/rules.d/10-midi.rules
```
# The DTX USB device stuff:
ATTRS{idVendor}=="0499", ATTRS{idProduct}=="7000", RUN="/usr/local/bin/midi.sh"# The USB cable stuff:
ATTRS{idVendor}=="15ca", ATTRS{idProduct}=="1806", RUN="/usr/local/bin/midi.sh"
```The udev rules have that "RUN" thing that makes it try to run a script. Here's the script:
### /usr/local/bin/midi.sh
```
#!/bin/bashaconnect -x
SOURCE=`/home/pi/alsalist/alsalist | grep DTX | awk '{print $1;}'`
DEST=`/home/pi/alsalist/alsalist | grep "MIDI Interface cable" | awk '{print $1;}'`aconnect $SOURCE $DEST
```In the above, the sequencer connections are flushed with "aconnect -x", then alsalist is called to fish out the "client:source" IDs of the appropriate things. In this case, my DTX input is being piped to my USB MIDI adapter's output.
You can find the idVendor and idProduct values for your hardware by running "lsusb" in a terminal, and you need to change what "grep" looks for to suit your device names (as seen in the output of alsalist when you run it by itself).
The script and udev rules are very basic and contain no error checking, but any errors that could happen would be harmless and when the conditions are appropriate (both devices connected) it should work as expected nonetheless.