Using Audiorecord With 8-bit Encoding In Android
I have made an application that records from the phones microphone using the AudioRecord and 16-bit encoding, and I am able to playback the recording. For some compatibility reason
Solution 1:
If you look at the source, it only supports little endian, but Android is writing out big endian. So you have to convert to little endian and then 8-bit. This worked for me and you can probably combine the two:
for (int i = 0; (offset + i + 1) < bytes.length; i += 2) {
lens[i] = bytes[offset + i + 1];
lens[i + 1] = bytes[offset + i];
}
for (int i = 1, j = 0; i < length; i += 2, j++) {
lens[j] = lens[i];
}
Here is a simpler version without endian
for (int i = 0, j = 0; (offset + i) < bytes.length; i += 2, j++) {
lens[j] = bytes[offset + i];
}
Post a Comment for "Using Audiorecord With 8-bit Encoding In Android"