unofficial mirror
 help / color / mirror / Atom feed
From: "Dr. Thomas Tensi" <>
Subject: SOX mcompand crossover algorithm?
Date: Tue, 23 Jul 2019 21:44:57 +0200
Message-ID: <> (raw)

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
         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

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,


Sox-users mailing list

             reply	other threads:[~2019-07-23 19:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-23 19:44 Dr. Thomas Tensi [this message]
2019-07-24 19:26 ` Dr. Thomas Tensi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link unofficial mirror

This inbox may be cloned and mirrored by anyone:

	git clone --mirror

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 sox-users sox-users/ \
	public-inbox-index sox-users

Example config snippet for mirrors.
Newsgroups are available over NNTP:
 note: .onion URLs require Tor:

code repositories for the project(s) associated with this inbox:

AGPL code for this site: git clone