[LAD] ALSA autoconnect

Pedro Lopez-Cabanillas pedro.lopez.cabanillas at gmail.com
Wed Dec 23 17:30:40 UTC 2009


On Wednesday, December 23, 2009, Jens M Andreasen wrote:
> Suppose you wanted a soft-synth to be instantly playable at startup
> (given the option: '--autoconnect') then what would be the ALSA
> functions for:
>
> 1) Saving the current "live" connection at exit (if any.)
> 2) Restoring the above (saved information.)
>
> /j

I suppose that you mean the functions used by an alsa sequencer client program 
of any kind. I think that saving/restoring connections has more sense for 
players/recorders than softsynths.

Using plain libasound API, the functions: 
snd_seq_connect_from() and snd_seq_connect_to() to make the conenctions,
snd_seq_disconnect_to() and snd_seq_disconnect_from() to disconnect, 
you will need also snd_seq_parse_address() to transform the address in string 
form into a pair of client:port numbers.

It is practical to save the address as a string "name:port_number", instead of 
saving the client number, because the numbers are likely going to change the 
next time you start your programs, and the function snd_seq_parse_address() 
is able to translate the client names into the corresponding client numbers. 
For instance, this is taken from my VMPK current .config file:

[Connections]
InPort=KMidimon:0
OutPort=MidiSport 2x2:0

Regards,
Pedro



More information about the Linux-audio-dev mailing list