Tips and tricks for Linux

In the following, we will show you a few commands for the Linux® command line that you can use to control the sound card. We assume that ALSA is installed with PipeWire or PulseAudio. We also assume that the sound card has been started in "Full-Featured Mode". We have described this in more detail in the manual.

This is the case with most Linux® distributions. You should also install the programs ffmpeg, ffplay, alsamixer, amixer and pactl. With Ubuntu, for example, you have to install the packages ffmpeg and alsa-utils. For other Linux® distributions, you can find out how to install the above programs on the distributor’s website or in the relevant forums.

ALSA vs. sound server

When using Linux®, a so-called sound server such as PulseAudio or PipeWire is typically installed. These sound servers do not display the controls of the audio hardware. The volume controls of these sound servers are purely software-based and therefore do not change the corresponding control element on the sound card. The sound servers do not communicate directly with the audio hardware, but only with an abstraction layer called ALSA (Advanced Linux Sound Architecture). With ALSA, a standardized programming interface is available that allows a program, such as a sound server, to control any sound card supported by ALSA without having to worry about the specific implementation details for the respective audio hardware. Of course, it is also possible to output audio directly via ALSA using a program. However, the sound servers offer some convenient functions that are not available with ALSA or can only be configured with some effort.

ALSA control with text-based interface

At ALSA, the states of the control elements can be displayed and changed with the following command:

alsamixer -c DSC8

The program can essentially be controlled using the cursor keys and space bar. Further information can be found in the program help.

Volume and muting

Strictly speaking, you have two volume controls. One slider controls the volume on the sound server and the other on ALSA. With most distributions, you can already control the volume of the sound server using the multimedia keys on your keyboard without any further action. If this is not already the case, it makes sense to change the volume at ALSA to the maximum. You can adjust the volume using the program alsamixer, which we have already described above.

Volume control for ALSA

Query all volume controls:

amixer -D hw:DSC8 sget Volume

Query main controller:

amixer -D hw:DSC8 sget Volume,1

The volume can be set absolutely in the range 0-127, where 0 is inaudibly quiet and 127 represents the maximum volume:

amixer -D hw:DSC8 sset Volume,1 10

The volume can be set as an absolute percentage, whereby 0% is inaudibly quiet and 100% represents the maximum volume:

amixer -D hw:DSC8 sset Volume,1 15%

The volume can also be increased relatively with the command:

amixer -D hw:DSC8 sset Volume,1 3%+

or

amixer -D hw:DSC8 sset Volume,1 5+

Accordingly, the volume can also be relatively reduced with the command:

amixer -D hw:DSC8 sset Volume,1 3%-

or

amixer -D hw:DSC8 sset Volume,1 5-

The following command mutes the output:

amixer -D hw:DSC8 sset Volume,1 mute

The following command switches off the muting of the output:

amixer -D hw:DSC8 sset Volume,1 unmute

You can mute the output as follows:

amixer -D hw:DSC8 sset Volume,1 toggle

Volume control at Sound Server via ALSA

The Sound Server PipeWire and PulseAudio only have a volume control. The commands are similar to ALSA. Only the device name hw:DSC8 is replaced with pulse and the name of the controller is changed from Volume,1 to Master.

The following command lists all control elements from Sound Server:

amixer -D pulse

Typically, you will then be shown two control elements named as follows: Master,0 and Capture,0. The control element Capture,0 is responsible for the recording volume and Master,0 is responsible for the output volume. Ultimately, however, only the Master,0 control will be of interest to you.

To query the volume, you must therefore execute the following command:

amixer -D pulse sget Master,0

You will certainly recognize the similarity to the commands from the previous section.

As described above, the device name and the name of the controller for the command simply need to be adapted. The structure of the command remains the same. The other commands, such as setting the volume, are analogous to the commands in the previous section. We will therefore not repeat these commands again in an adapted form.

There is another difference to the control element of ALSA that we would like to point out: The value range for the sound server is from 0 to 65535.

Volume control for Pulse Audio

This section is only relevant if Sound Server PipeWire or PulseAudio is installed. In fact, it is not a mistake that we also mention PipeWire here. PipeWire is backwards compatible with PulseAudio in terms of programming interfaces.

At Pulse Audio, however, there are other volume controls in addition to the main volume control, which can only be controlled via a separate command. Typically, you never have to change these volume controls. However, it has happened to us that these controls have been changed by a program. How to undo this change if necessary is described below.

First of all, you must determine the corresponding IDs for the control elements:

pactl list short | grep -P "alsa_output.*hifidom.*surround-71[^.]"

The command already looks quite complex. Therefore, we will now explain this command:

pactl list short queries all audio sources and sinks (e.g. loudspeakers or microphones) at Sound Server. A large number of sources and sinks can be displayed here, which is quite confusing. The | grep -P "alsa_output.*hifidom.*surround-71[^.]" part of the command is used to reduce the output to just the relevant sink. The program grep filters the output with the expression alsa_output.*hifidom.*surround-71[^.]. If this expression occurs in a line, then only this line is output. For example, the following line could be output:

421 alsa_output.usb-hifidom_DSC8_44534338-4d41494e-1127-00.analog-surround-71 PipeWire s32le 8ch 48000Hz SUSPENDED

The Id of the sink comes first. In the previous example, the Id is 421. We will now also use this Id for our other commands. You must adjust this Id accordingly.

You can use the following command to display the current volume:

pactl get-sink-volume 421

Now you get e.g. the following output:

Volume: front-left: 65536 / 100% / 0,00 dB, front-right: 65536 / 100% / 0,00 dB, rear-left: 65536 / 100% / 0,00 dB, rear-right: 65536 / 100% / 0,00 dB, front-center: 65536 / 100% / 0,00 dB, lfe: 65536 / 100% / 0,00 dB, side-left: 65536 / 100% / 0,00 dB, side-right: 65536 / 100% / 0,00 dB

