Question

I am recording sound from mic using audio recorder. recoChunk byte[] store raw recording as shown below.

while (isRecording == true) {
    Log.w("myMsg", "recording..");
    recoChunk = new byte[minBuffSize];
    audioRecord.read(recoChunk, 0, minBuffSize);
    mFosRaw.write(recoChunk);
}

now from recoChunk I want to find largest amplitude recorded how can I do that?

Was it helpful?

Solution

You can cast your byte array to an array of a type that matches the bit-depth of your recorded audio in its size. For example for 16-bit audio, you can use short, since it holds a 16-bit signed integer value. For 8-bit you can just use the byte array without casting. Then, simply, the largest "number" in the array (you would probably want to take the absolute value) will be the sample with the highest amplitude value.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top