Hello,
This guide intends to provide Audiophonics ES9018K2M DAC users and especially Rasptouch backers with instructions to get a usable Volumio 2 sound system with volume control.
It has been tested with the following system configuration :
- Volumio 2.041
- RPi 3
- ES9018K2M DAC
- Official 7" touchscreen plugin
- Volumio Spotify plugin
- Balbuze Volspotconnect plugin
As Audiophonics does not provide any support for ES9018K2M DAC use with Volumio, please consider this guide as a workaround.
Audiophonics ES9018K2M DAC supports both 16 and 24 bitdepth sound files. But there is no automatic recognition of bitdepth.
User has to send configuration parameters over a serial link to select the correct bitdepth for the sound file to play.
Step 0
To accept parameters coming on its serial link input, the DAC has to be setup in “mode serial hardware” as per instructions on product page.
Step 1
Make a fresh install of Volumio 2.041.
Do not install the SDcard on the RPi now.
Do steps 2 and 3 before Volumio first start.
Step 2
Make changes in /boot/config.txt to free up UART0 if using a RPi 3 with embedded bluetooth and to provide a suitable sound driver to the DAC.
Add following lines to /boot/config.txt
dtoverlay=pi3-disable-bt
dtoverlay=hifiberry-dac
After changes, /boot/config.txt contents should look like this:
initramfs volumio.initrd
gpu_mem=16
force_turbo=1
max_usb_current=1
disable_splash=1
dtparam=audio=on
dtparam=i2c_arm=on
dtoverlay=pi3-disable-bt
dtoverlay=hifiberry-dac
Step 3
If using a RPi 3 with embedded bluetooth, remove any reference to ttyAMA0 in /boot/cmdline.txt file.
These parts have to be removed:
console=ttyAMA0,115200 kgdboc=ttyAMA0,115200
Step 4
Insert the SDcard in the RPi and switch on the system.
Wait until Volumio 2 initial setup ends.
If required, install touchscreen plugin and/or Spotify plugin and/or volspotconnect plugin, reboot.
Then, SSH to your Volumio system.
User is volumio
Pass is volumio
Step 5
Go to file system root:
cd /
Disable UART0 use by the modem:
Root pass is also volumio
sudo systemctl disable hciuart
Step 6
Check your ES9018K2M DAC is well recognized by the system:
aplay -l
The DAC shall appear as card 1, assuming there is no other sound card but RPi embedded sound card on your system.
If this step fails, do no proceed further. Fix this step before.
Step 7
Reboot the Volumio system to make the asound.state file created.
SSH again to the Volumio system.
Step 8
As there is no driver for the ES9018K2M DAC, we have to create a dummy mixer to be able to control sound level through Volumio UI.
Go to file system root:
cd /
Edit file var/lib/alsa/asound.state
sudo nano var/lib/alsa/asound.state
Add following lines to var/lib/alsa/asound.state file:
state.sndrpihifiberry {
control.1 {
iface MIXER
name Digital
value.0 99
value.1 99
comment {
access 'read write user'
type INTEGER
count 2
range '0 - 99'
tlv '00000001000000080000000000000032'
dbmin 0
dbmax 4950
dbvalue.0 4950
dbvalue.1 4950
}
}
}
Step 9
Activate the dummy mixer:
sudo alsactl restore 1
Check that the dummy mixer has been correctly created:
amixer -c 1
Output shall look like this:
Simple mixer control 'Digital',0
Capabilities: volume
Playback channels: Front Left - Front Right
Capture channels: Front Left - Front Right
Limits: 0 - 99
Front Left: 99 [100%]
Front Right: 99 [100%]
If this step fails, do no proceed further. Fix this step before.
Step 10
Update packages list:
sudo apt-get update
Install python-serial package. This package is required to control DAC with a python script over the serial link:
sudo apt-get install python-serial
Step 11
Create python script required to control the DAC over serial link. This script is a derivative of the one created by Audiophonics for Runeaudio.
nano /volumio/app/plugins/system_controller/i2s_dacs/scripts/ES9018K2M_serial_sync_volumio2.py
Paste contents of this file and save.
Create bash script required to activate python script when Volumio boots:
nano /volumio/app/plugins/system_controller/i2s_dacs/scripts/ES9018K2M-serial.sh
Paste following lines and save:
#!/bin/sh
# Audiophonics ES9018K2M DAC hardware volume management starting script for Volumio 2
# Author: Jean-Charles BARBAUD
#
python /volumio/app/plugins/system_controller/i2s_dacs/scripts/ES9018K2M_serial_sync_volumio2.py
Make bash script executable:
chmod ugo+x /volumio/app/plugins/system_controller/i2s_dacs/scripts/ES9018K2M-serial.sh
Step 12
Add ES9018K2M DAC definition in Volumio 2:
nano /volumio/app/plugins/system_controller/i2s_dacs/dacs.json
Paste following line with respect to DAC name alphabetical order. Notice it is a single line even if this forum is showing it on multiple lines.
{"id":"es9018k2m-serial","name":"Audiophonics ES9018K2M Serial Mode DAC","overlay":"hifiberry-dac","alsanum":"1","mixer":"Digital","modules":"","script":"ES9018K2M-serial.sh","needsreboot":"yes"},
Step 13
Go to Volumio UI through a web browser.
In page “Playback options”:
- activate I2S
- in DAC model, select “Audiophonics ES9018K2M Serial Mode DAC” and save configuration.
Step 14
As Volumio 2 overwrites /boot/config.txt file when a DAC is selected, do again changes in /boot/config.txt file as per step 2.
Then, do not change DAC model as it will overwrite /boot/config.txt again.
Step 15
Shutdown the system and remove power supply.
Wait 10 seconds at least to reset the DAC.
Switch on the system.
At this stage, the startup sound management is not yet configured. So, a highly distorted sound may occur.
Step 16
Go to Volumio UI through a web browser.
In page “Playback options”:
- Mixer type shall be set to “Hardware”
- Mixer Control Name shall be set to “Digital”
In page “Playback”, volume control shall operate normally when clicking on it.
Check MPD settings:
cat /etc/mpd.conf
“audio_output” section shall look like this:
audio_output {
type "alsa"
name "alsa"
device "hw:1,0"
dop "yes"
mixer_device "hw:1"
mixer_control "Digital"
mixer_type "hardware"
}
If Spotify plugin is installed, /etc/spopd.conf configuration file shall look like this:
[spop]
spotify_username = your_username
spotify_password = your_password
high_bitrate = true
audio_output = sox
pretty_json = true
search_results = 50
cache_path =/run/shm
[sox]
output_type = alsa
output_name = hw:1
If this step fails, do no proceed further. Fix this step before.
At this stage, your Volumio system shall operate normally with Audiophonics ES9018K2M DAC.
Notice there is some latency, around half a second, when changing volume level through Volumio Ui. it is due to processing load to send new volume setting to the DAC.
Step 17
To fix startup sound playing, edit /volumio/app/platformSpecific.js file and search for PlatformSpecific.prototype.startupSound function.
Original Volumio 2.041 startupsound function is as follow:
PlatformSpecific.prototype.startupSound = function () {
var self = this;
var outdev = self.coreCommand.sharedVars.get('alsa.outputdevice');
var hwdev = '--device=plughw:' + outdev + ',0';
if (outdev === 'softvolume'){
hwdev = '-D softvolume';
}
exec(/usr/bin/aplay '+hwdev+' /volumio/app/startup.wav', function (error, stdout, $
if (error !== null) {
console.log(error);
} else self.coreCommand.pushConsoleMessage('Startup sound played');
});
}
Replace following lines:
exec('/usr/bin/aplay '+hwdev+' /volumio/app/startup.wav', function (error, stdout, stderr) {
if (error !== null) {
console.log(error);
}
});
with this one:
execSync('stty -F /dev/ttyAMA0 2400 && echo "A,0,100,1" > /dev/ttyAMA0 && /usr/bin/aplay '+hwdev+' /volumio/app/startup.wav', { uid: 1000, gid: 1000});
After making changes, startupsound function shall be as follow:
PlatformSpecific.prototype.startupSound = function () {
var self = this;
var outdev = self.coreCommand.sharedVars.get('alsa.outputdevice');
var hwdev = '--device=plughw:' + outdev + ',0';
if (outdev === 'softvolume'){
hwdev = '-D softvolume';
}
execSync('stty -F /dev/ttyAMA0 2400 && echo "A,0,100,1" > /dev/ttyAMA0 && /usr/bin/aplay '+hwdev+' /volumio/app/startup.wav', { uid: 1000, gid: 1000});
}
Reboot the Volumio system and enjoy.
Startup sound shall now play nicely.