|
From: David G. <gr...@ld...> - 2010-03-11 16:48:54
|
xl...@so... said:
> Is there some methods in SoX that I can use to get the SNR value of an
> audio? If not, could you give me some advice to do this?
ha...@st... said:
> First you need to specify what part of your audio constitute the
> "signal" and what constitutes "noise".
What Jan Stary said is correct, but also: if your audio file is
essentially "clean" (all portions are either "quiet" or "good signal",
with no portions that have loud noises, like doors slamming, tapping on
the microphone, etc), then the "stats" effect will report the following:
command line:
sox some_audio.file -n stats
output (for a sample audio file I happened to have available):
Overall Left Right
DC offset -0.000001 -0.000001 -0.000001
Min level -0.980347 -0.980347 -0.605347
Max level 0.980347 0.980347 0.542847
Pk lev dB -0.17 -0.17 -4.36
RMS lev dB -24.54 -21.79 -33.83
RMS Pk dB -7.06 -7.06 -16.96
RMS Tr dB -88.95 -72.85 -88.95
Crest factor - 12.05 29.76
Flat factor 1.09 1.10 0.00
Pk count 60 118 2
Bit-depth 14/14 14/14 14/14
Num samples 4.84M
Length s 605.040
Scale max 1.000000
Window s 0.050
In this example, the default window size of 50 msec ("Window s 0.050") is
used to compute the RMS dB for the loudest window ("RMS Pk dB -7.06") and
for the quietest ("trough") window ("RMS Tr dB -88.95"), and if my own
understanding is correct, the dB SNR can be estimated as the difference
between those two values (in this case, 81.89 overall, 65.79 on the left
channel, 71.99 on the right channel).
But this would be a "best case" type of estimate -- that is, it tells
you what the maximum possible SNR could be for the file. The actual SNR
is likely to be lower, if you take the average RMS dB from a bunch of
"quiet" portions and compare that to the average RMS dB from a bunch of
"typical signal" portions.
Check the sox documentation regarding the "stats" effect for more info.
Dave Graff
|