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.49
Copyright: Expat license
Notice:

Copyright (c) 2007-2023 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 choose "Winamp Classic Interface" interface plugin, and click on the Close button. Then, click on the interface with the right mouse button: a context menu appears. In the Playback submenu, check "Repeat" and "Shuffle", and uncheck "No Playlist Advance" and "Stop after Current Song". In the View submenu, check "Show Playlist Editor", uncheck "Show Equalizer", check "Show Remaining Time", "Always On Top", "On All Workspaces", "Roll up Player", "Roll up Playlist Editor", uncheck "Roll up Equalizer" and "Double Size".

Now you have two tiny windows: you can set the size of the playlist editor window so that its width exactly matches the player window one. Then you can place the playlist window to the bottom right of your desktop (in the room left unused by FBpanel) and stack the player window just on top of the playlist one.

Press [Alt+G] with the keyboard focus on the audacious window, so that you can set the equalizer controls as you wish (I like to amplify low and high frequencies, while leaving mid frequencies unamplified, in a parabola-like shape: your tastes may differ, especially if you don't listen to metal music...), and close the equalizer window when you're done.

Now, select Settings ... from the context menu. In the "Appearance" section confirm "Winamp Classic Interface" interface plugin. In the "General" tab, choose the Classic1.3 skin, choose "Sans | 7" as "Player" font, and "Sans | 7" as "Playlist" font; uncheck "Use Bitmap fonts (supports ASCII only)", check "Scroll song title", uncheck "Scroll song title in both directions". In the "Visualization" tab, choose "Analyzer" visualization type, check "Show peaks", choose "Normal" coloring, "Bars" style, "Fast" falloff, "Slowest" peak falloff, "Solid" scope style, "Normal" voiceprint coloring, "Smooth" VU meter style.

In the "Audio" section choose the JACK Output Plugin, and "Floating point" bit depth and set Buffer size "5000" ms; uncheck "Soft clipping" and "Use software volume control (not recommended)"; check "Enable Replay Gain", uncheck "Album 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" and "Use authentication with proxy". In the "Playlist" section uncheck "Resume playback on startup", "Advance when the current song is deleted", and "Clear the playlist when opening files", check "Open files in a temporary playlist"; uncheck "Interpret \ (backward slash) as a folder delimiter", leave Auto character encoding detector for "None" and leave Fallback character encodings unset; check "Show song numbers" and uncheck "Show leading zeroes (02:00 instead of 2:00)"; select Title format "Custom" and enter:

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

as custom string; check "Do not load metadata for songs until played", and "Probe content of files with no recognized file name extension". 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", and check "Show time scale for current song".

The last section is the "Plugins" one. In the "Transport" tab, make sure all plugins are enabled. Do the same for the "Playlist" tab. In the "Input" tab, make sure all input plugins are enabled and configure them by selecting them and clicking on the Settings button.

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

Audio CD Plugin: set Read speed "2", leave Override device blank, check "Use CD-Text", "Use CDDB", and "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".

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

In the "Effect" tab, make sure all effect plugins are disabled.

In the "General" tab, make sure all general plugins are disabled, except for the following ones (that should be configured by using the Settings button).

AOSD (On-Screen Display): choose top-left Placement, set Relative X offset "8", Relative Y offset "8", Max OSD width "0", and choose Display OSD using "all monitors"; set timings (ms) for Display "10000", Fade in "100", and Fade out "300"; choose Font 1 "Sans | 16", set color #00FF00 with maximum Opacity, enable "Shadow", set color #000000 with Opacity 204; choose Render Style "None"; enable all triggers (Playback Start, Title Change, Pause On, Pause Off); choose "Fake transparency".

Audio CD Menu Items: nothing to configure.

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 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).