MATLAB Answers


Segmentation of audio signal.

Asked by Djordje Damnjanovic on 13 Jun 2019
Latest activity Commented on by Djordje Damnjanovic on 25 Jun 2019
Hello everybody!
I have this issue about segmentation of audio signal. I want to do segmentation of audio signal but with overlap of each segment of 25%. For example, first segment of signal will start from 0 sec to 1 sec, next segment will start from 0.75 sec to 1.75 sec, third segment will start from 1.5 sec to 2.5 sec. etc. Later I need to use each segment seperatly for futher analysis so it is good to put every segment in some vector or again save as audio signal... I create picture where I paint segments in signal.
Thanks in front!


Sign in to comment.

2 Answers

Star Strider 님의 답변 13 Jun 2019

Try this:
s = 0.1*randn(1E+4,1)+sin(0.02*pi*(1:1E+4)'-1); % Signal (Column Vector)
L = numel(s); % Vector Length
Fs = 1000; % Sampling Frequency
Ts = 1/Fs; % Sampling Interval
sec1 = 1:Fs; % One-Second Segment Length
secq = fix(3*Fs/4); % 750ms Segment Length
seg = zeros(Fs,fix(L/Fs)); % Preallocate
for k = 1:fix(L/Fs)
seg(:,k) = s(sec1+secq*(k-1)); % Signal Segments
If you only wanted the segments without the offset, the reshape function would have been best.

  1 Comment

Thank You very much for help!
Here is the thing.
Signal s is size of 8000. So, L=8000. Sampling is Fs=16000;
So need segments of 50 ms, overlap of 25 ms.
How to rewrite Your code for this parameters?
Thanks Again!

Sign in to comment.

Greg Dionne 님의 답변 13 Jun 2019

If you have the Signal Processing Toolbox, buffer may be what you're after.
Hope this helps!

  1 Comment

I will also try with buffer! Thanks!

Sign in to comment.