diff options
Diffstat (limited to 'servers/audio')
26 files changed, 175 insertions, 135 deletions
diff --git a/servers/audio/audio_driver_dummy.cpp b/servers/audio/audio_driver_dummy.cpp index 635e4601c7..60eb657923 100644 --- a/servers/audio/audio_driver_dummy.cpp +++ b/servers/audio/audio_driver_dummy.cpp @@ -33,22 +33,24 @@ #include "core/config/project_settings.h" #include "core/os/os.h" +AudioDriverDummy *AudioDriverDummy::singleton = nullptr; + 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); + if (mix_rate == -1) { + mix_rate = GLOBAL_GET("audio/driver/mix_rate"); + } + channels = get_channels(); samples_in = memnew_arr(int32_t, (size_t)buffer_frames * channels); - thread.start(AudioDriverDummy::thread_func, this); + if (use_threads) { + thread.start(AudioDriverDummy::thread_func, this); + } return OK; }; @@ -93,11 +95,56 @@ void AudioDriverDummy::unlock() { mutex.unlock(); }; +void AudioDriverDummy::set_use_threads(bool p_use_threads) { + use_threads = p_use_threads; +} + +void AudioDriverDummy::set_speaker_mode(SpeakerMode p_mode) { + speaker_mode = p_mode; +} + +void AudioDriverDummy::set_mix_rate(int p_rate) { + mix_rate = p_rate; +} + +uint32_t AudioDriverDummy::get_channels() const { + static const int channels_for_mode[4] = { 2, 4, 8, 16 }; + return channels_for_mode[speaker_mode]; +} + +void AudioDriverDummy::mix_audio(int p_frames, int32_t *p_buffer) { + ERR_FAIL_COND(!active); // If not active, should not mix. + ERR_FAIL_COND(use_threads == true); // If using threads, this will not work well. + + uint32_t todo = p_frames; + while (todo) { + uint32_t to_mix = MIN(buffer_frames, todo); + lock(); + audio_server_process(to_mix, samples_in); + unlock(); + + uint32_t total_samples = to_mix * channels; + + for (uint32_t i = 0; i < total_samples; i++) { + p_buffer[i] = samples_in[i]; + } + + todo -= to_mix; + p_buffer += total_samples; + } +} + void AudioDriverDummy::finish() { - exit_thread = true; - thread.wait_to_finish(); + if (use_threads) { + exit_thread = true; + thread.wait_to_finish(); + } if (samples_in) { memdelete_arr(samples_in); }; -}; +} + +AudioDriverDummy::AudioDriverDummy() { + singleton = this; +} diff --git a/servers/audio/audio_driver_dummy.h b/servers/audio/audio_driver_dummy.h index 68b523e086..232a8d5e1f 100644 --- a/servers/audio/audio_driver_dummy.h +++ b/servers/audio/audio_driver_dummy.h @@ -44,9 +44,9 @@ class AudioDriverDummy : public AudioDriver { static void thread_func(void *p_udata); - unsigned int buffer_frames; - unsigned int mix_rate; - SpeakerMode speaker_mode; + uint32_t buffer_frames = 4096; + int32_t mix_rate = -1; + SpeakerMode speaker_mode = SPEAKER_MODE_STEREO; int channels; @@ -54,6 +54,10 @@ class AudioDriverDummy : public AudioDriver { bool thread_exited; mutable bool exit_thread; + bool use_threads = true; + + static AudioDriverDummy *singleton; + public: const char *get_name() const { return "Dummy"; @@ -67,7 +71,17 @@ public: virtual void unlock(); virtual void finish(); - AudioDriverDummy() {} + void set_use_threads(bool p_use_threads); + void set_speaker_mode(SpeakerMode p_mode); + void set_mix_rate(int p_rate); + + uint32_t get_channels() const; + + void mix_audio(int p_frames, int32_t *p_buffer); + + static AudioDriverDummy *get_dummy_singleton() { return singleton; } + + AudioDriverDummy(); ~AudioDriverDummy() {} }; 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 f59ef2fd2a..5d9a9e61dc 100644 --- a/servers/audio/audio_stream.cpp +++ b/servers/audio/audio_stream.cpp @@ -384,9 +384,11 @@ void AudioStreamRandomizer::add_stream(int p_index) { notify_property_list_changed(); } +// p_index_to is relative to the array prior to the removal of from. +// Example: [0, 1, 2, 3], move(1, 3) => [0, 2, 1, 3] void AudioStreamRandomizer::move_stream(int p_index_from, int p_index_to) { - ERR_FAIL_COND(p_index_from < 0); - ERR_FAIL_COND(p_index_from >= audio_stream_pool.size()); + ERR_FAIL_INDEX(p_index_from, audio_stream_pool.size()); + // p_index_to == audio_stream_pool.size() is valid (move to end). ERR_FAIL_COND(p_index_to < 0); ERR_FAIL_COND(p_index_to > audio_stream_pool.size()); audio_stream_pool.insert(p_index_to, audio_stream_pool[p_index_from]); @@ -400,36 +402,31 @@ void AudioStreamRandomizer::move_stream(int p_index_from, int p_index_to) { } void AudioStreamRandomizer::remove_stream(int p_index) { - ERR_FAIL_COND(p_index < 0); - ERR_FAIL_COND(p_index >= audio_stream_pool.size()); + ERR_FAIL_INDEX(p_index, audio_stream_pool.size()); audio_stream_pool.remove_at(p_index); emit_signal(SNAME("changed")); notify_property_list_changed(); } void AudioStreamRandomizer::set_stream(int p_index, Ref<AudioStream> p_stream) { - ERR_FAIL_COND(p_index < 0); - ERR_FAIL_COND(p_index >= audio_stream_pool.size()); + ERR_FAIL_INDEX(p_index, audio_stream_pool.size()); audio_stream_pool.write[p_index].stream = p_stream; emit_signal(SNAME("changed")); } Ref<AudioStream> AudioStreamRandomizer::get_stream(int p_index) const { - ERR_FAIL_COND_V(p_index < 0, nullptr); - ERR_FAIL_COND_V(p_index >= audio_stream_pool.size(), nullptr); + ERR_FAIL_INDEX_V(p_index, audio_stream_pool.size(), nullptr); return audio_stream_pool[p_index].stream; } void AudioStreamRandomizer::set_stream_probability_weight(int p_index, float p_weight) { - ERR_FAIL_COND(p_index < 0); - ERR_FAIL_COND(p_index >= audio_stream_pool.size()); + ERR_FAIL_INDEX(p_index, audio_stream_pool.size()); audio_stream_pool.write[p_index].weight = p_weight; emit_signal(SNAME("changed")); } float AudioStreamRandomizer::get_stream_probability_weight(int p_index) const { - ERR_FAIL_COND_V(p_index < 0, 0); - ERR_FAIL_COND_V(p_index >= audio_stream_pool.size(), 0); + ERR_FAIL_INDEX_V(p_index, audio_stream_pool.size(), 0); return audio_stream_pool[p_index].weight; } @@ -699,17 +696,14 @@ void AudioStreamRandomizer::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "streams_count", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_streams_count", "get_streams_count"); ADD_PROPERTY(PropertyInfo(Variant::INT, "playback_mode", PROPERTY_HINT_ENUM, "Random (Avoid Repeats),Random,Sequential"), "set_playback_mode", "get_playback_mode"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "random_pitch", PROPERTY_HINT_RANGE, "1,16,0.01"), "set_random_pitch", "get_random_pitch"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "random_volume_offset_db", PROPERTY_HINT_RANGE, "0,40,0"), "set_random_volume_offset_db", "get_random_volume_offset_db"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "random_volume_offset_db", PROPERTY_HINT_RANGE, "0,40,0,suffix:dB"), "set_random_volume_offset_db", "get_random_volume_offset_db"); BIND_ENUM_CONSTANT(PLAYBACK_RANDOM_NO_REPEATS); BIND_ENUM_CONSTANT(PLAYBACK_RANDOM); 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..bf200e7ecf 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(); @@ -125,7 +125,7 @@ class AudioStreamMicrophone : public AudioStream { GDCLASS(AudioStreamMicrophone, AudioStream); friend class AudioStreamPlaybackMicrophone; - Set<AudioStreamPlaybackMicrophone *> playbacks; + HashSet<AudioStreamPlaybackMicrophone *> playbacks; protected: static void _bind_methods(); @@ -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; @@ -192,10 +192,10 @@ private: float weight; }; - Set<AudioStreamPlaybackRandomizer *> playbacks; + HashSet<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_amplify.cpp b/servers/audio/effects/audio_effect_amplify.cpp index b01160ea5c..87d46f8bbe 100644 --- a/servers/audio/effects/audio_effect_amplify.cpp +++ b/servers/audio/effects/audio_effect_amplify.cpp @@ -64,7 +64,7 @@ void AudioEffectAmplify::_bind_methods() { ClassDB::bind_method(D_METHOD("set_volume_db", "volume"), &AudioEffectAmplify::set_volume_db); ClassDB::bind_method(D_METHOD("get_volume_db"), &AudioEffectAmplify::get_volume_db); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "volume_db", PROPERTY_HINT_RANGE, "-80,24,0.01"), "set_volume_db", "get_volume_db"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "volume_db", PROPERTY_HINT_RANGE, "-80,24,0.01,suffix:dB"), "set_volume_db", "get_volume_db"); } AudioEffectAmplify::AudioEffectAmplify() { diff --git a/servers/audio/effects/audio_effect_capture.cpp b/servers/audio/effects/audio_effect_capture.cpp index f605cfc9d4..1f5f5e259a 100644 --- a/servers/audio/effects/audio_effect_capture.cpp +++ b/servers/audio/effects/audio_effect_capture.cpp @@ -70,7 +70,7 @@ void AudioEffectCapture::_bind_methods() { ClassDB::bind_method(D_METHOD("get_buffer_length_frames"), &AudioEffectCapture::get_buffer_length_frames); ClassDB::bind_method(D_METHOD("get_pushed_frames"), &AudioEffectCapture::get_pushed_frames); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "buffer_length", PROPERTY_HINT_RANGE, "0.01,10,0.01"), "set_buffer_length", "get_buffer_length"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "buffer_length", PROPERTY_HINT_RANGE, "0.01,10,0.01,suffix:s"), "set_buffer_length", "get_buffer_length"); } Ref<AudioEffectInstance> AudioEffectCapture::instantiate() { diff --git a/servers/audio/effects/audio_effect_chorus.cpp b/servers/audio/effects/audio_effect_chorus.cpp index 8b1fe9cfd2..e5434eac02 100644 --- a/servers/audio/effects/audio_effect_chorus.cpp +++ b/servers/audio/effects/audio_effect_chorus.cpp @@ -313,32 +313,32 @@ void AudioEffectChorus::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "dry", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_dry", "get_dry"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "wet", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_wet", "get_wet"); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/1/delay_ms", PROPERTY_HINT_RANGE, "0,50,0.01"), "set_voice_delay_ms", "get_voice_delay_ms", 0); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/1/rate_hz", PROPERTY_HINT_RANGE, "0.1,20,0.1"), "set_voice_rate_hz", "get_voice_rate_hz", 0); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/1/depth_ms", PROPERTY_HINT_RANGE, "0,20,0.01"), "set_voice_depth_ms", "get_voice_depth_ms", 0); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/1/level_db", PROPERTY_HINT_RANGE, "-60,24,0.1"), "set_voice_level_db", "get_voice_level_db", 0); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/1/cutoff_hz", PROPERTY_HINT_RANGE, "1,20500,1"), "set_voice_cutoff_hz", "get_voice_cutoff_hz", 0); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/1/delay_ms", PROPERTY_HINT_RANGE, "0,50,0.01,suffix:ms"), "set_voice_delay_ms", "get_voice_delay_ms", 0); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/1/rate_hz", PROPERTY_HINT_RANGE, "0.1,20,0.1,suffix:Hz"), "set_voice_rate_hz", "get_voice_rate_hz", 0); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/1/depth_ms", PROPERTY_HINT_RANGE, "0,20,0.01,suffix:ms"), "set_voice_depth_ms", "get_voice_depth_ms", 0); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/1/level_db", PROPERTY_HINT_RANGE, "-60,24,0.1,suffix:dB"), "set_voice_level_db", "get_voice_level_db", 0); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/1/cutoff_hz", PROPERTY_HINT_RANGE, "1,20500,1,suffix:Hz"), "set_voice_cutoff_hz", "get_voice_cutoff_hz", 0); ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/1/pan", PROPERTY_HINT_RANGE, "-1,1,0.01"), "set_voice_pan", "get_voice_pan", 0); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/2/delay_ms", PROPERTY_HINT_RANGE, "0,50,0.01"), "set_voice_delay_ms", "get_voice_delay_ms", 1); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/2/rate_hz", PROPERTY_HINT_RANGE, "0.1,20,0.1"), "set_voice_rate_hz", "get_voice_rate_hz", 1); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/2/depth_ms", PROPERTY_HINT_RANGE, "0,20,0.01"), "set_voice_depth_ms", "get_voice_depth_ms", 1); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/2/level_db", PROPERTY_HINT_RANGE, "-60,24,0.1"), "set_voice_level_db", "get_voice_level_db", 1); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/2/cutoff_hz", PROPERTY_HINT_RANGE, "1,20500,1"), "set_voice_cutoff_hz", "get_voice_cutoff_hz", 1); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/2/delay_ms", PROPERTY_HINT_RANGE, "0,50,0.01,suffix:ms"), "set_voice_delay_ms", "get_voice_delay_ms", 1); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/2/rate_hz", PROPERTY_HINT_RANGE, "0.1,20,0.1,suffix:Hz"), "set_voice_rate_hz", "get_voice_rate_hz", 1); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/2/depth_ms", PROPERTY_HINT_RANGE, "0,20,0.01,suffix:ms"), "set_voice_depth_ms", "get_voice_depth_ms", 1); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/2/level_db", PROPERTY_HINT_RANGE, "-60,24,0.1,suffix:dB"), "set_voice_level_db", "get_voice_level_db", 1); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/2/cutoff_hz", PROPERTY_HINT_RANGE, "1,20500,1,suffix:Hz"), "set_voice_cutoff_hz", "get_voice_cutoff_hz", 1); ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/2/pan", PROPERTY_HINT_RANGE, "-1,1,0.01"), "set_voice_pan", "get_voice_pan", 1); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/3/delay_ms", PROPERTY_HINT_RANGE, "0,50,0.01"), "set_voice_delay_ms", "get_voice_delay_ms", 2); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/3/rate_hz", PROPERTY_HINT_RANGE, "0.1,20,0.1"), "set_voice_rate_hz", "get_voice_rate_hz", 2); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/3/depth_ms", PROPERTY_HINT_RANGE, "0,20,0.01"), "set_voice_depth_ms", "get_voice_depth_ms", 2); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/3/level_db", PROPERTY_HINT_RANGE, "-60,24,0.1"), "set_voice_level_db", "get_voice_level_db", 2); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/3/cutoff_hz", PROPERTY_HINT_RANGE, "1,20500,1"), "set_voice_cutoff_hz", "get_voice_cutoff_hz", 2); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/3/delay_ms", PROPERTY_HINT_RANGE, "0,50,0.01,suffix:ms"), "set_voice_delay_ms", "get_voice_delay_ms", 2); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/3/rate_hz", PROPERTY_HINT_RANGE, "0.1,20,0.1,suffix:Hz"), "set_voice_rate_hz", "get_voice_rate_hz", 2); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/3/depth_ms", PROPERTY_HINT_RANGE, "0,20,0.01,suffix:ms"), "set_voice_depth_ms", "get_voice_depth_ms", 2); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/3/level_db", PROPERTY_HINT_RANGE, "-60,24,0.1,suffix:dB"), "set_voice_level_db", "get_voice_level_db", 2); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/3/cutoff_hz", PROPERTY_HINT_RANGE, "1,20500,1,suffix:Hz"), "set_voice_cutoff_hz", "get_voice_cutoff_hz", 2); ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/3/pan", PROPERTY_HINT_RANGE, "-1,1,0.01"), "set_voice_pan", "get_voice_pan", 2); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/4/delay_ms", PROPERTY_HINT_RANGE, "0,50,0.01"), "set_voice_delay_ms", "get_voice_delay_ms", 3); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/4/rate_hz", PROPERTY_HINT_RANGE, "0.1,20,0.1"), "set_voice_rate_hz", "get_voice_rate_hz", 3); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/4/depth_ms", PROPERTY_HINT_RANGE, "0,20,0.01"), "set_voice_depth_ms", "get_voice_depth_ms", 3); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/4/level_db", PROPERTY_HINT_RANGE, "-60,24,0.1"), "set_voice_level_db", "get_voice_level_db", 3); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/4/cutoff_hz", PROPERTY_HINT_RANGE, "1,20500,1"), "set_voice_cutoff_hz", "get_voice_cutoff_hz", 3); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/4/delay_ms", PROPERTY_HINT_RANGE, "0,50,0.01,suffix:ms"), "set_voice_delay_ms", "get_voice_delay_ms", 3); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/4/rate_hz", PROPERTY_HINT_RANGE, "0.1,20,0.1,suffix:Hz"), "set_voice_rate_hz", "get_voice_rate_hz", 3); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/4/depth_ms", PROPERTY_HINT_RANGE, "0,20,0.01,suffix:ms"), "set_voice_depth_ms", "get_voice_depth_ms", 3); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/4/level_db", PROPERTY_HINT_RANGE, "-60,24,0.1,suffix:dB"), "set_voice_level_db", "get_voice_level_db", 3); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/4/cutoff_hz", PROPERTY_HINT_RANGE, "1,20500,1,suffix:Hz"), "set_voice_cutoff_hz", "get_voice_cutoff_hz", 3); ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "voice/4/pan", PROPERTY_HINT_RANGE, "-1,1,0.01"), "set_voice_pan", "get_voice_pan", 3); } diff --git a/servers/audio/effects/audio_effect_compressor.cpp b/servers/audio/effects/audio_effect_compressor.cpp index f75d092dd3..ee71a6dba7 100644 --- a/servers/audio/effects/audio_effect_compressor.cpp +++ b/servers/audio/effects/audio_effect_compressor.cpp @@ -221,8 +221,8 @@ void AudioEffectCompressor::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "threshold", PROPERTY_HINT_RANGE, "-60,0,0.1"), "set_threshold", "get_threshold"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ratio", PROPERTY_HINT_RANGE, "1,48,0.1"), "set_ratio", "get_ratio"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "gain", PROPERTY_HINT_RANGE, "-20,20,0.1"), "set_gain", "get_gain"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "attack_us", PROPERTY_HINT_RANGE, "20,2000,1"), "set_attack_us", "get_attack_us"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "release_ms", PROPERTY_HINT_RANGE, "20,2000,1"), "set_release_ms", "get_release_ms"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "attack_us", PROPERTY_HINT_RANGE, U"20,2000,1,suffix:\u00B5s"), "set_attack_us", "get_attack_us"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "release_ms", PROPERTY_HINT_RANGE, "20,2000,1,suffix:ms"), "set_release_ms", "get_release_ms"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "mix", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_mix", "get_mix"); ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "sidechain", PROPERTY_HINT_ENUM), "set_sidechain", "get_sidechain"); } diff --git a/servers/audio/effects/audio_effect_delay.cpp b/servers/audio/effects/audio_effect_delay.cpp index 1909ab6eae..80e7a8223c 100644 --- a/servers/audio/effects/audio_effect_delay.cpp +++ b/servers/audio/effects/audio_effect_delay.cpp @@ -287,18 +287,18 @@ void AudioEffectDelay::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "dry", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_dry", "get_dry"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "tap1/active"), "set_tap1_active", "is_tap1_active"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "tap1/delay_ms", PROPERTY_HINT_RANGE, "0,1500,1"), "set_tap1_delay_ms", "get_tap1_delay_ms"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "tap1/level_db", PROPERTY_HINT_RANGE, "-60,0,0.01"), "set_tap1_level_db", "get_tap1_level_db"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "tap1/delay_ms", PROPERTY_HINT_RANGE, "0,1500,1,suffix:ms"), "set_tap1_delay_ms", "get_tap1_delay_ms"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "tap1/level_db", PROPERTY_HINT_RANGE, "-60,0,0.01,suffix:dB"), "set_tap1_level_db", "get_tap1_level_db"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "tap1/pan", PROPERTY_HINT_RANGE, "-1,1,0.01"), "set_tap1_pan", "get_tap1_pan"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "tap2/active"), "set_tap2_active", "is_tap2_active"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "tap2/delay_ms", PROPERTY_HINT_RANGE, "0,1500,1"), "set_tap2_delay_ms", "get_tap2_delay_ms"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "tap2/level_db", PROPERTY_HINT_RANGE, "-60,0,0.01"), "set_tap2_level_db", "get_tap2_level_db"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "tap2/delay_ms", PROPERTY_HINT_RANGE, "0,1500,1,suffix:ms"), "set_tap2_delay_ms", "get_tap2_delay_ms"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "tap2/level_db", PROPERTY_HINT_RANGE, "-60,0,0.01,suffix:dB"), "set_tap2_level_db", "get_tap2_level_db"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "tap2/pan", PROPERTY_HINT_RANGE, "-1,1,0.01"), "set_tap2_pan", "get_tap2_pan"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "feedback/active"), "set_feedback_active", "is_feedback_active"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "feedback/delay_ms", PROPERTY_HINT_RANGE, "0,1500,1"), "set_feedback_delay_ms", "get_feedback_delay_ms"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "feedback/level_db", PROPERTY_HINT_RANGE, "-60,0,0.01"), "set_feedback_level_db", "get_feedback_level_db"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "feedback/delay_ms", PROPERTY_HINT_RANGE, "0,1500,1,suffix:ms"), "set_feedback_delay_ms", "get_feedback_delay_ms"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "feedback/level_db", PROPERTY_HINT_RANGE, "-60,0,0.01,suffix:dB"), "set_feedback_level_db", "get_feedback_level_db"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "feedback/lowpass", PROPERTY_HINT_RANGE, "1,16000,1"), "set_feedback_lowpass", "get_feedback_lowpass"); } diff --git a/servers/audio/effects/audio_effect_distortion.cpp b/servers/audio/effects/audio_effect_distortion.cpp index afc4353bd7..6820d796a4 100644 --- a/servers/audio/effects/audio_effect_distortion.cpp +++ b/servers/audio/effects/audio_effect_distortion.cpp @@ -161,7 +161,7 @@ void AudioEffectDistortion::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Clip,ATan,LoFi,Overdrive,Wave Shape"), "set_mode", "get_mode"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "pre_gain", PROPERTY_HINT_RANGE, "-60,60,0.01"), "set_pre_gain", "get_pre_gain"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "keep_hf_hz", PROPERTY_HINT_RANGE, "1,20500,1"), "set_keep_hf_hz", "get_keep_hf_hz"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "keep_hf_hz", PROPERTY_HINT_RANGE, "1,20500,1,suffix:Hz"), "set_keep_hf_hz", "get_keep_hf_hz"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "drive", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_drive", "get_drive"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "post_gain", PROPERTY_HINT_RANGE, "-80,24,0.01"), "set_post_gain", "get_post_gain"); diff --git a/servers/audio/effects/audio_effect_eq.cpp b/servers/audio/effects/audio_effect_eq.cpp index cc317031d4..b7c373479a 100644 --- a/servers/audio/effects/audio_effect_eq.cpp +++ b/servers/audio/effects/audio_effect_eq.cpp @@ -90,9 +90,9 @@ int AudioEffectEQ::get_band_count() const { } bool AudioEffectEQ::_set(const StringName &p_name, const Variant &p_value) { - const Map<StringName, int>::Element *E = prop_band_map.find(p_name); + HashMap<StringName, int>::ConstIterator E = prop_band_map.find(p_name); if (E) { - set_band_gain_db(E->get(), p_value); + set_band_gain_db(E->value, p_value); return true; } @@ -100,9 +100,9 @@ bool AudioEffectEQ::_set(const StringName &p_name, const Variant &p_value) { } bool AudioEffectEQ::_get(const StringName &p_name, Variant &r_ret) const { - const Map<StringName, int>::Element *E = prop_band_map.find(p_name); + HashMap<StringName, int>::ConstIterator E = prop_band_map.find(p_name); if (E) { - r_ret = get_band_gain_db(E->get()); + r_ret = get_band_gain_db(E->value); return true; } diff --git a/servers/audio/effects/audio_effect_eq.h b/servers/audio/effects/audio_effect_eq.h index 252f931e6c..9b0560223f 100644 --- a/servers/audio/effects/audio_effect_eq.h +++ b/servers/audio/effects/audio_effect_eq.h @@ -55,7 +55,7 @@ class AudioEffectEQ : public AudioEffect { EQ eq; Vector<float> gain; - Map<StringName, int> prop_band_map; + HashMap<StringName, int> prop_band_map; Vector<String> band_names; protected: diff --git a/servers/audio/effects/audio_effect_filter.cpp b/servers/audio/effects/audio_effect_filter.cpp index 06e66f22b1..a9409076cd 100644 --- a/servers/audio/effects/audio_effect_filter.cpp +++ b/servers/audio/effects/audio_effect_filter.cpp @@ -153,7 +153,7 @@ void AudioEffectFilter::_bind_methods() { ClassDB::bind_method(D_METHOD("set_db", "amount"), &AudioEffectFilter::set_db); ClassDB::bind_method(D_METHOD("get_db"), &AudioEffectFilter::get_db); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "cutoff_hz", PROPERTY_HINT_RANGE, "1,20500,1"), "set_cutoff", "get_cutoff"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "cutoff_hz", PROPERTY_HINT_RANGE, "1,20500,1,suffix:Hz"), "set_cutoff", "get_cutoff"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "resonance", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_resonance", "get_resonance"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "gain", PROPERTY_HINT_RANGE, "0,4,0.01"), "set_gain", "get_gain"); ADD_PROPERTY(PropertyInfo(Variant::INT, "db", PROPERTY_HINT_ENUM, "6 dB,12 dB,18 dB,24 dB"), "set_db", "get_db"); diff --git a/servers/audio/effects/audio_effect_limiter.cpp b/servers/audio/effects/audio_effect_limiter.cpp index 5923cf8cf5..7bcd68d48b 100644 --- a/servers/audio/effects/audio_effect_limiter.cpp +++ b/servers/audio/effects/audio_effect_limiter.cpp @@ -120,9 +120,9 @@ void AudioEffectLimiter::_bind_methods() { ClassDB::bind_method(D_METHOD("set_soft_clip_ratio", "soft_clip"), &AudioEffectLimiter::set_soft_clip_ratio); ClassDB::bind_method(D_METHOD("get_soft_clip_ratio"), &AudioEffectLimiter::get_soft_clip_ratio); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ceiling_db", PROPERTY_HINT_RANGE, "-20,-0.1,0.1"), "set_ceiling_db", "get_ceiling_db"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "threshold_db", PROPERTY_HINT_RANGE, "-30,0,0.1"), "set_threshold_db", "get_threshold_db"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "soft_clip_db", PROPERTY_HINT_RANGE, "0,6,0.1"), "set_soft_clip_db", "get_soft_clip_db"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ceiling_db", PROPERTY_HINT_RANGE, "-20,-0.1,0.1,suffix:dB"), "set_ceiling_db", "get_ceiling_db"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "threshold_db", PROPERTY_HINT_RANGE, "-30,0,0.1,suffix:dB"), "set_threshold_db", "get_threshold_db"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "soft_clip_db", PROPERTY_HINT_RANGE, "0,6,0.1,suffix:dB"), "set_soft_clip_db", "get_soft_clip_db"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "soft_clip_ratio", PROPERTY_HINT_RANGE, "3,20,0.1"), "set_soft_clip_ratio", "get_soft_clip_ratio"); } diff --git a/servers/audio/effects/audio_effect_phaser.cpp b/servers/audio/effects/audio_effect_phaser.cpp index af5dce707e..2f86630ce9 100644 --- a/servers/audio/effects/audio_effect_phaser.cpp +++ b/servers/audio/effects/audio_effect_phaser.cpp @@ -144,9 +144,9 @@ void AudioEffectPhaser::_bind_methods() { ClassDB::bind_method(D_METHOD("set_depth", "depth"), &AudioEffectPhaser::set_depth); ClassDB::bind_method(D_METHOD("get_depth"), &AudioEffectPhaser::get_depth); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "range_min_hz", PROPERTY_HINT_RANGE, "10,10000"), "set_range_min_hz", "get_range_min_hz"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "range_max_hz", PROPERTY_HINT_RANGE, "10,10000"), "set_range_max_hz", "get_range_max_hz"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rate_hz", PROPERTY_HINT_RANGE, "0.01,20"), "set_rate_hz", "get_rate_hz"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "range_min_hz", PROPERTY_HINT_RANGE, "10,10000,suffix:Hz"), "set_range_min_hz", "get_range_min_hz"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "range_max_hz", PROPERTY_HINT_RANGE, "10,10000,suffix:Hz"), "set_range_max_hz", "get_range_max_hz"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rate_hz", PROPERTY_HINT_RANGE, "0.01,20,suffix:Hz"), "set_rate_hz", "get_rate_hz"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "feedback", PROPERTY_HINT_RANGE, "0.1,0.9,0.1"), "set_feedback", "get_feedback"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "depth", PROPERTY_HINT_RANGE, "0.1,4,0.1"), "set_depth", "get_depth"); } diff --git a/servers/audio/effects/audio_effect_record.cpp b/servers/audio/effects/audio_effect_record.cpp index d68522e5b9..a6553e1431 100644 --- a/servers/audio/effects/audio_effect_record.cpp +++ b/servers/audio/effects/audio_effect_record.cpp @@ -71,8 +71,6 @@ bool AudioEffectRecordInstance::process_silence() const { } void AudioEffectRecordInstance::_io_thread_process() { - thread_active = true; - while (is_recording) { //Check: The current recording has been requested to stop if (!base->recording_active) { @@ -86,8 +84,6 @@ void AudioEffectRecordInstance::_io_thread_process() { OS::get_singleton()->delay_usec(500); } } - - thread_active = false; } void AudioEffectRecordInstance::_io_store_buffer() { diff --git a/servers/audio/effects/audio_effect_record.h b/servers/audio/effects/audio_effect_record.h index 305484d1cb..8a6247e27a 100644 --- a/servers/audio/effects/audio_effect_record.h +++ b/servers/audio/effects/audio_effect_record.h @@ -48,7 +48,6 @@ class AudioEffectRecordInstance : public AudioEffectInstance { bool is_recording; Thread io_thread; - bool thread_active = false; Vector<AudioFrame> ring_buffer; Vector<float> recording_data; diff --git a/servers/audio/effects/audio_effect_reverb.cpp b/servers/audio/effects/audio_effect_reverb.cpp index 0d4eb14e6a..bfc68152a4 100644 --- a/servers/audio/effects/audio_effect_reverb.cpp +++ b/servers/audio/effects/audio_effect_reverb.cpp @@ -176,7 +176,7 @@ void AudioEffectReverb::_bind_methods() { ClassDB::bind_method(D_METHOD("get_hpf"), &AudioEffectReverb::get_hpf); ADD_GROUP("Predelay", "predelay_"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "predelay_msec", PROPERTY_HINT_RANGE, "20,500,1"), "set_predelay_msec", "get_predelay_msec"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "predelay_msec", PROPERTY_HINT_RANGE, "20,500,1,suffix:ms"), "set_predelay_msec", "get_predelay_msec"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "predelay_feedback", PROPERTY_HINT_RANGE, "0,0.98,0.01"), "set_predelay_feedback", "get_predelay_feedback"); ADD_GROUP("", ""); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "room_size", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_room_size", "get_room_size"); diff --git a/servers/audio/effects/audio_effect_spectrum_analyzer.cpp b/servers/audio/effects/audio_effect_spectrum_analyzer.cpp index 10627be74c..30ebf626ae 100644 --- a/servers/audio/effects/audio_effect_spectrum_analyzer.cpp +++ b/servers/audio/effects/audio_effect_spectrum_analyzer.cpp @@ -264,7 +264,7 @@ void AudioEffectSpectrumAnalyzer::_bind_methods() { ClassDB::bind_method(D_METHOD("set_fft_size", "size"), &AudioEffectSpectrumAnalyzer::set_fft_size); ClassDB::bind_method(D_METHOD("get_fft_size"), &AudioEffectSpectrumAnalyzer::get_fft_size); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "buffer_length", PROPERTY_HINT_RANGE, "0.1,4,0.1"), "set_buffer_length", "get_buffer_length"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "buffer_length", PROPERTY_HINT_RANGE, "0.1,4,0.1,suffix:s"), "set_buffer_length", "get_buffer_length"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "tap_back_pos", PROPERTY_HINT_RANGE, "0.1,4,0.1"), "set_tap_back_pos", "get_tap_back_pos"); ADD_PROPERTY(PropertyInfo(Variant::INT, "fft_size", PROPERTY_HINT_ENUM, "256,512,1024,2048,4096"), "set_fft_size", "get_fft_size"); diff --git a/servers/audio/effects/audio_effect_stereo_enhance.cpp b/servers/audio/effects/audio_effect_stereo_enhance.cpp index c81efc55e2..e567add3e7 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; @@ -136,12 +138,8 @@ void AudioEffectStereoEnhance::_bind_methods() { ClassDB::bind_method(D_METHOD("get_surround"), &AudioEffectStereoEnhance::get_surround); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "pan_pullout", PROPERTY_HINT_RANGE, "0,4,0.01"), "set_pan_pullout", "get_pan_pullout"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "time_pullout_ms", PROPERTY_HINT_RANGE, "0,50,0.01"), "set_time_pullout", "get_time_pullout"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "time_pullout_ms", PROPERTY_HINT_RANGE, "0,50,0.01,suffix:ms"), "set_time_pullout", "get_time_pullout"); 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/audio_stream_generator.cpp b/servers/audio/effects/audio_stream_generator.cpp index a3d615b925..46de1692e4 100644 --- a/servers/audio/effects/audio_stream_generator.cpp +++ b/servers/audio/effects/audio_stream_generator.cpp @@ -75,8 +75,8 @@ void AudioStreamGenerator::_bind_methods() { ClassDB::bind_method(D_METHOD("set_buffer_length", "seconds"), &AudioStreamGenerator::set_buffer_length); ClassDB::bind_method(D_METHOD("get_buffer_length"), &AudioStreamGenerator::get_buffer_length); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "mix_rate", PROPERTY_HINT_RANGE, "20,192000,1"), "set_mix_rate", "get_mix_rate"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "buffer_length", PROPERTY_HINT_RANGE, "0.01,10,0.01"), "set_buffer_length", "get_buffer_length"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "mix_rate", PROPERTY_HINT_RANGE, "20,192000,1,suffix:Hz"), "set_mix_rate", "get_mix_rate"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "buffer_length", PROPERTY_HINT_RANGE, "0.01,10,0.01,suffix:s"), "set_buffer_length", "get_buffer_length"); } AudioStreamGenerator::AudioStreamGenerator() { 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; |