我正在开发一个录音应用程序。其中,我有一个 Seekbar 来更改输入语音增益。
我找不到任何方法来调整输入语音增益。
我正在使用AudioRecord
类来录制语音。
recorder = new AudioRecord(MediaRecorder.AudioSource.MIC,
RECORDER_SAMPLERATE, RECORDER_CHANNELS,
RECORDER_AUDIO_ENCODING, bufferSize);
recorder.startRecording();
我见过一个Google Play 商店中的应用程序 https://play.google.com/store/apps/details?id=com.grace.microphone使用此功能。
据我了解,您不需要任何自动调整,只需要从用户界面手动调整。 Android 中没有内置的功能,您必须手动修改数据。
假设你使用读取 (短[] audioData, int offsetInShorts, int sizeInShorts) http://developer.android.com/reference/android/media/AudioRecord.html#read(short%5B%5D,%20int,%20int)用于读取流。所以你应该这样做:
float gain = getGain(); // taken from the UI control, perhaps in range from 0.0 to 2.0
int numRead = read(audioData, 0, SIZE);
if (numRead > 0) {
for (int i = 0; i < numRead; ++i) {
audioData[i] = (short)Math.min((int)(audioData[i] * gain), (int)Short.MAX_VALUE);
}
}
Math.min
用于防止溢出,如果gain
大于1。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)