Jump to content
Sign in to follow this  
Wb-FreeKill

Possible to get music file length?

Recommended Posts

Is it possible to retrieve a mp3 or wav music file length? like 04:32

<{POST_SNAPBACK}>

There should be a dll for it, although I had no luck finding it. Windows Media player has to get the song length some how. Other then that, the only way I can think of is to filegetsize and do some math to figure out how long the song is. But if you did it that way, then quality will be a issue with then file size. All I know is that windows media player does it as well as other players and I believe there is a dll some where to return the length of a Mp3 file.

.

Share this post


Link to post
Share on other sites

Looked at it allready, and compared it with windows, my program says 03:28 and windows says 03:17 :S

MsgBox(4096,"file length","length in milliseconds: " & $answer /1000 / 60)

197609 milli / 1000 / 60 = 3.29348333333333

Share this post


Link to post
Share on other sites

That is correct...

3.29 is going out of 100... There are 60 seconds in 1 minute, not 100.

197609 milli / 1000 / 60 = 3.29348333333333

29 / 100 * 60 = 17.4 :(.


qq

Share this post


Link to post
Share on other sites

That is correct...

3.29 is going out of 100... There are 60 seconds in 1 minute, not 100.

197609 milli / 1000 / 60 = 3.29348333333333

29 / 100 * 60 = 17.4 :(.

<{POST_SNAPBACK}>

hah, wize boy - damn u :( thank you very much!

Share this post


Link to post
Share on other sites

thats cause its base 60 instead of base ten... reminds me of algebra and the SAT's


Share this post


Link to post
Share on other sites

For Mp3, it is the mp3 author's choice to code in the length in the ID tag, I believe.

But many utilities will calculate it for you.

For WAV, if you can access the header, you can calculate the length precisely.

If you know that it is 16 bit stereo, 44100 Sampling rate, such as CD quality, you can use:

Length in Seconds = (Size of File - Size of Header)/44100/2(for stereo)/(16*16)

Header is around 32 bytes I think, but there are exceptions.

(This is all from my memory -- Please correct me if I am wrong)

J


If I am too verbose, just say so. You don't need to run on and on.

Share this post


Link to post
Share on other sites

Can't you do (BytesPerSample - BitsPerSecond) / 1000? Or maybe its (BytesPerSecond - BitsPerSample) / 1000.


qq

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...