sound processing - avarage amplitude?

N

Niklas Paro

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
 
C

Christos TZOTZIOY Georgiou

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top