[Guide] High quality room correction with Raspberry Pi & Roon


(ulub81) #1

Hi,

I want to share my results about using room correction filters on Raspberry Pi together with Roon.

To put it in a nutshell, this gave me the biggest improvement in audio quality ever (way better than using for example a linear power supply, better audio interface or software tools like HQ-Player)!!

Not so long ago this feature costs thousands of bucks (€, $, …) and nowadays is still expensive (for example: MiniDSP). Therefore it is really amazing to implement such a feature with just a small Raspberry Pi!

My audio setup:
Raspberry Pi 3 running Roon Bridge, HifiBerry Digi+ Pro (with linear power supply), Nubert Nupro A-700

More info what this is all about:
Digital room correction


Here the steps (login on the Pi via SSH):

Create room correction filter:

This is the crucial part, because to get good results you need really good room correction filters. I use the software Acourate Pro together with a calibrated microphone (Behringer ECM8000, number of filter taps: 131.072).
Further instructions on how to measure your room with Acourate you can find here.

Setup up your Raspberry Pi with Roon-Bridge ( I used Raspbian Jessie-Lite)

First do update the Pi:
sudo apt-get update
sudo apt-get upgrade
sudo rpi-update

Reboot the Pi:
sudo reboot

Setup audio path for applying room correction filters on the roon-bridge player output:

Audio path looks like this:
Roon-Bridge->Room correction filtering->Output device

For this I use the Alsa Loopback Device, this routes audio to an virtual audio input device.

Audio path is then:
Roon-Bridge->Alsa Loopback out->Alsa Loopback in->Room correction filtering->Audio output device (In my case Hifiberry Digi+ Pro)

Create Alsa Loopback device:
sudo modprobe snd-aloop

Make it boot persistent:
sudo nano /etc/modules
Add snd-aloop and save file.

Install room correction software:

For this I use BruteFIR.

Install BruteFIR:
sudo apt-get install brutefir

Configure room correction filtering:

Create a folder /home/brutefir to store the filtering configuration and filters:
dir home
mkdir brutefir

Create a file brutefir_config to store the filtering configuration:
dir brutefir
sudo nano brutefir_config

Here my configuration (insert and save it):

## DEFAULT GENERAL SETTINGS ##

float_bits: 64;             # internal floating point precision
#sampling_rate: 44100;       # sampling rate in Hz of audio interfaces
filter_length: 8192,16;       # length of filters
#config_file: "~/.brutefir_config"; # standard location of main config file
overflow_warnings: true;    # echo warnings to stderr if overflow occurs
show_progress: false;        # echo filtering progress to stderr
max_dither_table_size: 0;   # maximum size in bytes of precalculated dither
allow_poll_mode: false;     # allow use of input poll mode
modules_path: ".";          # extra path where to find BruteFIR modules
monitor_rate: false;        # monitor sample rate
powersave: true;           # pause filtering when input is zero
lock_memory: true;          # try to lock memory if realtime prio is set
sdf_length: -1;             # subsample filter half length in samples
safety_limit: -0.01;           # if non-zero max dB in output before aborting
convolver_config: "~/.brutefir_convolver"; # location of convolver config file

## COEFF DEFAULTS ##

coeff "c-l" {
   filename: "/home/brutefir/Cor1L44.dbl";
   format: "FLOAT64_LE";
};

coeff "c-r" {
   filename: "/home/brutefir/Cor1R44.dbl";
   format: "FLOAT64_LE";
};

## INPUT DEFAULTS ##
#
input "left_in", "right_in" {
        device: "alsa" { device: "hw:0,0"; ignore_xrun: true; };
#	sample: "S16_LE";
};

## OUTPUT analog
#
output "left_out", "right_out" {
        device: "alsa" { device: "hw:2,0"; ignore_xrun: true; };
#	sample: "S16_LE";
	dither: true;
};

## FILTER DEFAULTS ##

filter "drc_l" {
   from_inputs: "left_in";
   to_outputs: "left_out";
   coeff: "c-l";
};

filter "drc_r" {
   from_inputs: "right_in";
   to_outputs: "right_out";
   coeff: "c-r";
};

Configure it to your needs and test it

(More on configuration here)
To get the correct audio device (for example: device: “hw:2,0”):
aplay -l
Now set the correct input and output audio device in the brutefir_config (input is loopback device, output your output audio device).

Then transfer the correction filter files to /home/brutefir and configure it in the brutefir_config.

coeff "c-l" {
   filename: "/home/brutefir/Cor1L44.dbl";
   format: "FLOAT64_LE";
};

coeff "c-r" {
   filename: "/home/brutefir/Cor1R44.dbl";
   format: "FLOAT64_LE";
};

For transfer I use the software WinSCP.

If everything is configured now start the room correction filtering (brutefir stops if you close session):
brutefir /home/brutefir/brutefir_config

Configure the audio output in Roon to the correct output (Loopback PCM) and play some music.

Now you should enjoy really better sounding audio!

Autostart room correction filtering on startup:

If everything works fine add brutefir to Autostart:
sudo nano /etc/rc.local
Add brutefir /home/brutefir/brutefir_config and Save


You can now have room corrected audio when using Loopback PCM in Roon and unfiltered audio if you select your previous audio device (stop brutefir for this)!

Let me know about your experience!

Enjoy the music! :slight_smile:


Roon Bridge and ALSA
(Rene Bouwmeester) #2

Great guide – thanks for sharing!

Modprobe? :slight_smile:


(ulub81) #3

yes! thanks, I already corrected it! :slight_smile:


(Joachim Herbert) #4

Brilliant. Will try as soon as my living room is cleared of stuff I am putting on sale (which may take a while :slight_smile:).

I will try filters generated with acourate and compare these to my lyngdorf tdai2200.


(Andrew Cox) split this topic #6

5 posts were split to a new topic: Hi-Fi Berry question


(Peter) #8

This looks interesting, has anyone compared the output versus using Roon’s built-in DSP convolution engine? Thanks in advance. (I am one Pacific Ocean away from my system at the moment…)