• WANTED: Happy members who like to discuss audio and other topics related to our interest. Desire to learn and share knowledge of science required. There are many reviews of audio hardware and expert members to help answer your questions. Click here to have your audio equipment measured for free!

Room correction - Linux

dasdoing

Major Contributor
Joined
May 20, 2020
Messages
4,208
Likes
2,673
Location
Salvador-Bahia-Brasil
run a 0dBfs sweep through the convolver to ajust the gain (digital peak meter on the output).
that way you never clip, though it is overkill imo. there will never be a 0dBfs tone at 2000Hz for example. I ajust by playing music and keep a look at the meter
 
OP
Lilith

Lilith

Active Member
Joined
Mar 28, 2021
Messages
267
Likes
79
Super happy with drc btw. :)
 

bcurtin

Member
Joined
Oct 9, 2019
Messages
28
Likes
11
Here's the bash script I use to run drc-fir:

Bash:
#!/bin/bash

IMPULSE_FILE="$1"
FILTER_NAME="$2"
CONFIG="$3"
DRC_DIR="/usr/share/drc"
DRC="/usr/bin/drc"
MIC_CORRECTION="$HOME/drc/mic/7032857-mod.txt"
TARGET_DIR="$DRC_DIR/target"
CONFIG_DIR="$DRC_DIR/config"
NFILTERS=8
TARGET_TYPE="pa"
TEMP_DIR="$(mktemp -d tmp.XXXX)"
trap "rm -rf $TEMP_DIR" EXIT

RATE=44100
FILTER_DIR="$FILTER_NAME"
mkdir -p "$FILTER_DIR"
MAX_GAIN=2
RATE_STRING="$((RATE/1000)).$((RATE%1000/100))"
CONFIG_FILE="$CONFIG_DIR/$RATE_STRING kHz/$CONFIG-$RATE_STRING.drc"
TARGET_FILE="$TARGET_DIR/$RATE_STRING kHz/$TARGET_TYPE-$RATE_STRING.txt"

for i in 0 1; do
  sox "$IMPULSE_FILE" -t f32 "$TEMP_DIR/impulse.pcm" remix $((i+1)) rate -v -L -s $RATE
  $DRC --BCInFile="$TEMP_DIR/impulse.pcm" \
    --PSOutFile="$TEMP_DIR/filter_$i.pcm" \
    --PSPointsFile="$TARGET_FILE" \
    --MCFilterType=M \
    --MCPointsFile="$MIC_CORRECTION" \
    --PLMaxGain="$MAX_GAIN" \
    --TCOutFile="$TEMP_DIR/predicted_$i.pcm" \
    "$CONFIG_FILE" | tee "$TEMP_DIR/output_$i.txt"
done

echo
cat "$TEMP_DIR"/output_[01].txt | grep 'Filtered signal RMS level'

sox -M -t f32 -r $RATE -c 1 "$TEMP_DIR/filter_0.pcm" \
       -t f32 -r $RATE -c 1 "$TEMP_DIR/filter_1.pcm" \
       "$FILTER_DIR/$FILTER_NAME-$CONFIG.wav"
     
sox -M -t f32 -r $RATE -c 1 "$TEMP_DIR/predicted_0.pcm" \
       -t f32 -r $RATE -c 1 "$TEMP_DIR/predicted_1.pcm" \
       "$FILTER_DIR/$FILTER_NAME-$CONFIG-predicted-response.wav"

The arguments it takes are the impulse response as a stereo wav file (I use REW to measure it), the name your filter will have, and the name of the drc-fir "preset" (one of: erb, minimal, soft, normal, strong, extreme, insane). It outputs the filter and a the predicted response as stereo wav files to to a directory with your filter name in the current working directory.

Note that I use just one sample rate in my setup, so if you may need resample the filter with sox for your own setup.

Are there any considerations or requirements for using REW to generate and measure the impulse response? For example, should any averaging be applied before exporting the impulse response?

I've gotten this flow working but noticed that DRC-FIR is preparing some tight filters at higher frequencies, which could indicate that the settings for erb/normal DRC correction are allowing this or that it's trying to correct high frequency noise that's usually averaged out.
 

Daverz

