Audio software configuration for a testing workstation

Configuring audio on our example Debian testing workstation/desktop machine

Author: Francesco Poli
Contact: invernomuto@paranoici.org
Version: 0.51
Copyright: Expat license
Notice:

Copyright (c) 2007-2024 Francesco Poli

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About this document
Web form HyperText Markup Language
Source form reStructuredText
Web stylesheet Cascading StyleSheets
Build directives Makefile

Contents

Summary of previous episodes

In another document (HTML, reST) you saw how to set up a backup strategy for our example Debian testing workstation/desktop box. Now it's time to install some audio-related packages.

Audio driver utilities

Install some utilities to configure and control the audio drivers:

# aptitude install alsa-utils

In order to ensure that the audio settings are saved whenever the system is shut down and restored on the next boot, issue the following commands, after the installation of the alsa-utils package:

# service alsa-restore stop
# touch /var/lib/alsa/asound.state
# service alsa-restore start

On our example workstation the soundcard is a Realtek audio controller (which is integrated in our ASRock Z97 Extreme6 motherboard) and is seen as the PCH sound card:

$ cat /proc/asound/cards
 0 [HDMI           ]: HDA-Intel - HDA Intel HDMI
                      HDA Intel HDMI at 0xefc34000 irq 49
 1 [Camera         ]: USB-Audio - HD USB Camera
                      Ingenic Semiconductor CO., LTD. HD USB Camera at usb-0000:09:00.0-1, high speed
 2 [PCH            ]: HDA-Intel - HDA Intel PCH
                      HDA Intel PCH at 0xefc30000 irq 47
$ grep Codec /proc/asound/card2/codec#0
Codec: Realtek ALC1150

Your regular user should adjust the soundcard's volume levels:

$ alsamixer -c PCH

Set values according to the following table:

Item Mute Value Left Right
Master OO 88 N/A N/A
Headphone OO N/A 66 66
PCM N/A N/A 100 100
Front OO N/A 75 75
Front Mic OO N/A 34 34
Front Mic Boost N/A N/A 0 0
Surround OO N/A 75 75
Center OO 75 N/A N/A
LFE OO 75 N/A N/A
Line OO N/A 75 75
Line Boost N/A N/A 0 0
S/PDIF OO N/A N/A N/A
S/PDIF Default PCM OO N/A N/A N/A
Beep MM N/A 0 0
Capture N/A CAPTURE 75 75
Capture 1 N/A CAPTURE 25 25
Auto-Mute Mode N/A Enabled N/A N/A
Input Source N/A Front Mi N/A N/A
Input Source 1 N/A Rear Mic N/A N/A
Loopback N/A Enabled N/A N/A
Rear Mic OO N/A 20 20
Rear Mic Boost N/A N/A 0 0

If you like having a handy volume control in the desktop systray, you may install a package providing one such application:

# aptitude install volumeicon-alsa

and configure it for your regular user:

$ volumeicon

Select Preferences from its context menu. In the Channels section, choose Device "HDA Intel PCH", Channel "Master", select "Linear Scale". In the Status Icon section, set Volume adjustment "2", External mixer "uxterm -e 'alsamixer -c PCH'", Icon Theme "Default", uncheck "Use panel-specific icons if available" and "Reverse scroll direction for volume adjustement", choose Left Mouse Button Action "Mute Volume", Middle Mouse Button Action "Open Mixer", uncheck "Use Horizontal Slider", check "Show Sound Level", uncheck "Use Transparent Background". In the Hotkeys section, check "Volume Up", "Volume Down", and "Mute". In the OSD section, check "Show Notifications" "GTK+ Popup Window".

If you want to have this systray icon started on each Fluxbox session you open, insert the following two lines into your regular user's ~/.xsession file (between MANAGER and HANG POINT):

$ grep -A 1 'start volume icon' ~/.xsession
# start volume icon
volumeicon &

and the following two lines as well (after the HANG POINT):

$ grep -A 1 'stop volume icon' ~/.xsession
# stop volume icon
killall -TERM volumeicon

Sound server

Install a sound server:

# aptitude install jackd qjackctl jackd2-firewire_

You'll be asked whether to enable real-time priority for jackd: you may answer yes. In order to have the sound server started on each Fluxbox session you open, insert the following three lines into your regular user's ~/.xsession file (between MANAGER and HANG POINT):

$ grep -A 2 'start sound server' ~/.xsession
# start sound server
sleep 2 && jackd --realtime -d alsa --device hw:PCH \
                 --softmode --hwmeter --rate 44100 &

and the following two lines as well (after the HANG POINT):

$ grep -A 1 'stop sound server' ~/.xsession
# stop sound server
killall -TERM jackd

You may want to configure the controlling user interface:

