0
$\begingroup$

I'm a beginner in audio signal processing, and trying to calculate the amplitude of a .wav file. I've read some documents from the web and some other questions asked about this topic. However, I still don't know how to calculate the amplitude and sum of the amplitude contour (in dB) from a .wav file in Python. Hope someone can help.

$\endgroup$
9
  • $\begingroup$ It depends on the type and range of the values in wav file. Or the library you use to load the wav file, which may convert it for you. How do you load the wav file? $\endgroup$
    – Justme
    Commented Sep 4, 2022 at 12:43
  • 1
    $\begingroup$ Most Wav files just contain PCM-encoded audio. In other words, whatever you load from the file is amplitude values. From the first to the last sample. $\endgroup$ Commented Sep 4, 2022 at 13:52
  • $\begingroup$ @Justme I load the wav file using librosa tool. $\endgroup$
    – Megan
    Commented Sep 4, 2022 at 14:41
  • $\begingroup$ @MarcusMüller Do you mean y in ` y, sr = librosa.load("try.wav")`? $\endgroup$
    – Megan
    Commented Sep 4, 2022 at 14:42
  • 1
    $\begingroup$ yeah, in the result of that, y contains instantaneous amplitude samples. $\endgroup$ Commented Sep 4, 2022 at 14:47

1 Answer 1

1
$\begingroup$

A wave file contains the instantaneous amplitude of the sound signal as series of time domain samples. The most common format is 16-bit signed integer but it can also be floating point, 32-bit integer, etc. I can have one or more channels. For example, stereo will have left and right channels.

librosa.load() has a lot of options to manipulate the data during the loading process, so I recommend carefully looking at those and pick what's required for your application.

In most (but not all) cases you will end up with a series of floating point numbers that are between -1.0 and +1.0. There is no direct connection too the original amplitude of the sound signal unless you have external calibration information, so you cannot reconstruct the original sound level.

I still don't know how to calculate amplitude and sum of the amplitude contour (in dB) from a wav file in Python.

I have no idea what this is supposed to mean. Please add some more detail or some formulas or equations.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.