Tweaking the audio performance Rpi3

Raspberry Pi related support

Tweaking the audio performance Rpi3

Postby Frost_dk » 05 Jan 2017, 23:22

Hi all.

I have been working on tweaking the runeaudio/rpi3 player software to get the best audible sound quality, and now I think I have made some progress. My tweaks is not very advanced, as im not that keen to linux software in general.

My setup is this :

Rpi3 with Aboes modifications to the power supply. This means that I have supplied the rpi with a linear psu on both 1.8v , 3,3v and 5v.
This is absolutely worth the effort and boosts the overall sound performance, even when used with a USB dac. This actually surprised me, as I didn't expect much from this tweak :)

The amplifier/dac is a Gato audio DIA-400.
Usb cable is a Black Rhodium Star

All my music is on a separate NAS (synology).

here is my list of tweaks:

- Isolate a CPU core and separate MPD to run on only this core (as Frank as described the the rpi3 Thread)

- Enable the kernel optimizations by entering DEV branch.
I prefer the OrionV2 setting.

- use SOXR to upscale to 192Khz/24bit ( this really depends on the DAC, some will get better performance as the SOXR is a better resampler than some of the integrated ones)
This can be done like this :
chattr -i /etc/mpd.conf
Nano /etc/mpd.conf
Add this to the active source:
format "192000:24:2"
samplerate_converter "soxr very high"
then :
Chattr +i /etc/mpd.conf

Then browse to runeaudio.local/dev and restart MPDservice


- Modify the voltage and clock frequencies on the Rpi in config.txt.

- Disable the HDMI output in config.txt

- Disable pvt (temperature mesurements in DRAM) in config.txt

- Disable the PWM_PLL in config.txt

- Add these tweaks to bootcfg.txt: (some are there already)
Code: Select all
nano /boot/cmdline.txt

Code: Select all
  dwc_otg.microframe_schedule=0
  dwc_otg.nak_holdoff_enable=1
  dwc_otg.fiq_fix_enable=0
  smsc95xx.turbo_mode=N
  dwc_otg.lpm_enable=0


I have tried without any luck to isolate USB IRQ handling to a separate core, but this is unfortunalty not possible with a Rpi :(



My config.txt has these lines :

Code: Select all
nano /boot/config.txt


Code: Select all
max_usb_current=1

# memory options
gpu_mem=64

# Overclocking options
force_turbo=1

avoid_pwm_pll=1
arm_freq=666
over_voltage=-10
gpu_freq=333

# sdram overclock
sdram_freq=333


sdram_schmoo=0x02000020
over_voltage_sdram_p=-5
over_voltage_sdram_i=-14
over_voltage_sdram_c=-6


disable_pvt=1

# HDMI disable
hdmi_blanking=2




Notice, that when the ARM voltage is lower than -7, then the integrated WIFI stop working. I normally dont use wifi, but if necessary, ill use a edimax dongle for wifi. But going below -7 is quite noticeable.. perhaps it is because of the internal wifi/bluetooth is then disabled :)

Please report back if anyone tries this :D

Im hoping that the developers (Orion) is working to optimize the kernel optimizations to the new Rpi3 and the current kernel, because I remember how much of a difference it did on the first Rpi. On Rpi2 and Rpi3, the changes in sound is much more subtle.

Kind regards,

Rune Frost
Last edited by Frost_dk on 30 Jan 2017, 16:53, edited 4 times in total.
Frost_dk
 
Posts: 44
Joined: 23 Nov 2015, 20:39
Location: Horsens, Denmark

Re: Tweaking the audio performance Rpi3

Postby dynobot » 06 Jan 2017, 02:33

Good info thanks!

Since graphics is not a priority you might want to turn gpu_mem down to 16 ie gpu_mem=16.
User avatar
dynobot
 
Posts: 114
Joined: 19 May 2014, 15:04
Location: GA-USA

Re: Tweaking the audio performance Rpi3

Postby dynobot » 06 Jan 2017, 17:05

BTW there are a few more kernel adjustments that should/could be made that are not included with the Rune sound profiles.

Usually I pick one of the profiles and comment out everything then put my own kernel mods in place.

