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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:41:26+00:00 2026-06-10T09:41:26+00:00

I have a byte array which contains pure sound data. I want to convert

  • 0

I have a byte array which contains pure sound data. I want to convert it to integer. bit per sample is 16. frame rate is 44100. but how to convert it into an integer?

  • 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-06-10T09:41:28+00:00Added an answer on June 10, 2026 at 9:41 am

    Just to clearify: You have a byte[] that contains pairs of byte‘s to form an integer? So like this: {int1B1, int1B2, int2B1, int2B2, int3B1, int3B2, ...}?

    If so, you can assemble them to integers like this:

    int[] audio = new int[byteArray.length/2];
    for (int i = 0; i < byteArray.length/2; i++) { // read in the samples
      int lsb = byteArray[i * 2 + 0] & 0xFF; // "least significant byte"
      int msb = byteArray[i * 2 + 1] & 0xFF; // "most significant byte"
      audio[i] = (msb << 8) + lsb;
    }
    

    Of course you can optimize that loop to a single line loop, but I prefer it that way for better readability. Also, depending on the endianness of the data, you can switch ub1 and ub2.

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

Sidebar

Related Questions

I have an array of bytes (say byte[] data), which contains text with custom
I have an array which contains a set of UIImage in byte forms. --My
I have a byte array which contains an image fetched from the net. I
I have a JarInputStream (constructed from a byte array which contains a JAR file)
I have a byte array which needs to be marshalled into the following struct:
I have a byte array of around 10,000 bytes which is basically a blob
I'm using ASP.NET MVC and have a model which has an image (byte array)
I have a byte array and I need to convert this to a image.
I've got an object[] array which contains some mixture of builtin types, like Int/Byte/String,
I have a byte list variable which I store byte array information here: internal

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.