matlab中音频信号前后的零填充

zero padding before and after audio signal in matlab

我有一个长度为 82778 且 Fs 为 44100 的音频信号。在对 0.25 秒的块应用自定义功能之后。我想在循环输出前后添加 .25*.5*Fs 的零填充,这样我可以获得与原始信号相同的长度。

[x, Fs] = audioread('RobynSpeakingFrom.wav');
time=length (x)/Fs; %time in second
N=Fs*0.250; %number of samples per chunk
M=length(x)-N; % the mumber of the required signals 
Fundamental=zeros(1,M); %signal frame
for i=1:M
    s = i;%start
    e = i+N-1;%end
    chunk = x(s:e);
    fundamental = F0(chunk,Fs);
    Fundamental(i)=fundamental;
end

您可以使用 padarray 方法添加零填充:

pad_size = round(0.25*0.5*Fs); %Number of zeros to pad
Fundamental = padarray(Fundamental, [0, pad_size], 0); %Pad with zeros before and after Fundamental.

我希望我在不知道 F0RobynSpeakingFrom.wav...

的情况下得到了正确答案