[LAD] Headless RME HDSP/HDSPM mixer settings

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux-audio-dev@...>
Date: Tuesday, November 19, 2013 - 10:08 pm

Hi!

I wrote a quick&dirty cmdline tool to dump and restore the internal
mixer state of an RME card (no matter if handled by snd_hdsp or
snd_hdspm, so this should apply to almost all RME cards except the new
MADIFX).

I call it hdspdump for now, if you like, grab it here:

http://adi.loris.tv/hdspdump.c

Almost no sanity checks, it's proof of concept atm. For your
convenience, I'll also attach it to this mail (who knows what will
happen to the URL above in the future...)

Idea is as follows:

1. Run hdspmixer ONCE to make your desired mix.
2. Run hdspdump hw:DSP > dumpfile to dump the current mixer state.
3. Run hdspdump hw:DSP write < dumpfile to restore the mixer state.

Of course, you can have multiple files for different mixes.

It's most likely used for headless setups with static signal routing.

I have only tested it on my Multiface, so if you have other RME gear and
have a few minutes to waste, I'm happy to hear from you.

Cheers

/* compile with gcc -std=gnu99 -o hdspdump hdspdump.c -lasound */
#include
#include
#include

void usage(char *name) {
fprintf(stderr, "usage: %s cardname [write]\n", name);
fprintf(stderr, "Example: %s hw:DSP > dumpfile\n", name);
fprintf(stderr, "Example: %s hw:DSP write < dumpfile\n", name);
}

void error_and_out(int err) {
fprintf(stderr, "ALSA error: %s\n", snd_strerror(err));
exit(err);
}

int main(int argc, char **argv) {
int err;
char *cardname;
snd_hwdep_info_t *info;
snd_hwdep_info_alloca(&info);

snd_ctl_elem_id_t *id;
snd_ctl_elem_value_t *ctl;
snd_ctl_t *handle;
int write = 0;

if (argc < 2) {
usage(argv[0]);
exit(1);
}

cardname = argv[1];

if (argc > 2 && (0 == strcmp("write", argv[2]))) {
write = 1;
}

snd_ctl_elem_value_alloca(&ctl);
snd_ctl_elem_id_alloca(&id);
snd_ctl_elem_id_set_name(id, "Mixer");
snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_HWDEP);
snd_ctl_elem_id_set_device(id, 0);
snd_ctl_elem_id_set_index(id, 0);
snd_ctl_elem_value_set_id(ctl, id);

if ((err = snd_ctl_open(&handle, cardname, SND_CTL_NONBLOCK)) < 0) {
error_and_out(err);
}

for (int source = 0; source < 128; source++) {
for (int dest = 0; dest < 64; dest++) {
snd_ctl_elem_value_set_integer(ctl, 0, source);
snd_ctl_elem_value_set_integer(ctl, 1, dest);

if (write) {
char buf[1024];
fgets(buf, sizeof(buf), stdin);
snd_ctl_elem_value_set_integer(ctl, 2,
atoi(buf));

if ((err = snd_ctl_elem_write(handle, ctl)) < 0) {
snd_ctl_close(handle);
error_and_out(err);
}
} else {
if ((err = snd_ctl_elem_read(handle, ctl)) < 0) {
snd_ctl_close(handle);
error_and_out(err);
}

printf("%li\n", snd_ctl_elem_value_get_integer(ctl, 2));
}
}
}

snd_ctl_close(handle);
}

_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/listinfo/linux-audio-dev

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[LAD] Headless RME HDSP/HDSPM mixer settings, Adrian Knoth, (Tue Nov 19, 10:08 pm)
Re: [LAD] Headless RME HDSP/HDSPM mixer settings, Mario Lang, (Wed Nov 20, 5:18 pm)
Re: [LAD] Headless RME HDSP/HDSPM mixer settings, Ralf Mardorf, (Tue Nov 19, 10:38 pm)
Re: [LAD] Headless RME HDSP/HDSPM mixer settings, Fons Adriaensen, (Tue Nov 19, 10:26 pm)
Re: [LAD] Headless RME HDSP/HDSPM mixer settings, Adrian Knoth, (Tue Nov 19, 10:38 pm)