-
Notifications
You must be signed in to change notification settings - Fork 48
Open
Description
我看你代码里面是这么写的,但是很多时候拿到的都是0
byteNumber = (outputFormat.containsKey("bit-width") ? outputFormat.getInteger("bit-width") : 0) / 8;
搜了下,建议用下面这种方式更合理点
//此处用于获取每个采样的位数
int pcm = outputFormat.containsKey("pcm-encoding") ? outputFormat.getInteger("pcm-encoding") : AudioFormat.ENCODING_PCM_16BIT;
if (pcm == AudioFormat.ENCODING_PCM_8BIT) {
byteNumber = 1;
} else if (pcm == AudioFormat.ENCODING_PCM_16BIT) {
byteNumber = 2;
} else if (pcm == AudioFormat.ENCODING_PCM_FLOAT) {
byteNumber = 4;
} else {
byteNumber = 2;
}
Metadata
Metadata
Assignees
Labels
No labels