Log in

View Full Version : sox - compand - dynamic range compression


Selur
3rd September 2012, 10:02
I wanted to add options to do 'dynamic range compression' in Hybrid using sox. Problem is I got no clue about it and since it can't really be done intuitively (from that I get), I wanted to add let the user choose from some 'general' profiles.

So I googled a bit and found:

speech:
compand 0.02,0.20 5:-60,-40,-10 -5 -90 0.1
source: http://www.benmcdowell.com/blog/2012/01/29/batch-processing-audio-file-cleanup-with-sox/

voice/music:
compand 0.1,0.3 -60,-60,-30,-15,-20,-12,-4,-8,-2,-7 -2
source: http://www.dzone.com/snippets/sox-audio-editor-settings
and
source: http://forums.joe.to/viewtopic.php?f=149&t=57817

voice/radio:
compand 0.01,1 -90,-90,-70,-70,-60,-20,0,0 -5
source: http://icecast.imux.net/viewtopic.php?t=3462

audio books:
compand 0.3,5 6:-70,-60,-20 -10 -6 0.2
source: http://www.ericphelps.com/batch/samples/MP3_Recode.txt

podcast:
compand 0.3,1 6:-70,-60,-20 -5 -90
source: https://dissectionbydavid.wordpress.com/2010/10/01/using-sox-via-php-to-cleanup-podcasts/

music:
compand 0.3,1 -90,-90,-70,-70,-60,-20,0,0 -10 0 0.2
source: https://groups.google.com/forum/?fromgroups=#!topic/de.comp.audio/TfV5SzdHxbk

MediaTomb:
compand 0.1,0.8 60:-40,-5 -20 -70 .2
compand .3,.8 -40,-5 -20 -70 .2
source: http://mediatomb.cc/dokuwiki/transcoding:transcoding

music:
compand 0.3,1 6:-70,-60,-20 -5 -90 0.2
source: http://sox.sourceforge.net/sox.html

music:
compand 0.3,1 -90,-90,-70,-70,-60,-20,0,0 -5 0 0.2
source: http://kevin.deldycke.com/tag/alac/
source: http://manpages.ubuntu.com/manpages/gutsy/man7/soxexam.7.html

music:
compand .1,.1 -60,-10 0 0 .1
compand .01,.3 -6,-4,-3,-3,0,-3
source: http://kevin.deldycke.com/tag/alac/

movie:
compand 0.0,1 6:-70,-43,-20 -6 -90 0.1
source: http://forum.videohelp.com/threads/340675-Mkv%D0%A2%D0%BEMp4-v0-221a-rapid-tool-for-repack-Mkv-to-Mp4?p=2181966&viewfull=1#post2181966

since my hearing ability is really untrained and audio knowledge are is very limited I wanted to ask if some of you have some suggestions for such profiles,... may be in the style aften offers them (Film Light, Film Standard, Music Light, Music Standard, Speech).

Cu Selur

tebasuna51
3rd September 2012, 15:51
I can't help you about the best options, but I make a test DRC funtcion for BeHappy with the options Film Light, Film Standard, Music Light, Music Standard, Speech here: http://forum.doom9.org/showthread.php?p=779165#post779165

Selur
3rd September 2012, 19:11
Thanks a lot! That really helps. :)

Cu Selur

nibus
11th September 2012, 06:29
A while back I was experimenting with sox to compress audio for some video encodes I was doing for my iPad. I wanted something to basically turn a movie soundtrack into a TV soundtrack, sort of brickwall the sound if you will, so it could be heard in loud environments.

I found that sox's compand feature couldn't apply enough compression, so I use wavebooster (pretty old software by LigH) in addition to sox.

Here's the package if you want to experiment with it:
http://www.mediafire.com/download.php?jgp14x4p9fcz2zj

You just drag the file onto the window. But it can't have spaces in the path, and the wav must be created using the following in eac3to: -simple, -down16, -resampleTo44100

Sox is set to use only one setting that I found worked quite well with movie soundtracks (in addition to the dynamic range that a user inputs). And to be honest, I don't remember all the settings on it.

edit: the lower the range, the more compression is applied.

