If you search for Nokia or newlc forums, there will be many posts asking you about how to record AMR audio files. First, let's take a look at the commonly used audio file formats on Nokia mobile phones. Generally, Nokia mobile phones support WAV, Midi, PCM, and Amr file formats. Among them, the wav waveform file is generally relatively large. Due to limited mobile phone resources, it is not widely used. The storage formats of MIDI and AMR are relatively small and widely used. The default recording audio files of Nokia are stored in Amr format.
Several familiar classes are required: cmdaaudioplayerutility, cmdaaudiorecorderutility, and cmdaaudioconvertutility.
In the past, it was said that recording an AMR file must first flow into the PCM format, and then convert the obtained PCM Data to save the disk. However, the simplest method is to directly record the data into an AMR file. Oh, I forgot to talk about a bunch of things. It's actually quite simple. You can directly use cmdaaudiorecorderutility: openfilel () to record an AMR file. However, before calling imdaaudiorecorderutility-> openfilel (afile), you must add ceikonenv: static () -> fssession (). replace (afile, afile) to ensure that the afile exists and there is no data in it. Then, do not call imdaaudiorecorderutility-> setposition (
Ttimeintervalmicroseconds (0) and imdaaudiorecorderutility-
> Cropl (). It's easy!
The source code is as follows:
// ============================================
Void cmyaudiorecorder: constructl (const tdesc & afile)
{
// Create a file Audio Recorder utility instance
Imdaaudiorecorderutility = cmdaaudiorecorderutility: newl (
* This );
// This is very important here
Ceikonenv: static ()-> fssession (). Replace (afile, afile );
Imdaaudiorecorderutility-> openfilel (afile );
}
//-------------
Void cmyaudiorecorder: recordl ()
{
// Create a file Audio Recorder utility instance
Imdaaudiorecorderutility = cmdaaudiorecorderutility: newl (
* This );
// This is very important here
Ceikonenv: static ()-> fssession (). Replace (afile, afile );
Imdaaudiorecorderutility-> openfilel (afile );
// Record from the device microphone
Imdaaudiorecorderutility-> setaudiodevicemode (
Cmdaaudiorecorderutility: elocal );
// Set maximum gain for recording
Imdaaudiorecorderutility-> setgain (
Imdaaudiorecorderutility-> maxgain ());
// The following two sentences cannot be left!
// Imdaaudiorecorderutility-> setposition (
Ttimeintervalmicroseconds (0 ));
// Imdaaudiorecorderutility-> cropl ();
// Start Recorder
Imdaaudiorecorderutility-> recordl ();
}