簡體   English   中英

如何使用Android Media Recorder的getMaxAmplitude函數

[英]how to use Android Media Recorder getMaxAmplitude function

我正在嘗試運行錄音http://developer.android.com/guide/topics/media/index.html ,它的工作正常,我需要在連續錄音的同時顯示最大振幅。 最好的方法是什么。

最大幅度給出了給定樣本的最大幅度,因此我每250毫秒采樣一次並計算出最大幅度

public void run() {
            int i = 0;
            while(i == 0) {
                Message msg = mHandler.obtainMessage();
                Bundle b = new Bundle();
                try {
                    sleep(250);
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                if (mRecorder != null) {
                    amplitude = mRecorder.getMaxAmplitude();
                    b.putLong("currentTime", amplitude);
                    Log.i("AMPLITUDE", new Integer(amplitude).toString());
                } else {
                    b.putLong("currentTime", 0);
                }
                msg.setData(b);
                mHandler.sendMessage(msg);
            }
        }

我使用消息處理程序使用后台進程線程來修改前端

創建一個一直運行的線程。 在線程中執行以下操作:

    int amp = mrec.getMaxAmplitude();
    if (amp > 0)
      yourcode;

您是否需要有關該線程的更多信息?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM