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 6003699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:09:30+00:00 2026-05-23T01:09:30+00:00

I am reading a .wav audio file using Java AudioInputStream.The audio file is 16

  • 0

I am reading a .wav audio file using Java AudioInputStream.The audio file is 16 bit PCM signed, with samplerate = 44100, framesize = 2, framelength= 114048. I managed to get the Audio data in the form of a byte array but I am not sure how much size should I assign to this byte array so that I can convert it to floatinf point values.
I am doing some audio manipulation using Goertzel algorithm which takes input of float array, something like “float[] x”. Below is some code fragment that I am using. Thanks in advance.

 try {
 AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(fileIn);
  }

while ( numBytesRead != -1) {
numBytesRead = audioInputStream.read(audioBytes);

// Logic goes here
floatValue = byteArrayToFloat(audioBytes);
}
  • 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-23T01:09:31+00:00Added an answer on May 23, 2026 at 1:09 am

    The audio file is 16 bit PCM signed, with samplerate = 44100, framesize = 2, framelength= 114048.

    I’m assuming from the above that you have only a single channel (2 byte samples * 1 channel = 2 byte frames).

    First step is to get the data as a sequence of a 16-bit integral type, which is short in Java.

    import java.nio.ByteBuffer;
    import java.nio.ByteOrder;
    import java.nio.ShortBuffer;
    
    ...
    
    byte[] audioBytes = ...
    
    ShortBuffer sbuf =
        ByteBuffer.wrap(audioBytes).order(ByteOrder.LITTLE_ENDIAN).asShortBuffer();
    short[] audioShorts = new short[sbuf.capacity()];
    sbuf.get(audioShorts);
    

    Now how you convert that to floats depends on how downstream functions expect the audio to be represented. For example if they expect floating point numbers >= -1 and <= 1, then you can do this:

    float[] audioFloats = new float[audioShorts.length];
    for (int i = 0; i < audioShorts.length; i++) {
        audioFloats[i] = ((float)audioShorts[i])/0x8000;
    }
    

    Unfortunately there are a lot of ways to represent audio.

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

Sidebar

Related Questions

I'm working on an application that processes audio data. I'm using java (I've added
Hi I need to downsample a wav audio file's sample rate from 44.1kHz to
I am reading a raw audio file (CD track rip) in, doing byte swapping,
Dupe of calculate playing time of a .mp3 file im reading a audio file(for
I want to read pcm samples from a file using fread and want to
reading excel files from C# working well in 32 bit version server. It is
I'm writing an an application in C# that will record audio files (*.wav) and
I'm working on processing the amplitude of a wav file and scaling it by
Total noob to anything lower-level than Java, diving into iPhone audio, and realing from
Reading through this , I came to the bit on default values for function

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.