Finding Highest Frequency Component from a Sound Recording

14 visualizaciones (últimos 30 días)
SAJJAD ALI
SAJJAD ALI el 5 de Mayo de 2023
Respondida: Star Strider el 25 de Jun. de 2023
I have a sound recording in ".wav" file format. I want to sample it according to sampling theorem (Nyquist Shannon Sampling Theorem) because I want to do some dsp on it. How can I extract maximum frequecncy component of this recording?

Respuestas (2)

Image Analyst
Image Analyst el 25 de Jun. de 2023
You have to define eactly, mathematically what you want when you say "maximum frequecncy component". This is vague and imprecise. Obviously the max frequency will be the sampling frequency for an arbitrary sound waveform.
Alternatively, perhaps you want the frequency at which the sound has maximum power. This is what @Mahesh Chilla's (probably chatbot) code does. That is an alternate definition. For example perhaps it's a song with frequencies out to 20 kHz but the power of higher frequencies is usually low and maybe there is a strong singer's voice at 1 kHz that has most of the power. So is the answer you want 20 kHz or 1 kHz?
So you really need to explain what you want and why you want it so we know the full context and can give you the right answer.
This looks like a homework problem. If you have any questions ask your instructor or read the link below to get started:
Obviously we can't give you the full solution if it's homework, because you're not allowed to turn in our code as your own.

Star Strider
Star Strider el 25 de Jun. de 2023
The audioread function has two outputs, the first being an (Nx2) matrix (the information) and the second being the sampling frequency. I am not certain what you intend by ‘maximum frequency’ because the highest frequency that it is possible to identify in the file is the Nyauist frequency, one-half the sampling frequency. So that is the highest (or maximum) possible frequency in the recording (even if no frequency actually exists there).
The maximum frequency otherwise is likely the maximum frequency with a non-zero amplitude. That requires calculating the Fourier transform of the signal, and then determining that frequency.
Example —
Fs = 10000; % Sampling Frequency (Hz)
L = 120; % Signal Length (s)
t = linspace(0, Fs*L-1, Fs*L)/Fs; % Time Vector
s = [1;2;3;2;1].*sin((1:5:25).'*2*pi*t*200); % Signal Matrix
ss = sum(s).'; % Signal
figure
plot(t, ss)
grid
xlabel('Time')
ylabel('Amplitude')
xlim([0 0.01]) % Show Detail
Ls = numel(ss); % Signal LEngth
Fn = Fs/2; % Nyquist Frequency
NFFT = 2^nextpow2(Ls); % For Efficiency
FTss = fft((ss-mean(ss)).*hann(Ls), NFFT)/Ls; % Fourier Transform
Fv = linspace(0, 1, NFFT/2+1)*Fn; % Frequency Vector
Iv = 1:numel(Fv); % Index Vector
[pks,locs] = findpeaks(abs(FTss(Iv))*2, 'MinPeakProminence',0.25); % Peaks & Locations
Freqs = Fv(locs).';
Mags = pks;
Spectrum_Peaks = table(Freqs,Mags)
Spectrum_Peaks = 5×2 table
Freqs Mags _____ _______ 200 0.49983 1200 0.9879 2200 1.4397 3200 0.97293 4200 0.4973
figure
plot(Fv, abs(FTss(Iv))*2)
grid
xlabel('Frequency')
ylabel('Magnitude')
Here, the highest possible frequency is 5000 Hz, however the highest frequency in the signal is 4200 Hz.
.

Categorías

Más información sobre Signal Generation, Manipulation, and Analysis en Help Center y File Exchange.

Productos


Versión

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by