3

I can tell my programs to output to either HDMI or the headphone jack just fine, but is there a way to create a virtual device in asound.conf that outputs to both simultaneously?

This config comes very close to working but it creates a sort of pulsing noise on the headphone jack.

pcm.internal {
  type hw
  card 1
  device 0
}

pcm.hdmi_hw {
  type hw
  card 0
  device 7
}

pcm.hdmi_complete {
  type softvol
  slave.pcm hdmi_hw
  control.name hdmi_volume
  control.card 1
}

pcm.sirmix {
    type plug
    slave.pcm {
        type multi
        slaves {
            a { channels 2 pcm "internal" }
            b { channels 2 pcm "hdmi_complete" }
        }
        bindings {
            0 { slave a channel 0 }
            1 { slave a channel 1 }
            2 { slave b channel 0 }
            3 { slave b channel 1 }
        }

    }
    ttable [
        [ 1 0 1 0 ]
        [ 0 1 0 1 ]
    ]
}

gst-launch-1.0 audiotestsrc ! audioconvert ! alsasink device="sirmix"

2

So apparently the settings and pipeline above are essentially good, and if you go to the ALSA forums they'll recommend something like the above, but a matching rate on your outputs is something that must be considered in addition.

pcm.internal {
  type hw
  card 1
  device 0
  rate 48000
}

pcm.hdmi_hw {
  type hw
  card 0
  device 7
  rate 48000
}

My final config file, which includes volume controls for both the individual output devices, as well as their shared parent, and mixing across multiple playback processes, is the following:

pcm.m_headphone_mixed {
 type dmix
 ipc_key 595900
 ipc_perm 0666
 slave {
  pcm "hw:1,0" 
  rate 48000
  period_time 0
  period_size 1024
  buffer_size 4096
  format S16_LE
 }
 bindings {
  0 0
  1 1  
 }
}

pcm.m_headphone_rate_adjusted {
 type rate
 slave {
  pcm "m_headphone_mixed"
  rate 48000
 }
}

pcm.m_headphone {
 type softvol
 slave.pcm m_headphone_rate_adjusted
 control.name m_headphone_volume
 control.card 1
}

pcm.m_hdmi_mixed {
 type dmix
 ipc_key 595901
 ipc_perm 0666
 slave {
  pcm "hw:0,7"
  rate 48000
  period_time 0
  period_size 1024
  buffer_size 4096
  format S16_LE
  channels 2
 }
 bindings {
  0 0 # channel 0 -> channel 0 
  1 1
 }
}

pcm.m_hdmi {
 type softvol
 slave.pcm "m_hdmi_mixed"
 control.name m_hdmi_volume
 control.card 1 
}

pcm.m_all_base {
 type plug

 slave.pcm {
   type multi
   slaves {
       a { channels 2 pcm "m_hdmi" }
       b { channels 2 pcm "m_headphone" }
   }
   bindings [
       { slave a channel 0 }
       { slave a channel 1 }
       { slave b channel 0 }
       { slave b channel 1 }
   ]
 } 
}

pcm.m_all_routed {
type route
 slave.pcm "m_all_base"
 slave.channels 4

 ttable [
  [ 1 0 1 0 ] # route left to channels 0,2
  [ 0 1 0 1 ] # route right to channels 1,3
 ]
}

pcm.m_all {
 type softvol;
 control.name m_all_volume;
 control.card 1
 slave.pcm "m_all_routed"
}

pcm.!default "m_all"

This was done for a standard Dell desktop PC to output simultaneously to the headphone jack and DisplayPort.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.