Symbian
Symbian OS Library

SYMBIAN OS V9.3

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



How to use the audio convert utility


Overview

Audio convert utility is used to convert audio clips contained in files or descriptors to other formats using the default codecs provided by MMF. This functionality is implemented by the CMdaAudioConvertUtility class.

[Top]


Description

Using a audio converter utility involves the following tasks:


Construct and open converter utility object

The MMF provides a utility class called CMdaAudioConverterUtility. Using this class, you can convert audio clips from one format to another. The CMdaAudioConverterUtility::NewL() function need to be used to construct an object of this utility class, with the following arguments:

The following code shows how the client application CClientApp inherits the MMdaObjectStateChangeObserver and creates the audio converter utility object:

class CClientApp : public CBase, MMdaObjectStateChangeObserver
    {
public:
   void CClientApp();
protected:

    // from MMdaObjectStateChangeObserver
    virtual void MoscoStateChangeEvent(CBase *aObject, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode);
    
protected:
    CMdaAudioConverterUtility*  iConverter;   
    };

void CClientApp()
{    
    iConverter = CMdaAudioConverterUtility::NewL(*this, EMdaPriorityNormal,
                   EMdaPriorityPreferenceTimeAndQuality);
}

Once the audio converter utility object is constructed, you can open an audio clip for conversion using the function CMdaAudioConverterUtility::OpenL(). You can use the following versions of this function:

Note: It is recommended to use the first version of OpenL to specify source and destination audio file location. The arguments for the other versions are deprecated.

The following code uses the first version of OpenL to specify source and destination audio location:

TFileName fromFilename = _L("C:\\rectest2.wav");
TFileName toFilename = _L("C:\\rectest2.wav");

iConverter->OpenL(&fromFilename, &toFilename);

Once the converter calls the CMdaAudioConverterUtility::OpenL() function, the callback function MMdaObjectStateChangeObserver::MoscoStateChangeEvent() will notify the client application about the change in state of the object.


Configure conversion parameters

The configuration parameters can be broadly classified into four categories as shown below:

Set recorded file length

You can control the size settings of a recorded file. This is handled by the SetMaxWriteLength() function that sets the maximum number of bytes that can be written to a recorded audio clip. The SetMaxWriteLength() function is provided so that converters can limit the amount of file storage or memory that should be allocated. If the maximum limit is reached, MMF stops recording and notifies the client application.

The following code sets the maximum number of bytes to 800:

iConverter->SetMaxWriteLength(800);

Formats and Codecs

You can report and set formats and codecs for audio data that is already open. The four methods related 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. A further three methods are provided to query and set the audio format to use.

Codec related actions:

Data format related actions:

Note: It is only possible to report the format and codec used by the source audio and cannot be changed.

Bit and sample rates

You can report and set bit and sample rates as required by specific codecs.

Methods to control the bit rate of audio data:

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, such as the audio format MP3.

Methods for controlling the sampling rate of audio data:

Note: It is only possible to report the bit rate or sample rate used by the source audio and cannot be changed.

Balance

You can report and set the audio mode (mono or stereo).

Note: It is only possible to report the number of supported channels for the source audio and cannot be changed.


Convert audio clip

Several methods are provided in CMdaAudioConvertUtility to enable the conversion of audio data. The specific functions to convert and perform related tasks are as follows:


Change conversion position and crop audio data

It is possible to crop the audio clip from the current position to the end of the clip or from the begging to the current position as illustrated below:

To retrieve the current position of the audio clip or move the position to the desired location use the following functions:


Custom commands