This page was last modified 12:49, 31 December 2007.
Playing audio tones
From Forum Nokia Wiki
The CTonePlayer example illustrates how to play tones on Symbian devices. This example plays a simple constant tone for a predefined time, but CMdaAudioToneUtility could also be used to play DTMF (Dual-Tone Multi-Frequency) strings and tone sequences.
To use CMdaAudioToneUtility you need to implement MMdaAudioToneObserver callback interface, which is used by the player to update its status. MMdaAudioToneObserver has two methods defined from which MatoPrepareComplete is called when the tone player is initialized and ready to play. Play function should never be called before MatoPrepareComplete is called. The MatoPlayComplete method is called after the playing of the tone has finalized.
TonePlayer.cpp
#include <MdaAudioTonePlayer.h> #include <eikmenup.h> CTonePlayer* CTonePlayer::NewL() { CTonePlayer* self = NewLC(); CleanupStack::Pop(self); return self; } CTonePlayer* CTonePlayer::NewLC() { CTonePlayer* self = new (ELeave) CTonePlayer(); CleanupStack::PushL(self); self->ConstructL(); return self; } CTonePlayer::CTonePlayer(): iFrequency(125),iDuration(5000000) { } CTonePlayer::~CTonePlayer() { delete iToneUtility; } void CTonePlayer::ConstructL() { iToneUtility = CMdaAudioToneUtility::NewL(*this); iToneUtility->PrepareToPlayTone(iFrequency,iDuration); } void CTonePlayer::Play() { iToneUtility->Play(); } void CTonePlayer::Stop() { iToneUtility->CancelPlay(); } void CTonePlayer::MatoPrepareComplete(TInt /*aError*/) { iToneUtility->SetVolume(iToneUtility->MaxVolume()); } void CTonePlayer::MatoPlayComplete(TInt /*aError*/) { }
TonePlayer.h
#include <e32std.h> #include <MdaAudioTonePlayer.h> class CTonePlayer : public CBase, public MMdaAudioToneObserver { public: static CTonePlayer* NewL(); static CTonePlayer* NewLC(); ~CTonePlayer(); public: void Play(); void Stop(); protected: // from MMdaAudioToneObserver void MatoPrepareComplete(TInt aError); void MatoPlayComplete(TInt aError); private: CTonePlayer(); void ConstructL(); private: CMdaAudioToneUtility* iToneUtility; TInt iFrequency; TTimeIntervalMicroSeconds iDuration; };
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| FOMRAT_TONE & polyphonic tones | RamiShaft | Mobile Java General | 1 | 1970-01-01 02:00 |
| PolyPhonic Tones | srikanth06 | Audio | 1 | 2003-05-02 07:31 |
| tones | steve1959 | General Discussion | 0 | 2003-10-16 20:02 |
| Audio recording/playback volume on 5300, 6300 | Phonetechgal | Audio | 4 | 2008-04-04 17:13 |
| Increasing volume. | khurshed79 | Symbian Media (Graphics & Sounds) | 1 | 2005-08-15 04:39 |
