A convolution based alternative to electrical loudspeaker correction networks

Updates:

  • Integrated 128-bit FFTW ( Fastest FFT in the West ) convolutions
  • Integrated 64-bit FFmpeg .wav I/O to eliminate manual pre-wav2pcm and post-pcm2wav conversions and SoX's 32-bit numerical precision losses.
  • Fixed bugs/issues to allow the entire app to be built/run in 128-bit internal precision - appears to work, but not fully validated.

Now, RePhase's 64-bit FIR wav XO's can be directly used along with REW's 32-bit FIR wav sweeps without manual conversions and the generated FIR wav sets can be drag and dropped straight back into REW for post inspection and then onto the convolution engine.

Removing the manual conversion steps from the workflow should make it easier for newbies to get working and easier for everyone. My run scripts have shrunk accordingly.

Another convenience upgrade would be to use FFmpeg's resampler to output filter sets in multiple desired sample rate sets (44.1, 48, 88.2, 96, 176.4, 192).

Also, FFmpeg's generated intermediate raw pcm files are binned for inspection and validation if desired.
 
  • Like
Reactions: 1 user
Updates:
  • - Updated OCTAVE code to generically print 3 plots per page.
  • - Scripts can document the following permutations:
    • - DIRAC, Left and Right Uncorrected
    • - DIRAC, Left and Right Corrected
    • - DIRAC, Left Uncorrected / Corrected
    • - DIRAC, Right Uncorrected / Corrected
  • - Reduced OCTAVE 62 file set generation duration by over 4X.
    • - OCTAVE is single threaded, broke plots into 7 parallel sets to be run concurrently.
  • - Can generate png or PDF formats with transparencies and specify DPI resolution
  • - Updated DIRAC plots to optionally plot actual target/baseline Band Pass XO FIRs.

CLR-SSHighRange_3.png
 
Last edited:
  • Like
Reactions: 1 user
You can use sox or ffmpeg to convert between raw pcm and wav formats.

Sox has a 32-bit internal format limit, ffmpeg does not. If you are not using 64-bit, either are fine.

Since you are going from raw pcm to wav, you will have to tell sox or ffmpeg what the raw format is since raw pcm does not have a header containing the number of channels, sample rates, number of samples, numeric format and bit depth.

You will also have to tell sox or ffmpeg the destination format information so it can stash it into the wav header as well as what to convert to.

This example converts a wav file (using the information in the wav's header) to a float 32-bit, 1 channel, 44100 sample rate raw pcm file.

sox filename.wav -t f32 -r 44100 -c 1 filename.pcm

To convert the other way around, you will have to specify the type information for both the source and destination as well as the wav format.
 
Last edited:
@emailtim
Thanks. Something i'm missing...
I tried like this on CMD.

C:\Room Correction\drc-3.2.3\sample\sox-14.3.2>sox LeftSpeaker-NormalFilter.pcm -t f32 -r 48000 -c 1 LeftSpeaker-NormalFilter.wav
sox FAIL formats: no handler for file extension `pcm'

What I was trying to do was convert a pcm filter file generated by drc to a WAV file.
 
You will need something like this because sox has no clue what the pcm file contains. All it knows is that it is a file of unknown format (no embedded header describing the internal file format).

This implies YOU KNOW its internal format and you are telling sox the correct internal format of the raw pcm file.

sox -t f32 -r 48000 -c 1 filename.pcm -t f32 -r 48000 -c 1 filename.wav

You can use soxi to dump wav file header information.

You can also drag and drop the .wav file in REW to inspect it graphically. It is a better way to verify the file conversion until you get your sox commands straightened out.
 
Jriver allegedly supports raw data so you can try changing the .pcm to .raw and see if it works. But as Tim says you will have to have Jriver fixed at the sample rate of the file to have it work.

PCM is just raw 32 bit float without a header.

If you download gmad’s script from the first post they include code for Sox in the script to automatically perform this conversion. Copy that code or edit the script if you are having trouble copying it manually.
 
  • Like
Reactions: 1 user
Sorry, try the following. Had the destination type wrong, it should be "-t wav"

sox -t f32 -r 48000 -c 1 filename.pcm -t wav -r 48000 -c 1 filename.wav

Verify in REW that it is a 32-bit float wav.

This is why I am putting ffmpeg wav I/O on the Multi-Amp DRC-FIR mods. Tired of the manual conversions.
 
Last edited:
  • Like
Reactions: 1 user
@emailtim Thanks. that works. Now i can bring wav file into REW.
@fluid Yes. I downloaed GMAD's file.
And that makes PCM file. But don't make wav file for me.
In Script info (Script name is NormalFilter) (I just changed 44.1 to 48.0)

Set DRC_DIR=\Room Correction\drc-3.2.3\sample
Set CONVOLVER=\Room Correction\Convolver Filters

cd %DRC_DIR%
drc.exe --BCInFile=LeftSpeakerImpulseResponse.pcm --PSOutFile=LeftSpeaker-NormalFilter.pcm normal-48.0.drc
pause
drc.exe --BCInFile=RightSpeakerImpulseResponse.pcm --PSOutFile=RightSpeaker-NormalFilter.pcm normal-48.0.drc
pause
sox.exe -t raw -e float -b 32 -r 48000 -c 1 LeftSpeaker-NormalFilter.pcm -e signed -t wavpcm LeftSpeaker-NormalFilter.wav
sox.exe -t raw -e float -b 32 -r 48000 -c 1 RightSpeaker-NormalFilter.pcm -e signed -t wavpcm RightSpeaker-NormalFilter.wav
sox.exe -M LeftSpeaker-NormalFilter.wav RightSpeaker-NormalFilter.wav -e signed -t wavpcm NormalFilter.wav
move /y NormalFilter.wav "%CONVOLVER%
del "LeftSpeaker-NormalFilter.pcm"
del "RightSpeaker-NormalFilter.pcm"
del "LeftSpeaker-NormalFilter.wav"
del "RightSpeaker-NormalFilter.wav"
 
  • Like
Reactions: 1 user
@dingdong3 ,

Don't be afraid to drag and drop the files into REW and verify them before playing them on your hardware.
Make sure the corrections/crossovers are at the correct frequencies.
If you mix and match sample rates, it can change your crossover points and correction points (unless your convolver handles the scaling properly). 192kHz is 4X as many samples as 48kHz so it can move key points by a factor of 4.
 
@dingdong3 ,

I haven't tried using setting it that low before.

Are you using the "Test Convolution" output feature ?

If not, you can specify the "Test Convolution" TCOutFile output file, convert it to .wav in your script and then drag and drop it into REW for analysis.

This allows you to compare your input sweep against the applied solution without running it through your convolution engine.

It is a much faster way to experiment with DRC-FIR settings in addition to looking at the (un-applied) correction file in REW.

Test Convolution Doc
 
I can only imagine there is some problem in the syntax of the script/file names or that you don’t have Sox installed in the place expected. Unfortunately there is no error if there is a problem with the conversion it just doesn’t happen.

You can remove all the DRC related stuff and just test the Sox commands without rerunning drc every time.
 
I have attached a test script for you to try. Copy your left and right pcm files and rename them to LeftManual.pcm and RightManual.pcm.

You should then end up with a combined stereo wav called FlatDRC.wav in the Convolver filters folder after running the script with the intermediate files deleted..

If you are having trouble with Sox and scripts try Audacity, that is point and click and harder to get wrong :) Although maybe not...
 

Attachments

  • Sox test.zip
    355 bytes · Views: 33