24bit96

  |  

USB HiFi and HighEnd

24bit96.com - USB HiFi and HighEnd

configure your usb audioserver
MPD/ALSA running under Debian with a Real-Time Kernel for a Low Latency and Bit-Accurate Audio Server

Bit-accurate playback is the ultimate solution for a USB sound system and currently there is no way around Linux. Ideally suited for this is the easy-to-install Linux distribution "Debian" which works without any problems with almost all DAC chips (XMOS, Sabre, Wolfson, TI etc.) and is able to play all high-res formats such as WAV, FLAC, AIFF, ALAC , MP3 and Ogg Vorbis.

Below, you’ll find a description of the installation of Debian in version 7.8 ( "Wheezy") to operate without a graphical user interface but with a real-time kernel for perfect playback with lowest latency using ALSA and the music player Daemon (MPD)

All this is remotely controlled via an iPhone / iPad / Android device, so that you can use the Linux audio server without keyboard, mouse and monitor.

The current version of Debian 8.0 ( "Jessie") will not be considered here, since you can achieve the optimal results with "Wheezy".


A) Installing the BIOS


The BIOS is configured as described under Configuring USB Audio Server with Windows and foobar 2000.


B) Installing Debian Linux and the Music Player Demon (MPD)


1) Downloading Debian Linux

We will be using the so-called "small installation image" (depending on the PC, select either the "64-Bit-PC Netinst-ISO" oder "32-Bit-PC Netinst-ISO" for "Wheezy") during which the most current files will be downloaded from the Internet as required. We recommend that before installation you load the most recent firmware package and copy the files to the medium on which it will be installed so that you will have all the necessary drivers for your hardware (learn more).


2) Installing Debian

Load the Universal USB Installer if you want to install Debian from a USB memory stick. This software allows you to easily create bootable USB installation media with the downloaded Debian ISO files.

Connect your USAB DAC to the PC and then to the Internet. Boot your system using the installation medium that you prepared and then proceed as follows
  • At the Installation Screen "Advanced Options" select "Expert Install"
  • In "Choose Language" select the language of your choice and the "base locale settings"
  • Select the keyboard layout
  • Even if you are installing from a USB thumb drive, select "Detect and mount CD-ROM"
  • Select option "Load Installer components from CD" - leave all empty. Go to the next step with "Continue"
  • Next, your network is detected and the automatic installation of the network "Detecting network hardware" / "Configure the network" follows - with DHCP based networks you can select "Auto-configure networking"
  • The hostname - in this example - "debianmusic" is set, the domain name can usually be left empty
  • "Set up users and passwords" lets you install the users (recommended: "shadow passwords"). Do not allow "Always login as root"
  • After the "root" is set up a "Normal User Account" is created. In this example we use the user "usbaudio"
  • At the prompt "Set the clock using NTP" answer with "no", you should then select your "time zone" manually
  • "Detect Disks" will detect the hard disk and "Partition disks" initiates the partitioning of the hard disk. It's easiest if you use the prompted partitioning procedure and then to specify to use the whole hard disk. Partitioning will then proceed to place all files on a single partition which in the list should be selected as the primary partition ("#1 primary") and the file system used reconfigured from "ext4" to "ext2" and set the "Boot-Flag" to "on". Format partition, changed to "Format the partition: yes, format it", other options should be left as is. Complete with "Done setting up the partition" & "Finish partitioning and write changes to disk"
  • "Install the base system" - the basic system will now be installed
  • For the Kernel with 64-bit systems, choose the preselected "linux-image-amd64"-Kernel
  • For the selection of drivers, you need only choose the drivers needed for the system ("only include drivers needed for this system")
  • If asked for "Non-Free and/or Contrib"-Software choose "no"
  • "Configure the package manager" is used to set a download mirror for additional software packages, it's best to look for a server locally in your own country. The "Security" and "Release Updates" can be deactivated in the following step
  • Next is software selection and installation ("Select and install software")
  • "man" and "mandb" program can be omitted
  • The software selection should be kept to "Standard System Utilities"
  • The GRUB bootloader is installed in the Master Boot Sector (MBR) ("Install the GRUB bootloader to a hard disk", maybe you have to choose the paticular harddisk here). If asked for "EFI" select "No" (except you do have an EFI based system) and then acknowledge with" Finish the installation" and boot the installed Debian system. If GRUB is not workink you can try the LILO Bootmanager


3) Installing the Real Time Kernel (Debian 7.8 only)

