gpt4 book ai didi

matlab - 在3个不同的频率区域中分离音频文件

转载 作者:行者123 更新时间:2023-12-03 01:49:42 25 4
gpt4 key购买 nike

如果标题令人困惑,我事先表示歉意。基本上,我有一个音频文件,每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。定义频率 vector 。

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

根据所需的频率范围对信号进行 slice 。
lowF = 0;
highF = 500;
part1Range = abs(F)>lowF&abs(F)<highF;
Fpart1 = F(part1Range);
Sig1FD = SigFD(part1Range);

请注意,我无法测试波形上的代码,因此应将其更多地视为伪代码!

关于matlab - 在3个不同的频率区域中分离音频文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40822666/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com