This is my first dive in DSP. I would like to familiarize myself with frequency analysis. I have two audio tracks which should be digitized at 16bit-44.1kHz and 24bit-192kHz (music, presented as a 24bit-192kHz sample) respectively.
I wanted to identify the effect of the low-pass filter around the Nyquist frequency (22.05kHz and 96kHz respectively).
Edit: I completely reworked the question.
Software used:
I basically estimated the power spectral density using Welch's method
as implemented by scipy.signal.welch
in the Scipy
library of the Python
programming language.
Basically, I used a script equivalent to:
import numpy as np
from matplotlib import pyplot as plt
from scipy import signal
from waveio import readwav
# Load data from one channel (#0) for each sample file
wav192 = readwav("24b-192khz.wav")[:,0]
wav44 = readwav("16b-44khz.wav")[:,0]
# DoE: 2 sample size and two windows types
chunks = [256, 4096]
windows = ["hanning", "boxcar"] # boxcar is rectangular
# Prepare a figure
plt.figure()
# Calculate density spectra and plot
for N in chunks:
for w in windows:
f, Pxx44 = signal.welch(wav44, fs=44100, window=w, nperseg=N, nfft=2*N, scaling="density")
plt.semilogy(f, Pxx44)
plt.legend(["chunk=%d; window=%s"%(c, w) for c in chunks for w in windows])
plt.xlabel("Frequency (Hz)")
plt.ylabel("Density (I$^2$/Hz)")
The power spectral density of the 44.1kHz audio sample:
Which is basically just as expected:
- The chunk size, i.e. the number of samples per fft-transform segment in the real domain, does not change the density a lot if a Hann window is used.
- The chunk size effect is clearly visible with the boxcar (rectangular) window. From what I understand, this is because of spectral leakage which diminishes as the chunk size increases. Is that correct?
- The low-pass filter effect at the Nyquist frequency (22.05kHz)
So far, so good.
The power spectral density of the 192kHz audio sample:
Good point:
- Same behaviour in regard to the chunk size and the window. Is spectral leakage really that strong? That's pretty impressive.
Oddities:
- What the heck is happening?
- Where is the low-pass filter near the Nyquist frequency?
- Why are very-high frequencies even increasing? Could that be related to the choice of the windowing function?
From my interpretation, there is no low-pass filter visible because basically no audio system would go above 192kHz and generally, the software/hardware creator are smart enough to apply a low-pass filter designed with regard to the actual output bandwidth of the audio system.
As for the increasing audio signal above 57kHz, I really can't explain it: the original audio sample is some classical music. I wouldn't expect any instrument to generate louder sounds in that range or frequencies. Any idea? Could this be an example of upsampling?