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

 

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 all at once on the symbian s60 platform, for  the latter would preempt the audio device of the previous one(However, It’s workable if we have a music file player and another stream player, here, I mean music file player 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, we wanna have some sound effect in our game?  If you try by using several music file player, I bet, you would have to stop the others while some is playing. This sounds no good, as it might be too difficult to control and also, the effect would be not as good as you expect.

Well,  here provides a solution to you,  that you can decode your mp3 to raw music datas, and then mixing then play(by using a single streamming player) these decoded raw datas. However, this solution is an opensource project which is licenced under the GPL licence, please agree to the license before you use the sourcecodes.

How did it work?

We use an open-sourced mp3 decoding library, madlib for mp3 decoding.  For mixing play, we register an channel everytime we’d like to 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(const TFileName& aSrcFileName, const TFileName& aDestFileName) of the observer class will be called, otherwise, the ReportError(const TFileName& aSrcFile, const TFileName& aDestFileName, TInt aErrorCode) 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 .

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值