3

I am writing some python program that is related to sounds, so I used the SoundDevice python module which used PortAudio library. I am on arch linux with deepin desktop.

If I just opened the computer and printed the available devices I get:

   0 HDA Intel PCH: ALC887-VD Analog (hw:0,0), ALSA (2 in, 2 out)
   1 HDA Intel PCH: ALC887-VD Digital (hw:0,1), ALSA (0 in, 2 out)
   2 HDA Intel PCH: ALC887-VD Alt Analog (hw:0,2), ALSA (2 in, 0 out)
   3 HDA ATI HDMI: 0 (hw:1,3), ALSA (0 in, 8 out)
   4 sysdefault, ALSA (128 in, 128 out)
   5 front, ALSA (0 in, 2 out)
   6 surround40, ALSA (0 in, 2 out)
   7 surround51, ALSA (0 in, 2 out)
   8 surround71, ALSA (0 in, 2 out)
   9 iec958, ALSA (0 in, 2 out)
  10 spdif, ALSA (0 in, 2 out)
  11 pulse, ALSA (32 in, 32 out)
  12 dmixed, ALSA (0 in, 2 out)
  13 dsnooped, ALSA (2 in, 0 out)
  14 duplex, ALSA (2 in, 2 out)
  15 dmix, ALSA (0 in, 2 out)
* 16 default, ALSA (128 in, 128 out)

It says that I am using the ALSA (128 in, 128 out). Now I will open an app--lets say Chromium--and played some music then went on to browse the internet. If I now print the available devices I would get:

   0 HDA Intel PCH: ALC887-VD Analog (hw:0,0), ALSA (2 in, 0 out)
<  1 HDA Intel PCH: ALC887-VD Digital (hw:0,1), ALSA (0 in, 2 out)
   2 HDA Intel PCH: ALC887-VD Alt Analog (hw:0,2), ALSA (2 in, 0 out)
   3 HDA ATI HDMI: 0 (hw:1,3), ALSA (0 in, 8 out)
   4 sysdefault, ALSA (128 in, 0 out)
   5 iec958, ALSA (0 in, 2 out)
   6 spdif, ALSA (0 in, 2 out)
   7 pulse, ALSA (32 in, 32 out)
   8 dsnooped, ALSA (2 in, 0 out)
   9 duplex, ALSA (2 in, 0 out)
> 10 default, ALSA (128 in, 0 out)

It tells me I am using the Intel as my output and ALSA (128 in, 0) as my input. Why isn't there ALSA input and output as before?

This happens in all the applications that uses sound including Audacity.

I am currently using pluse as an alternative, but It is said that ALSA is better so I want to use it even if multiple applications are opened at the same time.

Edit

Here is the list after editing the configuration:

>  0 HDA Intel PCH: ALC887-VD Analog (hw:0,0), ALSA (2 in, 2 out)
   1 HDA Intel PCH: ALC887-VD Digital (hw:0,1), ALSA (0 in, 2 out)
   2 HDA Intel PCH: ALC887-VD Alt Analog (hw:0,2), ALSA (2 in, 0 out)
   3 HDA ATI HDMI: 0 (hw:1,3), ALSA (0 in, 8 out)
   4 sysdefault, ALSA (128 in, 128 out)
   5 front, ALSA (0 in, 2 out)
   6 surround40, ALSA (0 in, 2 out)
   7 surround51, ALSA (0 in, 2 out)
   8 surround71, ALSA (0 in, 2 out)
   9 iec958, ALSA (0 in, 2 out)
  10 spdif, ALSA (0 in, 2 out)
  11 pulse, ALSA (32 in, 32 out)
  12 dmix, ALSA (0 in, 2 out)
< 13 default, ALSA (0 in, 128 out)
  • Use either PulseAudio or dmix, but all application must use the same. – CL. Apr 3 '17 at 18:47
  • @CL. Is there is a way to set either of them as the default for all the apps on my computer? – Omar Ahmad Apr 3 '17 at 18:49
  • No; that depends on the apps. – CL. Apr 3 '17 at 19:33
4

You need to output to the dmix ALSA device instead of the default device; that allows multiple streams to be mixed and output to the sound card. It is set up automatically on sound devices which don’t support hardware mixing; as you can see, it’s set up on your system.

You’ll find more information on the ALSA wiki.

You can configure dmix to be the default with a configuration such as

pcm.!default {
    type plug
    slave.pcm "dmix"
}

You’ll still need to configure all your applications to use ALSA. Note too that dmix is only an output device; if you want to manage multiple inputs you’ll need to use dsnoop. The ALSA wiki has detailed configuration examples for both that you can adapt to your particular settings (in particular, the default underlying hardware device).

  • But dmix isn't available as well when 2 applications are opened, you can see it in the first list yes, but not in the second one. – Omar Ahmad Apr 3 '17 at 18:22
  • 1
    If you change the first application to open dmix, you’ll see it remains available. It disappears in the second list because it can’t work if another application has opened default (by default). – Stephen Kitt Apr 3 '17 at 18:41
  • I see, this may be a problem because I am using a python interpreter that is inside an app, so as soon as I open the program, I won't be able to change it in its python. Thanks. – Omar Ahmad Apr 3 '17 at 18:47
  • The above conf. seems to set the default input as Intel Analog (index zero) and the output as ALSA (0 in , 128 out). – Omar Ahmad Apr 3 '17 at 19:16
  • 1
    The output looks OK, but it will only work for output. See my update. – Stephen Kitt Apr 3 '17 at 20:44

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.