is it possible?

For general discussion related FlowStone
Post Reply
Jay
Posts: 276
Joined: Tue Jul 13, 2010 5:42 pm

is it possible?

Post 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!
tester
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: is it possible?

Post 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/MP3

I 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.
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
User avatar
trogluddite
Posts: 1730
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK

Re: is it possible?

Post 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!
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
Jay
Posts: 276
Joined: Tue Jul 13, 2010 5:42 pm

Re: is it possible?

Post 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" :twisted:

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
tester
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: is it possible?

Post by tester »

Maybe it can be done... in ruby? :D
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
Post Reply