sox-users@lists.sourceforge.net unofficial mirror
 help / color / mirror / code / Atom feed
From: Todd Hartman <todd@hartmen.us>
To: sox-users@lists.sourceforge.net
Subject: How does the Sox Compand Transfer Function Work?
Date: Tue, 25 Sep 2018 20:20:13 -0500	[thread overview]
Message-ID: <5baaded3.1c69fb81.1ab9.5c49@mx.google.com> (raw)
In-Reply-To: <CAKWhy8Mp6+zf1S++tffUk_Y=kb7YsVvOQ4dzWzU6+-_mNGw=LA@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 2860 bytes --]



Sox's Compand Transfer FunctionI’m having trouble choosing compand parameters to get the results I want. I believe the problem is in my engineering the transfer function for sox’s compand effect.According to the sox docs:compand attack1,decay1{,attack2,decay2}
        [soft-knee-dB:]in-dB1[,out-dB1]{,in-dB2,out-dB2} 
        [gain [initial-volume-dB [delay]]]
My goal is to compress all the audio in a file to the top 20 dB of the available amplitude range (to overcome the noisy environment in which I’ll be listening).ExperimentHere’s a plot of the first ~25 seconds of the file. (Note: my method for plotting dB is potentially suspect. The Python code for it may be found here).Recommended: -70,-60,-20The sox docs also list a “common” transfer set of parameters: 0.3,1 6:−70,−60,−20 −5 −90 0.2. I used something similar: 0,.1 -70,-60,-20 (leaving out the gain, initial volume, and optional soft-knee value).The sox docs describe this transfer function:The transfer function (‘6:−70,...’) says that very soft sounds (below −70dB) will remain unchanged. This will stop the compander from boosting the volume on ‘silent’ passages such as between movements. However, sounds in the range −60dB to 0dB (maximum volume) will be boosted so that the 60dB dynamic range of the original music will be compressed 3-to-1 into a 20dB range, which is wide enough to enjoy the music but narrow enough to get around the road noise.When I tell sox to plot the transfer function, I expect output levels to be mostly in the -20dB - 0dB range.When I plot the resulting dB level of the audio, I get this:This is not what I expected. I was expecting the dB level to be almost entirely in the -20dB - 0dB range, but what I see is most of it in the -60dB - 0dB range. What is wrong with my expectations?I attempted a few other transfer functions, with results a little more to my liking, but never what I was expecting or wanted.-70,-60,-10Plotting the transfer function:I expected all the meaningful audio to be compressed into the -10dB - 0dB range.-91,-90,-10Plotting the transfer function:I expected a great deal of compression (nearly everything in the -10dB - 0dB range).Conclusions?I can only barely tell a difference between the results of the various transfer functions I tried. At no point was the dB level of the audio compressed to within the range I was expecting.Sox Source Code
https://github.com/chirlu/sox/blob/master/src/compand.c
Examination of this file doesn't sufficiently enlighten me to enable me to get what I want out of companding. I don't have criticism of the code—I just don't understand it.What do I not understand about the transfer function?I don't see the actual output of Sox's compand doing what is described in the docs. Can you help me understand how to use the compand effect?Thanks.

todd.


[-- Attachment #1.2: Type: text/html, Size: 25098 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



[-- Attachment #3: Type: text/plain, Size: 158 bytes --]

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

       reply	other threads:[~2018-09-26  1:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAKWhy8Mp6+zf1S++tffUk_Y=kb7YsVvOQ4dzWzU6+-_mNGw=LA@mail.gmail.com>
2018-09-26  1:20 ` Todd Hartman [this message]
2018-09-26 20:00   ` How does the Sox Compand Transfer Function Work? Eric Wong
2018-09-27  2:46 Todd Hartman
  -- strict thread matches above, loose matches on Subject: below --
2018-09-27 11:14 Todd Hartman

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=5baaded3.1c69fb81.1ab9.5c49@mx.google.com \
    --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).