[Jack-Devel] SOLVED: Re: How to control playback volume of loopback->JACK chain?

PrevNext  Index
DateTue, 27 Dec 2011 09:41:01 -0800
From Robert M. Riches Jr. <[hidden] at jacob21819 dot net>
To[hidden] at yahoo dot com, [hidden] at jacob21819 dot net, [hidden] at lists dot jackaudio dot org
In-Reply-ToRobert M. Riches Jr. Re: [Jack-Devel] How to control playback volume of loopback->JACK chain?
> Date: Sun, 25 Dec 2011 21:25:23 -0800
> To: [hidden], [hidden]
> From: [hidden] (Robert M. Riches Jr.)
>
> > Date: Thu, 22 Dec 2011 05:18:58 -0800 (PST)
> > From: James Warden <[hidden]>
> > To: "[hidden]" <[hidden]>
> >
> >
> >
> > Hello,
> >
> > Back in the days when I was hacking my way through to get the loopback method to work, I experimented with the "softvol" ALSA plugin.
> > If you want to have the volume control on the loopback device, just modify your .asoundrc like this in the !default section (I commented out the former stuff and added a "softvol" section instead, assuming that you are using the same naming as found in my TWIKI page):
> >
> > # ------------------------------------------------------
> > # default device
> >
> > pcm.!default {
> > #  type plug
> > #  slave.pcm "aduplex"
> >
> >   type softvol
> >   slave {
> >       pcm "aduplex"
> >   }
> >
> >   control {
> >       name "aduplex"
> >   }
> >
> >   min_dB -51.0  # 
> >   max_dB   0.0
> > }
> >
> > # -------------------------------------------------------
> >
> >
> > Try this and see if that fulfils your need.
>
> I suppose that would work for a static volume level, to code
> the gain in the max_dB and min_dB values.  However, alsamixer
> would not come up when talking with "-D default" or without
> the -D option.  I tried the above and a few variations on the
> name in the control {} block based on the URL from an earlier
> message.  Nothing appeared to allow real-time changes in
> volume level.
>
> Fwiw: I think I have a fall-back plan to exchange a public
> key at login time on the X terminal (aka zero client) that
> should allow ssh to run alsamixer on the terminal's physical
> hardware sound card(s) displaying via an ssh tunnel to the
> VNC X server running on the server (where all the apps run)
> that will be viewed by the VNC viewer back on the X terminal.
> That's insanely complex, but with the VNC viewer in full-screen
> mode, that's about the only way I can see to do it if softvol
> can't be connected to by alsamixer.

(Thank you for being patient with my user-level questions on this
list.  This posting is to close the loop in case anyone else finds
this thread with a similar problem.)

The solution ended up being softvol on the _client_ side, with
this .asoundrc:

    pcm.lineout {
      type hw
      card Intel
      device 0
    }
    ctl.lineout {
      type hw
      card Intel
      device 0
    }
    
    pcm.monitor {
      type hw
      card Intel
      device 3
    }
    ctl.monitor {
      type hw
      card Intel
      device 3
    }
    
    pcm.plugboth {
      type route;
      slave.pcm {
          type multi;
          slaves.a.pcm "lineout";
          slaves.b.pcm "monitor";
          slaves.a.channels 2;
          slaves.b.channels 2;
          bindings.0.slave a;
          bindings.0.channel 0;
          bindings.1.slave a;
          bindings.1.channel 1;
          bindings.2.slave b;
          bindings.2.channel 0;
          bindings.3.slave b;
          bindings.3.channel 1;
      }
      ttable.0.0 1;
      ttable.1.1 1;
      ttable.0.2 1; # front left
      ttable.1.3 1; # front right
    }
    ctl.plugboth {
      type hw;
      card Intel;
    }
    
    pcm.both plug:plugboth
    ctl.both {
      type hw;
      card Intel;
    }
    
    pcm.!default {
      type softvol
      slave.pcm "both"
      control.name "Softmaster"
      control.card Intel
    }
    ctl.!default {
      type hw;
      card Intel;
    }

Everything before the last double stanza existed before adding
softvol in order to route sound from NetJACK to _both_ the HDMI
monitor's speakers and the headphone/lineout jacks.  Without
softvol, alsamixer could control the headphone/lineout volume
with the 'Master' and 'Front' sliders, but the monitor was only
controllable via the 'S/PDIF 1' on-off button.  Now, with the
last double stanza, the 'Softmaster' slider created by softvol
interactively controls the volume of both headphones and
monitor speakers together.  With softvol, the system has been
deployed.

On a side note, the attempt to use softvol on the server was a
wild ride.  The softvol plugin apparently won't attach to an
ALSA loopback soundcard.  It will attach only to a real physical
hardware soundcard.  Doing so causes the control to be permanently
attached to that physical hardware soundcard, even surviving
reboots via /var/lib/alsa/asound.state (/etc/asound.state in some
documentation).  Removing it from the server requires moving
around init scripts or booting to a Live-CD, mounting the main
filesystem (a little more difficult with software RAID) and
editing the asound.state file.  Yikes!

Again, thank you for the help and for your patience with my
user-level questions.

Robert
PrevNext  Index

1325007676.19456_0.ltw:2,a <20111227174101.EDDB8264E2 at one dot localnet>