Measuring the length of a song

조회 수: 5 (최근 30일)
Seetha Rama Raju Sanapala
Seetha Rama Raju Sanapala 2015년 5월 22일
댓글: Seetha Rama Raju Sanapala 2015년 5월 22일
Suppose I have a code segment like this for measuring the time length of the song.
player = audioplayer(y, Fs);
tic
play(player)
toc
I do not get the actual length of the song with this tic toc. It just gave some 5 seconds whereas the song length was in minutes. I guess actually the 5 seconds is for the audioplayer process not the playing of the song in full. MatLAB prompt is becoming ready to receive the next command even while the song is being played. How to get the actually song time? Please do not advise me to multiply the sampling interval with the number of samples.
  댓글 수: 2
Guillaume
Guillaume 2015년 5월 22일
"Please do not advise me to multiply the sampling interval with the number of samples"
Why not? That would be the most accurate and straightforward way to get it.
Seetha Rama Raju Sanapala
Seetha Rama Raju Sanapala 2015년 5월 22일
Yes. but I am looking for some other tool like tic toc to measure the time. BTW, why is tic toc not able to measure this and is there a technical name for this feature of freeing up MATLAB for the next command before the song is played in full?

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

채택된 답변

Walter Roberson
Walter Roberson 2015년 5월 22일
If the song is stored in an audio file in standard format, then use audioinfo on the file and extract Duration from the result.
You could also change your play(player) call to playblocking(player). That would give you a wall-clock time to play the song, but that is not the same as how long the song is because of the overhead of setting up to play the song.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Audio and Video Data에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by