Need ideas on how to extract a 30s portion of a wav file and save as a new file

3 ビュー (過去 30 日間)
Benjamin Colbert
Benjamin Colbert 2022 年 5 月 6 日
コメント済み: Rik 2022 年 5 月 6 日
This may be easy but I'm no expert in MatLab. I have a bacth of wav files and I need to extract a 30s sample from each. Example
1.wav - need 1:34-2:04
2.wav - need 5:15 - 5:45
ideally I'd like to run a code which will take each wav file and extract the correct time period according to a pre-generated table and save each snippet as a new wav file (e.g., 1_snip.wav would be the 30secs I need to analyze). Any points in the right direction would be great. Thanks!

回答 (1 件)

Rik
Rik 2022 年 5 月 6 日
Have you already found a way to read a single wav file? If not, audioread should do what you want.
Remember that the second output is the sampling frequency (in samples per second), so you will have to multiply that by the number of seconds to determine the number of samples you need.
Then you can use audiowrite to create the new file.
  2 件のコメント
Benjamin Colbert
Benjamin Colbert 2022 年 5 月 6 日
Sure, i can use audioread to read in a wav file but how do I then extract the 30sec snippet I want in order to save via audiowrite?
Rik
Rik 2022 年 5 月 6 日
You need to convert the time in seconds to samples. You can use the sample frequency output parameter. Simply convert the time marks to seconds and multiply those with Fs. Then you can use those to index the data array.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSimulation, Tuning, and Visualization についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by