Major Contributor
Joined
Mar 17, 2019
Messages
1,294
Likes
1,451
Are there any considerations or requirements for using REW to generate and measure the impulse response? For example, should any averaging be applied before exporting the impulse response?

I've gotten this flow working but noticed that DRC-FIR is preparing some tight filters at higher frequencies, which could indicate that the settings for erb/normal DRC correction are allowing this or that it's trying to correct high frequency noise that's usually averaged out.

No, I don't believe you want to do any averaging for DRC-FIR, just a carefully aligned single point measurement. I use a Stabila laser ranger to align my mic between the speakers. DRC-FIR does its own psychoacoustic smoothing of the high-frequency response. You might ask on the DRC-FIR mailing list, though.


EDIT: make sure you use either a loopback signal (if possible) or an acoustic timing signal in REW to get a time aligned impulse response.
 
Last edited:

bcurtin

Member
Joined
Oct 9, 2019
Messages
28
Likes
11
No, I don't believe you want to do any averaging for DRC-FIR, just a carefully aligned single point measurement. I use a Stabila laser ranger to align my mic between the speakers. DRC-FIR does its own psychoacoustic smoothing of the high-frequency response. You might ask on the DRC-FIR mailing list, though.


EDIT: make sure you use either a loopback signal (if possible) or an acoustic timing signal in REW to get a time aligned impulse response.
Thanks! Is there a way to export the acoustic timing signal from the REW impulse response sweep? It didn't look like DRC found the impulse response in the sweep that I collected, so wasn't sure if this was exported by default.
 

Daverz

Major Contributor
Joined
Mar 17, 2019
Messages
1,294
Likes
1,451
Thanks! Is there a way to export the acoustic timing signal from the REW impulse response sweep? It didn't look like DRC found the impulse response in the sweep that I collected, so wasn't sure if this was exported by default.

If you used the acoustic timing signals, REW will take care of all that for you. The timing chirps are used just for that: aligning the impulse response and adjusting for any clock skew. They are discarded after that. You just need to export the impulse response as a 32-bit float WAV file and then convert them to raw 32-bit bin files with, for example, sox.
 

digitalfrost

Major Contributor
Joined
Jul 22, 2018
Messages
1,521
Likes
3,086
Location
Palatinate, Germany
You should absolutely not average with DRC-FIR, in fact you have the opposite problem. From the manual:

"4.6.5 Interchannel time alignment

First of all the current DRC release is able to compensate for interchannel misalignment of only few samples, no more than ± 8 with the default configuration files. "

8 samples at 48khz are:

(1/48000) * 8 = 0.0001666666 seconds. That is 166us or 0.16ms.

343m/s (speed of sound) * 0.00016s = 0.0549m = 5.49cm

So that is the max distance you can have in total difference between the left and right speaker. In other words, you mic should be pretty much in the center.

I always check with REW or Holmimpulse that the mic is in the (acoustic) center. You can check where the peak is and then move the mic left or right until you get difference down.
 
OP
Lilith

Lilith

Active Member
Joined
Mar 28, 2021
Messages
267
Likes
79
You should absolutely not average with DRC-FIR, in fact you have the opposite problem. From the manual:

"4.6.5 Interchannel time alignment

First of all the current DRC release is able to compensate for interchannel misalignment of only few samples, no more than ± 8 with the default configuration files. "

8 samples at 48khz are:

(1/48000) * 8 = 0.0001666666 seconds. That is 166us or 0.16ms.

343m/s (speed of sound) * 0.00016s = 0.0549m = 5.49cm

So that is the max distance you can have in total difference between the left and right speaker. In other words, you mic should be pretty much in the center.

I always check with REW or Holmimpulse that the mic is in the (acoustic) center. You can check where the peak is and then move the mic left or right until you get difference down.

You mean with peak the maximum volume or is there any method implemented in REW to find the center?
 

bcurtin

Member
Joined
Oct 9, 2019
Messages
28
Likes
11
You should absolutely not average with DRC-FIR, in fact you have the opposite problem. From the manual:

"4.6.5 Interchannel time alignment

First of all the current DRC release is able to compensate for interchannel misalignment of only few samples, no more than ± 8 with the default configuration files. "

8 samples at 48khz are:

(1/48000) * 8 = 0.0001666666 seconds. That is 166us or 0.16ms.

