フィルターのクリア

How to check length of a .wav file through GUI

3 ビュー (過去 30 日間)
Matlab Help Seeker
Matlab Help Seeker 2011 年 6 月 30 日
コメント済み: Walter Roberson 2022 年 2 月 17 日
Hi,
I have designed a GUI which allows a user to click on the browse button and browse through his hard disk to select a .wav file. Now, I want that the .wav file selected should have a minimum length of let's say 3 seconds.
So, what I want is that if the user selects a .wav file from hard disk with length lesser than 3 seconds, I could display a message. How could I implement this functionality through MATLAB that it checks the length of the .wav file selected by the user?
Thank you.

採用された回答

Paulo Silva
Paulo Silva 2011 年 6 月 30 日
[y,fs] = wavread(filename);
TotalTime = length(y)./fs; % time in seconds
  1 件のコメント
Matlab Help Seeker
Matlab Help Seeker 2011 年 6 月 30 日
I thought of this after posting the answer. That means I am getting intelligent too :p
Thank you!

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2011 年 6 月 30 日
wavfinfo can tell you the number of samples in the .wav file. You could combine that with asking to read only one sample in wavread() in order to get out the sampling frequency (and the bits per sample if you care about that.)
  2 件のコメント
manjula kumari
manjula kumari 2022 年 2 月 17 日
Hi, you can simply plot the .wav file by reading with "audioread" function. then plot the file, x-axis represents the number of samples only.
Walter Roberson
Walter Roberson 2022 年 2 月 17 日
audioread() did not exist at the time the question was asked; it was added in R2012b.
Plotting the data is not an effecient way of determining the number of samples.
audioinfo() can be used to determine the number of samples and the sampling rate. However, be sure to read the limitations: on Windows and Linux there are situations in which the returned number of samples can be inaccurate.

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

カテゴリ

Help Center および File ExchangeAudio and Video Data についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by