User:OlafMarzocchi
From DRC
DRC and Mac OS X: success!
Contents |
Hardware setup
I started this process mostly to experiment, so I wanted to test DRC with a pair of medium-low quality loudspeakers, taken from an Aiwa Hi-Fi of the early '90s, I am currently using with my computer.
They have 30 W of maximum power (I don't even remember "which" power the value is referring to), 3 way, bass reflex. You can see one of them, the desk and the room arrangement in the following pictures (don't laugh).
The room is arranged as in the following drawing:
As audio amplifier I use a T-Amp with a 70 W switching power supply.
To measure the impulse response, I used a Behringer ECM8000 microphone, a Behringer UB802 mixer and a Griffin iMic as USB audio input (my laptop has no audio inputs).
I measured the distance of the microphone from the window, from the wall behind and from the floor, in order to be able to reproduce the measurements. They are, respectively: 135 cm, 170 cm, 115 cm. The wall behind has a painting on clothe, so I think it could absorb some of the high frequencies.
The different components have been connected as shown in the following picture (you can find more details in the Wiki, the setup is a simple setup with reference channel):
The system shown in the previous image has four independent variables: audio volume output from the laptop, T-Amp volume, microphone gain ("Invisible mic") in the UB802 mixer, iMic input gain. I always kept the "Main" and "Level 1" gains of the UB802 to 0 dB. Moreover, when using a device with stereo capabilities (iMic or audio output of the laptop), I always kept left and right channels balanced, so same volume or gain.
The details about choosing the values of these variables are in the next section.
Software setup
There is no "Adobe Audition" under Mac OS X, so I used Audacity, an open source replacement.
First I decompressed DRC, then I opened the Makefile and selected the Mac OS X compiler flags. I then compiled everything and created the sweep audio file and its inverse, with the standard parameters suggested by the glsweep help. I only changed the amplitude, from 0.5 to 0.8, to get more dynamic range and to have a stronger sound, so that I could lower the T-Amp volume a bit, while keeping the same decibels in the air.
I then opened the sweep file in Audacity by selecting "Import RAW" and then 32 bit float, no endianness, 0 bytes of headers, 44100 Hz, 100%. In the Audacity preferences I checked the option "Play the other tracks while recording", but removed the checks from "Hardware play-through" and from "Software play-through".
The project was set up to 44100 Hz, since my integrated audio card can handle only that frequency and I didn't want any resampling.
Recording the sweeps
First I tried to lower the iMic gain as much as possible: below a certain value, the noise dropped only slightly, but the recorded volume much more, so I had to find a balance. I did it by using "Mac the Scope", an oscilloscope software you can use for free for some minutes.
Once I found the optimal balance, I played the sweep until I found an output audio volume able to avoid clipping in the reference channel. Once fixed this value, I played some portions of the sweep while increasing the T-Amp volume, until I found a quite powerful level, enough to make the outside noise no more important.
Next step is finding the microphone gain of the UB802. It was not difficult: I already knew which art of the spectrum was the loudest (100-200 Hz), so I played it a couple of times and I immediately set up the gain to a value which avoided clipping.
Once done these tests, I started a "Timer recording", so that I could go away from the room and avoid having my ears destroyed (I'm not used to high volume sounds). I set up the recording time to exactly the same length of the sweep file (with a 45 seconds sweep, I had a 52 seconds recording, due to the silence at the start and at the end).
I did this step twice, to get both audio channels. While doing this, I selected "Solo" in the sweep track, in order not to play the previous recording as well!
Correction impulse generation
Once I got all the recordings, I zoomed a lot, until I was able to see each audio sample, and I hecked the audio tracks length, to be sure they were all equal in length. Doing this is easy: put the cursor in the sweep track, from one of the menu items choose to position the cursor at the end, then, in the bottom of the Audacity window, choose to show the position in samples, instead of hours/minutes/seconds-milliseconds. Put then the cursor at the end of one of the recorded tracks (always with the menu item, not by hand), then use the input fields in the bottom of the Audacity window to select the audio track from the end of the sweep track to where the cursor is currently positioned.
Remember: add one sample t the value you wrote down before, because you want to keep all the tracks equally long. Then repeat with the other recording.
The next step is exporting. First split the recordings to dual mono tracks, so that you can select the left and right channels independently. Export then all the four mono tracks, one per file, into a Headerless RAW file. The procedure to accomplish this depends on the Audacity version, with the current 1.3.3 beta you have to export, then choose "Other uncompressed types", and then format "Other", header "RAW (header-less)", encoding "32 bit float".
I then executed DRC with normal settings and obtained the two correction files. I opened them with Audacity and trimmed at the end where there was only silence. You can easily find it by displaying the audio wave with decibel scale, and by choosing in the Audacity preferences 96 dB as decibel scale range. My impulse was silence after about 10k samples, so I cut at sample 16384. If you will follow this tutorial completely, you can cut the impulse file at samples multiple of 4096, since the convolver sees blocks of 4096 samples. Of course, if you see the main spike of the impulse at about half impulse, things will be different…
Once done with the impulse shortening, export it as Microsoft WAV file, 32 bit float. Try to put both channels on it, it's not difficult.
Final convolution
Mac OS X 10.4 and a user with administrator privileges arerequired, I will also assume you are using a 2 channels audio device. If you don't use a 2 channel device, guess the differences.
Download LAConvolver and install it. Download Soundflower and Soundflower Bed, install them (you need to reboot).
Download and install XCode or get somewhere else the "AU Lab" application, locate AU Lab and execute it. Execute "Audio Midi Setup", it is included in the standard Mac OS X installation, with administrator rights. From it, create a new "aggregate device" (there is a menu item) with the output device you plan to use and with Soundflower 2ch. Arrange them (drag and drop) so that Soundflower comes before the other device. Then select this new device as default audio output.
In AU Lab, you are prompted to set up a new project. Choose the new aggregate device as device, choose the channels 1 and 2 as inputs, channels 3 and 4 as outputs. Accept the settings.
Now, go to the preferences and disable the new project prompt at the start o the application :-), then load the LAConvolver as the first effect of the output column. You will see now the convolver settings window. Select channel 1, load the impulse, apply. Select channel 2, load the same impulse, select second channel of the impulse, apply.
Now lower the gain of the convolver of about 7-8 dB, in order to compensate for the filter effects. This will not avoid clipping, if you want to always avoid it, you have to select the appropriate option in the convolver settings. Now hide some VU meters to save cpu power and save the project. Everything should already be working, but go to the AU Lab preferences, Devices, select the aggregate device, select 4096 in the drop-down list on the right. The more frames you choose, the lower the processor power required, the higher the delay of the sound. 4096 means a delay of about 185 ms, but of course you also need to take into account the impulse delay, so you will get from 200 ms to almost 1 second, it depends on the impulse you generated.
Depending on your processor, you may want to lower the cpu power given to AU Lab, from the standard 100% to 50%, for a G4 at about 1 GHz. It is the maximum power AU Lab will use, not the constant power. If you are too strict, you will get errors (yellow warning triangle in the main AU Lab window). The higher the percentage of cpu power, the higher the delay.
You can put the saved AU Lab file in the Dock, so you don't have to start the application by hand.
By lowering the Soundflower and AU Lab/Soundflower buffers to 256 and 512 samples I managed to get only 200 ms of delay. It is too much for films and such, but it is ok for every other sound, plus I can set the audio delay in VLC, so I have no problems at all.
The processor power used by Soundflower+AU Lab+various kernel things needed for the process is about 40% on my 1 GHz iBook G4, but only 5% is used by the convolver itself, so the filter length is not very important.
A comparison of the frequency response before and after the correction (as calculated from the convolved Dirac impulse, not measured directly):
Downside of this working chain: you cannot set the volume with keyboard keys, so use Audio MIdi Setup instead. I simply set the audio volume to 0.60 for both channels, then I use the T-Amp volume for the adjustments.
Olaf Marzocchi (My e-mail address is my name @ surname .net)






