length of audio sample

조회 수: 74 (최근 30일)
God'sSon
God'sSon 2011년 4월 7일
댓글: Mayur Gudi 2020년 2월 22일
hello!
I am trying to import an audio sample into matlab and get matlab to tell me the length of the sample. Please can someone help me with this ,
cheers.
  댓글 수: 1
tubariaz tubariaz
tubariaz tubariaz 2017년 9월 19일
how to find sample rate of audio file in matlab

댓글을 달려면 로그인하십시오.

채택된 답변

Paulo Silva
Paulo Silva 2011년 4월 7일
Just in case you got a wave file
[y, Fs, nbits] = wavread(filename) %load the wav
[m d] = wavfinfo(filename) %get the wav information
Another way to get the length in seconds is:
siz = wavread(filename,'size') %siz = [samples channels]
siz(1)/Fs %should give you the length in seconds
  댓글 수: 1
Mayur Gudi
Mayur Gudi 2020년 2월 22일
I did this. But for a file of 500 ms. It is showing length as 23664 after dividing by 44100 we get 0.5365 which means 536 ms approx How is this possible !!? From where did this extra 36 ms come from ?
I tried with a file of exactly 2 seconds there also it showed 2.something. Why length is shown more than actual ?

댓글을 달려면 로그인하십시오.

추가 답변 (6개)

Yared Andarge
Yared Andarge 2018년 12월 6일
[y,Fs] = audioread('yared.wav'); % y samples from audio with Fs sampling frequency in [Hz].
sound(y,Fs);% listen your audio input
N = length(y); % sample lenth
slength = N/Fs; % total time span of audio signal
t = linspace(0, N/Fs, N);
plot(t, y); % pplots the audio

Neuron
Neuron 2014년 10월 16일
Is it really N/Fs or maybe (N-1)/Fs ? (N: number of samples)
I mean, 1 sample has what? 1/Fs duration? I think 2 samples should have 1/Fs (the minimum duration). We also use to plot it like [0:N-1] in the x-axis and not like [0:N] or [1:N]. Then, taking [0:N-1]/Fs really matches the duration if you notice. The right end is (N-1)/Fs.

Laura Proctor
Laura Proctor 2011년 4월 7일
You can import the data using an audio import function such as WAVREAD or AUREAD or even by using the Import Wizard by selecting File > Import Data. This will bring in your audio sample. You can see the number of elements in the variable you brought in by using the LENGTH function. However, if you want the timing length, then you will need to divide this number by the sampling frequency.

shaik
shaik 2014년 8월 19일
can any one tell how to change the default frame size of 1024 of audio signal to required frames size (1024*x) where x is a multiple of 2.

haroon urd
haroon urd 2016년 11월 29일
for length of an audio signal [x,fs]=wavread('filename.wav'); len=length(x); //length of an audio signal to=len/fs;// the total time of audio signal sound(x,fs);//play sound file for t=0:1:to set(handles.edit1,'string',num2str(t));//that will display the time duration of audiosignal
pause(1); end
  댓글 수: 1
Maria Sheeba
Maria Sheeba 2017년 4월 12일
I want to know simultaneously both the audio length and the frame size and also how to determine the sound pressure level for a particular audio using a matlab. Can anyone help me in this?
Thank You

댓글을 달려면 로그인하십시오.


sufyan masood
sufyan masood 2018년 8월 18일
hello can any one tell about sparsify subband signal and subband modification of subband signals coeffiects in compressive signal. kindly guide me about it. i will be highly thankful to all for help me counter this problem.

카테고리

Help CenterFile Exchange에서 Audio I/O and Waveform Generation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by