# Audio Devices

When using various Linux Distributions, you may (or may not) run into some issues with audio devices. See some of the configs, logs, and commands below for helpful output in troubleshooting these issues.

### GUI Tools / Applications

If looking for a GUI Tool to select or view output / input audio devices, check out `pavucontrol` -

```bash
sudo pacman -Syu pavucontrol
pavucontrol
```

will install and open the application, which provides a simple interface for selecting audio devices, and even provides application-level audio control, which enables you to easily specify the devices for individual applications instead of forcing a system-wide audio setting for all running apps.

### Commands

:)

#### Sound Card / Devices

Search for all connected audio cards, and output the result.

`aplay -L | grep :CARD`

List all connected PCI devices (Sound cards are a PCI device)

`lspci`

#### Audible Sound Test

The command below will send static to each speaker connected to the device, sequentially, one at a time. Running this will continually test all speakers on a loop, until the user exits with `CTRL+C`.

`speaker-test -D default:PCH -c 8`

The output from the above test will look similar to the below, depending on your system and devices. 

The `-D` argument specifies the audio device you want to test. This is useful when not entirely sure which device is valid, you can test quickly with this cmd and make changes later in `alsamixer` or another config tool with the results of your findings.

The `-c` argument specifies the number of audio channels you want to test, for my setup I only have a front left and right speaker, so 2 will suffice. If I had a surround sound with Left / Right speakers in the back and an additional center speaker, we would test over 5 channels. 

```bash
[kapper@kapper-pc ~]$  speaker-test -D default:PCH -c 2

speaker-test 1.1.9

Playback device is default:PCH
Stream parameters are 48000Hz, S16_LE, 2 channels
Using 16 octaves of pink noise
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 2048 to 16384
Period size range from 1024 to 1024
Using max buffer size 16384
Periods = 4
was set period_size = 1024
was set buffer_size = 16384
 0 - Front Left
 1 - Front Right
Time per period = 5.648263
 0 - Front Left
 1 - Front Right
Time per period = 5.973649
 0 - Front Left
^CWrite error: -4,Interrupted system call
xrun_recovery failed: -4,Interrupted system call
Transfer failed: Interrupted system call
```

#### Sound Mixer / Settings

To open alsa mixer, run the below and use the `F6` key to ensure the proper device is selected. This tool can also be used to change volume levels, be careful messing with settings you are unfamiliar with, you could easily blow a speaker. At the least, connect a cheaper pair.

`alsamixer`

To check device audio settings / levels via CMD - 

`amixer` to list devices and settings

`amixer sset Master unmute` to mute the Master device. Master can be changed to any valid device name given from the output of `amixer`

Also, see [Advanced Linux Sound Architecture](https://wiki.archlinux.org/index.php/Advanced_Linux_Sound_Architecture) for more information on various documented issues encountered.