By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,050 Members | 1,019 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,050 IT Pros & Developers. It's quick & easy.

sound processing - avarage amplitude?

P: n/a
Hello

I would need way to check the amplitude (over time) for a sound file in
python. I'm sure this can be done, for example the audioop.rms function
seems to be able return amplitude values. However, it would be really
great to get the results in dB, which does not seem to be the case.
Anyone who has more information about this, or a way to convert the
results? I've searched google but info about audioop seem to be quite
scarce. Also, does audioop function perfectly also for wave files? Also,
cross-platform solutions are of course preferred, but I'm running linux
(with oss).

I've also looked somewhat into tkSnack (http://www.speech.kth.se/snack/)
which has a dBPowerSpectrum function which might be doing at least
partially what i want it to, however, the returned values are approx.
-100 ... which I find odd. The "real", recorded sound was somewhere in
the 50-60dB range.
thanks in advance
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Sat, 19 Mar 2005 17:18:42 +0200, rumours say that Niklas Paro <np***@abo.fi>
might have written:
Hello

I would need way to check the amplitude (over time) for a sound file in
python. I'm sure this can be done, for example the audioop.rms function
seems to be able return amplitude values. However, it would be really
great to get the results in dB, which does not seem to be the case.
Anyone who has more information about this, or a way to convert the
results? I've searched google but info about audioop seem to be quite
scarce. Also, does audioop function perfectly also for wave files? Also,
cross-platform solutions are of course preferred, but I'm running linux
(with oss).
audioop is platform independent. You just might need to import wave also.
I've also looked somewhat into tkSnack (http://www.speech.kth.se/snack/)
which has a dBPowerSpectrum function which might be doing at least
partially what i want it to, however, the returned values are approx.
-100 ... which I find odd. The "real", recorded sound was somewhere in
the 50-60dB range.
Where is your 0dB mark? If it's at maximum amplitude (1), then any value
(except zero) can be expressed as (negative) dB by the following function:

def amp2dB(amplitude):
return 20*math.log(amplitude, 10)

If you're converting from the 0...32767 range of 16bit PCM files, first divide
the amplitude by 32767.0 and pass the result to amp2dB.
thanks in advance


Hope this helps.
--
TZOTZIOY, I speak England very best.
"Be strict when sending and tolerant when receiving." (from RFC1958)
I really should keep that in mind when talking with people, actually...
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.