如何检查音频的强度(强度),同时录制? [英] How to check strength (intensity) of audio while recording?

查看:489
本文介绍了如何检查音频的强度(强度),同时录制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个录音笔的应用程序。我想知道有没有办法找到声音的强度的同时进行录制。我不想在任何地方保存录音。我只是想告诉用户,如果被抓住的声音通过麦克风大声是那么predefined阈值。

I am working on a voice recorder application. I want to know is there any way to find strength of the audio while recording it. I don't want to save the recording anywhere. I just want to show user if the sound being caught by the mic is louder then a predefined threshold or not.

比方说,如果声音被夹在低于2分贝,它应该显示低的红色画布。当声音变得更响亮,并通过2分贝门槛画布应该变成绿色,并显示高的消息。

Let's say if the sound being caught in below 2 decibel, it should show "low" in a red canvas. As soon as sound gets louder and passes 2 decibel threshold the canvas should turn green and show "high" message.

使用MediaRecorder是否有可能还是我haveto使用AudioRecorder类。而如何解决它。

Is it possible using MediaRecorder or i haveto use AudioRecorder class. And how to work it out.

在此先感谢

推荐答案

您可以在录制开始启动另一个线程,并使用 getMaxAmplitude 函数来捕获的振幅。

You can start another thread when recording start and use getMaxAmplitude function to capture Amplitudes.

下面是snippet.here我们采取样品,每250毫秒计算的最大振幅

Below is the snippet.here we are taking sample for every 250 milliseconds and calculated max amplitude

public void run() {
            int i = 0;
            while(i == 0) {

                try {
                    sleep(250);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                if (mRecorder != null) {
                    amplitude = mRecorder.getMaxAmplitude();

                    //Here you can put condition (low/high)
                    Log.i("AMPLITUDE", new Integer(amplitude).toString());
                } 

            }
        }

这篇关于如何检查音频的强度(强度),同时录制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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