From 9ac02db9b1900f8c91d08d339b16dc9cadd20b06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mikrut?= Date: Mon, 13 Sep 2021 20:58:11 +0200 Subject: [PATCH] Initialize variabes in servers/audio --- core/math/audio_frame.h | 2 +- servers/audio/audio_driver_dummy.cpp | 7 -- servers/audio/audio_driver_dummy.h | 16 ++-- servers/audio/audio_filter_sw.cpp | 13 +--- servers/audio/audio_filter_sw.h | 21 +++-- servers/audio/audio_rb_resampler.cpp | 11 --- servers/audio/audio_rb_resampler.h | 20 ++--- servers/audio/audio_stream.cpp | 4 +- servers/audio/audio_stream.h | 12 +-- .../audio/effects/audio_effect_amplify.cpp | 4 +- servers/audio/effects/audio_effect_amplify.h | 4 +- servers/audio/effects/audio_effect_chorus.cpp | 4 - servers/audio/effects/audio_effect_chorus.h | 36 ++++----- .../audio/effects/audio_effect_compressor.cpp | 9 +-- .../audio/effects/audio_effect_compressor.h | 16 ++-- servers/audio/effects/audio_effect_delay.cpp | 19 +---- servers/audio/effects/audio_effect_delay.h | 32 ++++---- .../audio/effects/audio_effect_distortion.cpp | 8 +- .../audio/effects/audio_effect_distortion.h | 12 +-- servers/audio/effects/audio_effect_filter.cpp | 4 - servers/audio/effects/audio_effect_filter.h | 10 +-- .../audio/effects/audio_effect_limiter.cpp | 7 +- servers/audio/effects/audio_effect_limiter.h | 10 +-- servers/audio/effects/audio_effect_panner.cpp | 4 +- servers/audio/effects/audio_effect_panner.h | 2 +- servers/audio/effects/audio_effect_phaser.cpp | 8 +- servers/audio/effects/audio_effect_phaser.h | 19 ++--- .../effects/audio_effect_pitch_shift.cpp | 9 +-- .../audio/effects/audio_effect_pitch_shift.h | 19 ++--- servers/audio/effects/audio_effect_record.cpp | 5 +- servers/audio/effects/audio_effect_record.h | 13 ++-- servers/audio/effects/audio_effect_reverb.cpp | 11 +-- servers/audio/effects/audio_effect_reverb.h | 16 ++-- .../audio_effect_spectrum_analyzer.cpp | 6 +- .../effects/audio_effect_spectrum_analyzer.h | 18 ++--- .../effects/audio_effect_stereo_enhance.cpp | 6 +- .../effects/audio_effect_stereo_enhance.h | 14 ++-- .../audio/effects/audio_stream_generator.cpp | 12 +-- .../audio/effects/audio_stream_generator.h | 12 +-- servers/audio/effects/eq.cpp | 12 +-- servers/audio/effects/eq.h | 12 +-- servers/audio/effects/reverb.cpp | 11 --- servers/audio/effects/reverb.h | 34 ++++---- servers/audio_server.cpp | 11 +-- servers/audio_server.h | 78 ++++++++----------- 45 files changed, 222 insertions(+), 391 deletions(-) diff --git a/core/math/audio_frame.h b/core/math/audio_frame.h index a5616b8d798f..6cee54259d33 100644 --- a/core/math/audio_frame.h +++ b/core/math/audio_frame.h @@ -52,7 +52,7 @@ static const float AUDIO_MIN_PEAK_DB = -200.0f; // linear2db(AUDIO_PEAK_OFFSET) struct AudioFrame { //left and right samples - float l, r; + float l = 0, r = 0; _ALWAYS_INLINE_ const float &operator[](int idx) const { return idx == 0 ? l : r; } _ALWAYS_INLINE_ float &operator[](int idx) { return idx == 0 ? l : r; } diff --git a/servers/audio/audio_driver_dummy.cpp b/servers/audio/audio_driver_dummy.cpp index a28dcb101574..e33fb7c862a6 100644 --- a/servers/audio/audio_driver_dummy.cpp +++ b/servers/audio/audio_driver_dummy.cpp @@ -34,14 +34,7 @@ #include "core/os/os.h" Error AudioDriverDummy::init() { - active = false; - thread_exited = false; - exit_thread = false; - samples_in = nullptr; - mix_rate = GLOBAL_GET("audio/driver/mix_rate"); - speaker_mode = SPEAKER_MODE_STEREO; - channels = 2; int latency = GLOBAL_GET("audio/driver/output_latency"); buffer_frames = closest_power_of_2(latency * mix_rate / 1000); diff --git a/servers/audio/audio_driver_dummy.h b/servers/audio/audio_driver_dummy.h index 7d84e7ffc87b..c7607c981b87 100644 --- a/servers/audio/audio_driver_dummy.h +++ b/servers/audio/audio_driver_dummy.h @@ -40,19 +40,19 @@ class AudioDriverDummy : public AudioDriver { Thread thread; Mutex mutex; - int32_t *samples_in; + int32_t *samples_in = nullptr; static void thread_func(void *p_udata); - unsigned int buffer_frames; - unsigned int mix_rate; - SpeakerMode speaker_mode; + unsigned int buffer_frames = 0; + unsigned int mix_rate = 0; + SpeakerMode speaker_mode = SPEAKER_MODE_STEREO; - int channels; + int channels = 2; - bool active; - bool thread_exited; - mutable bool exit_thread; + bool active = false; + bool thread_exited = false; + mutable bool exit_thread = false; public: const char *get_name() const { diff --git a/servers/audio/audio_filter_sw.cpp b/servers/audio/audio_filter_sw.cpp index bcfa4c4c3725..2d69071c876c 100644 --- a/servers/audio/audio_filter_sw.cpp +++ b/servers/audio/audio_filter_sw.cpp @@ -219,18 +219,9 @@ float AudioFilterSW::get_response(float p_freq, Coeffs *p_coeffs) { return H; } -AudioFilterSW::AudioFilterSW() { - sampling_rate = 44100; - resonance = 0.5; - cutoff = 5000; - gain = 1.0; - mode = LOWPASS; - stages = 1; -} +AudioFilterSW::AudioFilterSW() {} -AudioFilterSW::Processor::Processor() { - set_filter(nullptr); -} +AudioFilterSW::Processor::Processor() {} void AudioFilterSW::Processor::set_filter(AudioFilterSW *p_filter, bool p_clear_history) { if (p_clear_history) { diff --git a/servers/audio/audio_filter_sw.h b/servers/audio/audio_filter_sw.h index 540d6368e30d..3617d1ceeba6 100644 --- a/servers/audio/audio_filter_sw.h +++ b/servers/audio/audio_filter_sw.h @@ -36,11 +36,10 @@ class AudioFilterSW { public: struct Coeffs { - float a1, a2; - float b0, b1, b2; + float a1 = 0.0, a2 = 0.0; + float b0 = 0.0, b1 = 0.0, b2 = 0.0; //bool operator==(const Coeffs &p_rv) { return (FLOATS_EQ(a1,p_rv.a1) && FLOATS_EQ(a2,p_rv.a2) && FLOATS_EQ(b1,p_rv.b1) && FLOATS_EQ(b2,p_rv.b2) && FLOATS_EQ(b0,p_rv.b0) ); } - Coeffs() { a1 = a2 = b0 = b1 = b2 = 0.0; } }; enum Mode { @@ -57,9 +56,9 @@ class AudioFilterSW { class Processor { // simple filter processor - AudioFilterSW *filter; + AudioFilterSW *filter = nullptr; Coeffs coeffs; - float ha1, ha2, hb1, hb2; //history + float ha1 = 0.0, ha2 = 0.0, hb1 = 0.0, hb2 = 0.0; //history Coeffs incr_coeffs; public: @@ -73,12 +72,12 @@ class AudioFilterSW { }; private: - float cutoff; - float resonance; - float gain; - float sampling_rate; - int stages; - Mode mode; + float cutoff = 5000.0; + float resonance = 0.5; + float gain = 1.0; + float sampling_rate = 44100.0; + int stages = 1; + Mode mode = LOWPASS; public: float get_response(float p_freq, Coeffs *p_coeffs); diff --git a/servers/audio/audio_rb_resampler.cpp b/servers/audio/audio_rb_resampler.cpp index 3c8a1469cdc0..a3e16fa1cdef 100644 --- a/servers/audio/audio_rb_resampler.cpp +++ b/servers/audio/audio_rb_resampler.cpp @@ -211,19 +211,8 @@ void AudioRBResampler::clear() { } AudioRBResampler::AudioRBResampler() { - rb = nullptr; - offset = 0; - read_buf = nullptr; rb_read_pos.set(0); rb_write_pos.set(0); - - rb_bits = 0; - rb_len = 0; - rb_mask = 0; - read_buff_len = 0; - channels = 0; - src_mix_rate = 0; - target_mix_rate = 0; } AudioRBResampler::~AudioRBResampler() { diff --git a/servers/audio/audio_rb_resampler.h b/servers/audio/audio_rb_resampler.h index c0f981704b70..d248ed351031 100644 --- a/servers/audio/audio_rb_resampler.h +++ b/servers/audio/audio_rb_resampler.h @@ -37,26 +37,26 @@ #include "servers/audio_server.h" struct AudioRBResampler { - uint32_t rb_bits; - uint32_t rb_len; - uint32_t rb_mask; - uint32_t read_buff_len; - uint32_t channels; - uint32_t src_mix_rate; - uint32_t target_mix_rate; + uint32_t rb_bits = 0; + uint32_t rb_len = 0; + uint32_t rb_mask = 0; + uint32_t read_buff_len = 0; + uint32_t channels = 0; + uint32_t src_mix_rate = 0; + uint32_t target_mix_rate = 0; SafeNumeric rb_read_pos; SafeNumeric rb_write_pos; - int32_t offset; //contains the fractional remainder of the resampler + int32_t offset = 0; //contains the fractional remainder of the resampler enum { MIX_FRAC_BITS = 13, MIX_FRAC_LEN = (1 << MIX_FRAC_BITS), MIX_FRAC_MASK = MIX_FRAC_LEN - 1, }; - float *read_buf; - float *rb; + float *read_buf = nullptr; + float *rb = nullptr; template uint32_t _resample(AudioFrame *p_dest, int p_todo, int32_t p_increment); diff --git a/servers/audio/audio_stream.cpp b/servers/audio/audio_stream.cpp index c098a97906a3..f27826084f19 100644 --- a/servers/audio/audio_stream.cpp +++ b/servers/audio/audio_stream.cpp @@ -421,9 +421,7 @@ void AudioStreamRandomPitch::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "random_pitch", PROPERTY_HINT_RANGE, "1,16,0.01"), "set_random_pitch", "get_random_pitch"); } -AudioStreamRandomPitch::AudioStreamRandomPitch() { - random_pitch = 1.1; -} +AudioStreamRandomPitch::AudioStreamRandomPitch() {} void AudioStreamPlaybackRandomPitch::start(float p_from_pos) { playing = playback; diff --git a/servers/audio/audio_stream.h b/servers/audio/audio_stream.h index 12d4343f5cf8..ee51aa91ffb3 100644 --- a/servers/audio/audio_stream.h +++ b/servers/audio/audio_stream.h @@ -78,7 +78,7 @@ class AudioStreamPlaybackResampled : public AudioStreamPlayback { AudioFrame internal_buffer[INTERNAL_BUFFER_LEN + CUBIC_INTERP_HISTORY]; unsigned int internal_buffer_end = -1; - uint64_t mix_offset; + uint64_t mix_offset = 0; protected: void _begin_resample(); @@ -89,7 +89,7 @@ class AudioStreamPlaybackResampled : public AudioStreamPlayback { public: virtual int mix(AudioFrame *p_buffer, float p_rate_scale, int p_frames) override; - AudioStreamPlaybackResampled() { mix_offset = 0; } + AudioStreamPlaybackResampled() {} }; class AudioStream : public Resource { @@ -140,8 +140,8 @@ class AudioStreamPlaybackMicrophone : public AudioStreamPlaybackResampled { GDCLASS(AudioStreamPlaybackMicrophone, AudioStreamPlaybackResampled); friend class AudioStreamMicrophone; - bool active; - unsigned int input_ofs; + bool active = false; + unsigned int input_ofs = 0; Ref microphone; @@ -175,7 +175,7 @@ class AudioStreamRandomPitch : public AudioStream { Set playbacks; Ref audio_stream; - float random_pitch; + float random_pitch = 1.1; protected: static void _bind_methods(); @@ -203,7 +203,7 @@ class AudioStreamPlaybackRandomPitch : public AudioStreamPlayback { Ref random_pitch; Ref playback; Ref playing; - float pitch_scale; + float pitch_scale = 1.0; public: virtual void start(float p_from_pos = 0.0) override; diff --git a/servers/audio/effects/audio_effect_amplify.cpp b/servers/audio/effects/audio_effect_amplify.cpp index 79788d334b75..1086c090bd8e 100644 --- a/servers/audio/effects/audio_effect_amplify.cpp +++ b/servers/audio/effects/audio_effect_amplify.cpp @@ -67,6 +67,4 @@ void AudioEffectAmplify::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "volume_db", PROPERTY_HINT_RANGE, "-80,24,0.01"), "set_volume_db", "get_volume_db"); } -AudioEffectAmplify::AudioEffectAmplify() { - volume_db = 0; -} +AudioEffectAmplify::AudioEffectAmplify() {} diff --git a/servers/audio/effects/audio_effect_amplify.h b/servers/audio/effects/audio_effect_amplify.h index 9d3facc23035..48fced07593c 100644 --- a/servers/audio/effects/audio_effect_amplify.h +++ b/servers/audio/effects/audio_effect_amplify.h @@ -40,7 +40,7 @@ class AudioEffectAmplifyInstance : public AudioEffectInstance { friend class AudioEffectAmplify; Ref base; - float mix_volume_db; + float mix_volume_db = 0.0; public: virtual void process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) override; @@ -50,7 +50,7 @@ class AudioEffectAmplify : public AudioEffect { GDCLASS(AudioEffectAmplify, AudioEffect); friend class AudioEffectAmplifyInstance; - float volume_db; + float volume_db = 0.0; protected: static void _bind_methods(); diff --git a/servers/audio/effects/audio_effect_chorus.cpp b/servers/audio/effects/audio_effect_chorus.cpp index 9af3ed30cc18..b9db3cdf52a8 100644 --- a/servers/audio/effects/audio_effect_chorus.cpp +++ b/servers/audio/effects/audio_effect_chorus.cpp @@ -343,7 +343,6 @@ void AudioEffectChorus::_bind_methods() { } AudioEffectChorus::AudioEffectChorus() { - voice_count = 2; voice[0].delay = 15; voice[1].delay = 20; voice[0].rate = 0.8; @@ -354,7 +353,4 @@ AudioEffectChorus::AudioEffectChorus() { voice[1].cutoff = 8000; voice[0].pan = -0.5; voice[1].pan = 0.5; - - wet = 0.5; - dry = 1.0; } diff --git a/servers/audio/effects/audio_effect_chorus.h b/servers/audio/effects/audio_effect_chorus.h index f81bebb0ae59..a266797ce0b4 100644 --- a/servers/audio/effects/audio_effect_chorus.h +++ b/servers/audio/effects/audio_effect_chorus.h @@ -41,11 +41,11 @@ class AudioEffectChorusInstance : public AudioEffectInstance { Ref base; Vector audio_buffer; - unsigned int buffer_pos; - unsigned int buffer_mask; + unsigned int buffer_pos = 0; + unsigned int buffer_mask = 0; - AudioFrame filter_h[4]; - uint64_t cycles[4]; + AudioFrame filter_h[4] = {}; + uint64_t cycles[4] = {}; void _process_chunk(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count); @@ -72,28 +72,18 @@ class AudioEffectChorus : public AudioEffect { private: struct Voice { - float delay; - float rate; - float depth; - float level; - float cutoff; - float pan; - - Voice() { - delay = 12.0; - rate = 1; - depth = 0; - level = 0; - cutoff = MS_CUTOFF_MAX; - pan = 0; - } - + float delay = 12.0; + float rate = 1.0; + float depth = 0.0; + float level = 0.0; + float cutoff = MS_CUTOFF_MAX; + float pan = 0.0; } voice[MAX_VOICES]; - int voice_count; + int voice_count = 2; - float wet; - float dry; + float wet = 0.5; + float dry = 1.0; protected: void _validate_property(PropertyInfo &property) const override; diff --git a/servers/audio/effects/audio_effect_compressor.cpp b/servers/audio/effects/audio_effect_compressor.cpp index cfa2ae6f7937..c2f928ec3356 100644 --- a/servers/audio/effects/audio_effect_compressor.cpp +++ b/servers/audio/effects/audio_effect_compressor.cpp @@ -227,11 +227,4 @@ void AudioEffectCompressor::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "sidechain", PROPERTY_HINT_ENUM), "set_sidechain", "get_sidechain"); } -AudioEffectCompressor::AudioEffectCompressor() { - threshold = 0; - ratio = 4; - gain = 0; - attack_us = 20; - release_ms = 250; - mix = 1; -} +AudioEffectCompressor::AudioEffectCompressor() {} diff --git a/servers/audio/effects/audio_effect_compressor.h b/servers/audio/effects/audio_effect_compressor.h index dae4618a648f..26027989bbd8 100644 --- a/servers/audio/effects/audio_effect_compressor.h +++ b/servers/audio/effects/audio_effect_compressor.h @@ -40,8 +40,8 @@ class AudioEffectCompressorInstance : public AudioEffectInstance { friend class AudioEffectCompressor; Ref base; - float rundb, averatio, runratio, runmax, maxover, gr_meter; - int current_channel; + float rundb = 0.0, averatio = 0.0, runratio = 0.0, runmax = 0.0, maxover = 0.0, gr_meter = 0.0; + int current_channel = 0; public: void set_current_channel(int p_channel) { current_channel = p_channel; } @@ -52,12 +52,12 @@ class AudioEffectCompressor : public AudioEffect { GDCLASS(AudioEffectCompressor, AudioEffect); friend class AudioEffectCompressorInstance; - float threshold; - float ratio; - float gain; - float attack_us; - float release_ms; - float mix; + float threshold = 0.0; + float ratio = 4.0; + float gain = 0.0; + float attack_us = 20.0; + float release_ms = 250.0; + float mix = 1.0; StringName sidechain; protected: diff --git a/servers/audio/effects/audio_effect_delay.cpp b/servers/audio/effects/audio_effect_delay.cpp index 07475e1ed402..4fa6804e58e1 100644 --- a/servers/audio/effects/audio_effect_delay.cpp +++ b/servers/audio/effects/audio_effect_delay.cpp @@ -305,21 +305,4 @@ void AudioEffectDelay::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "feedback/lowpass", PROPERTY_HINT_RANGE, "1,16000,1"), "set_feedback_lowpass", "get_feedback_lowpass"); } -AudioEffectDelay::AudioEffectDelay() { - tap_1_active = true; - tap_1_delay_ms = 250; - tap_1_level = -6; - tap_1_pan = 0.2; - - tap_2_active = true; - tap_2_delay_ms = 500; - tap_2_level = -12; - tap_2_pan = -0.4; - - feedback_active = false; - feedback_delay_ms = 340; - feedback_level = -6; - feedback_lowpass = 16000; - - dry = 1.0; -} +AudioEffectDelay::AudioEffectDelay() {} diff --git a/servers/audio/effects/audio_effect_delay.h b/servers/audio/effects/audio_effect_delay.h index 50a2233e5fb3..6fc57b068f78 100644 --- a/servers/audio/effects/audio_effect_delay.h +++ b/servers/audio/effects/audio_effect_delay.h @@ -42,13 +42,13 @@ class AudioEffectDelayInstance : public AudioEffectInstance { Vector ring_buffer; - unsigned int ring_buffer_pos; - unsigned int ring_buffer_mask; + unsigned int ring_buffer_pos = 0; + unsigned int ring_buffer_mask = 0; /* feedback buffer */ Vector feedback_buffer; - unsigned int feedback_buffer_pos; + unsigned int feedback_buffer_pos = 0; AudioFrame h; void _process_chunk(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count); @@ -66,22 +66,22 @@ class AudioEffectDelay : public AudioEffect { MAX_TAPS = 2 }; - float dry; + float dry = 1.0; - bool tap_1_active; - float tap_1_delay_ms; - float tap_1_level; - float tap_1_pan; + bool tap_1_active = true; + float tap_1_delay_ms = 250.0; + float tap_1_level = -6.0; + float tap_1_pan = 0.2; - bool tap_2_active; - float tap_2_delay_ms; - float tap_2_level; - float tap_2_pan; + bool tap_2_active = true; + float tap_2_delay_ms = 500.0; + float tap_2_level = -12.0; + float tap_2_pan = -0.4; - bool feedback_active; - float feedback_delay_ms; - float feedback_level; - float feedback_lowpass; + bool feedback_active = false; + float feedback_delay_ms = 340.0; + float feedback_level = -6.0; + float feedback_lowpass = 16000.0; protected: static void _bind_methods(); diff --git a/servers/audio/effects/audio_effect_distortion.cpp b/servers/audio/effects/audio_effect_distortion.cpp index 188b7a330147..67c205ae99ed 100644 --- a/servers/audio/effects/audio_effect_distortion.cpp +++ b/servers/audio/effects/audio_effect_distortion.cpp @@ -172,10 +172,4 @@ void AudioEffectDistortion::_bind_methods() { BIND_ENUM_CONSTANT(MODE_WAVESHAPE); } -AudioEffectDistortion::AudioEffectDistortion() { - mode = MODE_CLIP; - pre_gain = 0; - post_gain = 0; - keep_hf_hz = 16000; - drive = 0; -} +AudioEffectDistortion::AudioEffectDistortion() {} diff --git a/servers/audio/effects/audio_effect_distortion.h b/servers/audio/effects/audio_effect_distortion.h index 3a762f8cf64d..b0829955a138 100644 --- a/servers/audio/effects/audio_effect_distortion.h +++ b/servers/audio/effects/audio_effect_distortion.h @@ -39,7 +39,7 @@ class AudioEffectDistortionInstance : public AudioEffectInstance { GDCLASS(AudioEffectDistortionInstance, AudioEffectInstance); friend class AudioEffectDistortion; Ref base; - float h[2]; + float h[2] = {}; public: virtual void process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) override; @@ -58,11 +58,11 @@ class AudioEffectDistortion : public AudioEffect { }; friend class AudioEffectDistortionInstance; - Mode mode; - float pre_gain; - float post_gain; - float keep_hf_hz; - float drive; + Mode mode = MODE_CLIP; + float pre_gain = 0.0; + float post_gain = 0.0; + float keep_hf_hz = 16000.0; + float drive = 0.0; protected: static void _bind_methods(); diff --git a/servers/audio/effects/audio_effect_filter.cpp b/servers/audio/effects/audio_effect_filter.cpp index 1db8b1f1b5b1..9b88bb35631b 100644 --- a/servers/audio/effects/audio_effect_filter.cpp +++ b/servers/audio/effects/audio_effect_filter.cpp @@ -166,8 +166,4 @@ void AudioEffectFilter::_bind_methods() { AudioEffectFilter::AudioEffectFilter(AudioFilterSW::Mode p_mode) { mode = p_mode; - cutoff = 2000; - resonance = 0.5; - gain = 1.0; - db = FILTER_6DB; } diff --git a/servers/audio/effects/audio_effect_filter.h b/servers/audio/effects/audio_effect_filter.h index 1fa3df1570ee..211143474158 100644 --- a/servers/audio/effects/audio_effect_filter.h +++ b/servers/audio/effects/audio_effect_filter.h @@ -66,11 +66,11 @@ class AudioEffectFilter : public AudioEffect { }; friend class AudioEffectFilterInstance; - AudioFilterSW::Mode mode; - float cutoff; - float resonance; - float gain; - FilterDB db; + AudioFilterSW::Mode mode = AudioFilterSW::Mode::BANDLIMIT; + float cutoff = 2000.0; + float resonance = 0.5; + float gain = 1.0; + FilterDB db = FILTER_6DB; protected: static void _bind_methods(); diff --git a/servers/audio/effects/audio_effect_limiter.cpp b/servers/audio/effects/audio_effect_limiter.cpp index 280411641bb0..4b7e2502e132 100644 --- a/servers/audio/effects/audio_effect_limiter.cpp +++ b/servers/audio/effects/audio_effect_limiter.cpp @@ -126,9 +126,4 @@ void AudioEffectLimiter::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "soft_clip_ratio", PROPERTY_HINT_RANGE, "3,20,0.1"), "set_soft_clip_ratio", "get_soft_clip_ratio"); } -AudioEffectLimiter::AudioEffectLimiter() { - threshold = 0; - ceiling = -0.1; - soft_clip = 2; - soft_clip_ratio = 10; -} +AudioEffectLimiter::AudioEffectLimiter() {} diff --git a/servers/audio/effects/audio_effect_limiter.h b/servers/audio/effects/audio_effect_limiter.h index d5def670a480..c230ad26e182 100644 --- a/servers/audio/effects/audio_effect_limiter.h +++ b/servers/audio/effects/audio_effect_limiter.h @@ -40,7 +40,7 @@ class AudioEffectLimiterInstance : public AudioEffectInstance { friend class AudioEffectLimiter; Ref base; - float mix_volume_db; + float mix_volume_db = 0.0; public: virtual void process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) override; @@ -50,10 +50,10 @@ class AudioEffectLimiter : public AudioEffect { GDCLASS(AudioEffectLimiter, AudioEffect); friend class AudioEffectLimiterInstance; - float threshold; - float ceiling; - float soft_clip; - float soft_clip_ratio; + float threshold = 0.0; + float ceiling = -0.1; + float soft_clip = 2.0; + float soft_clip_ratio = 10.0; protected: static void _bind_methods(); diff --git a/servers/audio/effects/audio_effect_panner.cpp b/servers/audio/effects/audio_effect_panner.cpp index e2062609b9de..a88970f1d0d8 100644 --- a/servers/audio/effects/audio_effect_panner.cpp +++ b/servers/audio/effects/audio_effect_panner.cpp @@ -62,6 +62,4 @@ void AudioEffectPanner::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "pan", PROPERTY_HINT_RANGE, "-1,1,0.01"), "set_pan", "get_pan"); } -AudioEffectPanner::AudioEffectPanner() { - pan = 0; -} +AudioEffectPanner::AudioEffectPanner() {} diff --git a/servers/audio/effects/audio_effect_panner.h b/servers/audio/effects/audio_effect_panner.h index d75bcaeb955f..19ff869a8b9c 100644 --- a/servers/audio/effects/audio_effect_panner.h +++ b/servers/audio/effects/audio_effect_panner.h @@ -48,7 +48,7 @@ class AudioEffectPanner : public AudioEffect { GDCLASS(AudioEffectPanner, AudioEffect); friend class AudioEffectPannerInstance; - float pan; + float pan = 0.0; protected: static void _bind_methods(); diff --git a/servers/audio/effects/audio_effect_phaser.cpp b/servers/audio/effects/audio_effect_phaser.cpp index c76692eed765..721e25d81e1e 100644 --- a/servers/audio/effects/audio_effect_phaser.cpp +++ b/servers/audio/effects/audio_effect_phaser.cpp @@ -151,10 +151,4 @@ void AudioEffectPhaser::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "depth", PROPERTY_HINT_RANGE, "0.1,4,0.1"), "set_depth", "get_depth"); } -AudioEffectPhaser::AudioEffectPhaser() { - range_min = 440; - range_max = 1600; - rate = 0.5; - feedback = 0.7; - depth = 1; -} +AudioEffectPhaser::AudioEffectPhaser() {} diff --git a/servers/audio/effects/audio_effect_phaser.h b/servers/audio/effects/audio_effect_phaser.h index 2a0ed6480585..4e93f64c8ebd 100644 --- a/servers/audio/effects/audio_effect_phaser.h +++ b/servers/audio/effects/audio_effect_phaser.h @@ -40,11 +40,11 @@ class AudioEffectPhaserInstance : public AudioEffectInstance { friend class AudioEffectPhaser; Ref base; - float phase; + float phase = 0.0; AudioFrame h; class AllpassDelay { - float a, h; + float a = 0.0, h = 0.0; public: _ALWAYS_INLINE_ void delay(float d) { @@ -56,11 +56,6 @@ class AudioEffectPhaserInstance : public AudioEffectInstance { h = y * a + s; return y; } - - AllpassDelay() { - a = 0; - h = 0; - } }; AllpassDelay allpass[2][6]; @@ -73,11 +68,11 @@ class AudioEffectPhaser : public AudioEffect { GDCLASS(AudioEffectPhaser, AudioEffect); friend class AudioEffectPhaserInstance; - float range_min; - float range_max; - float rate; - float feedback; - float depth; + float range_min = 440.0; + float range_max = 1600.0; + float rate = 0.5; + float feedback = 0.7; + float depth = 1.0; protected: static void _bind_methods(); diff --git a/servers/audio/effects/audio_effect_pitch_shift.cpp b/servers/audio/effects/audio_effect_pitch_shift.cpp index d6c396e0a573..2b32a8fa161d 100644 --- a/servers/audio/effects/audio_effect_pitch_shift.cpp +++ b/servers/audio/effects/audio_effect_pitch_shift.cpp @@ -357,11 +357,4 @@ void AudioEffectPitchShift::_bind_methods() { BIND_ENUM_CONSTANT(FFT_SIZE_MAX); } -AudioEffectPitchShift::AudioEffectPitchShift() { - pitch_scale = 1.0; - oversampling = 4; - fft_size = FFT_SIZE_2048; - wet = 0.0; - dry = 0.0; - filter = false; -} +AudioEffectPitchShift::AudioEffectPitchShift() {} diff --git a/servers/audio/effects/audio_effect_pitch_shift.h b/servers/audio/effects/audio_effect_pitch_shift.h index 3ed096cd944e..aa6df928e8aa 100644 --- a/servers/audio/effects/audio_effect_pitch_shift.h +++ b/servers/audio/effects/audio_effect_pitch_shift.h @@ -48,7 +48,7 @@ class SMBPitchShift { float gAnaMagn[MAX_FRAME_LENGTH]; float gSynFreq[MAX_FRAME_LENGTH]; float gSynMagn[MAX_FRAME_LENGTH]; - long gRover; + long gRover = 0; void smbFft(float *fftBuffer, long fftFrameSize, long sign); @@ -56,7 +56,6 @@ class SMBPitchShift { void PitchShift(float pitchShift, long numSampsToProcess, long fftFrameSize, long osamp, float sampleRate, float *indata, float *outdata, int stride); SMBPitchShift() { - gRover = 0; memset(gInFIFO, 0, MAX_FRAME_LENGTH * sizeof(float)); memset(gOutFIFO, 0, MAX_FRAME_LENGTH * sizeof(float)); memset(gFFTworksp, 0, 2 * MAX_FRAME_LENGTH * sizeof(float)); @@ -65,6 +64,8 @@ class SMBPitchShift { memset(gOutputAccum, 0, 2 * MAX_FRAME_LENGTH * sizeof(float)); memset(gAnaFreq, 0, MAX_FRAME_LENGTH * sizeof(float)); memset(gAnaMagn, 0, MAX_FRAME_LENGTH * sizeof(float)); + memset(gSynFreq, 0, MAX_FRAME_LENGTH * sizeof(float)); + memset(gSynMagn, 0, MAX_FRAME_LENGTH * sizeof(float)); } }; @@ -75,7 +76,7 @@ class AudioEffectPitchShiftInstance : public AudioEffectInstance { friend class AudioEffectPitchShift; Ref base; - int fft_size; + int fft_size = 0; SMBPitchShift shift_l; SMBPitchShift shift_r; @@ -98,12 +99,12 @@ class AudioEffectPitchShift : public AudioEffect { FFT_SIZE_MAX }; - float pitch_scale; - int oversampling; - FFTSize fft_size; - float wet; - float dry; - bool filter; + float pitch_scale = 1.0; + int oversampling = 4; + FFTSize fft_size = FFT_SIZE_2048; + float wet = 0.0; + float dry = 0.0; + bool filter = false; protected: static void _bind_methods(); diff --git a/servers/audio/effects/audio_effect_record.cpp b/servers/audio/effects/audio_effect_record.cpp index f71679d30f73..1aec39d2097f 100644 --- a/servers/audio/effects/audio_effect_record.cpp +++ b/servers/audio/effects/audio_effect_record.cpp @@ -291,7 +291,4 @@ void AudioEffectRecord::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "format", PROPERTY_HINT_ENUM, "8-Bit,16-Bit,IMA-ADPCM"), "set_format", "get_format"); } -AudioEffectRecord::AudioEffectRecord() { - format = AudioStreamSample::FORMAT_16_BITS; - recording_active = false; -} +AudioEffectRecord::AudioEffectRecord() {} diff --git a/servers/audio/effects/audio_effect_record.h b/servers/audio/effects/audio_effect_record.h index 1a89821f8005..8e6cc1938e25 100644 --- a/servers/audio/effects/audio_effect_record.h +++ b/servers/audio/effects/audio_effect_record.h @@ -47,16 +47,16 @@ class AudioEffectRecordInstance : public AudioEffectInstance { friend class AudioEffectRecord; Ref base; - bool is_recording; + bool is_recording = false; Thread io_thread; bool thread_active = false; Vector ring_buffer; Vector recording_data; - unsigned int ring_buffer_pos; - unsigned int ring_buffer_mask; - unsigned int ring_buffer_read_pos; + unsigned int ring_buffer_pos = 0; + unsigned int ring_buffer_mask = 0; + unsigned int ring_buffer_read_pos = 0; void _io_thread_process(); void _io_store_buffer(); @@ -84,10 +84,9 @@ class AudioEffectRecord : public AudioEffect { IO_BUFFER_SIZE_MS = 1500 }; - bool recording_active; + bool recording_active = false; Ref current_instance; - - AudioStreamSample::Format format; + AudioStreamSample::Format format = AudioStreamSample::FORMAT_16_BITS; void ensure_thread_stopped(); diff --git a/servers/audio/effects/audio_effect_reverb.cpp b/servers/audio/effects/audio_effect_reverb.cpp index 819f9067739c..daaffacb39e6 100644 --- a/servers/audio/effects/audio_effect_reverb.cpp +++ b/servers/audio/effects/audio_effect_reverb.cpp @@ -187,13 +187,4 @@ void AudioEffectReverb::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "wet", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_wet", "get_wet"); } -AudioEffectReverb::AudioEffectReverb() { - predelay = 150; - predelay_fb = 0.4; - hpf = 0; - room_size = 0.8; - damping = 0.5; - spread = 1.0; - dry = 1.0; - wet = 0.5; -} +AudioEffectReverb::AudioEffectReverb() {} diff --git a/servers/audio/effects/audio_effect_reverb.h b/servers/audio/effects/audio_effect_reverb.h index d01d1120bd0e..b5963f6f0707 100644 --- a/servers/audio/effects/audio_effect_reverb.h +++ b/servers/audio/effects/audio_effect_reverb.h @@ -58,14 +58,14 @@ class AudioEffectReverb : public AudioEffect { friend class AudioEffectReverbInstance; - float predelay; - float predelay_fb; - float hpf; - float room_size; - float damping; - float spread; - float dry; - float wet; + float predelay = 150.0; + float predelay_fb = 0.4; + float hpf = 0.0; + float room_size = 0.8; + float damping = 0.5; + float spread = 1.0; + float dry = 1.0; + float wet = 0.5; protected: static void _bind_methods(); diff --git a/servers/audio/effects/audio_effect_spectrum_analyzer.cpp b/servers/audio/effects/audio_effect_spectrum_analyzer.cpp index 6f9e7ac67da4..8fc4b1351c95 100644 --- a/servers/audio/effects/audio_effect_spectrum_analyzer.cpp +++ b/servers/audio/effects/audio_effect_spectrum_analyzer.cpp @@ -276,8 +276,4 @@ void AudioEffectSpectrumAnalyzer::_bind_methods() { BIND_ENUM_CONSTANT(FFT_SIZE_MAX); } -AudioEffectSpectrumAnalyzer::AudioEffectSpectrumAnalyzer() { - buffer_length = 2; - tapback_pos = 0.01; - fft_size = FFT_SIZE_1024; -} +AudioEffectSpectrumAnalyzer::AudioEffectSpectrumAnalyzer() {} diff --git a/servers/audio/effects/audio_effect_spectrum_analyzer.h b/servers/audio/effects/audio_effect_spectrum_analyzer.h index 3c5ae4a5e8ed..e3bb64ec78c6 100644 --- a/servers/audio/effects/audio_effect_spectrum_analyzer.h +++ b/servers/audio/effects/audio_effect_spectrum_analyzer.h @@ -50,12 +50,12 @@ class AudioEffectSpectrumAnalyzerInstance : public AudioEffectInstance { Vector> fft_history; Vector temporal_fft; - int temporal_fft_pos; - int fft_size; - int fft_count; - int fft_pos; - float mix_rate; - uint64_t last_fft_time; + int temporal_fft_pos = 0; + int fft_size = 0; + int fft_count = 0; + int fft_pos = 0; + float mix_rate = 0.0; + uint64_t last_fft_time = 0; protected: static void _bind_methods(); @@ -82,9 +82,9 @@ class AudioEffectSpectrumAnalyzer : public AudioEffect { public: friend class AudioEffectSpectrumAnalyzerInstance; - float buffer_length; - float tapback_pos; - FFTSize fft_size; + float buffer_length = 2.0; + float tapback_pos = 0.01; + FFTSize fft_size = FFT_SIZE_1024; protected: static void _bind_methods(); diff --git a/servers/audio/effects/audio_effect_stereo_enhance.cpp b/servers/audio/effects/audio_effect_stereo_enhance.cpp index 3a016b06b84d..b02f366bb3a2 100644 --- a/servers/audio/effects/audio_effect_stereo_enhance.cpp +++ b/servers/audio/effects/audio_effect_stereo_enhance.cpp @@ -141,8 +141,4 @@ void AudioEffectStereoEnhance::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "surround", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_surround", "get_surround"); } -AudioEffectStereoEnhance::AudioEffectStereoEnhance() { - pan_pullout = 1; - time_pullout = 0; - surround = 0; -} +AudioEffectStereoEnhance::AudioEffectStereoEnhance() {} diff --git a/servers/audio/effects/audio_effect_stereo_enhance.h b/servers/audio/effects/audio_effect_stereo_enhance.h index e0f9d79a9488..7e24a7e36dc0 100644 --- a/servers/audio/effects/audio_effect_stereo_enhance.h +++ b/servers/audio/effects/audio_effect_stereo_enhance.h @@ -44,9 +44,9 @@ class AudioEffectStereoEnhanceInstance : public AudioEffectInstance { MAX_DELAY_MS = 50 }; - float *delay_ringbuff; - unsigned int ringbuff_pos; - unsigned int ringbuff_mask; + float *delay_ringbuff = nullptr; + unsigned int ringbuff_pos = 0; + unsigned int ringbuff_mask = 0; public: virtual void process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) override; @@ -58,11 +58,11 @@ class AudioEffectStereoEnhance : public AudioEffect { GDCLASS(AudioEffectStereoEnhance, AudioEffect); friend class AudioEffectStereoEnhanceInstance; - float volume_db; + float volume_db = 0.0; - float pan_pullout; - float time_pullout; - float surround; + float pan_pullout = 1.0; + float time_pullout = 0.0; + float surround = 0.0; protected: static void _bind_methods(); diff --git a/servers/audio/effects/audio_stream_generator.cpp b/servers/audio/effects/audio_stream_generator.cpp index 447acf53a499..58686a42a736 100644 --- a/servers/audio/effects/audio_stream_generator.cpp +++ b/servers/audio/effects/audio_stream_generator.cpp @@ -79,10 +79,7 @@ void AudioStreamGenerator::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "buffer_length", PROPERTY_HINT_RANGE, "0.01,10,0.01"), "set_buffer_length", "get_buffer_length"); } -AudioStreamGenerator::AudioStreamGenerator() { - mix_rate = 44100; - buffer_len = 0.5; -} +AudioStreamGenerator::AudioStreamGenerator() {} //////////////// @@ -205,9 +202,4 @@ void AudioStreamGeneratorPlayback::_bind_methods() { ClassDB::bind_method(D_METHOD("clear_buffer"), &AudioStreamGeneratorPlayback::clear_buffer); } -AudioStreamGeneratorPlayback::AudioStreamGeneratorPlayback() { - generator = nullptr; - skips = 0; - active = false; - mixed = 0; -} +AudioStreamGeneratorPlayback::AudioStreamGeneratorPlayback() {} diff --git a/servers/audio/effects/audio_stream_generator.h b/servers/audio/effects/audio_stream_generator.h index 918589f6d0b3..8ba60ca6e6b4 100644 --- a/servers/audio/effects/audio_stream_generator.h +++ b/servers/audio/effects/audio_stream_generator.h @@ -37,8 +37,8 @@ class AudioStreamGenerator : public AudioStream { GDCLASS(AudioStreamGenerator, AudioStream); - float mix_rate; - float buffer_len; + float mix_rate = 44100.0; + float buffer_len = 0.5; protected: static void _bind_methods(); @@ -62,10 +62,10 @@ class AudioStreamGeneratorPlayback : public AudioStreamPlaybackResampled { GDCLASS(AudioStreamGeneratorPlayback, AudioStreamPlaybackResampled); friend class AudioStreamGenerator; RingBuffer buffer; - int skips; - bool active; - float mixed; - AudioStreamGenerator *generator; + int skips = 0; + bool active = false; + float mixed = 0.0; + AudioStreamGenerator *generator = nullptr; protected: virtual int _mix_internal(AudioFrame *p_buffer, int p_frames) override; diff --git a/servers/audio/effects/eq.cpp b/servers/audio/effects/eq.cpp index e0c3eb6d3aa8..a125759eb82c 100644 --- a/servers/audio/effects/eq.cpp +++ b/servers/audio/effects/eq.cpp @@ -63,10 +63,7 @@ static int solve_quadratic(double a, double b, double c, double *r1, double *r2) } } -EQ::BandProcess::BandProcess() { - c1 = c2 = c3 = history.a1 = history.a2 = history.a3 = 0; - history.b1 = history.b2 = history.b3 = 0; -} +EQ::BandProcess::BandProcess() {} void EQ::recalculate_band_coefficients() { #define BAND_LOG(m_f) (log((m_f)) / log(2.)) @@ -195,9 +192,6 @@ EQ::BandProcess EQ::get_band_processor(int p_band) const { return band_proc; } -EQ::EQ() { - mix_rate = 44100; -} +EQ::EQ() {} -EQ::~EQ() { -} +EQ::~EQ() {} diff --git a/servers/audio/effects/eq.h b/servers/audio/effects/eq.h index afd5bf53345b..8e601ddd9943 100644 --- a/servers/audio/effects/eq.h +++ b/servers/audio/effects/eq.h @@ -52,10 +52,10 @@ class EQ { class BandProcess { friend class EQ; - float c1, c2, c3; + float c1 = 0.0, c2 = 0.0, c3 = 0.0; struct History { - float a1, a2, a3; - float b1, b2, b3; + float a1 = 0.0, a2 = 0.0, a3 = 0.0; + float b1 = 0.0, b2 = 0.0, b3 = 0.0; } history; @@ -67,13 +67,13 @@ class EQ { private: struct Band { - float freq; - float c1, c2, c3; + float freq = 0.0; + float c1 = 0.0, c2 = 0.0, c3 = 0.0; }; Vector band; - float mix_rate; + float mix_rate = 44100.0; void recalculate_band_coefficients(); diff --git a/servers/audio/effects/reverb.cpp b/servers/audio/effects/reverb.cpp index 1d97de52059c..4259e923e9e9 100644 --- a/servers/audio/effects/reverb.cpp +++ b/servers/audio/effects/reverb.cpp @@ -320,17 +320,6 @@ void Reverb::clear_buffers() { } Reverb::Reverb() { - params.room_size = 0.8; - params.damp = 0.5; - params.dry = 1.0; - params.wet = 0.0; - params.mix_rate = 44100; - params.extra_spread_base = 0; - params.extra_spread = 1.0; - params.predelay = 150; - params.predelay_fb = 0.4; - params.hpf = 0; - input_buffer = memnew_arr(float, INPUT_BUFFER_MAX_SIZE); configure_buffers(); diff --git a/servers/audio/effects/reverb.h b/servers/audio/effects/reverb.h index e7ce55098d1a..529b69664ddd 100644 --- a/servers/audio/effects/reverb.h +++ b/servers/audio/effects/reverb.h @@ -58,9 +58,9 @@ class Reverb { struct Comb { int size = 0; float *buffer = nullptr; - float feedback = 0; - float damp = 0; //lowpass - float damp_h = 0; //history + float feedback = 0.0; + float damp = 0.0; //lowpass + float damp_h = 0.0; //history int pos = 0; int extra_spread_frames = 0; @@ -77,24 +77,24 @@ class Reverb { Comb comb[MAX_COMBS]; AllPass allpass[MAX_ALLPASS]; - float *input_buffer; + float *input_buffer = nullptr; float *echo_buffer = nullptr; - int echo_buffer_size; - int echo_buffer_pos; + int echo_buffer_size = 0; + int echo_buffer_pos = 0; - float hpf_h1, hpf_h2 = 0; + float hpf_h1 = 0.0, hpf_h2 = 0.0; struct Parameters { - float room_size; - float damp; - float wet; - float dry; - float mix_rate; - float extra_spread_base; - float extra_spread; - float predelay; - float predelay_fb; - float hpf; + float room_size = 0.8; + float damp = 0.5; + float wet = 0.0; + float dry = 1.0; + float mix_rate = 44100.0; + float extra_spread_base = 0.0; + float extra_spread = 1.0; + float predelay = 150.0; + float predelay_fb = 0.4; + float hpf = 0.0; } params; void configure_buffers(); diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp index 758ce766c39f..941bd151b720 100644 --- a/servers/audio_server.cpp +++ b/servers/audio_server.cpp @@ -164,16 +164,7 @@ Array AudioDriver::capture_get_device_list() { return list; } -AudioDriver::AudioDriver() { - _last_mix_time = 0; - _last_mix_frames = 0; - input_position = 0; - input_size = 0; - -#ifdef DEBUG_ENABLED - prof_time = 0; -#endif -} +AudioDriver::AudioDriver() {} AudioDriverDummy AudioDriverManager::dummy_driver; AudioDriver *AudioDriverManager::drivers[MAX_DRIVERS] = { diff --git a/servers/audio_server.h b/servers/audio_server.h index a60d4ae4c4bd..030543ac085c 100644 --- a/servers/audio_server.h +++ b/servers/audio_server.h @@ -48,18 +48,18 @@ class AudioStreamPlayback; class AudioDriver { static AudioDriver *singleton; - uint64_t _last_mix_time; - uint64_t _last_mix_frames; + uint64_t _last_mix_time = 0; + uint64_t _last_mix_frames = 0; #ifdef DEBUG_ENABLED - uint64_t prof_ticks; - uint64_t prof_time; + uint64_t prof_ticks = 0; + uint64_t prof_time = 0; #endif protected: Vector input_buffer; - unsigned int input_position; - unsigned int input_size; + unsigned int input_position = 0; + unsigned int input_size = 0; void audio_server_process(int p_frames, int32_t *p_buffer, bool p_update_mix_time = true); void update_mix_time(int p_frames); @@ -169,44 +169,41 @@ class AudioServer : public Object { typedef void (*AudioCallback)(void *p_userdata); private: - uint64_t mix_time; - int mix_size; + uint64_t mix_time = 0; + int mix_size = 0; - uint32_t buffer_size; - uint64_t mix_count; - uint64_t mix_frames; + uint32_t buffer_size = 0; + uint64_t mix_count = 0; + uint64_t mix_frames = 0; #ifdef DEBUG_ENABLED - uint64_t prof_time; + uint64_t prof_time = 0; #endif - float channel_disable_threshold_db; - uint32_t channel_disable_frames; + float channel_disable_threshold_db = 0.0; + uint32_t channel_disable_frames = 0; - int channel_count; - int to_mix; + int channel_count = 0; + int to_mix = 0; - float playback_speed_scale; + float playback_speed_scale = 1.0; struct Bus { StringName name; - bool solo; - bool mute; - bool bypass; + bool solo = false; + bool mute = false; + bool bypass = false; - bool soloed; + bool soloed = false; //Each channel is a stereo pair. struct Channel { - bool used; - bool active; + bool used = false; + bool active = false; AudioFrame peak_volume; Vector buffer; Vector> effect_instances; - uint64_t last_mix_with_audio; + uint64_t last_mix_with_audio = 0; Channel() { - last_mix_with_audio = 0; - used = false; - active = false; peak_volume = AudioFrame(AUDIO_MIN_PEAK_DB, AUDIO_MIN_PEAK_DB); } }; @@ -215,16 +212,16 @@ class AudioServer : public Object { struct Effect { Ref effect; - bool enabled; + bool enabled = false; #ifdef DEBUG_ENABLED - uint64_t prof_time; + uint64_t prof_time = 0; #endif }; Vector effects; - float volume_db; + float volume_db = 0.0; StringName send; - int index_cache; + int index_cache = 0; }; struct AudioStreamPlaybackBusDetails { @@ -284,7 +281,7 @@ class AudioServer : public Object { struct CallbackItem { AudioCallback callback; - void *userdata; + void *userdata = nullptr; }; SafeList update_callback_list; @@ -442,26 +439,19 @@ class AudioBusLayout : public Resource { struct Bus { StringName name; - bool solo; - bool mute; - bool bypass; + bool solo = false; + bool mute = false; + bool bypass = false; struct Effect { Ref effect; - bool enabled; + bool enabled = false; }; Vector effects; - float volume_db; + float volume_db = 0.0; StringName send; - - Bus() { - solo = false; - mute = false; - bypass = false; - volume_db = 0; - } }; Vector buses;