Symbian
Symbian OS Library

SYMBIAN OS V9.3

[Index] [Spacer] [Previous] [Next]



How to use audio recorder utility


Overview

The CMdaAudioRecorderUtility provides an interface to record audio clips to files, descriptors, or URLs. It also provides methods for creating and manipulating meta data entries in the newly recorded clips. Though this class is intended primarily for recording audio data, the playback methods have been included for convenience sake. If you just need to play back an audio clip it is recommended that you use CMdaAudioPlayerUtility instead, as it gives more control over playing and does not include the overheads that are necessary to support recording functionality.

[Top]


Description

The sequence of the audio recording and playback process is shown in the sequence diagram below:

Audiorecorder Utility

Audiorecorder Utility

To record an audio clip and playback do the following:

[Top]


Opening the target device for recording

When using CMdaAudioRecorderUtility you can specify the name of the file, descriptor, or URL to record/play in a variety of ways. The MMF can automatically detect the file format and codec of most audio clips with the exception of raw audio. When opening a raw audio file, the codec and the audio settings must be specified. This is reflected in the range of open statements available in CMdaAudioRecorderUtilityclass.

The recorder object can be initialised by choosing a default recording and playback device or by specifying the format and codec of the recording and playback device as shown below:

With default recording and playback device

To open an audio file for record with default audio device, after the creation of the recorder object, use one of the following methods depending on the type of the clip say file, descriptor, or URL:

OpenFileL(const TDesC& aFileName);

OpenDesL(const TDesC8& aDescriptor);

OpenUrlL(const TDesC& aUrl, TInt aIapId = KUseDefaultIap, const TDesC8& aMimeType=KNullDesC8);

With specific format and codec of the recording and playback device

To open an audio file for record with a specific device by giving specified format and codec, use one of the following methods depending on the type of the clip say file, descriptor, or URL:

void OpenFileL(const TDesC& aFileName, TUid aRecordControllerUid, TUid aPlaybackControllerUid=KNullUid, TUid aFormatUid=KNullUid, TFourCC aCodec=NULL);

void OpenDesL(TDesC8& aDescriptor, TUid aControllerUid, TUid aPlaybackControllerUid=KNullUid, TUid aFormatUid=KNullUid, TFourCC aCodec=NULL);

void OpenUrlL(const TDesC& aUrl, TInt aIapId, TUid aControllerUid, TUid aPlaybackControllerUid=KNullUid, TUid aFormatUid=KNullUid, TFourCC aCodec=NULL);

Use these open statements to open a specified medium (file, descriptor, or URL) so that it can be used for recording/play back. These methods come handy when MMF cannot automatically determine the format and codec to use from the audio data. For example, when using raw audio.

Note: There is also another method to open and audio clip from a file. It is strongly recommended to use this method.

OpenFileL(const TMMSource& aSource);

Where aSource is a filename or an open handle to a file which is a source of existing audio sample data.

[Top]


Configuring the recording parameters

Upon opening a file, descriptor, or URL to play or record audio data, configuration adjustments can be made using the methods described below. The configuration methods can be categorised into the following three parts that can be used to retrieve and set configuration parameters when playing back or recording audio data.

General

This category covers the setting of modes for the playing/recording devices, setting the maximum size of a recorded file, and playback priorities in relation to other applications that may be running. The methods are:

Formats and Codecs

This category covers the reporting and setting of formats and codecs for audio data that is already open. The three methods relating to DataTypes (codecs) enable you to retrieve a list of supported codecs for the current data format, set a new codec to use or determine which codec is currently in use.

The codec related methods are:

The data format related methods are:

Bit and Sample rates

This section covers the reporting and setting of bit rates for audio sinks, such as the internal speaker and the sample rates used to sample data that is to be saved to a file or descriptor.

Methods for controlling the bit rate of audio sinks are:

Note: None of the default codecs provided in the MMF support the use of bit rates. These methods are provided to enable the creation of additional codecs that might require bit rate information. For example, the audio format, MP3.

Methods for controlling the sampling rate of audio data are:

Adding to the above configuration settings, the gain, volume, and the balance features needs to be set. To set the gain see "setting the gain factor" section under Recording audio data. For more details on volume and balance settings see How to use CMdAAudioPlayerUtility

[Top]


Recording audio data

To record an audio data, do the following:

For more details on how to play the recorded sample data, see How to use CMDAAudioPlayerUtility.

To close all related controllers, use Close() before opening a new clip.

[Top]


Edit audio data

The CMdaAudioRecorderUtility class allows you to set the start and end positions for playing and also permits the deletion of the recorded sample or overwrite it by cropping the recorded sample from the start or end of file. To retrieve or set the playing/recording position use the following methods:

To delete the existing audio sample, use the following methods:

[Top]


Meta data

Some audio formats allow the use of meta data, enabling the creator or player of an audio clip to retrieve or set information that is held within the clip itself. This meta data is usually used to store information such as copyright information, creator, creation date and so on. The CMdaAudioRecorderUtility class allows to add, retrieve, and delete meta data details.

[Top]


Plug-in control