This article explains how to create a room correction filter using a Slim Devices Squeezebox using Denis Sbragion's DRC tools.
This process is particularly handy for users of the BrutefirDRC plugin. It may also be useful for users of the Inguz room correction plugin as an alternative to its built-in filter recording process.
The process involves playing a sweep through your Squeezebox and simultaneously recording it on your PC using a microphone. Two sweeps are recorded, one for the left channel and one for right. Each sweep lasts less than a minute.
First you need to create the sweep.wav file using DRC's glsweep program. This command creates a sweep at 44.1kHz, at 50% full amplitude, from 5Hz to 22kHz. The sweep lasts 45 seconds. Then use sox to convert the sweep.pcm file to a .wav, and copy it to a directory which can be found from 'Browse Music Folder' on your Squeezebox
glsweep 44100 0.5 5 22000 45 2 0.05 0.005 sweep.pcm inverse.pcm sox -t raw -r 44100 -c 1 -f4 sweep.pcm -t wav -c 2 -s2 sweep.wav
If there is significant background noise then you may benefit from a longer sweep - perhaps 90 seconds.
Connect the microphone to the left channel of your sound card's Mic input. The left input channel will be used to record the room response.
Position the microphone at your normal listening position, ensuring it is approximately the same distance from both speakers. I find it easiest to use String.
For your first sweep you will be measuring the room response for your left speaker, with the right speaker silent. To do that you will need to disconnect the right channel RCA output from your squeezebox and replace it with a connection to the right channel of your sound card's Line In.
To summarize, for the sweep for the left speaker:
SB RCA Left --> Amplifier Left --> Speaker Left --> Sound Waves --> Microphone --> Mic In Left
SB RCA Right --> Line In Right
After the left sweep is complete you need to switch the RCA connections for the right speaker sweep. That gives you:
SB RCA Left --> Line In Right
SB RCA Right --> Amplifier Right --> Speaker Right --> Sound Waves --> Microphone --> Mic In Left
First, turn the SB volume right down. Play the sweep file (using 'Browse Music Folder') and gradually increase the volume to a normal listening level. Be careful with volume: Playing the sweep.wav at high volume will damage your speakers.
When the levels are right remind the family to be quiet, lock the dog out of the room, start recording, and play the sweep.wav.
Audacity can be used to record the sweep. Alternatively I prefer the ALSA command line:
arecord -D hw:2,0 -c 2 -f cd left.wav
When the sweep is complete trim the recording using audacity leaving a few seconds of silence before and after the sweep, then save it to left.wav. It should look like this. Here you can see the left channel (The uneven top trace) contains the room response recorded by the microphone. The right channel contains the reference signal recorded directly from the Squeezebox.

