mirror of
https://github.com/uowuo/abaddon.git
synced 2024-09-20 06:51:51 +00:00
add mix mono option to voice window (closes #238)
This commit is contained in:
parent
893c9b5241
commit
9a5e820f6d
|
@ -419,13 +419,23 @@ void AudioManager::OnCapturedPCM(const int16_t *pcm, ma_uint32 frames) {
|
|||
if (m_opus_buffer == nullptr || !m_should_capture) return;
|
||||
|
||||
const double gain = m_capture_gain;
|
||||
// i have a suspicion i can cast the const away... but i wont
|
||||
|
||||
std::vector<int16_t> new_pcm(pcm, pcm + frames * 2);
|
||||
for (auto &val : new_pcm) {
|
||||
const int32_t unclamped = static_cast<int32_t>(val * gain);
|
||||
val = std::clamp(unclamped, INT16_MIN, INT16_MAX);
|
||||
}
|
||||
|
||||
if (m_mix_mono) {
|
||||
for (size_t i = 0; i < frames * 2; i += 2) {
|
||||
const int sample_L = new_pcm[i];
|
||||
const int sample_R = new_pcm[i + 1];
|
||||
const int16_t mixed = static_cast<int16_t>((sample_L + sample_R) / 2);
|
||||
new_pcm[i] = mixed;
|
||||
new_pcm[i + 1] = mixed;
|
||||
}
|
||||
}
|
||||
|
||||
UpdateCaptureVolume(new_pcm.data(), frames);
|
||||
|
||||
static std::array<float, 480> denoised_L;
|
||||
|
@ -629,6 +639,14 @@ bool AudioManager::GetSuppressNoise() const {
|
|||
}
|
||||
#endif
|
||||
|
||||
void AudioManager::SetMixMono(bool value) {
|
||||
m_mix_mono = value;
|
||||
}
|
||||
|
||||
bool AudioManager::GetMixMono() const {
|
||||
return m_mix_mono;
|
||||
}
|
||||
|
||||
AudioManager::type_signal_opus_packet AudioManager::signal_opus_packet() {
|
||||
return m_signal_opus_packet;
|
||||
}
|
||||
|
|
|
@ -87,6 +87,9 @@ public:
|
|||
bool GetSuppressNoise() const;
|
||||
#endif
|
||||
|
||||
void SetMixMono(bool value);
|
||||
bool GetMixMono() const;
|
||||
|
||||
private:
|
||||
void OnCapturedPCM(const int16_t *pcm, ma_uint32 frames);
|
||||
|
||||
|
@ -144,6 +147,7 @@ private:
|
|||
std::atomic<double> m_prob_threshold = 0.5;
|
||||
std::atomic<float> m_vad_prob = 0.0;
|
||||
std::atomic<bool> m_enable_noise_suppression = false;
|
||||
std::atomic<bool> m_mix_mono = false;
|
||||
|
||||
std::unordered_set<uint32_t> m_muted_ssrcs;
|
||||
std::unordered_map<uint32_t, double> m_volume_ssrc;
|
||||
|
|
|
@ -89,6 +89,7 @@ VoiceWindow::VoiceWindow(Snowflake channel_id)
|
|||
, m_mute("Mute")
|
||||
, m_deafen("Deafen")
|
||||
, m_noise_suppression("Suppress Noise")
|
||||
, m_mix_mono("Mix Mono")
|
||||
, m_channel_id(channel_id)
|
||||
, m_menu_view("View")
|
||||
, m_menu_view_settings("More _Settings", true) {
|
||||
|
@ -178,6 +179,11 @@ VoiceWindow::VoiceWindow(Snowflake channel_id)
|
|||
Abaddon::Get().GetAudio().SetSuppressNoise(m_noise_suppression.get_active());
|
||||
});
|
||||
|
||||
m_mix_mono.set_active(audio.GetMixMono());
|
||||
m_mix_mono.signal_toggled().connect([this]() {
|
||||
Abaddon::Get().GetAudio().SetMixMono(m_mix_mono.get_active());
|
||||
});
|
||||
|
||||
auto *playback_renderer = Gtk::make_managed<Gtk::CellRendererText>();
|
||||
m_playback_combo.set_valign(Gtk::ALIGN_END);
|
||||
m_playback_combo.set_hexpand(true);
|
||||
|
@ -223,6 +229,7 @@ VoiceWindow::VoiceWindow(Snowflake channel_id)
|
|||
m_controls.add(m_mute);
|
||||
m_controls.add(m_deafen);
|
||||
m_controls.add(m_noise_suppression);
|
||||
m_controls.add(m_mix_mono);
|
||||
m_main.add(m_menu_bar);
|
||||
m_main.add(m_controls);
|
||||
m_main.add(m_vad_value);
|
||||
|
|
|
@ -54,6 +54,7 @@ private:
|
|||
Gtk::Scale m_capture_gain;
|
||||
|
||||
Gtk::CheckButton m_noise_suppression;
|
||||
Gtk::CheckButton m_mix_mono;
|
||||
|
||||
Gtk::ComboBoxText m_vad_combo;
|
||||
Gtk::ComboBox m_playback_combo;
|
||||
|
|
Loading…
Reference in New Issue
Block a user