The real-time kernel provides minimal latency, which is of greater significance for audio recordings but also has an effect on the reproduction of audio files over USB.
To proceed, log in as "root" and then enter the following commands:
sudo apt-get update
sudo apt-get install linux-image-rt-amd64

Reboot your system after entering the commands. You will then get a menu of options with the installed kernels and after short pause Debian will automatically start with the real-time kernel. You can check this using the following console command:
sudo uname -a

You should then get the following output ("RT" means "Real Time"):
usbaudio@debianmusic:~$ uname -a
Linux debianmusic 3.2.0-4-rt-amd64 #1 SMP PREEMPT RT Debian 3.2.54-2 x86_64 GNU/Linux


4) Installing and configuring ALSA

ALSA (Advanced Linux Sound Architecture) is a free sound architecture for Linux systems and controls the USB DACs. You install ALSA with the following command
sudo apt-get install alsa-base alsa-utils

The file "/etc/modprobe.d/alsa-base.conf" should have the following line added (if not exisiting) or the index of "snd-usb-audio" should be set to "0":
options snd-usb-audio index=0
Edit the file "/etc/security/limits.conf" and add the following lines:
@audio - rtprio 99
@audio - memlock unlimited
@audio - nice -10


5) Installing MPD

MPD (Music Player Daemon)is the actual music server and is installed as follows:
sudo apt-get install mpd

Now assign "mpd" to the group "audio":
sudo adduser mpd audio

Make the directory for your music- and playlist-files
sudo mkdir /home/usbaudio/share /home/usbaudio/share/music /home/usbaudio/share/playlist

The write permission should be set as follows:
sudo chmod 777 /home/usbaudio/share /home/usbaudio/share/music /home/usbaudio/share/playlist


6) Installing USBMOUNT

This is to get access to Plug-And-Play USB-Drives or USB-Sticks.

First of all we have to install "usbmount" and "ntfs-3g":
sudo apt-get install usbmount ntfs-3g

Edit "/etc/fstab" and uncomment the following line with a "#" (if line exists):
#/dev/sdb1       /media/usb0     auto    rw,user,noauto  0       0

When this has been done just edit "usbmount.conf"
sudo nano /etc/usbmount/usbmount.conf
and add "ntfs" to the "FILESYSTEMS" and change "FS_MOUNTOPTIONS" and "MOUNTOPTIONS":
FILESYSTEMS="vfat ext2 ext3 ext4 hfsplus ntfs"
MOUNTOPTIONS="noexec,nodev,noatime"
FS_MOUNTOPTIONS="-fstype=vfat,gid=floppy,dmask=0007,fmask=0117"

Now you can mount the directory "/media" to your music-directory as "_USB":
cd /home/usbaudio/share/music
ln -s /media _USB

If you want to copy files e.g. via Windows Explorer to the USB-Drive just do this:
sudo rm /media/usb
sudo chmod 777 /media
sudo chmod 777 /home/usbaudio/share/music/_USB

Before you pull the USB-Plug of the external drive you have to unmount it properly (e.g. the drive you are using is "usb0"):
cd /media
umount usb0


7) Installing and configuring SAMBA

You also need Samba to access music files on Windows computers and load them into the Debian audio server:
sudo apt-get install samba samba-common

Create user "usbaudio" for access over the Windows network:
sudo smbpasswd -a usbaudio

Edit the file "/etc/samba/smb.conf" and add the following:
[music]
	path = /home/usbaudio/share/music
	writeable = yes
;	browseable = yes
	guest ok = yes
	comment = debianmusic
	wins support = yes	

[usb]
	path = /home/usbaudio/share/music/_USB
	writeable = yes
;	browseable = yes
	guest ok = yes
	comment = debianmusic
	wins support = yes

[playlist]
	path = /home/usbaudio/share/playlist
	writeable = yes
;	browseable = yes
	guest ok = yes
	comment = debianmusic
	wins support = yes		
Test if the Samba configuration is ok:
sudo testparm /etc/samba/smb.conf


8) Installing SSH

If you subsequently want to access the music server from another computer via Telnet/SSH client to change the configuration or for testing purposes, you will need the open SSH server. Install this with:
sudo apt-get install openssh-server


9) Installing and configuring LIGHTTPD

So that you can later remotely use mPod to display the covers, you will need a web server. The small web server lighttpd is best suited for this and is installed using the following command:
sudo apt-get install lighttpd

