summaryrefslogtreecommitdiff
path: root/servers/audio
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-05-02 16:28:25 +0200
committerRémi Verschelde <rverschelde@gmail.com>2022-05-02 16:28:25 +0200
commitc273ddc3eefce78f8eed86dbc71fffd1b0443e2a (patch)
treec3f86b1b345720b6e0a56db4fbb75a20a0bf82ee /servers/audio
parentdd06cb90c541b39de764ac7bbafd61fb2b9abb48 (diff)
Style: Partially apply clang-tidy's `cppcoreguidelines-pro-type-member-init`
Didn't commit all the changes where it wants to initialize a struct with `{}`. Should be reviewed in a separate PR. Option `IgnoreArrays` enabled for now to be conservative, can be disabled to see if it proposes more useful changes. Also fixed manually a handful of other missing initializations / moved some from constructors.
Diffstat (limited to 'servers/audio')
-rw-r--r--servers/audio/audio_filter_sw.cpp9
-rw-r--r--servers/audio/audio_filter_sw.h34
-rw-r--r--servers/audio/audio_stream.cpp5
-rw-r--r--servers/audio/audio_stream.h10
-rw-r--r--servers/audio/effects/audio_effect_stereo_enhance.cpp8
-rw-r--r--servers/audio/effects/audio_effect_stereo_enhance.h18
-rw-r--r--servers/audio/effects/reverb.cpp2
-rw-r--r--servers/audio/effects/reverb.h7
8 files changed, 40 insertions, 53 deletions
diff --git a/servers/audio/audio_filter_sw.cpp b/servers/audio/audio_filter_sw.cpp
index 082931647a..003275f302 100644
--- a/servers/audio/audio_filter_sw.cpp
+++ b/servers/audio/audio_filter_sw.cpp
@@ -211,15 +211,6 @@ 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::Processor::Processor() {
set_filter(nullptr);
}
diff --git a/servers/audio/audio_filter_sw.h b/servers/audio/audio_filter_sw.h
index 1ec1abd4d5..e3f8188997 100644
--- a/servers/audio/audio_filter_sw.h
+++ b/servers/audio/audio_filter_sw.h
@@ -36,11 +36,11 @@
class AudioFilterSW {
public:
struct Coeffs {
- float a1, a2;
- float b0, b1, b2;
-
- //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; }
+ float a1 = 0.0f;
+ float a2 = 0.0f;
+ float b0 = 0.0f;
+ float b1 = 0.0f;
+ float b2 = 0.0f;
};
enum Mode {
@@ -52,14 +52,16 @@ public:
BANDLIMIT,
LOWSHELF,
HIGHSHELF
-
};
- class Processor { // simple filter processor
-
+ class Processor { // Simple filter processor.
AudioFilterSW *filter = nullptr;
Coeffs coeffs;
- float ha1, ha2, hb1, hb2; //history
+ // History.
+ float ha1 = 0.0f;
+ float ha2 = 0.0f;
+ float hb1 = 0.0f;
+ float hb2 = 0.0f;
Coeffs incr_coeffs;
public:
@@ -73,12 +75,12 @@ public:
};
private:
- float cutoff;
- float resonance;
- float gain;
- float sampling_rate;
- int stages;
- Mode mode;
+ float cutoff = 5000.0f;
+ float resonance = 0.5f;
+ float gain = 1.0f;
+ float sampling_rate = 44100.0f;
+ int stages = 1;
+ Mode mode = LOWPASS;
public:
float get_response(float p_freq, Coeffs *p_coeffs);
@@ -92,7 +94,7 @@ public:
void prepare_coefficients(Coeffs *p_coeffs);
- AudioFilterSW();
+ AudioFilterSW() {}
};
/* inline methods */
diff --git a/servers/audio/audio_stream.cpp b/servers/audio/audio_stream.cpp
index 1ebd57fa7f..9a9b9815ae 100644
--- a/servers/audio/audio_stream.cpp
+++ b/servers/audio/audio_stream.cpp
@@ -709,10 +709,7 @@ void AudioStreamRandomizer::_bind_methods() {
BIND_ENUM_CONSTANT(PLAYBACK_SEQUENTIAL);
}
-AudioStreamRandomizer::AudioStreamRandomizer() {
- random_pitch_scale = 1.1;
- random_volume_offset_db = 5;
-}
+AudioStreamRandomizer::AudioStreamRandomizer() {}
void AudioStreamPlaybackRandomizer::start(float p_from_pos) {
playing = playback;
diff --git a/servers/audio/audio_stream.h b/servers/audio/audio_stream.h
index 55031dec2c..9800707849 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();
@@ -145,8 +145,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<AudioStreamMicrophone> microphone;
@@ -194,8 +194,8 @@ private:
Set<AudioStreamPlaybackRandomizer *> playbacks;
Vector<PoolEntry> audio_stream_pool;
- float random_pitch_scale;
- float random_volume_offset_db;
+ float random_pitch_scale = 1.1f;
+ float random_volume_offset_db = 5.0f;
Ref<AudioStreamPlayback> instance_playback_random();
Ref<AudioStreamPlayback> instance_playback_no_repeats();
diff --git a/servers/audio/effects/audio_effect_stereo_enhance.cpp b/servers/audio/effects/audio_effect_stereo_enhance.cpp
index c81efc55e2..7bb62bcbed 100644
--- a/servers/audio/effects/audio_effect_stereo_enhance.cpp
+++ b/servers/audio/effects/audio_effect_stereo_enhance.cpp
@@ -29,7 +29,9 @@
/*************************************************************************/
#include "audio_effect_stereo_enhance.h"
+
#include "servers/audio_server.h"
+
void AudioEffectStereoEnhanceInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) {
float intensity = base->pan_pullout;
bool surround_mode = base->surround > 0;
@@ -140,8 +142,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 1f93d1cf9f..30ea11f625 100644
--- a/servers/audio/effects/audio_effect_stereo_enhance.h
+++ b/servers/audio/effects/audio_effect_stereo_enhance.h
@@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef AUDIOEFFECTSTEREOENHANCE_H
-#define AUDIOEFFECTSTEREOENHANCE_H
+#ifndef AUDIO_EFFECT_STEREO_ENHANCE_H
+#define AUDIO_EFFECT_STEREO_ENHANCE_H
#include "servers/audio/audio_effect.h"
@@ -45,8 +45,8 @@ class AudioEffectStereoEnhanceInstance : public AudioEffectInstance {
};
float *delay_ringbuff = nullptr;
- unsigned int ringbuff_pos;
- unsigned int ringbuff_mask;
+ 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.0f;
- float pan_pullout;
- float time_pullout;
- float surround;
+ float pan_pullout = 1.0f;
+ float time_pullout = 0.0f;
+ float surround = 0.0f;
protected:
static void _bind_methods();
@@ -82,4 +82,4 @@ public:
AudioEffectStereoEnhance();
};
-#endif // AUDIOEFFECTSTEREOENHANCE_H
+#endif // AUDIO_EFFECT_STEREO_ENHANCE_H
diff --git a/servers/audio/effects/reverb.cpp b/servers/audio/effects/reverb.cpp
index 4b5b9ab79f..adfd648514 100644
--- a/servers/audio/effects/reverb.cpp
+++ b/servers/audio/effects/reverb.cpp
@@ -28,8 +28,6 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-// Author: Juan Linietsky <reduzio@gmail.com>, (C) 2006
-
#include "reverb.h"
#include "core/math/math_funcs.h"
diff --git a/servers/audio/effects/reverb.h b/servers/audio/effects/reverb.h
index de25e8c52b..c9602c5b5a 100644
--- a/servers/audio/effects/reverb.h
+++ b/servers/audio/effects/reverb.h
@@ -77,10 +77,11 @@ private:
AllPass allpass[MAX_ALLPASS];
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.0f;
+ float hpf_h2 = 0.0f;
struct Parameters {
float room_size;