簡體   English   中英

在3個不同的頻率區域中分離音頻文件

[英]Separating audio file in 3 different frequency areas

如果標題令人困惑,我提前致歉。 基本上,我有一個音頻文件,每50毫秒執行一次STFT。 我的文件大約長11秒(10.8526秒),我已經從原聲帶中切斷了文件。 順便說一句,我不允許在Matlab中為STFT使用內置函數。 我知道這要容易得多。 無論如何,在我運行代碼后,每隔50毫秒執行一次STFT並繪制圖片。 現在我想在3個不同的地塊中將其分開。 在第一個圖中,我具有較低的頻率(0-300Hz),在第二個圖中,我具有較高的頻率(300-5kHz),而在最后一個圖中,我具有較高的頻率(5Khz-fs / 2)。 fs = 44100->以下代碼中的進一步說明。 我現在如何定義區域?

%AUDIO-FILE
%______________________________________________________
[y,fs]=audioread('UnchainMyHeart.wav');
% audioread = Reads Audio file
% y = A vector, which contains the audio signal
% fs = sample rate
% 'UnchainMyHeart' = Audio file
%______________________________________________________


% Paramter for the real-time spectral-analysis
%______________________________________________________
 NFA=2; 
% Every second picture is being plotted
% Don't need every picture
 t_seg=0.05; 
%Length of the audio signal on which is a STFT performed 

fftlen = 4096; 
% Length of the FFT, frequency resolution

 TPF= 300;
 BPF= 5000;
 HPF= 22050;
% Trying to define the frequencies areas
% Isn't working right now

 LOW=((TPF*fftlen)/fs);
 MEDIUM=((BPF*fftlen)/fs);
 HIGH=((HPF*fftlen)/fs);
% Contains the number of FFT points in the frequency 
%_______________________________________________________

 segl =floor(t_seg*fs); 

 windowshift=segl/2; 

 window=hann(segl); 

 window=window.'; 

 si=1; 
% Start Index

 ei=segl; 
% End Index

 AOS= length(y)/windowshift - 1;

 f1=figure;

f=0:1:fftlen-1;
f=f/(fftlen-1)*fs;

Ya=zeros(1,fftlen);

n=0;

for m= 1:1:AOS

y_a = y(si:ei);
y_a= y_a.*window;
Ya=fft(y_a, fftlen);

n=n+1;
if n==1
  Yres=abs(Ya);
  else
  Yres=Yres+abs(Ya);
end

if n==NFA
  Yres=Yres/NFA;
  n=0;

  drawnow; 
  %Updates the graphical objects which are being plotted every 50ms

figure(f1);
plot(f(1:end/2), 20*log10(abs(Yres(1:end/2))));

ylim([-90 50]);
title('Spektrum of audio signal');
xlabel('f(Hz)');
ylabel('dB');
grid on;

end

si=si+windowshift; 
% Updating Start Index    
ei=ei+windowshift; 
% Updating End index

end

我沒有您的音頻文件,因此無法運行您的代碼,但是我將嘗試從概念上進行解釋,並使用偽代碼。

頻率磚牆

如果您只是出於視覺目的將頻率分開,則可以使用磚牆濾波器。

執行全信號的fft 定義頻率向量。

SigFD = fft(signal);
n = length(signal); % number of samples
fs = 44100; % sampling rate
deltaF = fs/n; % frequency resolution
F = [0:floor(n/2)-1, -(floor(n/2)):-1]*deltaF; % frequency vector

根據所需的頻率范圍對信號進行切片。

lowF = 0;
highF = 500;
part1Range = abs(F)>lowF&abs(F)<highF;
Fpart1 = F(part1Range);
Sig1FD = SigFD(part1Range);

請注意,我無法測試波形上的代碼,因此應將其更多地視為偽代碼!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM