[GUIDE] Setup Audiophonics ES9018K2M DAC with Volumio 2

Guides to let you easily discover and enjoy Volumio

Ads helps Volumio remain Free and Open Source. Please consider donating to help us continue to serve you.

[GUIDE] Setup Audiophonics ES9018K2M DAC with Volumio 2

Postby vigo » Sun Mar 05 2017 17:16

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
Code: Select all
dtoverlay=pi3-disable-bt
dtoverlay=hifiberry-dac

After changes, /boot/config.txt contents should look like this:
Code: Select all
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:
Code: Select all
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:
Code: Select all
cd /

Disable UART0 use by the modem:
Root pass is also volumio
Code: Select all
sudo systemctl disable hciuart


Step 6
Check your ES9018K2M DAC is well recognized by the system:
Code: Select all
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:
Code: Select all
cd /

Edit file var/lib/alsa/asound.state
Code: Select all
sudo nano var/lib/alsa/asound.state

Add following lines to var/lib/alsa/asound.state file:
Code: Select all
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:
Code: Select all
sudo alsactl restore 1

Check that the dummy mixer has been correctly created:
Code: Select all
amixer -c 1

Output shall look like this:
Code: Select all
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:
Code: Select all
sudo apt-get update

Install python-serial package. This package is required to control DAC with a python script over the serial link:
Code: Select all
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.
Code: Select all
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:
Code: Select all
nano /volumio/app/plugins/system_controller/i2s_dacs/scripts/ES9018K2M-serial.sh

Paste following lines and save:
Code: Select all
#!/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:
Code: Select all
chmod ugo+x /volumio/app/plugins/system_controller/i2s_dacs/scripts/ES9018K2M-serial.sh


