Created
August 7, 2018 13:10
-
-
Save HViktorTsoi/d3eebab43a5e6255743858d9a3c615b1 to your computer and use it in GitHub Desktop.
解析16bit位宽PCM时将byte转换为short的方式
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 将raw数据中的二进制转换为实际的音频信号 由于默认音频格式为16bit 小端存储 因此这里只使用high和low两位 | |
* 如果用其他bit宽度需要修改此函数 | |
* | |
* */ | |
public static int rawAudioDataToShort(byte high, byte low) { | |
byte[] byteArray = {high, low}; | |
return ByteBuffer.wrap(byteArray).order(ByteOrder.LITTLE_ENDIAN).getShort(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment