Initialize variabes in servers/audio

This commit is contained in:
Rafał Mikrut 2021-09-13 20:58:11 +02:00 committed by qarmin
parent 32d93feebe
commit 9ac02db9b1
45 changed files with 222 additions and 391 deletions

View file

@ -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; }

View file

@ -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);

View file

@ -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 {

View file

@ -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) {

View file

@ -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 @@ public:
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 @@ public:
};
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);

View file

@ -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() {

View file

@ -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<int> rb_read_pos;
SafeNumeric<int> 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 <int C>
uint32_t _resample(AudioFrame *p_dest, int p_todo, int32_t p_increment);

View file

@ -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;

View file

@ -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 @@ protected:
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<AudioStreamMicrophone> microphone;
@ -175,7 +175,7 @@ class AudioStreamRandomPitch : public AudioStream {
Set<AudioStreamPlaybackRandomPitch *> playbacks;
Ref<AudioStream> audio_stream;
float random_pitch;
float random_pitch = 1.1;
protected:
static void _bind_methods();
@ -203,7 +203,7 @@ class AudioStreamPlaybackRandomPitch : public AudioStreamPlayback {
Ref<AudioStreamRandomPitch> random_pitch;
Ref<AudioStreamPlayback> playback;
Ref<AudioStreamPlayback> playing;
float pitch_scale;
float pitch_scale = 1.0;
public:
virtual void start(float p_from_pos = 0.0) override;

View file

@ -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() {}

View file

@ -40,7 +40,7 @@ class AudioEffectAmplifyInstance : public AudioEffectInstance {
friend class AudioEffectAmplify;
Ref<AudioEffectAmplify> 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();

View file

@ -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;
}

View file

@ -41,11 +41,11 @@ class AudioEffectChorusInstance : public AudioEffectInstance {
Ref<AudioEffectChorus> base;
Vector<AudioFrame> 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 @@ public:
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;

View file

@ -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() {}

View file

@ -40,8 +40,8 @@ class AudioEffectCompressorInstance : public AudioEffectInstance {
friend class AudioEffectCompressor;
Ref<AudioEffectCompressor> 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:

View file

@ -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() {}

View file

@ -42,13 +42,13 @@ class AudioEffectDelayInstance : public AudioEffectInstance {
Vector<AudioFrame> 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<AudioFrame> 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();

View file

@ -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() {}

View file

@ -39,7 +39,7 @@ class AudioEffectDistortionInstance : public AudioEffectInstance {
GDCLASS(AudioEffectDistortionInstance, AudioEffectInstance);
friend class AudioEffectDistortion;
Ref<AudioEffectDistortion> 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 @@ public:
};
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();

View file

@ -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;
}

View file

@ -66,11 +66,11 @@ public:
};
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();

View file

@ -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() {}

View file

@ -40,7 +40,7 @@ class AudioEffectLimiterInstance : public AudioEffectInstance {
friend class AudioEffectLimiter;
Ref<AudioEffectLimiter> 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();

View file

@ -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() {}

View file

@ -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();

View file

@ -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() {}

View file

@ -40,11 +40,11 @@ class AudioEffectPhaserInstance : public AudioEffectInstance {
friend class AudioEffectPhaser;
Ref<AudioEffectPhaser> 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();

View file

@ -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() {}

View file

@ -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 @@ public:
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 @@ public:
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<AudioEffectPitchShift> base;
int fft_size;
int fft_size = 0;
SMBPitchShift shift_l;
SMBPitchShift shift_r;
@ -98,12 +99,12 @@ public:
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();

View file

@ -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() {}

View file

@ -47,16 +47,16 @@ class AudioEffectRecordInstance : public AudioEffectInstance {
friend class AudioEffectRecord;
Ref<AudioEffectRecord> base;
bool is_recording;
bool is_recording = false;
Thread io_thread;
bool thread_active = false;
Vector<AudioFrame> ring_buffer;
Vector<float> 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<AudioEffectRecordInstance> current_instance;
AudioStreamSample::Format format;
AudioStreamSample::Format format = AudioStreamSample::FORMAT_16_BITS;
void ensure_thread_stopped();

View file

@ -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() {}

View file

@ -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();

View file

@ -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() {}

View file

@ -50,12 +50,12 @@ private:
Vector<Vector<AudioFrame>> fft_history;
Vector<float> 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 @@ public:
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();

View file

@ -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() {}

View file

@ -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();

View file

@ -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() {}

View file

@ -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<AudioFrame> 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;

View file

@ -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() {}

View file

@ -52,10 +52,10 @@ public:
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 @@ public:
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> band;
float mix_rate;
float mix_rate = 44100.0;
void recalculate_band_coefficients();

View file

@ -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();

View file

@ -58,9 +58,9 @@ private:
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 @@ private:
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();

View file

@ -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] = {

View file

@ -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<int32_t> 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 @@ public:
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<AudioFrame> buffer;
Vector<Ref<AudioEffectInstance>> 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 @@ private:
struct Effect {
Ref<AudioEffect> effect;
bool enabled;
bool enabled = false;
#ifdef DEBUG_ENABLED
uint64_t prof_time;
uint64_t prof_time = 0;
#endif
};
Vector<Effect> effects;
float volume_db;
float volume_db = 0.0;
StringName send;
int index_cache;
int index_cache = 0;
};
struct AudioStreamPlaybackBusDetails {
@ -284,7 +281,7 @@ private:
struct CallbackItem {
AudioCallback callback;
void *userdata;
void *userdata = nullptr;
};
SafeList<CallbackItem *> 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<AudioEffect> effect;
bool enabled;
bool enabled = false;
};
Vector<Effect> effects;
float volume_db;
float volume_db = 0.0;
StringName send;
Bus() {
solo = false;
mute = false;
bypass = false;
volume_db = 0;
}
};
Vector<Bus> buses;