After installing lighttpd you must adjust in "/etc/lighttpd/lighttpd.conf" the following line corresponding to the folder which is above the folder in which the music files are located:
server.document-root = "/home/usbaudio/share"
and below this enter the following:
dir-listing.activate = "enable"
to enable directory browing.


10) Set up DHCP or static IP address

Static IP-Address:

We recommend that under Debian you deactivate DHCP and use a static IP address instead. You can specify this in the file"/etc/network/interfaces" so that you can later easily access the shared folder with Windows Explorer (in our example "\\192.168.1.151").
# The primary network interface
allow-hotplug eth0
#iface eth0 inet dhcp
iface eth0 inet static
address 192.168.1.151
netmask 255.255.255.0
gateway 192.168.1.254

DHCP:

To use DHCP, "/etc/network/interfaces" should be as follows:
# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp
#iface eth0 inet static
#address 192.168.1.151
#netmask 255.255.255.0
#gateway 192.168.1.254
The file "/etc/dhcp/dhclient.conf" should also be edited for the Mac address (= dhcp-client-identifier) and host name (= send host-name):
send host-name = "debianmusic";
#send host-name = gethostname();
send dhcp-client-identifier 00:11:22:33:44:55;
You can get the Mac address (= dhcp-client-identifier) using the following command:
netstat -ei

Use "\\debianmusic" to access the shared folder in Windows (this works with DHCP and Static IP-Address configuration!).


11) Installing and configuring AVAHI

Install the Avahi Daemon with the command:
sudo apt-get install avahi-daemon
so that your remote clients are able to find your mpd-server.

After installing avahi-daemon edit "/etc/avahi/avahi-daemon.conf" and delete "#" in the line:
enable-dbus=yes


12) Installing and configuring ACPID

If your USB-Audio-Server does not shut down when pressing the power-button you have to do this:
sudo apt-get install acpi acpid

After that create the file "/etc/acpi/powerbtn.sh" and add these two lines:
/sbin/shutdown -h now "Power button pressed"
exit 0


13) Finishing the installation and rebooting

You are now finished with all the required steps for configuring the USB audio server. You can now restart the system with the console command sudo reboot and then continue with configuring the MPD.

Before continuing, you can also update your system to the newest version:
sudo apt-get update
sudo apt-get upgrade


C) Configuring the Music Player Daemons for bit-accurate reproduction through a USB DAC (D/A Converter)


1) Check the USB D/A converter

Connect the USB DAC and use the console to check the converter connections:
sudo aplay --list-devices

This is important both for the configuration of the music player daemons as well as the assignment of the DA converter as the default audio unit.

You should get something like the following output after entering "aplay" (Example used with the Firestone I Love Taiwan DA converter):
usbaudio@debianmusic:~$ sudo aplay --list-devices
**** List of Devices (PLAYBACK) ****
Karte 0: TW [I Love TW], Device 0: USB Audio [USB Audio]
  Sub-Device: 1/1
  Sub-Device #0: subdevice #0
The installed soundcards can be displayed with the following command:
sudo cat /proc/asound/cards
usbaudio@debianmusic:~$ sudo cat /proc/asound/cards
 0 [TW]: USB-Audio - I Love TW
	Firestone Audio Co., Ltd. I Love TW at usb-0000:00:1d.2-2, full speed


2) Configuring the Music Player Daemon (MPD)

The most important factor here is MPD configuration file "/etc/mpd.conf". This file contains various options, those that are not required and others that need to be enabled. An example for this is the configuration for "debianmusic" which will take the user that is installed in usbaudio and the hardware read in as for sudo aplay --list-devices. The only thing changed for the folders is the "music_directory".
# Files and directories #######################################################
music_directory         "/home/usbaudio/share/music"
playlist_directory      "/home/usbaudio/share/playlist"
db_file                 "/var/lib/mpd/tag_cache"
log_file                "/var/log/mpd/mpd.log"
pid_file                "/var/run/mpd/pid"
state_file              "/var/lib/mpd/state"
sticker_file            "/var/lib/mpd/sticker.sql"
# General music daemon options ################################################
user                            "mpd"
group                          	"audio"
# For network
#bind_to_address                "localhost"
port                            "6600"
auto_update     				"yes"
# Symbolic link behavior ######################################################
follow_outside_symlinks        "yes"
follow_inside_symlinks        "yes"
# Zeroconf / Avahi Service Discovery ##########################################
zeroconf_enabled               "yes"
zeroconf_name                  "debianmusic"
# Input #######################################################################
#input {
#       plugin "curl"
#       proxy "proxy.isp.com:8080"
#       proxy_user "user"
#       proxy_password "password"
#}
# Audio Output ################################################################
audio_output {
		type            "alsa"
		name            "My Alsa Device"
		device          "hw:0,0"       
}
# Volume control mixer ########################################################
#mixer_type                     "hardware"
#mixer_type                     "software"
mixer_type                     	"disabled"
# Character Encoding ##########################################################
filesystem_charset              "UTF-8"
id3v1_encoding                  "UTF-8"
###############################################################################


