Android AudioRecord与MediaRecorder对比,用于录制音频 [英] Android AudioRecord vs. MediaRecorder for recording audio

查看:340
本文介绍了Android AudioRecord与MediaRecorder对比,用于录制音频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的Android手机上录制人声.我注意到Android有两个类可以做到这一点: AudioRecord MediaRecorder .有人可以告诉我两者之间的区别是什么?什么是合适的用例?

I want to record human voice on my Android phone. I noticed that Android has two classes to do this: AudioRecord and MediaRecorder. Can someone tell me what's the difference between the two and what are appropriate use cases for each?

我希望能够实时分析人类语音以测量幅度等.我是否正确理解AudioRecord更适合此任务?

I want to be able to analyse human speech in real-time to measure amplitude, etc. Am I correct in understanding that AudioRecord is better suited for this task?

我在Android官方用于录制音频的指南网页上注意到,他们使用MediaRecorder,却没有提及AudioRecord.

I noticed on the official Android guide webpage for recording audio, they use MediaRecorder with no mention of AudioRecord.

推荐答案

如果要在录制过程中进行分析,则需要使用 AudioRecord ,作为 MediaRecorder 自动记录到文件中. AudioRecord 的缺点是,调用 startRecording()后,您需要自己从 AudioRecord 实例中轮询数据.另外,您必须足够快地读取和处理数据,以使内部缓冲区不会溢出(在logcat输出中查看, AudioRecord 会告诉您何时发生这种情况).

If you want to do your analysis while recording is still in progress, you need to use AudioRecord, as MediaRecorder automatically records into a file. AudioRecord has the disadvantage, that after calling startRecording() you need to poll the data yourself from the AudioRecord instance. Also, you must read and process the data fast enough such that the internal buffer is not overrun (look in the logcat output, AudioRecord will tell you when that happens).

这篇关于Android AudioRecord与MediaRecorder对比,用于录制音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