Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 580543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:29:03+00:00 2026-05-13T14:29:03+00:00

I currently use the AudioTrack and AudioRecord classes in Android. I use the pure

  • 0

I currently use the AudioTrack and AudioRecord classes in Android.

I use the pure PCM data but I was wondering what my options are for other codecs?

From this page it seems I can only encode and decode using AMR narrowband?

I currently set up the Audio classes as follows:

arec = new AudioRecord(MediaRecorder.AudioSource.MIC,
                     11025,
                     AudioFormat.CHANNEL_CONFIGURATION_MONO,
                     AudioFormat.ENCODING_PCM_16BIT,
                     buffersize);

atrack = new AudioTrack(AudioManager.STREAM_VOICE_CALL,
                     11025,
                     AudioFormat.CHANNEL_CONFIGURATION_MONO,
                     AudioFormat.ENCODING_PCM_16BIT,
                     buffersize,
                     AudioTrack.MODE_STREAM);

So my question is how do I change the encoding from PCM to one of the other supported codecs?

When I try to change ENCODING_PCM_16BIT on AudioFormat I only get the options of default or invalid encoding along with the PCM options.

Any links to tutorials on encoding and decoding audio on Android would be great if anyone knows of any or any help here greatly appreciated.

Thanks

EDIT: I have changed my code to the following:

arec = new AudioRecord(MediaRecorder.AudioSource.MIC,
                     11025,
                     AudioFormat.CHANNEL_CONFIGURATION_MONO,
                     **MediaRecorder.AudioEncoder.AMR_NB**,
                     buffersize);

atrack = new AudioTrack(AudioManager.STREAM_VOICE_CALL,
                     11025,
                     AudioFormat.CHANNEL_CONFIGURATION_MONO,
                     **MediaRecorder.AudioEncoder.AMR_NB**,
                     buffersize,
                     AudioTrack.MODE_STREAM);

The code runs properly but I’m wondering does it actually encode the Audio as AMR_NB and if this is not a proper way to do it?

I was getting a buffer overflow when using raw PCM but none have appeared since using the new code with the MediaRecorder.AudioEncoder.AMR_NB used instead of the AudioFormat.PCM

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T14:29:03+00:00Added an answer on May 13, 2026 at 2:29 pm

    As the documentation states for AudioRecord and AudioTrack:

    audioFormat     the format in which the audio data is represented. See ENCODING_PCM_16BIT and ENCODING_PCM_8BIT
    

    you can only work with 8-bit and 16-bit PCM. If you want audio in other formats, either don’t use AudioRecord and AudioTrack (try MediaRecorder and MediaPlayer) or you will have to transcode it using your own code, possibly leveraging the NDK.

    AudioRecord and AudioTrack are designed specifically for cases where the audio in question is not supported by the OpenCORE multimedia engine, either because it’s not a supported codec or not a supported streaming protocol (e.g., SIP).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently use several APIs to pull data from other sites. However, sometimes the
I currently use AudioRecord to record audio in from the mic of an Android
I currently use the rangeinput plugin from jQuery Tools in various places. But I
I currently use SQL2008 where I have a stored procedure that fetches data from
I currently use a DataTable to get results from a database which I can
I currently use the following command, but it's a little unwieldy to type. What's
I currently use FixedThreadPool to download images from the web, like this: ExecutorService mThreadPool
I currently use the following code to trigger an event from my Firefox Add-On.
I currently use a C extension library for Python, but it seems to have
I currently use the summaryBy command from the doBy package to group rows of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.