1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Add extra latency to microphone playback to reduce clipping.

This commit is contained in:
Saracen
2018-07-31 04:46:29 +01:00
parent d91183be52
commit 59b703c4f8
2 changed files with 3 additions and 1 deletions

View File

@@ -138,7 +138,7 @@ void AudioStreamPlaybackMicrophone::_mix_internal(AudioFrame *p_buffer, int p_fr
unsigned int input_size = AudioDriver::get_singleton()->get_input_size();
// p_frames is multipled by two since an AudioFrame is stereo
if ((p_frames * 2) > input_size) {
if ((p_frames + MICROPHONE_PLAYBACK_DELAY * 2) > input_size) {
for (int i = 0; i < p_frames; i++) {
p_buffer[i] = AudioFrame(0.0f, 0.0f);
}

View File

@@ -122,6 +122,8 @@ class AudioStreamPlaybackMicrophone : public AudioStreamPlaybackResampled {
GDCLASS(AudioStreamPlaybackMicrophone, AudioStreamPlayback)
friend class AudioStreamMicrophone;
const int MICROPHONE_PLAYBACK_DELAY = 256;
bool active;
unsigned int input_ofs;