SOX mcompand crossover algorithm?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear all,


I am currently trying to emulate some of the sox effects by
scripting them in Reaper.  I need those for exactly mirroring
an external effects chain in sox within a DAW.

For most of the effects reprogrammed, this works fine
(the results are bit-exact).

But I have significant problems with mcompand.

mcompand uses a 4-th order Linkwitz-Riley-filter for
crossovers.  I am able to reproduce the crossover algorithm
quite faithfully, but nevertheless I am not convinced about
the filter coefficients.

sox biquad filters produce the following IIR coefficients
for a sample rate of 44.1kHz and a crossover frequency of
1kHz (the numbers gained by checking the source-code):

    ======================================
    butterworth 2 biquad filters from sox:
    ======================================
    lb = [ 4.604E-03,  9.208E-03, 4.604E-03 ]
    hb = [ 9.042E-01, -1.808E+00, 9.042E-01 ]
    a  = [ 1.000E+00, -1.799E+00, 8.175E-01 ]

Those perfectly match the values from scipy.signal:
    signal.iirfilter(2, 1000/22050, btype="lowpass")
    signal.iirfilter(2, 1000/22050, btype="highpass")

    ==========================================
    butterworth 2 crossover from scipy.signal:
    ==========================================
    bLow2  = [ 0.004604,   0.009208,   0.004604  ]
    bHigh2 = [ 0.9041522, -1.80830441, 0.9041522 ]
    a2     = [ 1.,        -1.79909641, 0.8175124 ]

Using full debug mode for mcompand with a 1kHz crossover
frequency reveals the following coefficients:

    =================================
    butterworth 4 crossover from sox:
    =================================
    DBUG mcompand_xover:
    lb=[2.119680195800917e-005 8.47872078320367e-005
        0.000127180811748055
        8.47872078320367e-005 2.119680195800917e-005]
    DBUG mcompand_xover:
    hb=[0.8174912065828001 -3.2699648263312 4.9049472394968
        -3.2699648263312 0.8174912065828001]
    DBUG mcompand_xover:
    a=[1 -3.598192818969336 4.871772697390141 -2.9415672592774
       0.6683265296879234];

This does _not_ match the output from scipy.signal:

    ==========================================
    butterworth 4 crossover from scipy.signal:
    ==========================================
    lb=[2.15209512e-05, 8.60838049e-05, 1.29125707e-04,
        8.60838049e-05, 2.15209512e-05 ]
    hb=[ 0.82999258, -3.31997033, 4.97995549, -3.31997033,
         0.82999258 ]
    a=[ 1., -3.6278442, 4.95122513, -3.01192428, 0.68888769 ]

They are near, but not identical.  Is the coefficient
transformation for the iir filter cascade in
mcompand_xover.h possibly incorrect?


          Best regards,

                 Thomas


_______________________________________________
Sox-users mailing list
Sox-users@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/sox-users



[Index of Archives]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Photo Sharing]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux