How to determine song total length in minutes

Blitz3D Forums/Blitz3D Programming/How to determine song total length in minutes

Guy Fawkes(Posted 2008) [#1]
PLEASE tell me of any way to get a song's total time in minutes + secs, and / or ms.

~DarkShadowWing~


Mortiis(Posted 2008) [#2]
You can use Imphenzia Audio System which released some time ago. You can find it in the userlibs forum. Blitz3D doesn't have a function to find audio file length.


SLotman(Posted 2008) [#3]
You can also use my mciMP3 userlib, if you're playing MP3s. It has a function just for that. (Link in signature)


Guy Fawkes(Posted 2008) [#4]
id like to, but i need to get song time for midi, mp3, etc...


Guy Fawkes(Posted 2008) [#5]
anyone?


xlsior(Posted 2008) [#6]
Since B3D doesn't have a built-in function to determine this, you'd pretty much have to do it the hard way for each individual file format.

e.g. check wotsit.org for file format descriptions for each format you want to know this for, and analyze the headers of the file(s) to dig up the info you need.

To complicate matters, certain fileformats like MP3 don't always return accurate info if they happen to use VBR (Variable Bit Rate) compression where different parts of the file may be encoded with different compression rates.

But this might get you started:
http://www.wotsit.org/getfile.asp?file=mpeghdr&sc=281382876


Guy Fawkes(Posted 2008) [#7]
cant i just call a dll function? *sigh*


xlsior(Posted 2008) [#8]
Did you even read Mortiis and Slotman's postings above?


Guy Fawkes(Posted 2008) [#9]
yes. but imphenzia returns how LONG the song HAS been playing. I need the song file's length. whether its an mp3, a mid. w/e.

its easier if i use decls to do this. and as for mci, id use it, but as i said, i need mp3, midi, wav, pretty much.

~DarkShadowWing~


xlsior(Posted 2008) [#10]
For both MP# and WAV you can pretty much find the compression ratio in the header of the file, which you can then compare to the size of the file to calculate the length of the sample.

for .mod and .mid and such it's going to be more complicated... :-?


Guy Fawkes(Posted 2008) [#11]
is there any example i can see that does this? i apologize for askin, but this is the only way i learn. by seein examples.

~DarkShadowWing~


Guy Fawkes(Posted 2008) [#12]
Please. I'm desperate. Use MCI if you must.

~DarkShadowWing~


SLotman(Posted 2008) [#13]
AGAIN: Look at my userlibs. You can get MP3 length. For MIDI and WAV you will just need to adapt the .bb calls a little bit, just check how to access MCI stuff (probably change the filetype to "wavaudio" for wav, and to something else to MIDI, and thatīs it)

Nothing a 5 mins research, together with my mciMP3 userlib wouldnt solve.

Dont use file size to get MP3 time, it doenst work (isn't precise enough, and if you get a VBR MP3 it will be even worse)

EDIT: If you're that desperate, I can do it for you... for a small fee ;)


Guy Fawkes(Posted 2008) [#14]
ok. ill try. cuz im desperate. but if i cant get the mid / wav time, im screwed.

~DarkShadowWing~


Guy Fawkes(Posted 2008) [#15]
if this works, and its royalty free, id so get the full version. unless its already royalty free. but please, no insane prices, lol.

~DarkShadowWing~


SLotman(Posted 2008) [#16]
make me an offer at slotman@mysite :)

I already have MIDI timing working, just need to make WAV too...
Edit: just made it.

See http://www.icongames.com.br/b3duserlibs/mci_all.zip for a sample playing mp3,wav and midi with MCI, and getting status, current position and file length (all in milliseconds).

Send me an offer and you can have the source, to do whatever you want with it :)


Guy Fawkes(Posted 2008) [#17]
well. i have to talk w/ my parents about it, but i dont know how to convince them. =/ i really need song length in seconds as well as minutes.

~DarkShadowWing~


Gabriel(Posted 2008) [#18]
i really need song length in seconds as well as minutes.

Multiply by sixty?


Guy Fawkes(Posted 2008) [#19]
slotman. i talked to my parents, and they said its cool. i can offer u a SMALL amount.

ill email u =)

~DarkShadowWing~


Guy Fawkes(Posted 2008) [#20]
slotman, i emailed u. i have decided to use paypal. let me know when you can have the code.

i'll email u again when i hear from you =)

Thanks! =)

~DarkShadowWing~


Guy Fawkes(Posted 2008) [#21]
slotman, i emailed u again.

i'll email u again when i hear from you =)

Thanks! =)

~DarkShadowWing~


Guy Fawkes(Posted 2008) [#22]
Thanks =)

~DarkShadowWing~


Guy Fawkes(Posted 2008) [#23]
Slotman, I emailed you again =)

Check your email =)

Thanks! =)

~DarkShadowWing~


Guy Fawkes(Posted 2008) [#24]
slotman?


Guy Fawkes(Posted 2008) [#25]
ok, i donated slotman. Please check your email =)

~DarkShadowWing~


SLotman(Posted 2008) [#26]
Check your email, I just sent the code :)

Cheers!


Guy Fawkes(Posted 2008) [#27]
Slotman, I got the email. Thank you so much! =) So far it's perfect =)

If I find any errors or anything I'll letcha know A.S.A.P.

Thanks again! =)

~DarkShadowWing~


Guy Fawkes(Posted 2008) [#28]
Slotman, I emailed you again. Check your mail =)

~DarkShadowWing~


Wings(Posted 2008) [#29]
the lazy way
I open the song i media player and it tells me lenght of it :)


Guy Fawkes(Posted 2008) [#30]
no probs =) its taken care of, wings :P

~DarkShadowWing~


Buggy(Posted 2008) [#31]
I feel like this would have been way easier if you just used one of the countless free online whatever-to-mp3 converters, and then used Slotman's original lib. At least it would have spared us ten "i emailed u" posts. ;)