Android的MediaRecorder getMaxAmplitude总是在LG擎天柱返回0 [英] Android MediaRecorder getMaxAmplitude always returns 0 on LG Optimus

查看:90
本文介绍了Android的MediaRecorder getMaxAmplitude总是在LG擎天柱返回0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写一个应用程序,基本上只是测试,如果我们能够从话筒得到任何东西。

它完美的几款Android设备,但不能在LG擎天柱。每次我打电话 MediaRecorder.getMaxAmplitude 的LG则返回0。

该设备成功地拍摄,因为我可以听录音。

解决方案

getMaxAmplitude返回自从上次你把它称为最大振幅。

所以,你第一次调用它,它初始化本身(因此返回0)的时候,它应该返回另一个值。根据该文件:

  

getMaxAmplitude()返回,因为这个方法最后调用被取样的最大绝对幅度。只有setAudioSource后调用这个()。

     

当要求第一次返回自上次呼叫测得的最大绝对振幅,或0

或者,如果你使用它的权利,你有同样的问题,因为我有。我的code工作在一个GalaxyTab的7(升级Froyo),而不是10.1(蜂巢)。

编辑:我修好了我的问题(我希望它会帮助你太)。确保你第一次调用getMaxAmplitude,以初始化它,你先调用start()。 我使用的:

 刻录prepare()。
recorder.getMaxAmplitude();
recorder.start();
//倾听用户
INT幅度= recorder.getMaxAmplitude();
 

当它应该是:

 刻录prepare()。
recorder.start();
recorder.getMaxAmplitude();
//倾听用户
INT幅度= recorder.getMaxAmplitude();
 

修改:此code仍然有它似乎缺陷。这code似乎并不工作,S2,例如。它会返回0。不过,我叫getMaxAmplitude()只有两次,所以如果你需要更新的幅度每秒例如,它可能是好的。

I am writing an app that basically just tests if we can get anything at all from the microphone.

It works perfectly on several android devices, but not on the LG Optimus. Everytime I call MediaRecorder.getMaxAmplitude on the LG it returns 0.

The device is successfully recording, because I can listen to the recordings.

解决方案

getMaxAmplitude returns the maximum amplitude since the last time you called it.

So, the first time you call it, it initializes itself (and so returns 0) the second time, it should return another value. According to the documentation :

getMaxAmplitude() returns the maximum absolute amplitude that was sampled since the last call to this method. Call this only after the setAudioSource().

Returns the maximum absolute amplitude measured since the last call, or 0 when called for the first time

Or, if you use it right, you have the same problem as I have. My code works on a galaxyTab 7(Froyo), but not 10.1 (Honeycomb).

EDIT : I repaired my problem (I hope it'll help you too). Make sure the first time you call getMaxAmplitude, in order to initialize it, you called start() first. I used:

recorder.prepare();
recorder.getMaxAmplitude();
recorder.start();
//listening to the user
int amplitude = recorder.getMaxAmplitude();

When it should have been :

recorder.prepare();
recorder.start();
recorder.getMaxAmplitude();
//listening to the user
int amplitude = recorder.getMaxAmplitude();

EDIT : This code still has flaws it seems. This code doesn't seems to work on S2, for instance. It'll return 0. But I call getMaxAmplitude() only twice, so if you need to update the amplitude every second for example, it may be ok.

这篇关于Android的MediaRecorder getMaxAmplitude总是在LG擎天柱返回0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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