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

  • SEARCH
  • Home
  • 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 3759470
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T10:19:17+00:00 2026-05-19T10:19:17+00:00

I have an audio file which is stereo. Is converting it to mono just

  • 0

I have an audio file which is stereo. Is converting it to mono just a case of skipping every other byte (after the header)? It’s encoded in 16bit signed PCM format. I’ve got javax.sound.sampled available.

Here’s code I tried that didn’t work:

WaveFileWriter wfw = new WaveFileWriter();
AudioFormat format = new AudioFormat(Encoding.PCM_SIGNED, 44100, 16, 2, 2, 44100, false);
AudioFormat monoFormat = new AudioFormat(Encoding.PCM_SIGNED, 44100, 16, 1, 2, 44100, false);

byte[] audioData = dataout.toByteArray();
int length = audioData.length;
ByteArrayInputStream bais = new ByteArrayInputStream(audioData);

AudioInputStream stereoStream = new AudioInputStream(bais,format,length);
AudioInputStream monoStream = new AudioInputStream(stereoStream,format,length/2);

wfw.write(monoStream, Type.WAVE, new File(Environment.
                 getExternalStorageDirectory().getAbsolutePath()+"/stegDroid/un-ogged.wav"));

This code is used after reading a .ogg file using Jorbis to convert it to PCM data. The only problem is the result is stereo and I need it to be mono, so if there’s another solution I’m happy to hear it!

  • 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-19T10:19:18+00:00Added an answer on May 19, 2026 at 10:19 am

    I have an audio file which is stereo.
    Is converting it to mono just a case
    of skipping every other byte (after
    the header)?

    Almost – you want to skip every other sample, not byte. In your case it looks like each sample is of size 16 bits = 2 bytes. So you would want to take 2 bytes, skip 2 bytes, take 2 bytes and so on.

    AudioInputStream monoStream = new AudioInputStream(stereoStream,format,length/2);
    
    wfw.write(monoStream, Type.WAVE, new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/stegDroid/un-ogged.wav"));
    

    This looks like you just write out the first half of the file instead of writing out every other sample. Also you have to fix the WAV header, to specify a single channel (see your monoFormat).

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

Sidebar

Related Questions

So I have a script that, when run, plays an audio file which I
I have an audio file in .3gp format on my Android device which I
I have a content type Audio which includes an audio file field. This field
I have big problems with stopping a service, which plays audio file. I want
I have got an audio file which is quite quiet. I'm playing it using
I'm trying to play audio file at particular time which i have set.for that
I have a .out file which has xml content like this. <header stub> <article
Hey!! I have made an application through which I am publishing an audio file
i have to display text of the playing audio (file in sdcard). After given
I have a Service which takes in an audio file and plays it with

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.