Page 1 of 1
is it possible?
Posted: Sun Dec 15, 2013 12:54 pm
by Jay
Hi all
Is it possible to in some way, too get the lengh of an mp3 file in samples? like we can with the wave prims? the reason i ask this is, on the audiostreamin prim the output of Play position info is never ever correct on any of my 8 machines! it always gives out random results such as - 18% when a track has acctualy played all the way through!
i am trying to get an output of 1 trigger everytime a song has ended, tried lots of ways to do this but have failed so far!
can anyone help?
cheers!
Re: is it possible?
Posted: Sun Dec 15, 2013 1:27 pm
by tester
As far I remember, mp3 files are "measured" in frames. A "frame" here is a smallest portion of audio, that is being processed by the mp3 algo. Check here:
http://en.wikipedia.org/wiki/MP3I suspect, that you could follow frames with some sort of ruby algo. Otherwise - you have to decode mp3 partials to wave somewhere virtually (buffer), and then you can measure samples.
Re: is it possible?
Posted: Sun Dec 15, 2013 3:20 pm
by trogluddite
Are your mp3's variable bit-rate by any chance?
My guess is that the length measurement is wrong because it assumes a constant bit-rate mp3 - i.e. it is lazy and only checks the header for the first frame to get the bit-rate. For a variable-rate mp3 you would have to read every single frame header and arrive at a cumulative value for it to be accurate. VBR is the default for a lot of encoders, as it allows the best compromise between quality and compression for typical music files.
The first frame of most tracks would be pretty much silence at the start of the fade-in, so a variable bit-rate file would encode that at a very low bit-rate indeed, massively throwing out the size measurement for the more "detailed" frames that come along when the music kicks in.
Parsing the file format in Ruby would certainly be possible - though maybe not very quickly, as a long VBR track would have a lot of frames to scan through.
Would be interesting to study the format of the data blocks - "stored as frequency and amplitude data" it says on the Wiki; that sounds like it could be rather useful!
Re: is it possible?
Posted: Sun Dec 15, 2013 5:07 pm
by Jay
cheers for the info guys!
yup you are correct Trogg!" ive just converted some tracks into single bitrate files (256kbp) and everything works now! still ,its useless to use in a product though!
"hey here is my free app! you just have to re-encode and degrade all of your mp3's to use it"
maybe that is something that could be fixed out with the new dll thing! although i cant understand why this has not been addressed by the devs! so it's just like the haar cascade primitive that does not understand haar files

(been waiting what? 2 years for that to get fixed lol)
in the meantime we have synthedit

regards
Re: is it possible?
Posted: Sun Dec 15, 2013 6:04 pm
by tester
Maybe it can be done... in ruby?
