Tweaking the audio performance Rpi3

Raspberry Pi related support

Re: Tweaking the audio performance Rpi3

Postby s.k. » 22 Jan 2017, 15:44

HI ian,
Thanks a lot for your answers!
I am not familiar with this tweaking "thing", so I am a little bit confused.
But your explanations make sense, so I shall give them a try.
The other mods that I mention are OK or you suggest something different?
Regards
Stavros
RPi2B Rev 1.1, Allo DigiOne, ATXRaspi, 16x2 OLED display - running rAudio
s.k.
 
Posts: 113
Joined: 04 Jan 2017, 08:38

Re: Tweaking the audio performance Rpi3

Postby pietpara » 22 Jan 2017, 22:08

@s.k.: That looks very good. I have the same. I did not yet set up SOX up sampler. You have to compare with and without because it is probably a matter of taste whether it sounds better for you. But I'd do this when having listened quite some time to the setting you have now.

Furthermore, I have set the taskset command for mpd in mpd.service now. I see more activity in the cpu load table of top, than before with the taskset command in the sound profile.

However, I see more processes running on cpu3. Processes called 'migration', 'kworker' and 'ksoftirqd'.
Is that expected behavior?
pietpara
 
Posts: 48
Joined: 12 Jan 2017, 21:17

Re: Tweaking the audio performance Rpi3

Postby Frost_dk » 22 Jan 2017, 22:14

However, I see more processes running on cpu3. Processes called 'migration', 'kworker' and 'ksoftirqd'.
Is that expected behavior?


The processes you mention is some that can not be moved away from the core. It is IRQ handling and such.

Kind regards,

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

Re: Tweaking the audio performance Rpi3

Postby Frost_dk » 22 Jan 2017, 22:21

ianhaynes wrote:In the article by Archimago quoted above he recommends underclocking rather than overclocking the Pi, his reasons being:

Lower clock speed --> less power use --> less CPU noise --> better sound
Better aligned clock speeds --> less random & periodic jitter --> better sound
Less power use --> less strain on power supply --> less noise & jitter (cuz it's like that) --> better sound

I've made some of the mods in this thread including underclocking as he suggests with my settings now being:

Code: Select all
force_turbo=0
initial_turbo=60
arm_freq=700
sdram_freq=350
core_freq=350
gpu_freq=300
over_voltage=-4
sdram_over_voltage=-4
gpu_mem=16

# HDMI disable
hdmi_blanking=2


The initial_turbo=60 gives you 60 seconds of turbo mode when you boot up.

This article https://haydenjames.io/raspberry-pi-2-overclock/ gives some useful background.

The system runs perfectly with these lower settings. Not sure I can hear a significant difference but perhaps my ears can no longer detect real subtleties. Listening comparisons are notoriously difficult anyway, with minute differences in volume giving an apparent improvement.

Ian


Hello Ian.
I have tried many speed settings, and I find the ones I suggest to be the best in my setup :)

I have a suggestion you should try in your settings.

The setting : FORCE_TURBO should be set to 1. If not, the speed setting on the cpu can change depending of the load on the cpu, and I can imagine that this might have a impact in sound quality. I also believe that if not set to 1, there is some speed settings that are not "unlocked".

Have you tried the Dram voltage settings also? This is where I could hear the biggest changes in sound. Although the sound changes are still quite subtle.
If you try it, then you should # the SDRAM_over_voltage

Oh.. and why not set the GPU speed to 350 also? Then all the cpus follow each other byer 1:1 or 1:2 :)

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

Re: Tweaking the audio performance Rpi3

Postby ianhaynes » 23 Jan 2017, 11:06

Hi,

Thanks for this, I was misunderstanding the way force_turbo works.

I'd followed the example in Archimago's blog for the sdram_over_voltage setting, but looking else where it appears that the correct syntax is over_voltage_sdram.

Ian
Pi 2, Ver. 0.5b, IQAudio DAC+
ianhaynes
 
Posts: 207
Joined: 04 Mar 2015, 12:51

Re: Tweaking the audio performance Rpi3

Postby Discovery » 23 Jan 2017, 22:25

