필터 지우기
필터 지우기

How to display audio file length in Matlab GUI

조회 수: 3 (최근 30일)
Nikos Korobos
Nikos Korobos 2022년 4월 9일
댓글: Walter Roberson 2022년 4월 17일
Hello everyone,
I have created an audio file player on Matlab, with Upload file and Play/Stop buttons.
Interested to code a display timer to show how long is the audio file while being played.
Can I use disp.AudioFileReader to count its length?
Need to count seconds in every loop.
Any suggestions appreciated.
  댓글 수: 2
Jan
Jan 2022년 4월 10일
What does "in every loop" mean? audioinfo tells you the length of a sound file.
Nikos Korobos
Nikos Korobos 2022년 4월 10일
편집: Nikos Korobos 2022년 4월 10일
Just trying to code a timer to show at which second the audio file that is being played is.

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

채택된 답변

Geoff Hayes
Geoff Hayes 2022년 4월 10일
@Nikos Korobos - if you are using an audioplayer, you could use the CurrentSample to determine how many samples havve been played which you can translate to how much (in seconds) of the track has been played (you would need to use the sampling rate to perform the correct calculation).
  댓글 수: 10
Nikos Korobos
Nikos Korobos 2022년 4월 17일
편집: Nikos Korobos 2022년 4월 17일
One more question, what if i wanted to code two buttons on my audio player, one to rewind and one to fast forward while a file is playing?
Can i use audioDeviceWriter method for those?
Thanks in advance!
Walter Roberson
Walter Roberson 2022년 4월 17일
audioDeviceWriter does not care where you get the audio samples that you send to the device. As far as it is concerned, you could flipud() the vector of samples or read two buffers from the file and throw away every second sample (fast forward) or whatever.
But for moving backwards the challenge is the audio file reader, which has no documented way of changing the position in the file - no way to seek back by 10 seconds for example. So in order to accomplish that you would need to keep a copy of the audio you read in, using a buffer the same size as the maximum total distance back you want the user to be able to move back. If you want the user to be able to move back all the way to the beginning (even if only 5 seconds at a time) then you would need to record the entire file in memory... unless there is an undocumented property that can help.

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

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by