zero padding before and after audio signal in matlab

Viewed 915

I have an audio signal of length 82778 with Fs 44100. after applying a customise function on chunks of .25 second. I want to add zero paddings of .25*.5*Fs before and after the output of the loop, so I can get the same length of the original signal.

[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
1 Answers

You can add zero padding using padarray method:

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.

I hope I got the right answer without knowing F0 and RobynSpeakingFrom.wav...

Related