I've compiled a list of all of Rune Frost's changes for the RPi3. Please see below.

I've used 'nano' as my line editor, and reference this in the instructions. It's simple to use but doesn't allow copy and paste of multiple lines. If you have a better editor, that's great.

All the text to be entered or modified is in orange text.

Please read the instructions carefully if you wish to edit the mpd.conf file (to enable the soxr upsampler). If you don't use chattr before and after the changes won't be saved...

Once the changes have been made, reboot the Pi and then select the 'OrionV2' profile from the Settings menu.

Warning: all computers need perfect syntax. If this doesn't work, just recreate a new SD card from the original image and start again. :D

Lastly, all credit to Rune Frost and Dynobot for their efforts in devising these mods, and a special mention to the ever-helpful Frank (hondagx35) for providing unstinting assistance.

Simpler Alternative
If you're not feeling brave, Dynobot suggested a useful article which makes some comparitively simple changes in /boot/config.txt This will give an improvement but, from personal experience, the changes below have a much more obvious (and beneficial) effect. You choose. The article is here: http://archimago.blogspot.co.uk/2017/01 ... s-usb.html

--------------------------------------------------------------------------------------------------------------------------------------------------------------

Nightly Build
The nightly builds has to be enabled and updated to enable the kernel optimizations.

Nightly builds are based on the latest development code, which means they are probably unstable and definitely not documented. As such, your mileage may vary.

Updating to these builds is better suited for more experienced users and developers, although everyone is welcome to test them and provide feedback.

Currently, development is progressing along different branches in the RuneUI repository: dev branch - closer to the main branch, this is likely to be merged with main on a regular basis next branch - a more experimental one, typically intended to be the next version of RuneAudio.

These are the required steps to switch from the main branch to another one (the following example refers to the dev branch):

delete the contents of /var/www (including hidden files)
DOUBLE CHECK the path before entering the command!
rm -rf /var/www/{*,.*}
clone the 'dev' branch on your device (notice the -b dev)
git clone -b dev https://github.com/RuneAudio/RuneUI.git/ /var/www
clear the PHP OPcache
curl -s http://localhost/clear
reboot your device
As final step, always remember to hard refresh the cache of your browser. How to: http://www.refreshyourcache.com/en/cache/


To Use SOXR Upscaler (optional – may not work well with all DACs)
Use SOXR to upscale to 192Khz/16bit ( this really depends on the DAC, some will get better performance as the SOXR is a better resampler than some of the integrated ones).

The chattr –i command must precede the edit and the chattr +I must follow the edit. The mpd.conf file is locked for editing - the first chattr command unlocks it; the second locks it after changes.

Please note – the ‘active source’ is usually the section that has ‘enabled “yes”’ in it. In the example below, this is my USB Audio DAC – the second section, where the lines have been added.

Note: Other upsampling values also work, e.g. 96000:16:2

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

Example Content
audio_output {
name "bcm2835 ALSA_1"
type "alsa"
device "hw:1,0"
dsd_usb "yes"
auto_resample "no"
auto_format "no"
}

audio_output {
name "USB Audio DAC"
type "alsa"
device "hw:0,0"
dsd_usb "yes"
auto_resample "no"
auto_format "no"
format "192000:16:2"
samplerate_converter "soxr very high"

enabled "yes"
}


Changes to /boot/config.txt
Rune Frost tells me that the changes in this file to the Dram and frequency settings add an 'analogue' sound to the output. Always a good thing... :-)
Note: some of these values may be already present.

nano /boot/config.txt

max_usb_current=1

# memory options
#gpu_mem=64
gpu_mem=16

# 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


Please note: Rune Frost advises that when the ARM voltage is lower than -7, the integrated wi-fi will stop working. If wi-fi is required, you can still use an edimax (or similar) dongle for wi-fi. But going below -7 is quite noticeable.. perhaps it is because of the internal wifi/bluetooth is also then disabled :-)

It should be noted that the best internet link is always an ethernet cable. If your router is not near your hi-fi, a good quality powerplug extender works well for the author, e.g. TP-Link AV500, or similar.


