0
$\begingroup$

I'm a beginner of audio signal processing, and trying to understand some basic things about audio signals.

I primary work with .wav files, so please allow me to use wav as my data to describe my questions.

Q1: Sample values in .wav file represent the waveform amplitude?

When we load data from .wav file, we will have the audio sample values (typically signed ints), and I searched on google, these values are the amplitude of the audio signal, right?

See example code

In [69]: from scipy.io import wavfile

In [70]: frame_rate, values = wavfile.read("data/test.wav")

In [71]: frame_rate
Out[71]: 48000

In [72]: values
Out[72]:
array([[  0,   0],
       [  0,   0],
       [  0,   0],
       ...,
       [385, 247],
       [412, 266],
       [359, 232]], dtype=int16)

Q2: What is silence?

If the answer to Q1 is YES, then given bit-16, I tried to create a numpy array with all values of 10000, expecting it should be loud sound. However, to my surprise it's just no sound at all. Why? I though value=0 is silence, but it's obviously not.

See example code

import numpy as np
from IPython.display import Audio

# 100k frames
x = np.arange(0, 100000)

# sine wave, max value=10000
sine = np.sin(x) * 10000
Audio(sine, rate=50000)  # i.e. 2sec audio, and I can hear the sound

# dummy, all values = 10000
dummy = np.ones(x.shape[0]) * 10000
Audio(dummy, rate=50000)  # same 2sec, but silence

Q3: How to compute decibels from the .wav amplitude values?

Given Q2, now I'm lost and don't know how decibels look like given amplitude values, I thought bigger amplitude values should mean higher decibels, but now it's apparently not the case.

$\endgroup$
1
$\begingroup$

Q1: Sample values in .wav file represent the waveform amplitude?

Yes.

Q2: What is silence?

That depends on how you define it. The signal that you generated actually has a lot of energy but it's all at 0 Hz. Your DAC cannot reproduce 0 Hz, your speaker cannot reproduce 0 Hz, air cannot transmit 0 Hz, and your ear can't hear 0 Hz. There is lots of energy but you can't get it to you ear or perceive it. If you want a loud signal, create a sine wave with a frequency 1000 Hz and an amplitude of 10000. That will be loud.

Q3: How to compute decibels from the .wav amplitude values?

That depends on what type of decibels and for what purpose. You can always calculate dBFS (dB re digital Full Scale) as

$$20 \cdot log(x/x_{max})$$

where $x$ is your sample and $x_{max}$ the clipping point of your AD or DA converter, i.e. 32768 for signed 16-bit integers.

Sound pressure levels, dBSPL, are much more complicated and require calibration and in many cases also a frequency weighting function.

$\endgroup$
1
  • $\begingroup$ Thanks so so much for dropping this answer! Follow-up Qs: According to your answer to Q2, only with high amplitude (i.e. 10000) is not enough, it should have variation or should be periodical, right? Otherwise the wave has no frequency (i.e. 0Hz?) ? So how to compute Hz given my dummy array? This is a bit confusing to me, since in my dummy array, although values are all the same, but I thought the period of peak value is 1, i.e. from current time-step to next one (+1), so the freq = 1Hz? $\endgroup$ – avocado May 7 at 14:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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