Finding Highest Frequency Component from a Sound Recording
12 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
回答(2 个)
Image Analyst
2023-6-25
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.
0 个评论
Star Strider
2023-6-25
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)
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.
.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Signal Generation, Manipulation, and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!