sox-users@lists.sourceforge.net unofficial mirror
 help / color / mirror / code / Atom feed
From: "Dr. Thomas Tensi" <t.tensi@gmx.de>
To: sox-users@lists.sourceforge.net
Subject: Re: Multi Band Processor
Date: Tue, 20 Apr 2021 15:54:20 +0200	[thread overview]
Message-ID: <b7162b75-bf07-7489-4bd3-0d2ced0b5bed@gmx.de> (raw)
In-Reply-To: <3d7b0ecc-585b-aae6-d5ad-01824cb3032f@gmail.com>

Hello Robert,


you wrote:
 > Thanks for responding Thomas

You're always welcome.  Sorry to be that late, but I was
busy...

 > my system starts with a compand function to iron out the
 > devastating differences in audio levels on our sources.
 >
 > This is followed by a mcompand 5 band process which has a
 > low end rolloff, a voice presence tweak, and a gentle high
 > end caress to mitigate hiss and sibilance.
 >
 > [results with compand plus mcompand are acceptable]

This seems to me like a very good approach.

 > > [compand is just a special case of mcompand with a
 > >  single band and a crossover frequency of 22kHz]
 > compand will do some things that don't work in mcompand.
 > The manual implies that the parameters are identical.

Maybe I do not understand the problem.  Doing a compand
followed by an mcompand can be absolutely reasonable,
because the first stage levels the signal overall and then
the second stage does some individual tweaks on the
frequency bands.

So there is no disagreement on your approach at all.

But definitely: although the implementation for compand and
mcompand is separate in SoX (there is code duplication in
the source code for mcompand.c and compand.c), they
implement _exactly the same algorithm_.

I have tested it against my reimplementation (where both
approaches are unified) and a reimplemented mcompand with a
single band behaves _exactly_ like the original SoX
command-line compand.

If this were not the case, you would just have crushed my
mental model ;-)

 > mcompand has to have a global compand type item at the
 > end. This is not clearly explained. I have played with
 > this and arrived at something that works for me.

No.  The compand item at the end does not have a frequency
specification because this compander band does not have an
upper crossover frequency.

The command line logic is

   mcompand band1CompanderSpec     band1TopFrequency \
            band2CompanderSpec     band2TopFrequency \
	   ... \
            band(n-1)CompanderSpec band(n-1)TopFrequency \
            band(n)CompanderSpec

The last compander has no explicit top frequency, but it is
just infinity or - more precisely - the Nyquist frequency
(e.g. for a 48kHz sample rate signal this is 48kHz/2 =
24kHz).

In command-line SoX an mcompand with one band behaves exactly
like a compand.  I did not check whether you can specify
such an mcompand, but if yes, there must be no difference.
You just have the additional double quotes with mcompand.

Let me clarify this with an ASCII-art picture (hope this
works). This is the signal flow in mcompand:

   Input
   Signal
     |
     v
   +----+   +----+           +------+   +...+
   |LR1 |-->|LR2 |--> ... -->|LRn-1 |-->.LRn.--> x
   +----+   +----+           +------+   +...+
     |        |                 |         |
     v        v                 v         v
   +----+   +----+           +------+   +----+
   |CMP1|   |CMP2|    ...    |CMPn-1|   |CMPn|
   +----+   +----+           +------+   +----+
     |        |                 |         |
     v        v                 v         v
   +-----------------------------------------+
   |              Signal Adder               |
   +-----------------------------------------+
                       |
                       v
		   Output
		   Signal

So the input signal is split by so-called Linkwitz-Riley
crossover filters that take a signal and split it into two
signals at their crossover frequency: a low frequency signal
below that frequency and a high frequency signal above that
frequency.  In the picture "low" goes down into a compander
and "high" goes right into the next LR-filter.  The last
filter LRn (with the x-output) is not specified in the
mcompand command line, because it does not really do
anything complicated: its crossover frequency is the Nyquist
frequency, hence x must be the null signal and everything
coming in from the left goes directly down to CMPn (the n-th
compander).