For example here I used ACX's profile and put my tweaks in place
# mod1
if [ "$1" == "ACX" ]; then
echo -n performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
ifconfig eth0 mtu 9000
echo noop > /sys/block/mmcblk0/queue/scheduler
echo 0 > /proc/sys/vm/swappiness
echo 1000000 > /proc/sys/kernel/sched_latency_ns
echo 100000 > /proc/sys/kernel/sched_min_granularity_ns
echo 25000 > /proc/sys/kernel/sched_wakeup_granularity_ns
echo 1 > /proc/sys/kernel/hung_task_check_count
echo 20 > /proc/sys/vm/stat_interval
echo -1 > /proc/sys/kernel/sched_rt_runtime_us
echo 5 > /proc/sys/vm/dirty_background_ratio

I also increased the priority of the audio threads in the same file as well as putting MPD on its own core, under the Common Start up section.

renice 19 $(pidof nmbd)
taskset -c -p 1 $(pidof mpd)
renice -10 -p 3
renice -10 -p 12
renice -10 -p 16
renice -10 -p 20

Recently I've been looking at more 'hardware' tweaks
User avatar
dynobot
 
Posts: 114
Joined: 19 May 2014, 15:04
Location: GA-USA

Re: Tweaking the audio performance Rpi3

Postby Frost_dk » 06 Jan 2017, 18:05

Hi Dynobot.
Thanks a lot for your tweaks.. I will try them right away :)
Does the pidof nmbd do anything if im not using a samba share?
is it too much to ask for a explanation of the kernel optimizations you made? Just so I kan play with it myself.
Thanks in advance :D


Kind regards,
Rune Frost
Frost_dk
 
Posts: 44
Joined: 23 Nov 2015, 20:39
Location: Horsens, Denmark

Re: Tweaking the audio performance Rpi3

Postby dynobot » 06 Jan 2017, 18:47

Hi Frost,

Not sure what you mean by pidof nmbd....

But these kernel adjustments came from IBM, RedHat and others, over the years I would read Performance Tuning Guides by companies who used Linux for different purposes....usually single purpose machines like a RedBox for example.

Here is a link for RedHat as an exmple.
https://access.redhat.com/documentation ... ing_Guide/
User avatar
dynobot
 
Posts: 114
Joined: 19 May 2014, 15:04
Location: GA-USA

Re: Tweaking the audio performance Rpi3

Postby Frost_dk » 06 Jan 2017, 21:58

Cool.. Thanks a lot for the link and info...
I will read your link, and search some more..

I have tried your suggestions.. and this together with Orion_v2 settings, it sounds REALLY amazing..


Code: Select all
nano /var/www/command/orion_optimize.sh

My Orion_optimize mod looks like this :

Code: Select all
##################
# common startup #
##################
#if [ "$PID" != null  ]; then
#echo "Set priority for: cifsd"
#renice -20 $PID
#fi
cifsprio pid=$(pidof cifsd)
echo "Set normal priority for: rune_SY_wrk"
renice 20 $(pgrep rune_SY_wrk)
echo "Set normal priority for: rune_PL_wrk"
renice 20 $(pgrep rune_PL_wrk)
echo "Set normal priority for: smbd"
renice 19 $(pidof smbd)
echo "Set normal priority for: nmbd"
renice 19 $(pidof nmbd)
#runeFrost
renice -10 -p 3
renice -10 -p 12
renice -10 -p 16
renice -10 -p 20


and

Code: Select all

ifconfig eth0 mtu 9000
ifconfig wlan0 mtu 9000
ifconfig eth0 txqueuelen 4000
ifconfig wlan0 txqueuelen 4000
echo 0 > /proc/sys/vm/swappiness
modKschedLatency hw=$2 s01=120000 s02=2000000 s03=2000000 s04=2000000 s05=2000000 s06=2000000 s07=2000000 s08=2000000 s09=2000000 s10=2000000 u01=2 u02=2 u03=2 u04=2 u05=2 u06=2 u07=2 u08=2 u09=2 u10=2
#runeFrost
echo -n performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo -n performance > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
echo -n performance > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor
echo 1000000 > /proc/sys/kernel/sched_latency_ns
echo 100000 > /proc/sys/kernel/sched_min_granularity_ns
echo 25000 > /proc/sys/kernel/sched_wakeup_granularity_ns
echo 1 > /proc/sys/kernel/hung_task_check_count
echo 20 > /proc/sys/vm/stat_interval
echo -1 > /proc/sys/kernel/sched_rt_runtime_us
echo 5 > /proc/sys/vm/dirty_background_ratio

