麦克风输入归来幅度不记录时, [英] Return amplitude of the mic input when not recording

查看:100
本文介绍了麦克风输入归来幅度不记录时,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下的code和需要能够收听手机上的麦克风并使用该值要在一些可视化的图形显示:

I have the following code and need to be able to listen to the mic on the phone and use that value to be displayed graphically on some sort of visualizer:

Timer micTimer = new Timer();
micTimer.schedule(new TimerTask(){
    @Override
    public void run(){
        int x = MediaRecorder.getAudioSourceMax();
        Log.v("Timer", "" + x);
    }
}, 0, 100);

我知道这可能是远没有错的。后来在类我使用的是AudioRecorder对象来录制声音对于一些后期处理。在这里,我不想录制任何内容只是显示一个可视化的声音。从这个code日志只输出数6每100ms。难道有什么用它做自动调整增益?如果让我怎么轮得到呢?

I know this is probably far from wrong. Later in the class I am using an AudioRecorder object to record the sound for some post processing. Here I don't want to record anything just display the sound on a visualizer. The log from this code just outputs the number 6 every 100ms. Could it have something to do with it auto-adjusting the gain? If so how do I get round this?

推荐答案

好吧,我很抱歉地说山姆,但你无法从麦克风的没有的记录的幅度。我开发了一个应用程序非常相似这一点。你要开始​​录音,请拨打getMaxAmplitude()函数(返回0),等待一点点,然后再次调用它,它会返回幅度最大,因为函数被调用最后一次。看看进入 NoiseAlert应用。这真的帮了我。

Well, I'm sorry to say Sam, but you can't get the amplitude from the mic without recording. I developed an app very similar to this. You have to begin recording, call the getMaxAmplitude() function(which will return 0), wait a little bit, then call it again and it will return the maximum amplitude since the function was called last. Look into the NoiseAlert app. It really helped me out.

此外,作为一个侧面说明,在我的研究,我发现它更容易使用MediaRecorder对象,因为它不具备自动增益;你会得到什么实际被麦克风听到'。

Also, as a side note, in my research I have found that it's easier to use the MediaRecorder object because it doesn't have the auto-gain; you get what's actually being 'heard' by the microphone.

这篇关于麦克风输入归来幅度不记录时,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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