343m/s (speed of sound) * 0.00016s = 0.0549m = 5.49cm

So that is the max distance you can have in total difference between the left and right speaker. In other words, you mic should be pretty much in the center.

I always check with REW or Holmimpulse that the mic is in the (acoustic) center. You can check where the peak is and then move the mic left or right until you get difference down.
Maybe more of a practical question, but how does this apply to listening in different positions? Is compensating for interchannel misalignment important for establishing proper filters for each channel by time aligning the impulse response, and are these only valid for a position within a ~6 cm window around the listening position?

In the past I've used the MMM with pink noise and an RTA for room correction with mixed success. This is my first pass at attempting to use a measured impulse response/DRC-FIR, and it seems like this technique would create more position-specific filters.
 

Daverz

Major Contributor
Joined
Mar 17, 2019
Messages
1,294
Likes
1,451
Maybe more of a practical question, but how does this apply to listening in different positions? Is compensating for interchannel misalignment important for establishing proper filters for each channel by time aligning the impulse response, and are these only valid for a position within a ~6 cm window around the listening position?

In the past I've used the MMM with pink noise and an RTA for room correction with mixed success. This is my first pass at attempting to use a measured impulse response/DRC-FIR, and it seems like this technique would create more position-specific filters.

You may have already read this, but in the docs Denis says about the erb config file:

"This file provides an accurate approximation of the ERB psychoacoustic scale (see figure 8). It is important to notice that basically the correction isn’t much stronger than the “minimal.drc” sample configuration, but being approximately tuned to our ear psychoacoustic resolution it is probably going to provide a good perceived correction accuracy with minimal listening position sensitivity, and so it is well suited for multiple listeners situations, like home theater applications."

 

digitalfrost

Major Contributor
Joined
Jul 22, 2018
Messages
1,521
Likes
3,086
Location
Palatinate, Germany
You mean with peak the maximum volume or is there any method implemented in REW to find the center?
You can see the delay on the left side for example "Delay -0,049±0,010 ms (-17 mm, -0,66 in) using estimated IR delay relative to Acoustic reference"

You compare this between both channels and get it as close (identical) as you can, then it is in the acoustic centre.

Maybe more of a practical question, but how does this apply to listening in different positions? Is compensating for interchannel misalignment important for establishing proper filters for each channel by time aligning the impulse response, and are these only valid for a position within a ~6 cm window around the listening position?

In the past I've used the MMM with pink noise and an RTA for room correction with mixed success. This is my first pass at attempting to use a measured impulse response/DRC-FIR, and it seems like this technique would create more position-specific filters.
The accuracy requirements of the measurements have nothing to do with listening positions. How strong/position dependend the correction is depends on the software and settings used. It is important for the quality of the filters generated, but it does not mean the correction is only valid for a 6cm window.

Btw. Acourate also has this requirement http://archimago.blogspot.com/2015/11/measurements-digital-room-correction.html See "You know you're in the right place when "Delay in samples" is 0 and green as shown above."
 

Daverz

Major Contributor
Joined
Mar 17, 2019
Messages
1,294
Likes
1,451
You can see the delay on the left side for example "Delay -0,049±0,010 ms (-17 mm, -0,66 in) using estimated IR delay relative to Acoustic reference"

You compare this between both channels and get it as close (identical) as you can, then it is in the acoustic centre.

The accuracy requirements of the measurements have nothing to do with listening positions. How strong/position dependend the correction is depends on the software and settings used. It is important for the quality of the filters generated, but it does not mean the correction is only valid for a 6cm window.

Btw. Acourate also has this requirement http://archimago.blogspot.com/2015/11/measurements-digital-room-correction.html See "You know you're in the right place when "Delay in samples" is 0 and green as shown above."

By the way, Acourate now has a "Moving Mic Recorder" mode, which I have not tried.
 

digitalfrost

Major Contributor
Joined
Jul 22, 2018
Messages
1,521
Likes
3,086
Location
Palatinate, Germany
holmimpuse.png



Found this old screenshot from Holmimpulse, it makes it really easy to center the mic. You can also center it first with Holm and then measure with REW afterwards.

