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?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
Just to clearify: You have a
byte[]that contains pairs ofbyte‘s to form an integer? So like this:{int1B1, int1B2, int2B1, int2B2, int3B1, int3B2, ...}?If so, you can assemble them to integers like this:
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.