Selur
11th September 2012, 06:38
seems like it simply applies:
sox.exe "%INPUT%" "%INPUT%_%DRC%db.wav" compand 0.3,1 5:-80,-79,-%DRC% -%LIMIT% -90 0.2
where the user specifies DRC and Limit,...

as choice the user can use one of the options:
ECHO.& ECHO.
ECHO Select amount:
ECHO.
ECHO.
ECHO 0) 54db Range / 5db Limit
ECHO 1) 50db Range / 6db Limit
ECHO 2) 46db Range / 7db Limit
ECHO 3) 42db Range / 8db Limit
ECHO 4) 38db Range / 9db Limit
ECHO 5) 34db Range / 10db Limit
ECHO 6) 30db Range / 11db Limit
ECHO.
ECHO 7) Custom Range
ECHO.
ECHO 8) Light (70db Range / 4db Limit)
ECHO 9) Light (66db Range / 4db Limit)
ECHO.& ECHO.

SET CHOICE=& SET /P CHOICE=Select Option: %=%
IF "%CHOICE%"=="0" SET DRC=54& SET LIMIT=5& GOTO :GO
IF "%CHOICE%"=="1" SET DRC=50& SET LIMIT=6& GOTO :GO
IF "%CHOICE%"=="2" SET DRC=46& SET LIMIT=7& GOTO :GO
IF "%CHOICE%"=="3" SET DRC=42& SET LIMIT=8& GOTO :GO
IF "%CHOICE%"=="4" SET DRC=38& SET LIMIT=9& GOTO :GO
IF "%CHOICE%"=="5" SET DRC=34& SET LIMIT=10& GOTO :GO
IF "%CHOICE%"=="6" SET DRC=30& SET LIMIT=11& GOTO :GO
IF "%CHOICE%"=="8" SET DRC=70& SET LIMIT=4& GOTO :GO
IF "%CHOICE%"=="9" SET DRC=66& SET LIMIT=4& GOTO :GO

IF "%CHOICE%"=="7" GOTO :CUSTOM
IF "%CHOICE%"=="" GOTO :DRC
-> shouldn't be to hard to implement something similar in Hybrid,..

it later applies:
Data\WaveBooster\BOOSTCLI.EXE /i="%INPUT%_%DRC%db.wav" /o="%INPUT%_%DRC%db_Maxd.wav" /a=-12 /m=-.5
( [+] /a=Avg_dB /m=Max_dB (2-pass autom. setup, Avg=-12..-3, Max=-3..0))
which seems to do the magic:
This program was made to allow normalisation and dynamic compression of high
resolution wave files, therefore it might be useful for a variety of purposes,
for example enhancing the quality of decoded, previously compressed audio like
MPEG Layer 3 (per "mad" WinAmp plugin) or Dolby Digital (per Azid 1.7+).

Problem is that this would be a windows only solution, so I' reluctant to add it to Hybrid,...

Sparktank
4th February 2013, 01:23
Really great input, guys.
I've got several threads bookmarked and ready to read over.
I've been meaning to experiment and look for solutions when converting my Blu-Ray collection to containers or DVD's.
I find a lot of movies tend to have really quiet dialogue while the action is blaring.
I'm just starting to learn more about using SoX lately and hoping it will produce decent results.

nibus, going to check out your solution.
I'll be having fun trying out all the options I'm finding to try and make a movie watchable without worrying about adjusting the volume.

PeterTheMaster
7th February 2013, 09:54
the wavebooster part speaks about maximizing the audio. is that just regular nomalization? so could i replace it by besweet -norm 0.97?

if wavebooster does drc too i dont unterstand the need for two programs.

nibus
9th February 2013, 20:03
the wavebooster part speaks about maximizing the audio. is that just regular nomalization? so could i replace it by besweet -norm 0.97?

if wavebooster does drc too i dont unterstand the need for two programs.

Wavebooster does further normalization and adds gain; I found I needed the combination to boost audio for my mobile devices like smartphones and tablets. BeSweet would probably work instead. Only one way to find out.

Selur
9th February 2013, 20:21
they could do that with sox too, but that's not really related to DRC anymore,..