Read melodies in portions of 2 seconds Matlab

2 views (last 30 days)
Read melodies in portions of 2 seconds Matlab

Accepted Answer

VINAYAK LUHA
VINAYAK LUHA on 8 Jun 2022
Edited: VINAYAK LUHA on 8 Jun 2022
Hi Monika,
Hope this sorts your problem.
[y,fs] = audioread('filename.mp3');
info =audioinfo('filename.mp3');
sample_every=2;
dur=round(info.Duration);
trimmed=[[]]
for i=0:2*sample_every:dur
if(i==0)
trimmed =[trimmed;y(1:min(dur*fs,sample_every*fs),:)];
else
trimmed =[trimmed;y(i*fs:min(dur*fs,(i+sample_every)*fs),:)];
end
end
sound(trimmed,fs);
audiowrite("trimmed.wav",trimmed,fs);

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!