Discussion:
[SoX-users] normalize across multiple files in one go?
Peter P.
2016-11-30 10:17:00 UTC
Permalink
Hi,

didn't find an answer in the mailing list archives nor the web.
I am trying to normalize multiple files while keeping their relative
levels intact. Is there a way to do this with SoX in one call?

How could it be done with multiple calls (eg. analyze first, then raise
gain of all files)?

thanks for ideas!
Peter

------------------------------------------------------------------------------
Graff, David E
2016-11-30 16:22:51 UTC
Permalink
Can you be more specific about what this phrase means: "normalize multiple files while keeping their relative levels intact."


What sort of "normalization" are you talking about? Does "keeping relative levels intact" mean, e.g. that if file_A is generally louder (by some proportion) than file_B before normalization, then this is still true after normalization?


Dave Graff


________________________________
From: Peter P. <***@fastmail.com>
Sent: Wednesday, November 30, 2016 5:17:00 AM
To: sox-***@lists.sourceforge.net
Subject: [SoX-users] normalize across multiple files in one go?

Hi,

didn't find an answer in the mailing list archives nor the web.
I am trying to normalize multiple files while keeping their relative
levels intact. Is there a way to do this with SoX in one call?

How could it be done with multiple calls (eg. analyze first, then raise
gain of all files)?

thanks for ideas!
Peter

------------------------------------------------------------------------------
fmiser
2016-11-30 23:25:04 UTC
Permalink
Post by Peter P.
I am trying to normalize multiple files while keeping their
relative levels intact. Is there a way to do this with SoX in
one call?
Hmmm. I don't think in one call.
Post by Peter P.
How could it be done with multiple calls (eg. analyze first,
then raise gain of all files)?
Idea 1.
wavegain can do this sort of batch process. It calls in "album" mode -
but it is not "normalizing", rather it is calculating replay-gain.

Idea 2.
You could use soxi (or the effect "stat" or "stats") to figure out
the value for each.

Idea 3.
If the files aren't too big, may concatenate them, then figure the
normalize value for the big file, the apply that amount of gain to
each of the pieces.

The details of the last two ideas are going to be system and/or
shell dependent. Wavegain I know works on Linux, and may compile
to other platforms, but I don't know.

------------------------------------------------------------------------------
Eric Wong
2016-12-01 00:01:15 UTC
Permalink
Post by Peter P.
Hi,
didn't find an answer in the mailing list archives nor the web.
I am trying to normalize multiple files while keeping their relative
levels intact. Is there a way to do this with SoX in one call?
How could it be done with multiple calls (eg. analyze first, then raise
gain of all files)?
Yes, I do what fmiser said for 2),

assumes no shell-unsafe chars in filenames:

# subtract some from the $PK value if you want a level below 0 dBFS
PK=$(sox $INPUT_FILES -n stats 2>&1 | awk '/^Pk lev dB/ {print($4 * -1)}')

for i in $INPUT_FILES
do
sox $i normalized-$i gain $PK
done

------------------------------------------------------------------------------
Peter P.
2016-12-01 18:50:27 UTC
Permalink
Post by Eric Wong
Post by Peter P.
Hi,
didn't find an answer in the mailing list archives nor the web.
I am trying to normalize multiple files while keeping their relative
levels intact. Is there a way to do this with SoX in one call?
How could it be done with multiple calls (eg. analyze first, then raise
gain of all files)?
Yes, I do what fmiser said for 2),
# subtract some from the $PK value if you want a level below 0 dBFS
PK=$(sox $INPUT_FILES -n stats 2>&1 | awk '/^Pk lev dB/ {print($4 * -1)}')
for i in $INPUT_FILES
do
sox $i normalized-$i gain $PK
done
Thank you Eric (and fmiser), this is a nice solution and works great!
cheers, P

------------------------------------------------------------------------------
Continue reading on narkive:
Loading...