CMdaAudioToneUtility Class Reference

class CMdaAudioToneUtility : public CBase

Generates tones on an audio capable EPOC device.

The class offers an interface for generating tones on all audio capable EPOC devices.

To use the tone utility:

1. Create an instance by calling NewL().

2. Call the appropriate PrepareToPlay variant for the required tone type and wait for the callback indicating success.

3. Call Play and either wait for the callback to indicate completion, or call CancelPlay to end playback early.

4. Delete the instance.

It is possible to call Play before calling any PrepareToPlay variant. This will result in a default fixed sequence tone being played.

Since
5.0

Inherits from

  • CMdaAudioToneUtility
Public Member Functions
~CMdaAudioToneUtility()
voidCancelPlay()
voidCancelPrepare()
IMPORT_C TAny *CustomInterface(TUid)
TInt FixedSequenceCount()
const TDesC &FixedSequenceName(TInt)
IMPORT_C TIntGetBalanceL()
TInt MaxVolume()
IMPORT_C CMdaAudioToneUtility *NewL(MMdaAudioToneObserver &, CMdaServer *)
IMPORT_C CMdaAudioToneUtility *NewL(MMdaAudioToneObserver &, CMdaServer *, TInt, TInt)
IMPORT_C TIntPause()
voidPlay()
voidPrepareToPlayDTMFString(const TDesC &)
voidPrepareToPlayDesSequence(const TDesC8 &)
IMPORT_C voidPrepareToPlayDualTone(TInt, TInt, const TTimeIntervalMicroSeconds &)
voidPrepareToPlayFileSequence(const TDesC &)
IMPORT_C voidPrepareToPlayFileSequence(RFile &)
voidPrepareToPlayFixedSequence(TInt)
voidPrepareToPlayTone(TInt, const TTimeIntervalMicroSeconds &)
IMPORT_C voidRegisterPlayStartCallback(MMdaAudioTonePlayStartObserver &)
IMPORT_C TIntResume()
IMPORT_C voidSetBalanceL(TInt)
voidSetDTMFLengths(TTimeIntervalMicroSeconds32, TTimeIntervalMicroSeconds32, TTimeIntervalMicroSeconds32)
voidSetPriority(TInt, TInt)
voidSetRepeats(TInt, const TTimeIntervalMicroSeconds &)
voidSetVolume(TInt)
voidSetVolumeRamp(const TTimeIntervalMicroSeconds &)
TMdaAudioToneUtilityState State()
TInt Volume()
Inherited Functions
CBase::CBase()
CBase::Delete(CBase *)
CBase::Extension_(TUint,TAny *&,TAny *)
CBase::operator new(TUint)
CBase::operator new(TUint,TAny *)
CBase::operator new(TUint,TLeave)
CBase::operator new(TUint,TLeave,TUint)
CBase::operator new(TUint,TUint)
CBase::~CBase()
Protected Attributes
CMMFMdaAudioToneUtility *iProperties

Constructor & Destructor Documentation

~CMdaAudioToneUtility()

~CMdaAudioToneUtility()

Destructor. Frees any resources held by the tone player

Since
5.0

Member Functions Documentation

CancelPlay()

voidCancelPlay()[virtual]

Cancels the tone playing operation.

The observer callback function MMdaAudioToneObserver::MatoPlayComplete() is not called.

Since
5.0

CancelPrepare()

voidCancelPrepare()[virtual]

Cancels the configuration operation.

The observer callback function MMdaAudioToneObserver::MatoPrepareComplete() is not called.

Since
5.0

CustomInterface(TUid)

IMPORT_C TAny *CustomInterface(TUidaInterfaceId)

Retrieves a custom interface to the underlying device.

Parameters

TUid aInterfaceIdThe interface UID, defined with the custom interface.

FixedSequenceCount()

TInt FixedSequenceCount()[virtual]

Returns the number of available pre-defined tone sequences.

Since
5.0

FixedSequenceName(TInt)

const TDesC &FixedSequenceName(TIntaSequenceNumber)[virtual]

