You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
Add extra latency to microphone playback to reduce clipping.
This commit is contained in:
@@ -138,7 +138,7 @@ void AudioStreamPlaybackMicrophone::_mix_internal(AudioFrame *p_buffer, int p_fr
|
|||||||
unsigned int input_size = AudioDriver::get_singleton()->get_input_size();
|
unsigned int input_size = AudioDriver::get_singleton()->get_input_size();
|
||||||
|
|
||||||
// p_frames is multipled by two since an AudioFrame is stereo
|
// 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++) {
|
for (int i = 0; i < p_frames; i++) {
|
||||||
p_buffer[i] = AudioFrame(0.0f, 0.0f);
|
p_buffer[i] = AudioFrame(0.0f, 0.0f);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,6 +122,8 @@ class AudioStreamPlaybackMicrophone : public AudioStreamPlaybackResampled {
|
|||||||
GDCLASS(AudioStreamPlaybackMicrophone, AudioStreamPlayback)
|
GDCLASS(AudioStreamPlaybackMicrophone, AudioStreamPlayback)
|
||||||
friend class AudioStreamMicrophone;
|
friend class AudioStreamMicrophone;
|
||||||
|
|
||||||
|
const int MICROPHONE_PLAYBACK_DELAY = 256;
|
||||||
|
|
||||||
bool active;
|
bool active;
|
||||||
unsigned int input_ofs;
|
unsigned int input_ofs;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user