mirror of
https://github.com/celisej567/abaddon.git
synced 2026-09-19 20:11:59 +03:00
basic voice gate
This commit is contained in:
@@ -176,6 +176,10 @@ void AudioManager::SetPlayback(bool playback) {
|
||||
m_should_playback = playback;
|
||||
}
|
||||
|
||||
void AudioManager::SetCaptureGate(double gate) {
|
||||
m_capture_gate = gate * 0.01;
|
||||
}
|
||||
|
||||
void AudioManager::SetMuteSSRC(uint32_t ssrc, bool mute) {
|
||||
std::lock_guard<std::mutex> _(m_mutex);
|
||||
if (mute) {
|
||||
@@ -197,6 +201,8 @@ void AudioManager::OnCapturedPCM(const int16_t *pcm, ma_uint32 frames) {
|
||||
|
||||
UpdateCaptureVolume(pcm, frames);
|
||||
|
||||
if (m_capture_peak_meter / 32768.0 < m_capture_gate) return;
|
||||
|
||||
int payload_len = opus_encode(m_encoder, pcm, 480, static_cast<unsigned char *>(m_opus_buffer), 1275);
|
||||
if (payload_len < 0) {
|
||||
printf("encoding error: %d\n", payload_len);
|
||||
|
||||
@@ -30,6 +30,8 @@ public:
|
||||
void SetCapture(bool capture);
|
||||
void SetPlayback(bool playback);
|
||||
|
||||
void SetCaptureGate(double gate);
|
||||
|
||||
void SetMuteSSRC(uint32_t ssrc, bool mute);
|
||||
void SetVolumeSSRC(uint32_t ssrc, double volume);
|
||||
|
||||
@@ -71,6 +73,8 @@ private:
|
||||
std::atomic<bool> m_should_capture = true;
|
||||
std::atomic<bool> m_should_playback = true;
|
||||
|
||||
std::atomic<double> m_capture_gate = 0.0;
|
||||
|
||||
std::unordered_set<uint32_t> m_muted_ssrcs;
|
||||
std::unordered_map<uint32_t, double> m_volume_ssrc;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user