3) Testing for bit-accurate reproduction via USB

If you don't own a DAC that displays the bit/sample rate, you can get the correct bit-accurate reproduction directly using the terminal when playing a song:
sudo cat /proc/asound/card0/pcm0p/sub0/hw_params

This should look like the following with a 24 bit / 176 kHz file:
usbaudio@debianmusic:~$ sudo cat /proc/asound/card0/pcm0p/sub0/hw_params
access: RW_INTERLEAVED
format: S24_3LE
subformat: STD
channels: 2
rate: 176400 (176400/1)
period_size: 22050
buffer_size: 88200
Note, that you should replace "card1" with your own hardware using sudo aplay --list-devices.


D) Initial Startup


  1. Connect your USB-DAC with the USB-Music-Server
  2. Connect your network-cable to the USB-Music-Server
    Depending on your network configuration it is recommended to setup your router as DHCP-Server
  3. Turn on your DAC
    The DAC has to be turned on before the USB-Music-Server
  4. Turn on the USB-Music-Server
  5. Copy your Music on the USB-Music-Server
    If you are using Windows you can connect with the Explorer using "\\debianmusic"
  6. Setup Remote Access (check out topic E)


E) Remote Access to MPD


1) MPoD for iOS based mobile devices

Install the MPoD app, start it and, if the Linux MPD audio server doesn't automatically recognize it, install it manually ("Connections / Add player manually"). In this case go to the MPD section and edit "Server" (in this example "192.168.1.151" or "debianmusic.local" if you're using DHCP). Important in this case is to set "Connection Mode / Connection" to "Remote". To display covers (if they are not present), enter in the section "Local Cover Art" the IP address and folder name in which the music data are located or which were configured for lighttp (such as here "http://192.168.1.151/music" or "http://debianmusic.local/music") and enter under "Cover Filename" the filename of the cover files (Note: Be careful, Linux does distinguish between upper- and lowercase.)

2) MPDroid for Android based mobile devices

Quite easy to setup: When starting MPDroid the first time choose your network-connection-mode (if you are in your local network use "WLAN"). Than enter your IP-address in "Host" (take care to setup MPDroid only with the IP-address, not the hostname - if you do not know your IP address download the tool "Fing" from the Play Store and scan your network) - all other options can be left as is.

3) Auremo for Windows

Auremo is a very good choice to easily access the Music Player Demon from Windows computers . After installation you only need to add the IP address of the music server under "Settings/Servername or address, in this case "192.168.1.151", or "debianmusic". "Enable volume slider" is disabled which in any case would not work in the bit-perfect configuration described above. Use "Apply and save settings" to save the setup and, if everything is set up right, Auremo will immediately access the MPD server. Auremo requires Microsoft .NET Framework.

4) GMPC for Linux

GMPC can be used as graphic front end for MPD on a Linux system to provide a graphical user interface. It's easy to install with the Package manager of the Linux desktop or through Terminal with:
sudo apt-get install gmpc.

5) Cantata for Mac OS X

For Mac OS X users, Cantata is one of the best graphical clients for the Music Player Daemon with a lot of features and is very customizable.


F) Download of the config-files


Downloading configuration files

You can download all the above described configuration files here



G) Notes


Previous Knowledge

Some basic knowledge of Linux is advantageous. The use of editors such Nano or VIM should not present any difficulty when working via the console.


Security Note

The above described configuration is meant to enable a Debian server to play bit-accurate music over USB in best-possible quality. Login via "root" is not provided for the configuration above. The standard user with "sudo" as root is used here. We make no provisions for network security in this configuration. You should take appropriate care when using this Debian Music Server configuration over the Internet.
For best results platforms based on Intels Atom processor are highly recommended.


Primephonic - Classical Music as DSD, WAV and FLAC

HighEndSale