A volume control is available for each channel individually. Typically, all volume controls should be set to 100%. If this is not the case, you can correct this with the following command:

pactl set-sink-volume 421 100%

If the sound card DSC8 is selected by default for the output, then you can simply write @DEFAULT_SINK@ instead of the Id. You can find this out with the following command:

pactl get-default-sink

If the sound card DSC8 is not selected by default for the output, you can adjust this with the following command: pactl set-default-sink 421

You must replace Id 421 with the corresponding value as described above.

Volume control for Pipewire

This section is only relevant if the Sound Server PipeWire is installed. Furthermore, it is assumed in the following that sound card DSC8 is selected by default for the output.

At Pipewire you can use the command line tool wpctrl to view and change any setting of PipeWire. The value range of the volume at Pipewire is from 0 to 1, where 0 represents the minimum and 1 the maximum volume. Decimal places are also possible, e.g. 0.5.

You can display the current volume as follows:

wpctl get-volume @DEFAULT_AUDIO_SINK@

For example, you can set the absolute volume to 0.75:

wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.75

This corresponds to 75% of the maximum volume. Alternatively, you can also write the following:

wpctl set-volume @DEFAULT_AUDIO_SINK@ 75%

You can also reduce the volume relatively by 5% with :

wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-

You can increase the volume by 5% with the following command:

wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+

You can mute the output with the following command:

wpctl set-mute @DEFAULT_AUDIO_SINK@ 1

And with this command you can switch off the mute function:

wpctl set-mute @DEFAULT_AUDIO_SINK@ 0

And with this command you switch the mute function, i.e. either on or off, depending on which state it was in before:

wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle

The current status of the mute function is displayed with the following command:

wpctl get-volume @DEFAULT_AUDIO_SINK@

A [MUTED] is displayed after the volume. The tool does not have an explicit get-mute command.

Switch inputs

If you have connected an input expansion card to the sound card, you can control the inputs with the following commands. The following command returns the current status of the inputs:

amixer -D hw:DSC8 sget 'Input Capture Source',0

All available inputs are listed in the line beginning with Items:. The currently selected input is displayed in the line beginning with Item0:.

In the following, we assume that the input ''Input 2: card = 1 (SPDIF), port = 2'' is displayed under 'Items:'. We can select this input as follows:

amixer -D hw:DSC8 sset 'Input Capture Source',0 'Input 2: card = 1 (SPDIF), port = 2'

Unfortunately, it is no longer possible to select the next or previous input with a simple command. A script is required for this. You can download this script here. After the download you only have to make the script executable with the following command:

chmod +x input.sh

Now you can select the next input with :

./input.sh next

You can select the previous input as follows:

./input.sh prev

The script can do even more. Simply call up the following to see all the options:

./input.sh

Display the status of the sound card

With the following command you can see, for example, whether the recording or playback function of the sound card is currently in use or not:

cat /proc/asound/DSC8/stream0

If the beginning of the line Status: is followed by Stop, then the respective function is not in use. Otherwise, the parameters with which playback or recording was started are displayed. You can use this status information, for example, to switch the active loudspeakers on or off with a time delay.

Redirect data stream from input to output

This section is only relevant if you have connected an input expansion card to the sound card. The data stream must be redirected from the input to the output using software. The tool alsaloop from alsautils can do this. Unfortunately, the tool can only process PCM signals and not compressed surround signals. The tool outputs compressed surround signals unchanged, which means that only an unpleasant noise can be heard.

However, it is possible to solve this problem with the ffmpeg tool. If this has not already been done, it must first be installed on the system.

You can activate automatic decoding with the following command:

ffmpeg -hide_banner -loglevel panic -f alsa -ac 2 -ar 48000 -i plughw:CARD=DSC8,DEV=0 -c:a pcm_s16le -f wav - | ffplay -loglevel quiet -nodisp -fflags nobuffer -flags low_delay -framedrop -

Ok, the command is a bit unwieldy. Furthermore, the command must be adapted to the sample rate that is currently present at the input, otherwise the sound card will only record silence. The parameter -ar 48000 is responsible for this. We have written a script to automate the whole process for you. You can download it here. The script is not yet perfect. If you take the computer out of stand-by mode, you should definitely restart the script, as occasionally a process of the script gets stuck and this leads to unpleasant noises. However, we are working on fixing this.

No sound output! What to do?

The first step is to check whether the sound card is available in ALSA. This is done with the following command:

ls -l /proc/asound/

If DSC8 appears in the list, which will be the case for all mainstream Linux® distributions, then the drivers for the sound card are loaded correctly and the card can be used to generate sound. The sound card requires the USB driver for "USB Audio Class 2" (UAC2). If the driver is missing from your distribution, please contact your distributor. The subsequent installation of the driver is then specific to your Linux® distribution. Unfortunately, we cannot provide support for all Linux® distributions.

If the sound card is displayed but no sound can be heard, it is too quiet or distorted, then at least one volume control in the system is not set correctly. Unfortunately, not all volume controls are accessible through a graphical user interface. Therefore, the best way to check all controls is to use commands. If no sound can be heard, you should also check the mute switches in addition to the volume controls.

We recommend starting with the control elements for ALSA. We have described this in the sections ALSA control with text-based interface and Volume control for ALSA.

Then you should check the volume controls as described in the section Volume control at Sound Server via ALSA.

If it still does not fit, then check the controls as described in the section Volume control for Pulse Audio.

IMPORTANT: Please do not immediately set the volume to the maximum value, otherwise it could become unpleasantly loud ;-).