How do I trim a WAV file from point A to B.
15 次查看(过去 30 天)
显示 更早的评论
I am looking into trimming a WAV file to section out a beep sound. The clip is 47 seconds long and was converted from an AAC file. Here is what I am needing for this script.
-Retrieve file
-Use point A and B with different inputs of seconds (ex. A=37 seconds and B =39 seconds, or A=37.5 and B=38.5)
-Send file out in WAV
I can retrive the file and send a new one out just fine. The new thing I would like to learn about is trimming audio clips. How should I do this?
Any script help and code reffeences would be awesome.
0 个评论
回答(1 个)
Daniel M
2019-10-23
编辑:Daniel M
2019-10-23
You have the sampling frequency as an output from the audioread function. The time vector would typically go
t = 0:1/fs:(length(soundfile)-1)/fs;
So then, 37 seconds will occur at roughly (37*fs + 1) in t. But this won't always work. Safer is to search for the closest value in your t variable.
[~,loc37] = min(abs(t-37));
[~,loc39] = min(abs(t-39));
x(loc37:loc39) = []; % this will cut out the sections of your sound file between 37 and 39 seconds
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio and Video Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!