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!