update vad param value on combobox change

This commit is contained in:
ouwou
2023-07-23 02:08:26 -04:00
parent dc92fef708
commit 18172a8890
4 changed files with 27 additions and 2 deletions

View File

@@ -572,6 +572,10 @@ float AudioManager::GetCurrentVADProbability() const {
return m_vad_prob;
}
double AudioManager::GetRNNProbThreshold() const {
return m_prob_threshold;
}
AudioManager::type_signal_opus_packet AudioManager::signal_opus_packet() {
return m_signal_opus_packet;
}

View File

@@ -78,7 +78,9 @@ public:
void SetVADMethod(const std::string &method);
void SetVADMethod(VADMethod method);
VADMethod GetVADMethod() const;
float GetCurrentVADProbability() const;
double GetRNNProbThreshold() const;
private:
void OnCapturedPCM(const int16_t *pcm, ma_uint32 frames);

View File

@@ -119,7 +119,6 @@ VoiceWindow::VoiceWindow(Snowflake channel_id)
m_vad_param.set_range(0.0, 100.0);
m_vad_param.set_value_pos(Gtk::POS_LEFT);
m_vad_param.set_value(audio.GetCaptureGate() * 100.0);
m_vad_param.signal_value_changed().connect([this]() {
const double val = m_vad_param.get_value() * 0.01;
switch (Abaddon::Get().GetAudio().GetVADMethod()) {
@@ -133,6 +132,7 @@ VoiceWindow::VoiceWindow(Snowflake channel_id)
#endif
};
});
UpdateVADParamValue();
m_capture_gain.set_range(0.0, 200.0);
m_capture_gain.set_value_pos(Gtk::POS_LEFT);
@@ -161,9 +161,12 @@ VoiceWindow::VoiceWindow(Snowflake channel_id)
#endif
}
m_vad_combo.signal_changed().connect([this]() {
auto &audio = Abaddon::Get().GetAudio();
const auto id = m_vad_combo.get_active_id();
Abaddon::Get().GetAudio().SetVADMethod(id);
audio.SetVADMethod(id);
Abaddon::Get().GetSettings().VAD = id;
UpdateVADParamValue();
});
auto *playback_renderer = Gtk::make_managed<Gtk::CellRendererText>();
@@ -278,6 +281,20 @@ bool VoiceWindow::UpdateVoiceMeters() {
return true;
}
void VoiceWindow::UpdateVADParamValue() {
auto &audio = Abaddon::Get().GetAudio();
switch (audio.GetVADMethod()) {
case AudioManager::VADMethod::Gate:
m_vad_param.set_value(audio.GetCaptureGate() * 100.0);
break;
#ifdef WITH_RNNOISE
case AudioManager::VADMethod::RNNoise:
m_vad_param.set_value(audio.GetRNNProbThreshold() * 100.0);
break;
#endif
}
}
void VoiceWindow::OnUserConnect(Snowflake user_id, Snowflake to_channel_id) {
if (m_channel_id == to_channel_id) {
if (auto it = m_rows.find(user_id); it == m_rows.end()) {

View File

@@ -34,6 +34,8 @@ private:
bool UpdateVoiceMeters();
void UpdateVADParamValue();
Gtk::Box m_main;
Gtk::Box m_controls;