什么是Android的getMaxAmplitude()函数MediaRecorder实际上给我吗? [英] What does Android's getMaxAmplitude() function for the MediaRecorder actually give me?

查看:1880
本文介绍了什么是Android的getMaxAmplitude()函数MediaRecorder实际上给我吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

而Android MediaRecorder有一个函数

The Android MediaRecorder has a function

.getMaxAmplitude();

其中,作为<一个href="http://developer.android.com/reference/android/media/MediaRecorder.html#getMaxAmplitude%28%29">API告诉我,返回,因为这种方法的最后一个电话被取样的最大绝对幅度。,但我找不到什么幅度,这是?它是用Pascal或瓦特?

which, as the API tells me, "Returns the maximum absolute amplitude that was sampled since the last call to this method." but I can't find what amplitude this is? Is it in pascal or watts?

我发现在网络上几个页面,你可以计算出紧密corelated使用(以分贝值作为建议的<一个href="http://stackoverflow.com/questions/7189275/how-to-calculate-microphone-audio-input-power-in-decibell-unit">here).

I have found on several pages on the web that you can calculate a value closely corelated to decibels using (as suggested here).

double db = (20 * Math.log10(amplitude / REFERENCE)); 

这将让我假定所返回的值是在某些线性度(大概就像milipascal ...)

which would let me assume that the returned value is in some linear scale (probably something like milipascal...)

REFERENCE = 0.1(我知道这应该是这样的2 * 10 ^( - 5)帕斯卡((20 uPascal)),但奇怪的返回值... 0.1奇怪的效果更好。)

REFERENCE=0.1 (I am aware that this should be something like 2*10^(-5) Pascal ((20 uPascal)), but that returns strange values... 0.1 strangely works better.)

现在我用测量MaxAmplitude()的

Right now I measure the MaxAmplitude() using the

getMaxAmplitude()

和将其放入变量幅度

这是方法:

public double getNoiseLevel() 
{
    //Log.d("SPLService", "getNoiseLevel() ");
    int x = mRecorder.getMaxAmplitude();
    double x2 = x;
    Log.d("SPLService", "x="+x);
    double db = (20 * Math.log10(x2 / REFERENCE));
    //Log.d("SPLService", "db="+db);
    if(db>0)
    {
        return db;
    }
    else
    {
        return 0;
    }
}

这是做5次在半秒,它得到的平均那种

This is done 5 times in half a second, which gets kind of an average

for(int i=0; i<5; i++)
{
    try 
    {
            Thread.sleep(100);
    } 
    catch (InterruptedException e) 
    {
            e.printStackTrace();
            return 0;
    }
    level = level+getNoiseLevel();
    if(level>0)
    {
        counter++;
    }
}
level=level/counter;
Log.d(LOG_TAG, "level="+level);

我得到的东西,有点貌似分贝,但我不知道它的actualy分贝在所有...

I get something that kinda looks like decibel but I'm not sure its actualy decibel at all...

所以,任何人都可以帮助我在这?这似乎很奇怪的是,API不specefy在所有返回什么...

So, could anyone help me on this? It seems very odd that the API does not specefy at all what is returned...

推荐答案

我能找到这个问题的答案,我会在这里分享的人谁在乎:本MediaRecorder.getMaxAmplitude()函数返回16位无符号整数值(0-32767)。这也许是范围从-32768到32767的CD音质的采样值仅仅是ABS(),这意味着,他们可能重新present电力输出的16位数字,从0〜100%最大电压范围麦克风构筑成的手机。因为即使在一个品牌的移动这些麦克风有时会发生变化在其precise范围甚至不给予相同的声音源的距离相同类似的手机将必然返回相同的值。

I could find the answer to this question and I'll share it here for anyone who cares: The MediaRecorder.getMaxAmplitude() function returns unsigned 16-bit integer values (0-32767). Which is probably just the abs() of the CD-quality sample values that range from -32768 to 32767. This means that they probably represent a 16-bit digitalization of the electrical output from 0-100% maximum voltage range of the microphone build into that mobile phone. Since even in one brand of mobile these microphones sometimes vary in their precise range not even to similar phones will necessarily return the same value given the same distance to the same sound source.

此值但相关声音pressure帕斯卡尔,因为它也是solund pressure线性量化,在声音可利用给定的麦克风进行测量的面积(这不会覆盖整个US prectrum由于手机的限制)。

This value however correlates to sound pressure in Pascal since it's also a linear quantisation of the solund pressure, in the area where sound can be measured with the given microphone (which will not cover the entire sprectrum due to the limitations of the phone).

这篇关于什么是Android的getMaxAmplitude()函数MediaRecorder实际上给我吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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