Android - how to add gain control when recording

你。 提交于 2019-12-13 02:57:28

问题


I work for an audio recorder app and would like to add gain control but I don't know how to do it. I have access to audio buffer but I don't know how to make the sound louder or slower. I see another apps that have a seekBar for selecting the decibels from a specific range.

aRecorder.read(buffer, 0, buffer.length);
fWriter.write(buffer); // Write buffer to file

Please tell me what should I do to implement gain control in my app.

Thanks.


回答1:


Changing the volume is simple, just multiply all the samples by some fraction. A change of +/- 3dB (decibels) corresponds to multiplication by 2 or 0.5 respectively (see http://en.wikipedia.org/wiki/Decibel). To prevent discontinuities in the output, make sure that you vary the multiplication factor smoothly from beginning to end.

See AudioSampleBuffer::applyGainRamp() @ http://www.rawmaterialsoftware.com/api/classAudioSampleBuffer.html



来源:https://stackoverflow.com/questions/10449963/android-how-to-add-gain-control-when-recording

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!