Ring Daemon 16.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
speex.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2004-2025 Savoir-faire Linux Inc.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17#pragma once
18
19#include "audio_processor.h"
20
21// typedef speex C structs
22extern "C" {
23struct SpeexEchoState_;
24typedef struct SpeexEchoState_ SpeexEchoState;
25struct SpeexPreprocessState_;
26typedef struct SpeexPreprocessState_ SpeexPreprocessState;
27}
28
29namespace jami {
30
32{
33public:
34 SpeexAudioProcessor(AudioFormat format, unsigned frameSize);
36
37 std::shared_ptr<AudioFrame> getProcessed() override;
38
39 void enableEchoCancel(bool enabled) override;
40 void enableNoiseSuppression(bool enabled) override;
41 void enableAutomaticGainControl(bool enabled) override;
42 void enableVoiceActivityDetection(bool enabled) override;
43
44private:
45 using SpeexEchoStatePtr = std::unique_ptr<SpeexEchoState, void (*)(SpeexEchoState*)>;
46 using SpeexPreprocessStatePtr
47 = std::unique_ptr<SpeexPreprocessState, void (*)(SpeexPreprocessState*)>;
48
49 // multichannel, one for the entire audio processor
50 SpeexEchoStatePtr echoState;
51
52 // one for each channel
53 std::vector<SpeexPreprocessStatePtr> preprocessorStates;
54
55 std::unique_ptr<AudioFrame> procBuffer {};
56 Resampler deinterleaveResampler;
57 Resampler interleaveResampler;
58
59 // if we should do echo cancellation
60 bool shouldAEC {false};
61
62 // if we should do voice activity detection
63 // preprocess_run returns 1 if vad is disabled, so we have to know whether or not to ignore it
64 bool shouldDetectVoice {false};
65};
66} // namespace jami
Wrapper class for libswresample.
Definition resampler.h:36
void enableVoiceActivityDetection(bool enabled) override
Set the status of voice activity detection.
Definition speex.cpp:168
void enableEchoCancel(bool enabled) override
Set the status of echo cancellation.
Definition speex.cpp:106
std::shared_ptr< AudioFrame > getProcessed() override
Process and return a single AudioFrame.
Definition speex.cpp:183
void enableNoiseSuppression(bool enabled) override
Set the status of noise suppression includes de-reverb, de-noise, high pass filter,...
Definition speex.cpp:134
void enableAutomaticGainControl(bool enabled) override
Set the status of automatic gain control.
Definition speex.cpp:153
void emitSignal(Args... args)
Definition ring_signal.h:64
struct SpeexPreprocessState_ SpeexPreprocessState
Definition speex.h:26
struct SpeexEchoState_ SpeexEchoState
Definition speex.h:24
Structure to hold sample rate and channel number associated with audio data.