Use the CMMFDevSound::NewL()
method to construct a
new instance of DevSound.
After construction, use an
CMMFDevSound::InitializeL()
method to initialize DevSound
to play tones. This method requires that you specify the DevSound observer
class to handle callbacks.
Once initialization has completed, successfully or otherwise, DevSound
calls the MDevSoundObserver::InitializeComplete()
function.
The following settings can be configured before or during tone play:
To set the number of times a tone is to be repeated during playback
use the CMMFDevSound::SetToneRepeats()
method:
IMPORT_C void SetToneRepeats(TInt aRepeatCount, const TTimeIntervalMicroSeconds
&aRepeatTrailingSilence);
This method has two parameters:
aRepeatCount
- the number of times the tone is to
be repeated.
&aRepeatTrailingSilence
- the interval of
silence to be played after each tone.
To change the volume of the audio device to a specific value, use
the CMMFDevSound::SetVolume()
function. The volume can be
set to any value from 0 to CMMFDevSound::MaxVolume()
.
To define a period over which the volume rises from 0 to the normal
volume level, use the CMMFDevSound::SetVolumeRamp()
function.
Note: The
CMMFDevSound::SetVolumeRamp()
function is only available
during tone play.
To set the speaker balance, use the
CMMFDevSound::SetPlayBalanceL()
function. This function
has two parameters:
aLeftPercentage
- the left speaker volume
percentage.
aRightPercentage
- the right speaker volume
percentage.
To set the priority setting for this instance of DevSound to access
the audio device, use the
CMMFDevSound::SetPrioritySettings()
method. Priority
settings are used by the Audio Policy component to resolve multiple requests to
access the audio hardware.
To start playing a tone, use the
CMMFDevSound::PlayToneL()
method:
IMPORT_C void PlayToneL(TInt aFrequency, const TTimeIntervalMicroSeconds &aDuration);
This method has two parameters:
aFrequency
- the frequency at which the tone is to be
played.
&aDuration
- the period over which the tone is to
be played.
Tip: If you want to play two tones simultaneously, the
CMMFDevSound::PlayDualToneL
method can be called instead
of CMMFDevSound::PlayToneL()
.
CMMFDevSound::PlayDualToneL
has an extra parameter,
aFrequencyTwo
, to specify the frequency at which the second tone
is to be played.
When an attempt to play a tone has completed, successfully or
otherwise, DevSound calls the
MDevSoundObserver::ToneFinished()
function.
Note: Further calls to
CMMFDevSound::PlayToneL()
can be made both before and
after the MDevSoundObserver::ToneFinished()
callback is
received. If subsequent calls are made to
CMMFDevSound::PlayToneL()
, only one
MDevSoundObserver::ToneFinished()
callback is received.