$ qjackctl

and click on the "Setup..." button. In the Options tab, uncheck "Execute script after Shutdown". In the Misc tab, uncheck "Stop JACK audio server on application exit". Leave all the remaining settings at their default values.

For applications that do not directly support this sound server, you can redirect their ALSA output to jackd. Install the following package:

# aptitude install libasound2-plugins

and write the following file for your regular user:

$ cat ~/.asoundrc
# redirect the default ALSA device to JACK
pcm.rawjack {
    type jack
    playback_ports {
        0 system:playback_1
        1 system:playback_2
    }
    capture_ports {
        0 system:capture_1
        1 system:capture_2
    }
}

pcm.jack {
    type plug
    slave { pcm "rawjack" }
    hint {
        description "JACK"
    }
}

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

Audio player

Install an audio player:

# aptitude install audacious

and a useful set of MIDI soundfonts:

# aptitude install fluid-soundfont-gm

In order to have the audio player started on each Fluxbox session you open, insert the following two lines into your regular user's ~/.xsession file (between MANAGER and HANG POINT):

$ grep audacious ~/.xsession
# start audacious
audacious &

Now it's time to configure audacious for your regular user. Once it is started, select Settings ... from the File menu. In the "Appearance" section click on the "Restart in Qt mode" button.

Then, in the Playback menu, enable "Repeat", enable "Shuffle", uncheck "Shuffle by Album", uncheck "No Playlist Advance", uncheck "Stop after Current Song".

In the View menu, check "Show Menu Bar", check "Show Info Bar", check "Show Info Bar Album Art", check "Show Info Bar Visualization", check "Show Status Bar", check "Show Remaining Time".

