View previous topic :: View next topic |
Author |
Message |
Bluddy
Joined: 22 Apr 2007 Posts: 17
|
Posted: Sun May 16, 2010 9:01 pm Post subject: mp3 on the ME at 22Khz |
|
|
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 |
|
 |
jojojoris
Joined: 30 Mar 2008 Posts: 261
|
Posted: Mon May 17, 2010 2:17 am Post subject: |
|
|
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 |
|
 |
cooleyes
Joined: 18 May 2006 Posts: 125
|
Posted: Tue May 18, 2010 6:54 pm Post subject: Re: mp3 on the ME at 22Khz |
|
|
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 |
|
 |
Bluddy
Joined: 22 Apr 2007 Posts: 17
|
Posted: Sun May 23, 2010 10:55 pm Post subject: |
|
|
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 |
|
 |
cooleyes
Joined: 18 May 2006 Posts: 125
|
Posted: Sun May 23, 2010 11:36 pm Post subject: |
|
|
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 |
|
 |
Bluddy
Joined: 22 Apr 2007 Posts: 17
|
Posted: Mon May 24, 2010 3:21 am Post subject: |
|
|
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 |
|
 |
psPea
Joined: 01 Sep 2007 Posts: 64
|
Posted: Mon May 24, 2010 11:08 am Post subject: |
|
|
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 |
|
 |
Bluddy
Joined: 22 Apr 2007 Posts: 17
|
Posted: Mon May 24, 2010 8:41 pm Post subject: |
|
|
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 |
|
 |
Bluddy
Joined: 22 Apr 2007 Posts: 17
|
Posted: Sun May 30, 2010 7:54 pm Post subject: |
|
|
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 |
|
 |
|