Tom*_*Tom 11 android audio-recording
我在三星Galaxy S i9000上测试它.
int sampleRate = 44100;
int bufferSize = AudioRecord.getMinBufferSize(sampleRate,
AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_8BIT);
Run Code Online (Sandbox Code Playgroud)
它返回-2 ERROR_BAD_VALUE.
原始采样率为44100Hz,由返回
AudioTrack.getNativeOutputSampleRate(AudioManager.STREAM_SYSTEM).
我已经尝试将sampleRate设置为1000,8000,22100和44100.我也尝试过更改AudioFormat.CHANNEL_IN_MONO为AudioFormat.CHANNEL_CONFIGURATION_MONO.我也试过STEREO(两个IN_STEREO和CONFIGURATION_STEREO).我也尝试过16位编码而不是8位.
更新:我的清单有AUDIO_RECORD权限.
结果我一直得-2.为什么会这样?
Reu*_*ton 18
从平台源文件AudioRecord.java:
static public int getMinBufferSize(int sampleRateInHz, int channelConfig, int audioFormat) {
...
// PCM_8BIT is not supported at the moment
if (audioFormat != AudioFormat.ENCODING_PCM_16BIT) {
loge("getMinBufferSize(): Invalid audio format.");
return AudioRecord.ERROR_BAD_VALUE;
}
...
}
Run Code Online (Sandbox Code Playgroud)
看起来你的选择是16位或没有.:\
| 归档时间: |
|
| 查看次数: |
10164 次 |
| 最近记录: |