Changes to /boot/cmdline.txt
N.B. Some of these parameters are already present.

Nano /boot/cmdline.txt
dwc_otg.microframe_schedule=0
dwc_otg.nak_holdoff_enable=1
dwc_otg.fiq_fix_enable=0
dwc_otg.microframe_schedule=1
smsc95xx.turbo_mode=N
dwc_otg.lpm_enable=0


Orion Optimize Mods (/var/www/command/orion_optimize.sh)
nano /var/www/command/orion_optimize.sh
##################
# 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


Also in /var/www/command/orion_optimize.sh
Find the Sound Profiles section (see below), then modify the ‘# mod 3’ section to look like following lines. This content replaces the original parameters so the original lines must be deleted. Alternatively, they can be commented out by putting a ‘#’ at the start of each line.

##################
# Sound Profiles
##################
# mod 3
if [ "$1" == "OrionV2" ]; then
# runefrost version
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
echo "(OrionV2) sound signature profile"
fi
Last edited by Discovery on 24 Jan 2017, 14:08, edited 12 times in total.
Discovery
 
Posts: 110
Joined: 06 May 2015, 08:22
Location: Cambridgeshire, UK

Re: Tweaking the audio performance Rpi3

Postby pietpara » 23 Jan 2017, 23:31

Wow! Fantastic summary, discovery!
Thank you too, together with RuneFrost, Dynobot and of course Frank.

I had already implemented the settings without the SOXR upsampling, and now I just did that.
My first experience is that it is a significant improvement. I'll have to test more, though.

One thing, however, since I activated the SOXR, I no longer have gapless playback. Anyone experience the same? Any ideas?

Also, I had isolated mpd to core 3, and I now see that it is running at about 52% cpu all the time, whereas before the SOXR up sampler it was merely 1 or 2%.
So, it clearly is calculating upsampling algorithms like mad. :lol:

Thanks!
Pietpara
pietpara
 
Posts: 48
Joined: 12 Jan 2017, 21:17

Re: Tweaking the audio performance Rpi3

Postby Frost_dk » 24 Jan 2017, 00:00

Hi Pietpara
Thank you for reporting back :)

Yes the ARM core is working when SOXR is enabled :)

I have not used gapless playback, so unfortunately I can't give you an answer.

have you implemented all the changes in this thread?
You should also try to mount the +5V and gnd directly to the GPIO instead of using the microUSB connecter. It is not the biggest change in sound quality, but it is still possible to notice a difference :) A Linear supply is also recommendable.

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

Re: Tweaking the audio performance Rpi3

Postby pietpara » 24 Jan 2017, 00:10

Hi RuneFrost,

Yes, all changes, step by step. The last was the soxr thing.
I always listen to full albums and most, or lots, are continuous, so it's really nasty to hear the gap each time with a loud pop.

The GPIO thing I may try. Is that (part of) the fboe mod?
Thing is, I'm not a soldering expert.

Cheers!
pietpara
 
Posts: 48
Joined: 12 Jan 2017, 21:17

Re: Tweaking the audio performance Rpi3

Postby Frost_dk » 24 Jan 2017, 00:17

pietpara wrote:Hi RuneFrost,

Yes, all changes, step by step. The last was the soxr thing.
I always listen to full albums and most, or lots, are continuous, so it's really nasty to hear the gap each time with a loud pop.

The GPIO thing I may try. Is that (part of) the fboe mod?
Thing is, I'm not a soldering expert.

Cheers!


Well.. I think that Fboe mentions it in his thread, but it is not that big of a mod, after all. It is only to solder 5V to pin 2 and gnd to pin 6 at the GPIO port. Thats it :)

You can see the GPIO pins here :
https://pinout.xyz/pinout/pin2_5v_power

regards.
Last edited by Frost_dk on 24 Jan 2017, 00:30, edited 1 time in total.
Frost_dk
 
Posts: 44
Joined: 23 Nov 2015, 20:39
Location: Horsens, Denmark

support RuneAudio Donate with PayPal

PreviousNext

Return to Raspberry Pi

Who is online

Users browsing this forum: Bing [Bot] and 5 guests