Returns the name assigned to a specific pre-defined tone sequence.

Parameters

TInt aSequenceNumberThe index identifying the specific pre-defined tone sequence. Index values are relative to zero. This can be any value from zero to the value returned by a call to FixedSequenceCount() - 1. The function raises a panic if sequence number is not within this range.

GetBalanceL()

IMPORT_C TIntGetBalanceL()

Returns The current playback balance.This function may not return the same value as passed to SetBalanceL depending on the internal implementation in the underlying components.

Since
7.0s

MaxVolume()

TInt MaxVolume()[virtual]

Returns the maximum volume supported by the device. This is the maximum value which can be passed to CMdaAudioToneUtility::SetVolume().

Since
5.0

NewL(MMdaAudioToneObserver &, CMdaServer *)

IMPORT_C CMdaAudioToneUtility *NewL(MMdaAudioToneObserver &aObserver,
CMdaServer *aServer = NULL
)[static]

Creates a new instance of the tone player utility. The default volume is set to MaxVolume() / 2.

Since
5.0

Parameters

MMdaAudioToneObserver & aObserverA class to receive notifications from the tone player.
CMdaServer * aServer = NULLThis parameter is no longer used and should be NULL.

NewL(MMdaAudioToneObserver &, CMdaServer *, TInt, TInt)

IMPORT_C CMdaAudioToneUtility *NewL(MMdaAudioToneObserver &aObserver,
CMdaServer *aServer,
TIntaPriority,
TIntaPref = EMdaPriorityPreferenceTimeAndQuality
)[static]

Creates a new instance of the tone player utility. The default volume is set to MaxVolume() / 2.

Since
5.0
Note: The Priority Value and Priority Preference are used primarily when deciding what to do when several audio clients attempt to play or record simultaneously. In addition to the Priority Value and Preference, the adaptation may consider other parameters such as the SecureId and Capabilities of the client process. Whatever, the decision as to what to do in such situations is up to the audio adaptation, and may vary between different phones. Portable applications are advised not to assume any specific behaviour.

Parameters

MMdaAudioToneObserver & aObserverA class to receive notifications from the tone player
CMdaServer * aServerThis parameter is no longer used and should be NULL
TInt aPriorityThe Priority Value - this client's relative priority. This is a value between EMdaPriorityMin and EMdaPriorityMax and represents a relative priority. A higher value indicates a more important request.
TInt aPref = EMdaPriorityPreferenceTimeAndQualityThe Priority Preference - an additional audio policy parameter. The suggested default is EMdaPriorityPreferenceNone. Further values are given by TMdaPriorityPreference, and additional values may be supported by given phones and/or platforms, but should not be depended upon by portable code.

Pause()

IMPORT_C TIntPause()

Play()

voidPlay()[virtual]

Plays the tone.

The tone played depends on the current configuration.This function is asynchronous. On completion, the observer callback function MMdaAudioToneObserver::MatoPlayComplete() is called, indicating the success or failure of the play operation.The play operation can be cancelled by calling CMdaAudioToneUtility::CancelPlay().

Since
5.0

PrepareToPlayDTMFString(const TDesC &)

voidPrepareToPlayDTMFString(const TDesC &aDTMF)[virtual]

Configures the audio tone utility player to play a DTMF (Dual-Tone Multi-Frequency) string.

This function is asynchronous. On completion, the observer callback function MMdaAudioToneObserver::MatoPrepareComplete() is called, indicating the success or failure of the configuration operation. The configuration operation can be cancelled by calling CMdaAudioToneUtility::CancelPrepare(). The configuration operation cannot be started if a play operation is in progress.

Since
5.0

Parameters

const TDesC & aDTMFA descriptor containing the DTMF string.

PrepareToPlayDesSequence(const TDesC8 &)

voidPrepareToPlayDesSequence(const TDesC8 &aSequence)[virtual]

Configures the audio tone player utility to play a tone sequence contained in a descriptor.

