mirror of
https://github.com/celisej567/abaddon.git
synced 2026-09-13 20:18:50 +03:00
add mix mono option to voice window (closes #238)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user