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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top