Symbian S60 mp3解压(解码)与混音解决方案(含源代码)

来源:互联网 发布:知乎 日本 编辑:程序博客网 时间:2024/06/10 22:11

 

Symbian S60 MP3 decoding & sound mixing solution.

Official website: http://www.wanwann.com/2010/02/21/symbian-s60-mp3-decoding-sound-mixing-solution/

preamble:

As we might know, It is not workable to play mutiple music file allat once on the symbian s60 platform, for  the latter would preempt theaudio device of the previous one(However, It’s workable if we have amusic file player and another stream player, here, I mean music fileplayer by playing some music by using the CMdaAudioPlayerUtility::de>OpenFileL()de>, or some similiar operation, stream player by playing some music by using the CMdaAudioInputStream::de>Open() de> or some operation like that.)

So what if we wanna play multiple music or sound at the some time?What if we wanna play some background music, and at this moment, wewanna have some sound effect in our game?  If you try by using severalmusic file player, I bet, you would have to stop the others while someis playing. This sounds no good, as it might be too difficult tocontrol and also, the effect would be not as good as you expect.

Well,  here provides a solution to you,  that you can decode yourmp3 to raw music datas, and then mixing then play(by using a singlestreamming player) these decoded raw datas. However, this solution isan opensource project which is licenced under the GPL licence, pleaseagree to the license before you use the sourcecodes.

How did it work?

We use an open-sourced mp3 decoding library, madlib for mp3decoding.  For mixing play, we register an channel everytime we’d liketo play one music(sound).

How do I get started?

We provide a demo here, so you can learn how to use it.

For decoding, just create an instance of  class CMp3ToRawdataDecoder, then set your resample rate, then decode.

iDecoder1 = CMp3ToRawdataDecoder::NewL(iObserver);  // The observer to observe this decoding process
iDecoder1->SetResampleRate(44100);
TFileName srcFile = KSrcFilePath;  // The source mp3 file to be decoded
TFileName destFile = KDestFilePath;  // The file path where the decoded raw datas will be saved
iDecoder1->StartDecode(srcFile, destFile);

If the decoding process succeeds,  the    DecodeComplete(constTFileName& aSrcFileName, const TFileName& aDestFileName) of theobserver class will be called, otherwise, the ReportError(constTFileName& aSrcFile, const TFileName& aDestFileName, TIntaErrorCode) of the observer class would be called.

For mixing play, just create an instance of class CMixingPlayer, then play.

iMixingPlayer = CMixingPlayer::NewL();

iMixingPlayer->play(aDestFileName1, 100, FALSE);

If you wanna play another music, easy, just call play again.

iMixingPlayer->play(aDestFileName2, 100, FALSE);

Downloads

The Solution Library is downloadable here.

The Solution Demo is downloadable here.

原创粉丝点击