soxequalizer

How do I create a equalizer curve using sox


I have been shown how to filter a noisy audio track using Audacity. Audacity forum link here

Audacity accepts python script commands however not for the crucial noise reduction function. I have looked for a command line tool to do this process and SoX appears to be suitable.

The 1st step in Audacity is to apply the following: Effect > Filter Curve > Manage > Factory Presets > Telephone Filter

Reading the SoX manual - SoX does not provide a filter curve. SoX does however provide this.

equalizer frequency[k] width[q|o|h|k] gain Apply a two-pole peaking equalisation (EQ) filter. With this filter, the signal-level at and around a selected frequency can be increased or decreased, whilst (unlike band-pass and band-reject filters) that at all other frequencies is unchanged. frequency gives the filter’s central frequency in Hz, width, the band-width, and gain the required gain or attenuation in dB. Beware of Clipping when using a positive gain. In order to produce complex equalisation curves, this effect can be given several times, each with a different central frequency.

Is this the right SoX function to use? How do I use this function to achieve the EQ curve?


Solution

  • I guess you must've found the answer elsewhere by now, but this is how I do it:

    for file in *.flac; do sox "$file" "rha_$file" -S norm -7.3 equalizer 28 0.91q +6.7 equalizer 4585 1.17q -9.4 equalizer 5356 3.33q +8.4 equalizer 6627 1.58q +7.5 equalizer 11297 1.62q +6.2; done
    

    The norm is to normalize the file to -7.3dB.

    sox also accepts an effects file, so you could instead also write

    for file in *.flac; do sox "$file" "rha_$file" -S blabla.txt; done
    

    with blabla.txt containing

    norm -7.3 equalizer 28 0.91q +6.7 equalizer 4585 1.17q -9.4 equalizer 5356 3.33q +8.4 equalizer 6627 1.58q +7.5 equalizer 11297 1.62q +6.2
    

    or the effects you want to use in this format. Also, the effects file should end with a newline as far as I know; otherwise it doesn't do anything.