34 lines
1.1 KiB
C
34 lines
1.1 KiB
C
|
|
/*
|
||
|
|
* audio/apm_processor.h — Send-side audio processing module (AEC/NS/AGC/VAD).
|
||
|
|
*
|
||
|
|
* Design: docs/voice.md §11. Uses webrtc-audio-processing when VOICECAT_HAS_APM is defined;
|
||
|
|
* falls back to a no-op passthrough (VAD always open, PCM unmodified) otherwise.
|
||
|
|
*/
|
||
|
|
#ifndef VOICECAT_AUDIO_APM_PROCESSOR_H
|
||
|
|
#define VOICECAT_AUDIO_APM_PROCESSOR_H
|
||
|
|
|
||
|
|
#include <cstdint>
|
||
|
|
#include <memory>
|
||
|
|
|
||
|
|
namespace voicecat::audio {
|
||
|
|
|
||
|
|
class ApmProcessor {
|
||
|
|
public:
|
||
|
|
virtual ~ApmProcessor() = default;
|
||
|
|
|
||
|
|
// Feed the most recent playback reference (for AEC). Call before process_capture().
|
||
|
|
virtual void process_render(const int16_t* pcm, int samples, int sample_rate) = 0;
|
||
|
|
|
||
|
|
// Process one capture frame in-place (AEC, NS, AGC).
|
||
|
|
// Returns true if VAD detects speech (or always true in passthrough mode).
|
||
|
|
// Returns false → caller should skip encode/send (silence gate).
|
||
|
|
virtual bool process_capture(int16_t* pcm, int samples, int sample_rate) = 0;
|
||
|
|
|
||
|
|
// Factory: returns a real APM if VOICECAT_HAS_APM is defined, else a passthrough.
|
||
|
|
static std::unique_ptr<ApmProcessor> create();
|
||
|
|
};
|
||
|
|
|
||
|
|
} // namespace voicecat::audio
|
||
|
|
|
||
|
|
#endif // VOICECAT_AUDIO_APM_PROCESSOR_H
|