sox-users@lists.sourceforge.net unofficial mirror
 help / color / mirror / code / Atom feed
* How does the Sox Compand Transfer Function Work?
       [not found] <CAKWhy8Mp6+zf1S++tffUk_Y=kb7YsVvOQ4dzWzU6+-_mNGw=LA@mail.gmail.com>
@ 2018-09-26  1:20 ` Todd Hartman
  2018-09-26 20:00   ` Eric Wong
  0 siblings, 1 reply; 4+ messages in thread
From: Todd Hartman @ 2018-09-26  1:20 UTC (permalink / raw)
  To: sox-users


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How does the Sox Compand Transfer Function Work?
  2018-09-26  1:20 ` Todd Hartman
@ 2018-09-26 20:00   ` Eric Wong
  0 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2018-09-26 20:00 UTC (permalink / raw)
  To: sox-users

Your message is just a wall of text with paragraph breaks when
rendered with my terminal mail client.

Just replying to the Subject of your post; fmiser has some
EXCELLENT explanations of compand in the list archives:

https://public-inbox.org/sox-users/20100922043937.778a1914.fmiser@gmail.com/
https://public-inbox.org/sox-users/20090829011522.cf27e6ee.fmiser@gmail.com/

I've found his posts extremely informative when learning sox myself.


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How does the Sox Compand Transfer Function Work?
@ 2018-09-27  2:46 Todd Hartman
  0 siblings, 0 replies; 4+ messages in thread
From: Todd Hartman @ 2018-09-27  2:46 UTC (permalink / raw)
  To: sox-users


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

Thanks for the reply. Sorry about the non-text. Here's a blog post with my question (essentially the same as the email)https://wordpress.com/post/thewhackhacker.wordpress.com/486
I (think I) understand the theory explained in the mall archives you mentioned. My observation is that sox doesn't behave in a manner consistent with that explanation.
I have been unable to compress an audio signal to the 0 - -20dB range, regardless of the transfer function I used, even though I thought I had crafted some that should have worked, per the explained theory.
What am I doing wrong, or what don't I understand, that the transfer functions I tried don't produce my expected results?

todd.
null

[-- Attachment #1.2: Type: text/html, Size: 1350 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How does the Sox Compand Transfer Function Work?
@ 2018-09-27 11:14 Todd Hartman
  0 siblings, 0 replies; 4+ messages in thread
From: Todd Hartman @ 2018-09-27 11:14 UTC (permalink / raw)
  To: sox-users


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

The link was wrong. Here's the blog post with details.https://thewhackhacker.wordpress.com/2018/09/26/companding-with-sox/

null

[-- Attachment #1.2: Type: text/html, Size: 271 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-09-27 11:15 UTC | newest]

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

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