I need to play Mp3 on 6600. Presently I am getting mostly only noises as output. What are the things that I need to consider to play Mp3 on 6600. If you know some details in getting this task done please refer the source.
Presently I am using the libmad library and using the DecodeOneFrame function in that to get the file decoded frame by frame and I am appending the output into an HBufC. Then I am converting the HBufC to HBufC8 and writing the HBufC8 into the audio buffer by using the normal streaming functionality. Still I am seeing that the output I am recieving is only noise.
Some observations while decoding the code (All tests were done only on emulator) were:
(1) While converting the HBufC to HBufC8 when bufferes of different size were converted, I got different results. I have found the maximum conversion were made when convertions were made using temporary TBuf's of length 8. Most of the times the ConvertFromUnicodeToUtf8 function is still returning error "KErrCorrupt" identified by return value of -20. In such situations there was no conversion that had taken place whatso ever.
(2) Different MP3 files gave different responses to the same code. In one file, using TBuf's of length 8 all the frames are sucessfully converted, but still not playing properly. In rest of the files most of the times the ConvertFromUnicodeToUtf8 function is still returning error "KErrCorrupt" identified by return value of -20.
How can I convert the 16 bit data that the DecodeOneFrame funcftion is giving into an 8 bit value and retain its audio properties so as to sucessfully pass it onto WriteL function and get the desired output sound?
I am finding that the decoded MP3 data is present in the 16 bit HBufC. I need some code to properly write the same audio information to be copied into 8-bit descriptors to be played sucessfully in the mobile phone. Please could you tell me a proper method of conversion without loss of essential data.
Are you able to put the output of the decoder in a TUint16 array directly?
If so, then you don't need that expensive for loop (and iGenBuffer) because you can set the array-pointer directly in the iDescBuf var. You have to cast the TUint16 * to a TUint8 * then, but that's no problem.
The code will the be something like:
// creating buffer to hold 8-bit data
// Get the length of the MP3 data somehow (from decoder?)
// iMp3toPcmStream array contains the decoded stream.
TInt mp3Len = decoder.getbyteswritten(); // if you get samples, multiply with sizeof( TUint16 )
iDescBuf.Set((TUint8*) iMp3toPcmStream,mp3Len ,mp3Len );
// Write data to audio device
iAudioDevice->WriteL( iDescBuf );