forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

mp3 on the ME at 22Khz

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Bluddy



Joined: 22 Apr 2007
Posts: 17

PostPosted: Sun May 16, 2010 9:01 pm    Post subject: mp3 on the ME at 22Khz Reply with quote

I tried to adapt coolEyes' audioCodec code that uses the ME. Unfortunately, MP3s at 22kHz play with heavy clicking, and all my MP3 data in ScummVM is 22kHz. Comparing the output to libMAD, half of the MP3 frames translate fine, and half aren't what they're supposed to be (at all). I tested it on LightMP3 as well.

Anyone have any idea what parameter needs to be passed to tell the ME to decode in 22kHz?

I know the XMB can decode 22kHz files properly. Where in flash (ie which PRX) will I find these calls? Any ideas?
Back to top
View user's profile Send private message
jojojoris



Joined: 30 Mar 2008
Posts: 261

PostPosted: Mon May 17, 2010 2:17 am    Post subject: Reply with quote

Maybe you can use double buffering.
That could be a solution when the audio is not processed fast enough.
_________________
Code:
int main(){
     SetupCallbacks();
     makeNiceGame();
     sceKernelExitGame();
}
Back to top
View user's profile Send private message
cooleyes



Joined: 18 May 2006
Posts: 125

PostPosted: Tue May 18, 2010 6:54 pm    Post subject: Re: mp3 on the ME at 22Khz Reply with quote

Bluddy wrote:
I tried to adapt coolEyes' audioCodec code that uses the ME. Unfortunately, MP3s at 22kHz play with heavy clicking, and all my MP3 data in ScummVM is 22kHz. Comparing the output to libMAD, half of the MP3 frames translate fine, and half aren't what they're supposed to be (at all). I tested it on LightMP3 as well.

Anyone have any idea what parameter needs to be passed to tell the ME to decode in 22kHz?

I know the XMB can decode 22kHz files properly. Where in flash (ie which PRX) will I find these calls? Any ideas?


use sceAudioSRC* functions to output,
do not use sceAudio* functions
because sceAudio* functions only support 44.1Khz and 48Khz

you can use my code in sirens2 project
http://code.google.com/p/sirens2/
Back to top
View user's profile Send private message
Bluddy



Joined: 22 Apr 2007
Posts: 17

PostPosted: Sun May 23, 2010 10:55 pm    Post subject: Reply with quote

Thanks for the reply cooleyes.

The problem is not with the output -- I can resample to 44.1kHz. The problem is with decoding the MP3 on the ME. My MP3 files are all 22kHz, and decoding them using sceAudioCodecDecode etc. produces serious clicking. Looking at the samples that are decoded, I see that 2 MP3 frames are decoded correctly (really close to MAD's values) and 2 MP3 frames are completely off (for example, full of many high values when libMAD produces values close to 0's). This repeats itself over and over -- 2 good frames, 2 bad frames. Since lightMp3, which also uses your MP3 decoding code, has the same problem, I think it's a problem with the ME's MP3 decoding.

However, since the VSH can decode 22kHz MP3s perfectly, I think that there must be some missing argument that tells the ME to decode 22kHz MP3s as opposed to 44kHz.

Does that make more sense?
Back to top
View user's profile Send private message
cooleyes



Joined: 18 May 2006
Posts: 125

PostPosted: Sun May 23, 2010 11:36 pm    Post subject: Reply with quote

Bluddy wrote:
Thanks for the reply cooleyes.

The problem is not with the output -- I can resample to 44.1kHz. The problem is with decoding the MP3 on the ME. My MP3 files are all 22kHz, and decoding them using sceAudioCodecDecode etc. produces serious clicking. Looking at the samples that are decoded, I see that 2 MP3 frames are decoded correctly (really close to MAD's values) and 2 MP3 frames are completely off (for example, full of many high values when libMAD produces values close to 0's). This repeats itself over and over -- 2 good frames, 2 bad frames. Since lightMp3, which also uses your MP3 decoding code, has the same problem, I think it's a problem with the ME's MP3 decoding.

However, since the VSH can decode 22kHz MP3s perfectly, I think that there must be some missing argument that tells the ME to decode 22kHz MP3s as opposed to 44kHz.

Does that make more sense?


maybe your mp3 is not mpeg1 , it is mpeg2 or mpeg2.5
one frame is not still 1152 samples, maybe 384 samples

samples_per_frame = mp3_samples_per_frames[mp3_version*3+mp3_level];


http://code.google.com/p/sirens2/source/browse/trunk/sirens2/parsers/mp3_parser.cpp
Back to top
View user's profile Send private message
Bluddy



Joined: 22 Apr 2007
Posts: 17

PostPosted: Mon May 24, 2010 3:21 am    Post subject: Reply with quote

I did account for that. Basically I use MAD's parser to do the heavy lifting for me, since right now it's just a hack in the scummvm code.

Does sirens play a 22kHz mp3? I think I'll build it and try it out.
Back to top
View user's profile Send private message
psPea



Joined: 01 Sep 2007
Posts: 64

PostPosted: Mon May 24, 2010 11:08 am    Post subject: Reply with quote

You should post your code, so we can see if you did something wrong.

Also you could check this audio library, it can decode mp3 @ 22500k
_________________
Click ME!
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Bluddy



Joined: 22 Apr 2007
Posts: 17

PostPosted: Mon May 24, 2010 8:41 pm    Post subject: Reply with quote

cooleyes, your sirens2 code is a pain to compile... missing files in the latest rev (r41 is ok) and needs the M33SDK which I don't have.

psPea I'll check out that lib. I'll also post my code when I get a chance.
Back to top
View user's profile Send private message
Bluddy



Joined: 22 Apr 2007
Posts: 17

PostPosted: Sun May 30, 2010 7:54 pm    Post subject: Reply with quote

psPea, your suggestion was excellent! I was able to fix my mistakes using the code you pointed out.

For those who would like to know, I had 2 mistakes in using libaudiocodec:

1. A 65 word array must be used for each and every file if you want to play them at the same time. It's like the audio file's handle. I used one global one, which wasn't enough.

2. Array position [10] (ie. @40 bytes) must contain the sample rate of the file to play a 22kHz file, and this should be set before calling sceAudiocodecInit()

Thanks again psPea. Now ScummVM supports native MP3 playback!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group