- [Device & Singal]
- Setup how you need it sources etc...
- (o) Square Noise (Improved MLS)
- [Measurements]: At A press measurement (left/right channel doesn't matter)
- Go back to [Data Analysis] -> (o) Time zero locked [Use] (this will put T0 to the first peak and lock it there)
- [Device & Signal] -> Select the other channel that you didn't measure yet, then go back to [Measurements] and as B measure it
- You can now zoom into the impulse response
- Move the microphone until the differences between the impulses is less than 5.5cm.

Obviously you have to repeat the measurements if you move the mic and also reset Time zero locked before the first new measurement to get a new T0.
 
Last edited:

bcurtin

Member
Joined
Oct 9, 2019
Messages
28
Likes
11
I've spent some time playing with DRC after time aligning speakers and am pretty happy with the results. I haven't had a chance to measure some of the corrected impulse responses, but will follow up once I get some measurements. The uncorrected frequency response is below:
SPL_initial.jpg

Had a few questions in the meantime:
  • All the default configuration files include full BW correction, and target files (except for ones that have subsonic filters) go down below the lowest frequency my speakers support. I'd limit the correction range in REW to avoid gain filters < 35 Hz but it seems like the only ways to do this with DRC is to create custom target files or modify the frequency range for each stage in DRC.
  • Built-in BK target curves with the normal configuration all sound pretty neutral. The uncorrected sweep shows an uneven, boosted lower end with some bad room modes, so maybe I'm just used to more pronounced bass. Could this be something with the correct/config file, or would it make sense to look into different targets with more tilt/low end gain?
 

digitalfrost

Major Contributor
Joined
Jul 22, 2018
Messages
1,521
Likes
3,086
Location
Palatinate, Germany
Both the configurations files and the target curves affect how it will sound in the end. It's definitely worth it to tune both. I would start with the target curve because it is much easier.
Note that due to frequency dependend windowing the correction strength is also related to the window length so it makes little sense to compare target curves without knowing the other parameters. Still I will attach mine so you can try it.

The easiest way remove content below a certain frequency is with the target curve. Here you can see I've set a subsonic filter at 30hz.

Code:
0 -40.0
28 -20.0
29 2.49
35 2.49
41 2.47
47 2.46
53 2.43
59 2.4
64 2.35
70 2.29
76 2.23
82 2.14
88 2.05
94 1.95
100 1.84
105 1.72
111 1.6
117 1.48
123 1.37
129 1.25
135 1.14
141 1.04
147 0.94
152 0.85
158 0.77
164 0.69
170 0.63
176 0.56
182 0.51
188 0.46
193 0.42
199 0.38
205 0.34
211 0.31
217 0.28
223 0.26
229 0.23
234 0.21
240 0.19
480 0.0
20000 -7.5
22000 -40.0
24000 -100.0

This is for 48khz, adjust accordingly. Also, take a look at the peak limiting settings especially PLStartFreq and and PLMaxGain to influence how much boost you will get in the bass.

The simplest way to make a target curve yourself is to start thinking in db/oct and adjusting the tilt in 0.1db increments - this is easily audible over the whole frequency range. I would wager you will end up with a tilt between 0.67-1.1db/oct.
My curve is a bit more elaborate with a configurable bass boost and as you can see I use a knee at 480hz for the high frequency tilt.

If you want less correction for the high frequencies, instead of simply making a hard cut by changing the *EndFreq parameters, you can make MPUpperWindow and RTUpperWindow smaller. Be aware that you might have to turn down EPUpperWindow as well. I like to use much less excess phase correction than the rest because too much will collapse the soundstage depth (I use 5 cycles).
Or you can play with the window exponents as layed out in the manual.

Figure_1.png
 
Last edited:

dasdoing

Major Contributor
Joined
May 20, 2020
Messages
4,208
Likes
2,673
Location
Salvador-Bahia-Brasil
here you go. strong conf with flat target

drc.jpg


I recomend reading the PTT part of the documentation. if you use it it makes no sense to put a house curve. it actualy creates a house curve
 

digitalfrost

Major Contributor
Joined
Jul 22, 2018
Messages
1,521
Likes
3,086
Location
Palatinate, Germany
Interesting. I always had this enabled. I can hear a difference with it off, however since I've tuned my curve with this on, obvisously I prefer it. The differences are not huge. With it off, I have less bass and more highs than with it on.
 
Top Bottom