sleep 2
mpdprio_nice


.

Thanks for advise..

Kind Regards,
Rune Frost
Last edited by Frost_dk on 09 Jan 2017, 10:23, edited 1 time in total.
Frost_dk
 
Posts: 44
Joined: 23 Nov 2015, 20:39
Location: Horsens, Denmark

Re: Tweaking the audio performance Rpi3

Postby fboe » 06 Jan 2017, 22:05

Hi Frost and Dynobot

Great tweaks you got. I'm really impressed how much improvement in sound you can make with these tweaks. I have tried them, and that's defently the way to go. The sound is fantastic :-)

And Dynobot, you where asking for hardware tweaks, and I have done some, and I have put them in the forum:
3xpsu, and reclocking the rpi with a serious clock from Newclassd.

I'm still a newbie in Linux, so I'm still learning, and hopefully I can come back with some Linux tweaks in the future :-)

Fboe
fboe
 
Posts: 27
Joined: 11 Mar 2016, 17:41
Location: Odense, Denmark

Re: Tweaking the audio performance Rpi3

Postby Discovery » 09 Jan 2017, 10:10

dynobot wrote:BTW there are a few more kernel adjustments that should/could be made that are not included with the Rune sound profiles.

Usually I pick one of the profiles and comment out everything then put my own kernel mods in place.

For example here I used ACX's profile and put my tweaks in place
# mod1
if [ "$1" == "ACX" ]; then
echo -n performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
ifconfig eth0 mtu 9000
echo noop > /sys/block/mmcblk0/queue/scheduler
echo 0 > /proc/sys/vm/swappiness
echo 1000000 > /proc/sys/kernel/sched_latency_ns
echo 100000 > /proc/sys/kernel/sched_min_granularity_ns
echo 25000 > /proc/sys/kernel/sched_wakeup_granularity_ns
echo 1 > /proc/sys/kernel/hung_task_check_count
echo 20 > /proc/sys/vm/stat_interval
echo -1 > /proc/sys/kernel/sched_rt_runtime_us
echo 5 > /proc/sys/vm/dirty_background_ratio

I also increased the priority of the audio threads in the same file as well as putting MPD on its own core, under the Common Start up section.

renice 19 $(pidof nmbd)
taskset -c -p 1 $(pidof mpd)
renice -10 -p 3
renice -10 -p 12
renice -10 -p 16
renice -10 -p 20

Recently I've been looking at more 'hardware' tweaks


Hi Dynobot,

Thanks for these ideas.

Which file are these changes added to?
Discovery
 
Posts: 110
Joined: 06 May 2015, 08:22
Location: Cambridgeshire, UK

Re: Tweaking the audio performance Rpi3

Postby Frost_dk » 09 Jan 2017, 10:20

Hi Discovery.

I have modified my config files with Dynobots suggestions, so you should be able to copy the info in my last post :)

i have added the file paths in the post, so it is easier to import :)

Please let us know if you can notice an improvement?

Kind regards,

Rune Frost
Frost_dk
 
Posts: 44
Joined: 23 Nov 2015, 20:39
Location: Horsens, Denmark

Re: Tweaking the audio performance Rpi3

Postby s.k. » 09 Jan 2017, 11:28

Hi ,
Thanks for sharing !

Are those tweaks suitable for the raspberry 2 ?
If yes, is it possible to describe them in a more simple/detail (noobproof :shock: ) way ?

regards
RPi2B Rev 1.1, Allo DigiOne, ATXRaspi, 16x2 OLED display - running rAudio
s.k.
 
Posts: 113
Joined: 04 Jan 2017, 08:38

support RuneAudio Donate with PayPal

Next

Return to Raspberry Pi

Who is online

Users browsing this forum: No registered users and 5 guests