This function is asynchronous. On completion, the observer callback function MMdaAudioToneObserver::MatoPrepareComplete() is called, indicating the success or failure of the configuration operation. The configuration operation can be cancelled by calling CMdaAudioToneUtility::CancelPrepare(). The configuration operation cannot be started if a play operation is in progress.

Since
5.0

Parameters

const TDesC8 & aSequenceThe descriptor containing the tone sequence. The format of the data is unspecified but is expected to be platform dependent. A device might support more than one form of sequence data.

PrepareToPlayDualTone(TInt, TInt, const TTimeIntervalMicroSeconds &)

IMPORT_C voidPrepareToPlayDualTone(TIntaFrequencyOne,
TIntaFrequencyTwo,
const TTimeIntervalMicroSeconds &aDuration
)

Configures the audio tone player utility to play a dual tone. The generated tone consists of two sine waves of different frequencies summed together.

This function is asynchronous. On completion, the observer callback function MMdaAudioToneObserver::MatoPrepareComplete() is called, indicating the success or failure of the configuration operation. The configuration operation can be cancelled by calling CMdaAudioToneUtility::CancelPrepare(). The configuration operation cannot be started if a play operation is in progress.

Since
7.0sy

Parameters

TInt aFrequencyOneThe first frequency (pitch) of the tone.
TInt aFrequencyTwoThe second frequency (pitch) of the tone.
const TTimeIntervalMicroSeconds & aDurationThe duration of the tone in microseconds.

PrepareToPlayFileSequence(const TDesC &)

voidPrepareToPlayFileSequence(const TDesC &aFileName)[virtual]

Configures the audio tone player utility to play a tone sequence contained in a file.

This function is asynchronous. On completion, the observer callback function MMdaAudioToneObserver::MatoPrepareComplete() is called, indicating the success or failure of the configuration operation. The configuration operation can be cancelled by calling CMdaAudioToneUtility::CancelPrepare(). The configuration operation cannot be started if a play operation is in progress.

Since
5.0

Parameters

const TDesC & aFileNameThe full path name of the file containing the tone sequence. The format of the data is unspecified but is expected to be platform dependent. A device might support more than one form of sequence data.

PrepareToPlayFileSequence(RFile &)

IMPORT_C voidPrepareToPlayFileSequence(RFile &aFile)

Configures the audio tone player utility to play a tone sequence contained in a file.

This function is asynchronous. On completion, the observer callback function MMdaAudioToneObserver::MatoPrepareComplete() is called, indicating the success or failure of the configuration operation. The configuration operation can be cancelled by calling CMdaAudioToneUtility::CancelPrepare(). The configuration operation cannot be started if a play operation is in progress.

Since
5.0

Parameters

RFile & aFileA handle to an open file containing the tone sequence. The format of the data is unspecified but is expected to be platform dependent. A device might support more than one form of sequence data.

PrepareToPlayFixedSequence(TInt)

voidPrepareToPlayFixedSequence(TIntaSequenceNumber)[virtual]

Configures the audio tone player utility to play the specified pre-defined tone sequence.

This function is asynchronous. On completion, the observer callback function MMdaAudioToneObserver::MatoPrepareComplete() is called, indicating the success or failure of the configuration operation. The configuration operation can be cancelled by calling CMdaAudioToneUtility::CancelPrepare(). The configuration operation cannot be started if a play operation is in progress.

Parameters

TInt aSequenceNumberAn index into the set of pre-defined tone sequences. This can be any value from zero to the value returned by a call to FixedSequenceCount() - 1. If the sequence number is not within this range, a panic will be raised when Play() is called later.

PrepareToPlayTone(TInt, const TTimeIntervalMicroSeconds &)

voidPrepareToPlayTone(TIntaFrequency,
const TTimeIntervalMicroSeconds &aDuration
)[virtual]

Configures the audio tone player utility to play a single tone.

This function is asynchronous. On completion, the observer callback function MMdaAudioToneObserver::MatoPrepareComplete() is called, indicating the success or failure of the configuration operation.The configuration operation can be cancelled by calling CMdaAudioToneUtility::CancelPrepare(). The configuration operation cannot be started if a play operation is in progress.

Since
5.0

Parameters