Step 12
Add ES9018K2M DAC definition in Volumio 2:
Code: Select all
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.
Code: Select all
{"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:
Code: Select all
cat /etc/mpd.conf

"audio_output" section shall look like this:
Code: Select all
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:
Code: Select all
[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:
Code: Select all
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:
Code: Select all
exec('/usr/bin/aplay '+hwdev+' /volumio/app/startup.wav', function (error, stdout, stderr) {
      if (error !== null) {
         console.log(error);
      }
   });

with this one:
Code: Select all
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:
Code: Select all
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.
Last edited by vigo on Wed Mar 22 2017 22:04, edited 2 times in total.
Random avatar
vigo
Sunday DIYer
Sunday DIYer
 
Posts: 36
Joined: Tue Jan 10 2017 10:29

Ads helps Volumio remain Free and Open Source. Please consider donating to help us continue to serve you.


[GUIDE] Setup Audiophonics ES9018K2M DAC with Volumio 2

Postby kjarrig » Mon Mar 20 2017 22:25

I've been trying this, still with no luck. Could there be an error in Step 9? sudo alsactl restore 1 is done two times?

Kjartan
Random avatar
kjarrig
Sunday DIYer
Sunday DIYer
 
Posts: 37
Joined: Mon Apr 27 2015 14:40


[GUIDE] Setup Audiophonics ES9018K2M DAC with Volumio 2

Postby vigo » Wed Mar 22 2017 18:31

kjarrig wrote:I've been trying this, still with no luck. Could there be an error in Step 9? sudo alsactl restore 1 is done two times?

Yes, you are right.
Second command line at step 9 shall be:
Code: Select all
amixer -c 1
Original post updated.
But it does not explain why you didn't succeed.
Notice that your DAC firmware shall support hardware mode. According to Audiophonics, DACs manufactured before november 1st 2016 do not support this mode. It includes DACs provided to Rasptouch backers. In such case, you have to request a firmware update to Auciophonics customer support.
Random avatar
vigo
Sunday DIYer
Sunday DIYer
 
Posts: 36
Joined: Tue Jan 10 2017 10:29


[GUIDE] Setup Audiophonics ES9018K2M DAC with Volumio 2

Postby kjarrig » Thu Mar 23 2017 13:14

I'm thinking maybe I did step 8 wrong, I replaced the
state.ALSAMixer {
control.1 {

to state.sndrpihifiberry {
control.1 {
and the rest of the code.

Is that right, or should I add the statements in step 8 as you say? Thought it could be a typo error to have two control.1
Random avatar
kjarrig
Sunday DIYer
Sunday DIYer
 
Posts: 37
Joined: Mon Apr 27 2015 14:40


[GUIDE] Setup Audiophonics ES9018K2M DAC with Volumio 2

Postby vigo » Thu Mar 23 2017 20:57

kjarrig wrote:I'm thinking maybe I did step 8 wrong, I replaced the
state.ALSAMixer {
control.1 {

to state.sndrpihifiberry {
control.1 {
and the rest of the code.

Is that right, or should I add the statements in step 8 as you say? Thought it could be a typo error to have two control.1

First, keep in mind that this procedure is suitable for a fresh Volumio installation.
Second, you have to add the statement at the end of the file, not to replace existing statement with new one.
This will add a new mixer to alsa.
Random avatar
vigo
Sunday DIYer
Sunday DIYer
 
Posts: 36
Joined: Tue Jan 10 2017 10:29


[GUIDE] Setup Audiophonics ES9018K2M DAC with Volumio 2

Postby kjarrig » Fri Mar 24 2017 19:16

Now I've done everything, but the 16 bit files are still distorted.
One thing I noticed is that the config.txt did not change when I selected the Audiophonics DAC. I can choose Hardware as Mixer type in Playback options, and Mixer control name is Digital. I can't turn the volume up and down through the web page of Volumio in Playback. All outputs that you did show are identical to mine.
If my jumper-settings were not right on the DAC, I could not choose Hardware in Playback options, am I right?
One thing I did not do, were to install the plugins as you said. I installed the later, but I don't believe that could be the problem. I've looked over all files that should be changed, and can't find any difference between what you wrote and my files.
I also tried to update Volumio to 2.118, but it doesn't matter.
Any help is greatly appreciated.

Kjartan
Random avatar
kjarrig
Sunday DIYer
Sunday DIYer
 
Posts: 37
Joined: Mon Apr 27 2015 14:40


[GUIDE] Setup Audiophonics ES9018K2M DAC with Volumio 2

Postby vigo » Fri Mar 24 2017 21:18

kjarrig wrote:Now I've done everything, but the 16 bit files are still distorted.
What 16 bit file source do you try ? Spotify ?

kjarrig wrote:One thing I noticed is that the config.txt did not change when I selected the Audiophonics DAC.
Did you save the Volumio settings after selecting Audiophonics DAC by clicking on "save" button in Volumio UI ?

kjarrig wrote:If my jumper-settings were not right on the DAC, I could not choose Hardware in Playback options, am I right?
No, you are not.
There is no relationship between Volumio UI settings and the behaviour of the DAC.
The procedure creates a dummy mixer required to make UI volume control working as expected. That's all.
Then the python script is asking current sound file playback parameters (bitdepth, current volume) to Volumio periodically and forwards these parameters to the DAC through the serial link.
What is the manufacturing date of your DAC ?
Are you sure it embeds the right firmware ?
If your DAC has been manufactured before november 1st 2016 then it cannot work in hardware mode without firmware update from Audiophonics.
Random avatar
vigo
Sunday DIYer
Sunday DIYer
 
Posts: 36
Joined: Tue Jan 10 2017 10:29


[GUIDE] Setup Audiophonics ES9018K2M DAC with Volumio 2

Postby kjarrig » Fri Mar 24 2017 22:00

vigo wrote:
kjarrig wrote:Now I've done everything, but the 16 bit files are still distorted.
What 16 bit file source do you try ? Spotify ?
Spotify and 16 bit flac files.

kjarrig wrote:One thing I noticed is that the config.txt did not change when I selected the Audiophonics DAC.
Did you save the Volumio settings after selecting Audiophonics DAC by clicking on "save" button in Volumio UI ?
Yes I did.

kjarrig wrote:What is the manufacturing date of your DAC ?
Are you sure it embeds the right firmware ?
If your DAC has been manufactured before november 1st 2016 then it cannot work in hardware mode without firmware update from Audiophonics.

Got mine mid December, it got delayed because the update of firmware.
Random avatar
kjarrig
Sunday DIYer
Sunday DIYer
 
Posts: 37
Joined: Mon Apr 27 2015 14:40


[GUIDE] Setup Audiophonics ES9018K2M DAC with Volumio 2

Postby vigo » Fri Mar 24 2017 22:11

kjarrig wrote:Spotify and 16 bit flac files.

Didn't try flac files as I don't have any but it works with Spotify.

kjarrig wrote:Got mine mid December, it got delayed because the update of firmware.

So it should be hardware mode compliant.
When changing volume through Volumio UI, does the DAC sound output follow the volume change ?
What version of RPi do you use ?
Random avatar
vigo
Sunday DIYer
Sunday DIYer
 
Posts: 36
Joined: Tue Jan 10 2017 10:29


[GUIDE] Setup Audiophonics ES9018K2M DAC with Volumio 2

Postby kjarrig » Fri Mar 24 2017 22:48

vigo wrote:
kjarrig wrote:Spotify and 16 bit flac files.

Didn't try flac files as I don't have any but it works with Spotify.

kjarrig wrote:Got mine mid December, it got delayed because the update of firmware.

So it should be hardware mode compliant.
When changing volume through Volumio UI, does the DAC sound output follow the volume change ?
What version of RPi do you use ?


The DAC output does not follow volume change.
RPi 2 Model B
I'm trying a new setup and first installed the Touchscreen plugin. It have been in 70% Disabling Kios Service for about 10 minutes.
Random avatar
kjarrig
Sunday DIYer
Sunday DIYer
 
Posts: 37
Joined: Mon Apr 27 2015 14:40

Next

Return to Guides

Who is online

Users browsing this forum: No registered users and 0 guests