【发布时间】:2017-07-10 23:52:18
【问题描述】:
我按如下方式初始化我的 AudioRecord 实例:
// TODO: remember to add RECORD_AUDIO permission
int audioSource = MediaRecorder.AudioSource.MIC;
// TODO: I should consider Nyquist frequency and tell the user if her device can correctly detect frequencies in the range of her instrument
int sampleRateInHz = getDeviceSampleRate(context);
int channelConfig = AudioFormat.CHANNEL_IN_MONO;
int audioFormat = AudioFormat.ENCODING_PCM_16BIT;
// TODO: bufferSizeInBytes should be set according to minimum detectable frequency in order to have at least three periods
int bufferSizeInBytes = AudioRecord.getMinBufferSize(sampleRateInHz, channelConfig, audioFormat);
AudioRecord audioRecord = new AudioRecord(audioSource, sampleRateInHz, channelConfig, audioFormat, bufferSizeInBytes);
这是我的问题:
- 我必须从缓冲区中读取短裤,因为我指定了
ENCODING_PCM_16BIT。对吗? - 如果以字节为单位的最小缓冲区大小为 1000,我将有 500 个短裤。所以如果我需要 4096 个样本,我必须将 bufferSizeInBytes 设置为 8192。是否正确?
谢谢。
【问题讨论】:
标签: android audiorecord