TInt aFrequencyThe frequency (pitch) of the tone in Hz.
const TTimeIntervalMicroSeconds & aDurationThe duration of the tone in microseconds.

RegisterPlayStartCallback(MMdaAudioTonePlayStartObserver &)

IMPORT_C voidRegisterPlayStartCallback(MMdaAudioTonePlayStartObserver &aObserver)

Parameters

MMdaAudioTonePlayStartObserver & aObserver

Resume()

IMPORT_C TIntResume()

SetBalanceL(TInt)

IMPORT_C voidSetBalanceL(TIntaBalance =  KMMFBalanceCenter )

Sets the stereo balance for playback.

Since
7.0s

Parameters

TInt aBalance =  KMMFBalanceCenter The balance. Should be between KMMFBalanceMaxLeft and KMMFBalanceMaxRight.

SetDTMFLengths(TTimeIntervalMicroSeconds32, TTimeIntervalMicroSeconds32, TTimeIntervalMicroSeconds32)

voidSetDTMFLengths(TTimeIntervalMicroSeconds32aToneLength,
TTimeIntervalMicroSeconds32aToneOffLength,
TTimeIntervalMicroSeconds32aPauseLength
)[virtual]

Changes the duration of DTMF tones, the gaps between DTMF tones and the pauses.

Parameters

TTimeIntervalMicroSeconds32 aToneLengthThe duration of the DTMF tone in microseconds.
TTimeIntervalMicroSeconds32 aToneOffLengthThe gap between DTFM tones in microseconds.
TTimeIntervalMicroSeconds32 aPauseLengthPauses in microseconds

SetPriority(TInt, TInt)

voidSetPriority(TIntaPriority,
TIntaPref
)[virtual]

Changes the clients priority.

Parameters

TInt aPriorityThe Priority Value.
TInt aPrefThe Priority Preference.

SetRepeats(TInt, const TTimeIntervalMicroSeconds &)

voidSetRepeats(TIntaRepeatNumberOfTimes,
const TTimeIntervalMicroSeconds &aTrailingSilence
)[virtual]

Sets the number of times the tone sequence is to be repeated during the play operation.

A period of silence can follow each playing of the tone sequence. The tone sequence can be repeated indefinitely.

Since
5.0

Parameters

TInt aRepeatNumberOfTimesThe number of times the tone sequence, together with the trailing silence, is to be repeated. If this is set to KMdaRepeatForever, then the tone sequence, together with the trailing silence, is repeated indefinitely. The behaviour is undefined for values other than KMdaRepeatForever, zero and positive.
const TTimeIntervalMicroSeconds & aTrailingSilenceThe time interval of the training silence. The behaviour is undefined for values other than zero and positive.

SetVolume(TInt)

voidSetVolume(TIntaVolume)[virtual]

Changes the volume of the audio device.

The volume can be changed before or during play and is effective immediately.

Since
5.0

Parameters

TInt aVolumeThe volume setting. This can be any value from zero to the value returned by a call to CMdaAudioToneUtility::MaxVolume(). Setting a zero value mutes the sound. Setting the maximum value results in the loudest possible sound.

SetVolumeRamp(const TTimeIntervalMicroSeconds &)

voidSetVolumeRamp(const TTimeIntervalMicroSeconds &aRampDuration)[virtual]

Defines the period over which the volume level is to rise smoothly from nothing to the normal volume level.

Since
5.0

Parameters

const TTimeIntervalMicroSeconds & aRampDurationThe period over which the volume is to rise. A zero value causes the tone to be played at the normal level for the full duration of the playback. A value which is longer than the duration of the tone sequence means that the tone never reaches its normal volume level.

State()

TMdaAudioToneUtilityState State()[virtual]

Returns the current state of the audio tone utility.

Since
5.0

Volume()

TInt Volume()[virtual]

Returns an integer representing the current volume of the audio device.

Since
5.0

Member Data Documentation

CMMFMdaAudioToneUtility * iProperties

CMMFMdaAudioToneUtility *iProperties[protected]

This member is internal and not intended for use.