[Solved] MP3 issues - unusual header

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
foebea
Posts: 9
Joined: Fri Mar 23, 2007 9:03 pm

[Solved] MP3 issues - unusual header

Post by foebea »

Heyyas all, I am working to support 22khz mp3 for my application. I have tried tearing apart the code of others to find out how to properly decode audio. The code by Cooleyes just recently is a huge help with this, but still my problem remains.

The audio file in question is a short (few seconds) which on every homebrew mp3 player has distortion and clicks, followed by a staticy rendition of the vocal at double speed.

When I play the same file with the sonys builtin music player it plays normally, with full audio, no distortion, no problems.

I don't suppose there is a way to call the builtin player to play audio files, yet no matter how i fiddle with source which claims to support 22khz, i cant rid the distortion.

It is not a viable solution to just reencode the audio to 44khz, as they are supplied by the user at runtime, and there are many thousands of them for each user.

I have been struggling with this since March :D
Any assistance would be appreciated and fully credited.

here is a sample mp3 which plays fine in sonys psp music player, but is messed up everywhere else: http://www.poorlywritten.com/piki/images/6/6e/Test.rar
Last edited by foebea on Sun Sep 16, 2007 2:29 pm, edited 2 times in total.
crazyc
Posts: 408
Joined: Fri Jun 17, 2005 10:13 am

Re: MP3 issues - quagmire?

Post by crazyc »

That file has a unusual 324 byte header which confuses libmad. If I chop off the header, it plays fine.
foebea
Posts: 9
Joined: Fri Mar 23, 2007 9:03 pm

Post by foebea »

That would certainly explain it. if it starts trying to decode nonstandard data it messes up the data sync for the rest of the file.

Exactly how would I go about skipping over that header?
If you solve this for me I will be forever in your debt (or at least until friday, if you can accept paypal)
crazyc
Posts: 408
Joined: Fri Jun 17, 2005 10:13 am

Post by crazyc »

foebea wrote:That would certainly explain it. if it starts trying to decode nonstandard data it messes up the data sync for the rest of the file.

Exactly how would I go about skipping over that header?
If you solve this for me I will be forever in your debt (or at least until friday, if you can accept paypal)
If you build libmad with OPT_STRICT defined, the file plays correctly with the header.
foebea
Posts: 9
Joined: Fri Mar 23, 2007 9:03 pm

Post by foebea »

I have found this functionality for OPT_STRICT in the layer12.c and layer3.c in the src directory, but I have not found in any of the files from svn where I would actually define anything. My best guess is that this would be done with configure, but ps2dev svn does not include a configure.sh or autogen.sh or anything like that.

Do I just need to add #define OPT_STRICT to one of the files?
I have been checking for instances in the source and includes that look like they would accept something like this, and have googled for similar scenarios. nothing is popping out.

Sorry for all the questions.
crazyc
Posts: 408
Joined: Fri Jun 17, 2005 10:13 am

Post by crazyc »

Do I just need to add #define OPT_STRICT to one of the files?
Yes, config.h is probably the most appropriate place.
foebea
Posts: 9
Joined: Fri Mar 23, 2007 9:03 pm

Post by foebea »

ah.... I feel blind. I even looked at that file.
it should have all come clear when I saw:
#define OPT_SPEED

Thanks so much for your help. I will try that out as soon as I get back to my computer.
foebea
Posts: 9
Joined: Fri Mar 23, 2007 9:03 pm

Post by foebea »

This has absotively solved my issue. I thank you. My users thank you. This means they can stop manually converting mp3s to 44khz and really start to use the program. I will pay a bounty for this one, if you want it. I had thought the audio issue was completely due to bad memory management on my side until recently, and I had almost gotten to the point at attempting a full rewrite in a different language. I can be reached at gmail if you would prefer not discuss reward here. Thanks again!
Post Reply