【问题标题】:How to show MIC input visualization while audio recording Android如何在 Android 音频录制时显示 MIC 输入可视化
【发布时间】:2014-08-26 07:17:38
【问题描述】:

我正在寻找一种显示 MIC 输入级语音强度的方法。 我正在使用 Android AudioRecord 录制语音输入。

我正在关注本教程以供参考

http://developer.samsung.com/android/technical-docs/Displaying-Sound-Volume-in-Real-Time-While-Recording

我也将其实现为

while (isRecording) {
            read = recorder.read(data, 0, bufferSize);

            if (AudioRecord.ERROR_INVALID_OPERATION != read) {
                try {
                    os.write(data);                 


                     int amplitude = (data[0] & 0xff) << 8 | data[1];
                      amplitude = Math.abs(amplitude);
                      pbVisulaizer.setProgress(amplitude);

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }

但是幅度变化太频繁了,我也在根据记录质量寻找进度条的最大进度。任何建议。

【问题讨论】:

    标签: java android visualization audiorecord android-audiorecord


    【解决方案1】:

    https://github.com/Audioboo/audioboo-android/blob/master/src/fm/audioboo/application/FLACRecorder.java

    有关在每个 IO 上捕获“getAmplitudes()”的编码器,请参见 #361、362

    messageHandler 是返回 UI 线程的异步方式,其中标准 ProgressBar 管理实际级别 Meter...

    return new Handler(new Handler.Callback()
                {
                      public boolean handleMessage(Message m)
                      {
                        switch (m.what) {
                          case FLACRecorder.MSG_AMPLITUDES:
                            FLACRecorder.Amplitudes amp = (FLACRecorder.Amplitudes) m.obj;
    
                            // Create a copy of the amplitude in mLastAmplitudes; we'll use
                            // that when we restart recording to calculate the position
                            // within the Boo.
                            mLastAmplitudes = new FLACRecorder.Amplitudes(amp);
                            //TODO call the amp routine from the other process
                            if (null != mAmplitudes) {
                              amp.mPosition += mAmplitudes.mPosition;
                            }                                               
                     mProgressBar.setProgress((int)Math.round(mLastAmplitudes.mAverage * 10000));
    }}}
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-06-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多