In the Output menu, select Equalizer ... so that you can set the equalizer controls as you wish (I like to amplify low and high frequencies: 6, 3, 0, -3, -6, -6, -3, 0, 3, 6: your tastes may differ, especially if you don't listen to metal music...), check "Enable" and close the equalizer window when you're done.

Then again select Settings... from the File menu. In the "Appearance" section choose "Qt Interface" interface, "Native" theme, "Native" icon theme, "Auto-hide" show playlist tabs; check "Show entry counts", check "Show close buttons", check "Show column headers", uncheck "Use bold font for column headers", check "Scroll on song change". In the "Audio" section choose the "JACK Output" output plugin, and "Floating point" bit depth and set Buffer size "5000" ms; uncheck "Soft clipping", uncheck "Use software volume control (not recommended)"; uncheck "Enable audio stream recording with FileWriter Plugin"; check "Enable Replay Gain", choose "Track" mode, check "Prevent clipping (recommended)"; set Amplify all files "0.0" dB and Amplify untagged files "-9.0" dB. In the "Network" section, set "128" KiB buffer size, uncheck "Enable proxy usage", uncheck "Use authentication with proxy", uncheck "Use SOCKS proxy". In the "Playlist" section uncheck "Resume playback on startup", uncheck "Advance when the current song is deleted", uncheck "Clear the playlist when opening files", check "Open files in a temporary playlist"; check "Show song numbers", uncheck "Show leading zeroes (02:00 vs. 2:00)", check "Show hours separately (1:30:00 vs. 90:00)"; select Title format "Custom" and enter:

${title}${?artist: - ${artist}}${?album: - ${album}}

as custom string; check "Use relative paths when possible". In the "Song Info" section leave Search for images matching these words (comma-separated) unset, set Exclude images matching these words (comma-separated) "back", uncheck "Search for images matching song file name" and "Search recursively"; check "Show popup information", set Popup delay (tenths of a second) "1". In the "Advanced" section uncheck "Interpret \ (backward slash) as a folder delimiter", leave Auto character encoding detector for "None" and leave Fallback character encodings unset; uncheck "Add folders recursively", uncheck "Add folders nested within playlist files"; check "Guess missing metadata from file path", check "Do not load metadata for songs until played", check "Probe content of files with no recognized file name extension"; set step forward/backward by "5" seconds and adjust volume by "2" percent.

The last remaining section is the "Plugins" one. In the "General" entry, make sure all general plugins are disabled, except for the following ones (that should be configured by using the Settings button).

Audio CD Menu Items: nothing to configure.

Desktop Notifications: check "Show playback controls", uncheck "Always show notification", check "Include album name in notification", uncheck "Custom notification duration".

Status Icon: choose "Change volume" mouse scroll action, uncheck "Disable the popup window", uncheck "Close to the system tray", uncheck "Advance in playlist when scrolling upward".

In the "Effect" entry, make sure all effect plugins are disabled, except for the following one.

Sample Rate Converter: choose "Fast sinc interpolation" method, set "44100" Hz rate.

In the "Visualization" entry, make sure all visualization plugins are disabled.

In the "Input" entry, make sure all input plugins are enabled and configure them by selecting them and clicking on the Settings button.

2SF Decoder: uncheck "Ignore length from file", set "5000" ms default fade time, "32728 Hz" sample rate, "None" interpolation mode.

AMIDI-Plug: set Transpose "0" semitones, Drum shift "0" note numbers, uncheck "Skip leading silence", uncheck "Skip trailing silence"; add "/usr/share/sounds/sf2/FluidR3_GM.sf2" as SoundFont, uncheck "Override default gain", uncheck "Override default poliphony", uncheck "Override default reverb", uncheck "Override default chorus", set sample rate "44100" Hz.

Audio CD Plugin: set Read speed "2", leave Override device blank, check "Use CD-Text", check "Use CDDB", check "Use HTTP instead of CDDBP"; set Server "freedb.musicbrainz.org", leave Path blank and set Port "80".

Game Console Music Decoder: set Bass "0", Treble "0", Echo "0", default song length "180" seconds, and uncheck "Enable audio resampling"; uncheck "Ignore length from SPC tags", and "Increase reverb".

MPG123 Plugin: uncheck "Use accurate length calculation (slow)".

OpenMPT (Module Player): set "70" % stereo separation, choose "Windowed sinc" interpolation.

OpenPSF PSF1/PSF2 Decoder: uncheck "Ignore length from file".

SID Player: set "2" channels, "44100" Hz sample rate, uncheck "Emulate MOS 8580 (default: MOS 6581)", uncheck "Do not automatically select chip model", check "Emulate filter", choose "PAL" clock speed, uncheck "Do not automatically select clock speed", check "Set maximum playback time", set "500" seconds, check "Use only when song length is unknown", uncheck "Set minimum playback time", check "Enable subtunes", uncheck "Ignore subtunes shorter than".

ModPlug (Module Player): choose "Stereo", "Polyphase (best)", "44 kHz", uncheck reverb "Enable", uncheck bass boost "Enable", check surround "Enable", set "20" % level, "20" ms delay, uncheck preamp "Enable", uncheck "Oversample", check "Noise reduction", check "Play Amiga MODs", set "0" repeat count.

In the "Playlist" entry, make sure all plugins are enabled. Do the same for the "Transport" entry.

Finally, elect audacious as your default audio player:

$ xdg-mime default audacious.desktop \
   application/ogg application/x-ogg audio/midi audio/mp3 audio/mp4 \
   audio/mpeg audio/mpegurl audio/ogg audio/prs.sid audio/x-flac \
   audio/x-mp3 audio/x-mpeg audio/x-mpegurl audio/x-ms-wma \
   audio/x-vorbis+ogg audio/x-wav x-content/audio-cdda

Audio file analysis

Some packages may be useful to analyze audio files. You may want to install a tool to visually analyze musical recordings:

# aptitude install sonic-visualiser vamp-examples

When you first start it:

$ sonic-visualiser

you will be asked whether you want to allow the program to access the network: you may safely uncheck the "Allow this" option. Select Preferences... from the File menu. In the "Plugins" tab, add one more location for Vamp plugins: /usr/lib/x86_64-linux-gnu/vamp/.

Audio file editing

If you need to perform simple editing operations on OGG Vorbis files, you may wish to install the following package of command-line tools:

# aptitude install vorbis-tools

Among other tools, it includes a command to split OGG Vorbis files (vcut) and one to edit their tags (vorbiscomment).

In order to split MP3, FLAC (and also OGG Vorbis) files, you may install the following package (which can also modify tags on the fly, see the -g option):

# aptitude install mp3splt

Audio CD encoder

If you are tired of always exchanging audio CDs on your CD player, you'll probably find out that listening to OGG Vorbis files is more practical. Install an automated audio CD encoder:

# aptitude install abcde normalize-audio bsd-mailx_

Configure it for your regular user:

$ cat ~/.abcde.conf
PADTRACKS=y
OGGENCOPTS='-b 192'
NORMALIZEOPTS='--amplitude=-12dBFS'
ACTIONS=cddb,read,normalize,encode,tag,move,clean
OUTPUTDIR=~/music/CDs
OUTPUTFORMAT='${ARTISTFILE}/${ALBUMFILE}/${ARTISTFILE}_-_${ALBUMFILE}_-_${TRACKNUM}_-_${TRACKFILE}'
VAOUTPUTFORMAT='Various_Artists/${ALBUMFILE}/${ARTISTFILE}_-_${ALBUMFILE}_-_${TRACKNUM}_-_${TRACKFILE}'
BATCHNORM=y
mungefilename ()
{
    echo "$@" | tr -d '[:cntrl:]' | \
                sed "s/[ :\'\/\!\?<>|]/_/g" | \
                sed 's/_[_]*/_/g' | \
                sed 's/^_*//' | \
                sed 's/_*$//'
}

In order to encode one whole audio CD, just insert it into the CD drive and issue the following command (assuming you're online, in order to let abcde retrieve the track list of the CD):

$ abcde

If you want to encode only some tracks:

$ abcde 1-4 9 12-13

In order to encode a multi-artist CD and normalize each track independently of the others, use an additional configuration file:

$ abcde -c ~/.abcde_nobatch.conf

where:

$ cat ~/.abcde_nobatch.conf
BATCHNORM=n

Online audio stream recorder

If you listen to Internet radios, you may sometimes find yourself in the necessity to stop listening to the radio stream (maybe because you have other things to do), while waiting for a song you're interested in. You may record the stream to disk and listen to it later. Install an online stream recorder:

# aptitude install streamripper

Audio input from external musical instruments

If you have an electric musical instrument (such as an electric guitar or bass) and a DI box, you may wish to connect them to the front microphone input and amplify and/or apply effects. Install a software amplifier:

# aptitude --without-recommends install guitarix jack-capture

When you run:

$ guitarix

you may want to enable its Jack server connection (by checking it in the Engine menu, or by hitting [Ctrl+C]) and configure its Jack ports (by hitting [Ctrl+P]): check "system:capture_1" as Input, "system:playback_1" as Output 1, and "system:playback_2" as Output 2. This configuration will be remembered, as long as the same Jack ports are found the next time you start guitarix.

If you have an external USB sound card with specific (high impedence) inputs for musical instruments (such as a Focusrite Scarlett Solo, for instance), you do not need a DI box and can connect the electric musical instrument directly to the dedicated input of the external sound card. This external sound card (when connected to a USB port) will be seen as an additional sound card:

$ cat /proc/asound/cards
 0 [HDMI           ]: HDA-Intel - HDA Intel HDMI
                      HDA Intel HDMI at 0xefc34000 irq 49
 1 [PCH            ]: HDA-Intel - HDA Intel PCH
                      HDA Intel PCH at 0xefc30000 irq 47
 2 [Camera         ]: USB-Audio - HD USB Camera
                      Ingenic Semiconductor CO., LTD. HD USB Camera at usb-0000:09:00.0-1, high speed
 3 [USB            ]: USB-Audio - Scarlett Solo USB
                      Focusrite Scarlett Solo USB at usb-0000:00:14.0-2, high speed

In order to use its capture ports as additional capture ports, you can install the following package:

# aptitude install jack-example-tools

and issue the following command (after connecting the external sound card to a USB port):

$ alsa_in -j ext -d hw:USB -r 44100

In guitarix, you may then want to also check "ext:capture_2" as additional Input.

If you keep the external sound card permanently connected to a USB port, you may wish to have the additional capture ports automatically enabled on each Fluxbox session you open. To this aim, insert the following two lines into your regular user's ~/.xsession file (between MANAGER and HANG POINT, after the jackd invocation):

$ grep -A 1 'enable external capture ports' ~/.xsession
# enable external capture ports
sleep 3 && alsa_in -j ext -d hw:USB -r 44100 &

and the following two lines as well (after the HANG POINT, before the jackd stop):

$ grep -A 1 'disable external capture ports' ~/.xsession
# disable external capture ports
killall -TERM alsa_in

Music creation software

If you want to create music from scratch, you may want to install some special-purpose packages. You may install a drum machine:

# aptitude --without-recommends install hydrogen \
  rubberband-cli+M

and configure it for your regular user:

$ hydrogen

Select Preferences from the Options menu. In the General section, leave the default Language "American English (United States)", uncheck "Reopen last used song", uncheck "Reopen last used playlist", uncheck "Use relative paths for playlist", uncheck "Hide keyboard input cursor", uncheck "Use LASH", set "0" Beat counter drift compensation in 1/10 ms, "0" Beat counter start offset in ms, "400" Maximum number of bars, "16" Maximum number of layers, "60" Number of autosaves per hour, "/usr/bin/rubberband" Path to the Rubberband command-line utility. In the Audio System section, choose Audio System "Auto" (which should automatically select JACK Audio Connection Kit Driver), set "1024" Buffer size, choose "Post-Fader" Track output, "constant measure" BBT sync method, check "Connect to default JACK output ports", uncheck "Create per-instrument JACK output ports", check "Enable JACK timebase master supprt", set "256" Polyphony, "50" Metronome volume, choose "Linear" Interpolate resampling. Leave all the other sections at their default settings.

Conclusions

Now that your ears are pleased, it's the eyes' turn! More details in a separate document (HTML, reST).