support mindeps build without rnnoise

This commit is contained in:
ouwou 2023-07-18 02:02:39 -04:00
parent 7bc6116e21
commit be2ab2ef31
6 changed files with 30 additions and 2 deletions

View File

@ -35,7 +35,7 @@ DerivePointerAlignment: 'false'
FixNamespaceComments: 'true'
IncludeBlocks: Merge
IndentCaseLabels: 'true'
IndentPPDirectives: BeforeHash
IndentPPDirectives: None
IndentWidth: '4'
IndentWrappedFunctionNames: 'false'
JavaScriptQuotes: Double

View File

@ -67,7 +67,7 @@ jobs:
with:
cond: ${{ matrix.mindeps == true }}
if_true: |
cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=${{ matrix.buildtype }} -DUSE_LIBHANDY=OFF -DENABLE_VOICE=OFF -DENABLE_NOTIFICATION_SOUNDS=OFF -DENABLE_QRCODE_LOGIN=OFF
cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=${{ matrix.buildtype }} -DUSE_LIBHANDY=OFF -DENABLE_VOICE=OFF -DENABLE_NOTIFICATION_SOUNDS=OFF -DENABLE_QRCODE_LOGIN=OFF -DENABLE_RNNOISE=OFF
cmake --build build
if_false: |
cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=${{ matrix.buildtype }} -DCMAKE_CXX_FLAGS="-Wl,--default-image-base-low"

View File

@ -163,6 +163,8 @@ if (ENABLE_VOICE)
target_link_libraries(abaddon ${CMAKE_DL_LIBS})
if (ENABLE_RNNOISE)
target_compile_definitions(abaddon PRIVATE WITH_RNNOISE)
find_package(rnnoise QUIET)
if (NOT rnnoise_FOUND)
message("rnnoise was not found and will be included as a submodule")

View File

@ -82,7 +82,12 @@ AudioManager::AudioManager() {
spdlog::get("audio")->info("Audio backend: {}", ma_get_backend_name(m_context.backend));
Enumerate();
#ifdef WITH_RNNOISE
SetVADMethod(VADMethod::RNNoise);
#else
SetVADMethod(VADMethod::Gate);
#endif
m_playback_config = ma_device_config_init(ma_device_type_playback);
m_playback_config.playback.format = ma_format_f32;
@ -144,7 +149,10 @@ AudioManager::~AudioManager() {
ma_device_uninit(&m_capture_device);
ma_context_uninit(&m_context);
RemoveAllSSRCs();
#ifdef WITH_RNNOISE
RNNoiseUninitialize();
#endif
}
void AudioManager::AddSSRC(uint32_t ssrc) {
@ -425,9 +433,11 @@ void AudioManager::OnCapturedPCM(const int16_t *pcm, ma_uint32 frames) {
case VADMethod::Gate:
if (!CheckVADVoiceGate()) return;
break;
#ifdef WITH_RNNOISE
case VADMethod::RNNoise:
if (!CheckVADRNNoise(pcm)) return;
break;
#endif
}
m_enc_mutex.lock();
@ -475,6 +485,7 @@ bool AudioManager::CheckVADVoiceGate() {
return m_capture_peak_meter / 32768.0 > m_capture_gate;
}
#ifdef WITH_RNNOISE
bool AudioManager::CheckVADRNNoise(const int16_t *pcm) {
static float denoised[480];
static float rnnoise_input[480];
@ -503,6 +514,7 @@ void AudioManager::RNNoiseUninitialize() {
m_rnnoise = nullptr;
}
}
#endif
bool AudioManager::OK() const {
return m_ok;
@ -531,11 +543,13 @@ uint32_t AudioManager::GetRTPTimestamp() const noexcept {
void AudioManager::SetVADMethod(VADMethod method) {
m_vad_method = method;
#ifdef WITH_RNNOISE
if (method == VADMethod::RNNoise) {
RNNoiseInitialize();
} else {
RNNoiseUninitialize();
}
#endif
}
AudioManager::type_signal_opus_packet AudioManager::signal_opus_packet() {

View File

@ -14,7 +14,10 @@
#include <miniaudio.h>
#include <opus.h>
#include <sigc++/sigc++.h>
#ifdef WITH_RNNOISE
#include <rnnoise.h>
#endif
#include "devices.hpp"
// clang-format on
@ -84,10 +87,13 @@ private:
bool DecayVolumeMeters();
bool CheckVADVoiceGate();
#ifdef WITH_RNNOISE
bool CheckVADRNNoise(const int16_t *pcm);
void RNNoiseInitialize();
void RNNoiseUninitialize();
#endif
friend void data_callback(ma_device *, void *, const void *, ma_uint32);
friend void capture_data_callback(ma_device *, void *, const void *, ma_uint32);
@ -132,7 +138,9 @@ private:
AudioDevices m_devices;
VADMethod m_vad_method;
#ifdef WITH_RNNOISE
DenoiseState *m_rnnoise;
#endif
std::atomic<uint32_t> m_rtp_timestamp = 0;
public:

View File

@ -138,8 +138,12 @@ VoiceWindow::VoiceWindow(Snowflake channel_id)
m_vad_combo.set_hexpand(true);
m_vad_combo.set_halign(Gtk::ALIGN_FILL);
m_vad_combo.append("gate", "Gate");
#ifdef WITH_RNNOISE
m_vad_combo.append("rnnoise", "RNNoise");
m_vad_combo.set_active_id("rnnoise");
#else
m_vad_combo.set_active_id("gate");
#endif
m_vad_combo.signal_changed().connect([this]() {
const auto id = m_vad_combo.get_active_id();
if (id == "gate") {