[linux-audio-user] sending program change to alsa

Clemens Ladisch clemens at ladisch.de
Sat Jun 18 08:01:45 EDT 2005


Atte André Jensen wrote:
> I need a program that will allow me to send predefined program changes
> to alsa clients.

You could load snd-virmidi, connect its port(s) to the destination
port(s), and then call something like

amidi -p hw:X,Y -S "c1 23"

> If not, could anyone point me in the right direction of some
> documentation on how to write such a program, esp how to register as an
> alsa-client and exactly what should be send out how for it to be program
> change.

In C, this would be something like this:

snd_seq_t *seq;
snd_seq_event_t ev;

snd_seq_open(&seq, "default", SND_SEQ_OPEN_DUPLEX, 0);
snd_seq_set_client_name(seq, "my funky program changer");
snd_seq_create_simple_port(seq, "source port",
			   SND_SEQ_PORT_CAP_READ,
			   SND_SEQ_PORT_TYPE_MIDI_GENERIC |
			   SND_SEQ_PORT_TYPE_APPLICATION);
snd_seq_ev_clear(&ev);
snd_seq_ev_set_dest(&ev, dest_client, dest_port);
snd_seq_ev_set_direct(&ev);
snd_seq_ev_set_pgmchange(&ev, channel, program);
snd_seq_event_output_direct(seq, &ev);


HTH
Clemens



More information about the linux-audio-user mailing list