Finally all compander outputs are summed up into the output
signal.

Reduced to one band this gives you: an LR-filter with no
signal change (the filter parameters degenerate to an
identity filter without phase issues), a standard compander
and finally an adder with just one signal.  Looks like a
compander to me.

 >> Your functions look okay, but you could consider rounding
 >> off the corners of the transfer function by adding a knee
 >> value of e.g. 4dB.
 > I copied someone else's and then modified. It came without
 > knee.  I have added the knee and it certainly smooths the
 > transitions.  Thanks for that.

I guess you really can't hear the difference with your rough
material and your compression settings, but it does no harm.

 > > What you could do is factor out the common parameters and
 > > just put in the changed values instead; you already did
 > > that in part, but putting this further would make your
 > > script more modular.

 > At the prototype stage it was easier for me to keep each
 > band seperate.  I found that to much difference between
 > band parameters caused phase issues. It works best when
 > each band is processed more or less the same and the
 > outputs are combined in the desired ratio. I roll off the
 > low end. Allow voice frequencies

I didn't check that, but I can imagine that this is
generally a problem with multiband companders.  Frequencies
near the crossover frequency behave completely differently
depending on whether they are below it (and in band i-1) or
above it (and in band i).  Hence your approach is reasonable.

 > > [extreme release times of 1.2s or even 2.0s]
 > The audio sourced from three different TV channels,
 > typically comes crashing in at high level. 20db above the
 > average level. Either a device or an operator cranks it
 > down. Given the consistency it's a device. To even things
 > out a fast attack and a slow release works. The noise
 > floor [ hum hiss air condx passing traffic etc ] is about
 > -32. Long release prevents the noise being sucked up. I am
 > dealing with speech. Sources run from reverberant studios
 > to less than ideal remote locations. Camera operators have
 > the high pass filter useful for lapel mic's in circuit
 > when the reporter is using a hand held ENG mic. Automatic
 > level controllers [that don't] at venues used for Press
 > Conferences or to deliver speeches defeat everything in
 > the subsequent path.
 > I have been able to get a consistent clear result. Today
 > there was a vox pop segment recorded at a bus station with
 > several diesel buses running in the background. The
 > processed version was better then the original broadcast
 > audio.

Congratulations! That requires a lot of tweaking and
expertise from your side.

 > The 'processor' can be run in a shell script that is
 > invoked when an operator edits the source audio and sends
 > it 'to be carted'. Our low budget LPFM can't afford the
 > $7k processor, which I am not so sure could be tuned as
 > sweetly as this.

That's the advantage of command-line open-source tools.

 > I have a set of processors, one for each of our sources.
 > The goal is to deliver a consistent sound to our listener
 > but not have the processing so heavy as to be tiresome.
 > mcompand has enabled me to build a virtual device which
 > achieves this.  I am really appreciative of all the work
 > done in sox and associated code by a legion of people.

I myself am not active in the SoX development, which is a
great work in my opinion.  Standing on the shoulders of
giants...

 > I wish I had the skill to be able to read the source code
 > and perhaps write manuals.

We as developers are typically not good at the latter; so we
appreciate people getting along with the software anyway ;-)


           Best regards,

                    Thomas



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

  reply	other threads:[~2021-04-20 13:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-11  3:47 Multi Band Processor Robert Jeffares
2021-04-18 18:50 ` Dr. Thomas Tensi
2021-04-19 21:52   ` Robert Jeffares
2021-04-20 13:54     ` Dr. Thomas Tensi [this message]
2021-05-02 15:14       ` SoX Plugins for DAWs 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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.sourceforge.net/lists/listinfo/sox-users

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

  git send-email \
    --in-reply-to=b7162b75-bf07-7489-4bd3-0d2ced0b5bed@gmx.de \
    --to=sox-users@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/sox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).