Now is a good time to check levels. The traces should not be much smaller than shown above, and neither should they be close to clipping.
When you have a good sweep in left.wav, switch the RCA connections and record a right.wav without moving the microphone or adjusting levels.
When you are complete it is a good idea to delete sweep.wav right away. Before it turns up in a random mix.
It is probably best to record your first few sweeps as described above. But once you have done it a few times the process quickly becomes tedious, particularly if the computer and squeezebox are not in the same room.
It is possible to automatically start the squeezebox playing the sweep while getting alsa to record for exactly the right duration using:
echo -e "00:00:00:00:00:00 playlist play /path/to/my/sweep.wav\nexit\n" | nc localhost 9090;arecord -D hw:2,0 -c 2 -f cd -d 60 right.wav
Replace 00:00:00:00:00:00 with your player's MAC address. The -d 60 switch sets it recording for 60 seconds - a little longer than the sweep duration.
The room's impulse response needs to be calculated from left.wav, right.wav, and the inverse.pcm file which was generated at the same time as your sweep.wav. Here we use sox to extract the pcm data from the two wav files, then DRC's lsconv program:
sox left.wav -t raw -c 1 -f4 recorded-l.pcm mixer -l sox left.wav -t raw -c 1 -f4 reference-l.pcm mixer -r sox right.wav -t raw -c 1 -f4 recorded-r.pcm mixer -l sox right.wav -t raw -c 1 -f4 reference-r.pcm mixer -r lsconv sweep.pcm inverse.pcm impulse-l.pcm reference-l.pcm 0.1 0.8 lsconv sweep.pcm inverse.pcm impulse-r.pcm reference-r.pcm 0.1 0.8
If you are not familiar with DRC and do not already have a preferred DRC configuration:
Copy /usr/local/share/drc/config/soft.drc into the same directory as your measurement files. (other .drc files are available, but soft.drc is a good starting point.)
Copy a microphone calibration file from /usr/local/share/drc/mic which matches your microphone, and change the MCPointsFile line in soft.drc to refer to this file name. If your microphone is not mentioned then use a flatmic.txt file containing:
0.0 0 0 22050.0 0 0Copy a target frequency response file from /usr/local/share/drc/target and change the PSPointsFile line in soft.drc to refer to this file name. bk-3-spline.txt may be a good starting point.
The DRC manual contains more information on its configuration which is beyond the scope of this document.
DRC needs to be run twice, once for each channel:
drc --BCInFile=impulse-l.pcm --PSOutFile=filter-l.pcm --TCOutFile=test-l.pcm soft.drc drc --BCInFile=impulse-r.pcm --PSOutFile=filter-r.pcm --TCOutFile=test-r.pcm soft.drc
Finally, the files filter-l.pcm and filter-r.pcm can be used in a BruteFIR filter.
It is sometimes interesting to review the frequency response of a filter (filter-l.pcm), of the room's uncorrected response (impulse-l.pcm), or of the theoretical corrected response (test-l.pcm) using Room EQ Wizard.
The floating point .pcm files loved by DRC must first be converted to integer .wav files for use in REW. The -v switch adjusts amplitude - you may need to adjust this (check in audacity). The impulse files need 45 seconds of silence trimmed from the start. This also may need to be changed to match your sweep duration:
sox -t raw -r 44100 -v 20 -c 1 -f4 impulse-l.pcm -t wav -c 1 -s2 int/impulse-l.wav trim 45 sox -t raw -r 44100 -v 20 -c 1 -f4 impulse-r.pcm -t wav -c 1 -s2 int/impulse-r.wav trim 45 sox -t raw -r 44100 -c 1 -f4 filter-l.pcm -t wav -c 1 -s2 int/filter-l.wav sox -t raw -r 44100 -c 1 -f4 filter-r.pcm -t wav -c 1 -s2 int/filter-r.wav sox -t raw -r 44100 -v 0.8 -c 1 -f4 test-r.pcm -t wav -c 1 -s2 int/test-r.wav sox -t raw -r 44100 -v 0.8 -c 1 -f4 test-l.pcm -t wav -c 1 -s2 int/test-l.wav
The procedure described in this article may also be of advantage to users of the Inguz DRC plugin, instead of the InguzTools package. Key advantages of this approach include:
- You can adjust the sweep duration. A longer sweep may help if your listening environment has background noise.
- You can adjust the sweep start and end frequency to include (or exclude!) the subsonic range.
- Inguz attempts to correct for inter-channel delay, however the process described above adjust each channel independantly and leaves inter-channel delay untouched. Whether each approach is an advantage depends on whether you see inter-channel delay as something worth correcting, or an artifact of your microphone positioning.
- The DRC tools are much faster (2 minutes vs 15 minutes on my AMD Athlon(tm) XP 2400+) and use less memory than InguzTools. (InguzTools needs 2G RAM)
- All open source
Inguz users on Windows wont be able to use the the arecord command line to record the sweep but everything else described above should just work. Windows builds of sox are available.
Search eBay for music matching your last.fm profile.
www.exitahead.co.uk
Amakode; a media transcoding script for Amarok 1.4. September 2008.
Generating filters for BrutefirDRC. June 2008.
Dependency graphs for Python programs. September 2004.
Using the dvorak keyboard layout to beat acheing forearms. August 2004.
Using spambayes to handle spam email in kmail. July 2004.