Script to install Odroid HiFi Shield 2

Post Reply
Fourdee
Posts: 298
Joined: Fri Apr 03, 2015 5:01 am
languages_spoken: english
ODROIDs: C1 / C2 / XU4 + Cloudshell.
Has thanked: 0
Been thanked: 0
Contact:

Script to install Odroid HiFi Shield 2

Post by Fourdee »

This script will:
  • Install and setup the Odroid HiFi Shield 2 with ALSA. For C1+ and C2.
  • Enables all required modules for the sound card
  • Create an /etc/asound.conf, which sets the HiFi Shield 2 to the default sound card on system (hw:1,0)
  • Creates a service which will complete the following during boot:
    • Enable pcm5242 over i2c
    • Set volume to -3 dB.
Requires:
  • Debian Jessie or higher
  • Ubuntu 16.xx
  • Any Debian based OS with SystemD
See the scripts sourcecode: http://dietpi.com/downloads/misc/commun ... shield2.sh

Download script:

Code: Select all

wget http://dietpi.com/downloads/misc/community/install_odroid_hifishield2.sh -O install_odroid_hifishield2.sh
chmod +x install_odroid_hifishield2.sh
How to install the HiFi Shield 2:

Code: Select all

sudo apt-get install -y alsa-base alsa-utils; sudo ./install_odroid_hifishield2.sh install
How can I test the sound?:
After rebooting your system, use the command below (press CTRL+C to terminate):

Code: Select all

speaker-test -c2
How do I change the hardware volume?:

Code: Select all

#Always keep the volume below 0.0 dB (eg: -0.1dB), else clipping will occur.
# -3 dB
amixer -c 1 sset Digital 201
# -1 dB
amixer -c 1 sset Digital 205
How can I change the DSP filter on the sound card?:
The following DSP filters are available. Each one is unique and may improve the sound quality, so try them all:
  • 'FIR interpolation with de-emphasis'
  • 'Low latency IIR with de-emphasis'
  • 'High attenuation with de-emphasis'
  • 'Fixed process flow'
  • 'Ringing-less low latency FIR'

    Code: Select all

    #Example to set the DSP program to 'Ringing-less low latency FIR'
    amixer -c 1 sset 'DSP Program' 'Ringing-less low latency FIR'
Where can I see a full list of hardware options for the sound card?:

Code: Select all

amixer -D hw:1
How to uninstall the HiFi Shield 2:

Code: Select all

sudo ./install_odroid_hifishield2.sh uninstall
http://DietPi.com - Lightweight justice for your Odroid.
DietPi web hosting is powered by http://MyVirtualServer.com

User avatar
odroid
Site Admin
Posts: 35920
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 1325 times
Been thanked: 915 times
Contact:

Re: Script to install Odroid HiFi Shield 2

Post by odroid »

Thank you for the great guide!
We confirm it works on official Ubuntu well.

We've added a link of this thread on our WiKi page. (on the bottom area)
http://odroid.com/dokuwiki/doku.php?id= ... fi-shield2

barturblits
Posts: 51
Joined: Fri Jan 06, 2017 6:33 pm
languages_spoken: english, dutch, german
Has thanked: 0
Been thanked: 0
Contact:

Re: Script to install Odroid HiFi Shield 2

Post by barturblits »

I would like to request the DAC set to 0dB in the kernel drivers to prevent accidental damage to speakers and amplifiers instead of soft limiting it in the alsa higher API. As far as I understand, the +24dB is only useful for recording / audio professionals (please correct me if I am wrong). Since the hifi shield 2 has no inputs, it seems to be a consumer only product. Consumer mode is normally 0dB (with alsa on 255).

Edit:
I think I found a solution:

-static const DECLARE_TLV_DB_SCALE(digital_tlv, -10350, 50, 1);
+static const DECLARE_TLV_DB_SCALE(digital_tlv, -12750, 50, 1);

When using the following equation:

maximum steps (in alsa) * step size (in dB) + start point (in dB) = max gain (in dB)
starting point in code is declared in units of 0.01 dB.

current alsa max = +24 dB @ 255
used alsa value = 0dB @ 207

255 * 0.5 - 10350 * 0.01 dB = +24 dB
207 * 0.5 - 10350 * 0.01 dB = 0 dB

So:
starting point = max gain - maximum steps * step size
starting point = 0 - 255 * 0.5 = -127.5 db

correcting unit:
-127.5 * 0.01 = -12750

Edit:
I just noticed ubuntu uses pulse audio.(volumio directly uses alsa). The limit set in the first post seems to depend on using pulse. When I want to disable the autospawn of pulse and only use ALSA, I have to use the main alsa mixer to change volume, so the limit will have no effect anymore.

barturblits
Posts: 51
Joined: Fri Jan 06, 2017 6:33 pm
languages_spoken: english, dutch, german
Has thanked: 0
Been thanked: 0
Contact:

Re: Script to install Odroid HiFi Shield 2

Post by barturblits »

barturblits wrote:I would like to request the DAC set to 0dB in the kernel drivers to prevent accidental damage to speakers and amplifiers instead of soft limiting it in the alsa higher API. As far as I understand, the +24dB is only useful for recording / audio professionals (please correct me if I am wrong). Since the hifi shield 2 has no inputs, it seems to be a consumer only product. Consumer mode is normally 0dB (with alsa on 255).

Edit:
I think I found a solution:

-static const DECLARE_TLV_DB_SCALE(digital_tlv, -10350, 50, 1);
+static const DECLARE_TLV_DB_SCALE(digital_tlv, -12750, 50, 1);

When using the following equation:

maximum steps (in alsa) * step size (in dB) + start point (in dB) = max gain (in dB)
starting point in code is declared in units of 0.01 dB.

current alsa max = +24 dB @ 255
used alsa value = 0dB @ 207

255 * 0.5 - 10350 * 0.01 dB = +24 dB
207 * 0.5 - 10350 * 0.01 dB = 0 dB

So:
starting point = max gain - maximum steps * step size
starting point = 0 - 255 * 0.5 = -127.5 db

correcting unit:
-127.5 * 0.01 = -12750

Edit:
I just noticed ubuntu uses pulse audio.(volumio directly uses alsa). The limit set in the first post seems to depend on using pulse. When I want to disable the autospawn of pulse and only use ALSA, I have to use the main alsa mixer to change volume, so the limit will have no effect anymore.
Edit:
solution did not work, changed only the scale, not the output.

Riven67
Posts: 2
Joined: Tue Jun 28, 2016 8:53 am
languages_spoken: english
ODROIDs: Xu4, C1+, hifi shield
Has thanked: 0
Been thanked: 0
Contact:

Re: Script to install Odroid HiFi Shield 2

Post by Riven67 »

Will these instructions also work for earlier version of HiFi shield? Ie.. not hifi shield 2?

Post Reply

Return to “I2S Devices (HiFi Shield DAC and Stereo Boom Bonnet Kit)”

Who is online

Users browsing this forum: No registered users and 1 guest