Implementation Code for recording an AMR audio file

Source: Internet
Author: User

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 ();
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.