webrtc audioprocess 分析

来源:互联网 发布:qq拼音 ubuntu 编辑:程序博客网 时间:2024/06/08 13:55

webrtc audioprocess 简称 apm是:

 // The Audio Processing Module (APM) provides a collection of voice processing
// components designed for real-time communications software.

这里说了 apm是一个用于实时音频处理的组件


APM accepts only 16-bit linear PCM audio data in frames of 10 ms. Multiple channels should be interleaved.

这里说的很清楚 apm仅仅接受16bit的10毫秒每帧的pcm音频数据


// Usage example, omitting error checking:
// AudioProcessing* apm = AudioProcessing::Create(0);
//
// apm->high_pass_filter()->Enable(true);
//
// apm->echo_cancellation()->enable_drift_compensation(false);
// apm->echo_cancellation()->Enable(true);
//
// apm->noise_reduction()->set_level(kHighSuppression);
// apm->noise_reduction()->Enable(true);
//
// apm->gain_control()->set_analog_level_limits(0, 255);
// apm->gain_control()->set_mode(kAdaptiveAnalog);
// apm->gain_control()->Enable(true);
//
// apm->voice_detection()->Enable(true);
//
// // Start a voice call...
//
// // ... Render frame arrives bound for the audio HAL ...
// apm->AnalyzeReverseStream(render_frame);
//
// // ... Capture frame arrives from the audio HAL ...
// // Call required set_stream_ functions.
// apm->set_stream_delay_ms(delay_ms);
// apm->gain_control()->set_stream_analog_level(analog_level);
//
// apm->ProcessStream(capture_frame);
//
// // Call required stream_ functions.
// analog_level = apm->gain_control()->stream_analog_level();
// has_voice = apm->stream_has_voice();
//
// // Repeate render and capture processing for the duration of the call...
// // Start a new call...
// apm->Initialize();
//
// // Close the application...
// delete apm;
//



  // DEPRECATED: It is now possible to modify the sample rate directly in a call
  // to |ProcessStream|.
  // Sets the sample |rate| in Hz for both the primary and reverse audio
  // streams. 8000, 16000 or 32000 Hz are permitted.

这里有说 目前支持 8000  16000 32000hz采样率的音频



  // Processes a 10 ms |frame| of the primary audio stream. On the client-side,
  // this is the near-end (or captured) audio.
  //
  // If needed for enabled functionality, any function with the set_stream_ tag
  // must be called prior to processing the current frame. Any getter function
  // with the stream_ tag which is needed should be called after processing.
  //
  // The |sample_rate_hz_|, |num_channels_|, and |samples_per_channel_|
  // members of |frame| must be valid. If changed from the previous call to this
  // method, it will trigger an initialization.

这里说的很清楚:调用此processstream之前必须要至少设置3个参数 第一个是:

sample_rate_hz_ = 32000

num_channels_ =2

samples_per_channel_ = 320


  virtual int ProcessStream(AudioFrame* frame) = 0;

后续文章继续追加

0 0