Read melodies in portions of 2 seconds Matlab
2 views (last 30 days)
Show older comments
Read melodies in portions of 2 seconds Matlab
0 Comments
Accepted Answer
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);
0 Comments
More Answers (0)
See Also
Categories
Find more on Audio and Video Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!