diff options
author | Micky <micheledevita2@gmail.com> | 2022-08-13 17:45:42 +0200 |
---|---|---|
committer | Micky <micheledevita2@gmail.com> | 2022-08-26 14:58:22 +0200 |
commit | 59e11934d893cbcde70c10f9f861c710b19f3dfa (patch) | |
tree | edae8feaed897b098bd92af4574723192da2eb23 /servers/audio | |
parent | 85ed9eac6f57b87b175fefee303845abf23ebc18 (diff) |
Rename `str2var` to `str_to_var` and similar
Affects the Math class, a good chunk of the audio code, and a lot of other miscellaneous classes, too.
- `var2str` -> `var_to_str`
- `str2var` -> `str_to_var`
- `bytes2var` -> `bytes_to_var`
- `bytes2var_with_objects` -> `bytes_to_var_with_objects`
- `var2bytes` -> `var_to_bytes`
- `var2bytes_with_objects` -> `var_to_bytes_with_objects`
- `linear2db` -> `linear_to_db`
- `db2linear` -> `db_to_linear`
- `deg2rad` -> `deg_to_rad`
- `rad2deg` -> `rad_to_deg`
- `dict2inst` -> `dict_to_inst`
- `inst2dict` -> `inst_to_dict`
Diffstat (limited to 'servers/audio')
-rw-r--r-- | servers/audio/audio_stream.cpp | 2 | ||||
-rw-r--r-- | servers/audio/effects/audio_effect_amplify.cpp | 4 | ||||
-rw-r--r-- | servers/audio/effects/audio_effect_chorus.cpp | 2 | ||||
-rw-r--r-- | servers/audio/effects/audio_effect_compressor.cpp | 8 | ||||
-rw-r--r-- | servers/audio/effects/audio_effect_delay.cpp | 6 | ||||
-rw-r--r-- | servers/audio/effects/audio_effect_distortion.cpp | 4 | ||||
-rw-r--r-- | servers/audio/effects/audio_effect_eq.cpp | 2 | ||||
-rw-r--r-- | servers/audio/effects/audio_effect_limiter.cpp | 14 |
8 files changed, 21 insertions, 21 deletions
diff --git a/servers/audio/audio_stream.cpp b/servers/audio/audio_stream.cpp index 80485845c9..4252131161 100644 --- a/servers/audio/audio_stream.cpp +++ b/servers/audio/audio_stream.cpp @@ -782,7 +782,7 @@ void AudioStreamPlaybackRandomizer::start(float p_from_pos) { float range_to = randomizer->random_volume_offset_db; float volume_offset_db = range_from + Math::randf() * (range_to - range_from); - volume_scale = Math::db2linear(volume_offset_db); + volume_scale = Math::db_to_linear(volume_offset_db); } if (playing.is_valid()) { diff --git a/servers/audio/effects/audio_effect_amplify.cpp b/servers/audio/effects/audio_effect_amplify.cpp index 87d46f8bbe..2889562173 100644 --- a/servers/audio/effects/audio_effect_amplify.cpp +++ b/servers/audio/effects/audio_effect_amplify.cpp @@ -33,8 +33,8 @@ void AudioEffectAmplifyInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) { //multiply volume interpolating to avoid clicks if this changes float volume_db = base->volume_db; - float vol = Math::db2linear(mix_volume_db); - float vol_inc = (Math::db2linear(volume_db) - vol) / float(p_frame_count); + float vol = Math::db_to_linear(mix_volume_db); + float vol_inc = (Math::db_to_linear(volume_db) - vol) / float(p_frame_count); for (int i = 0; i < p_frame_count; i++) { p_dst_frames[i] = p_src_frames[i] * vol; diff --git a/servers/audio/effects/audio_effect_chorus.cpp b/servers/audio/effects/audio_effect_chorus.cpp index 54c08ef644..69b416f5f7 100644 --- a/servers/audio/effects/audio_effect_chorus.cpp +++ b/servers/audio/effects/audio_effect_chorus.cpp @@ -95,7 +95,7 @@ void AudioEffectChorusInstance::_process_chunk(const AudioFrame *p_src_frames, A //vol modifier - AudioFrame vol_modifier = AudioFrame(base->wet, base->wet) * Math::db2linear(v.level); + AudioFrame vol_modifier = AudioFrame(base->wet, base->wet) * Math::db_to_linear(v.level); vol_modifier.l *= CLAMP(1.0 - v.pan, 0, 1); vol_modifier.r *= CLAMP(1.0 + v.pan, 0, 1); diff --git a/servers/audio/effects/audio_effect_compressor.cpp b/servers/audio/effects/audio_effect_compressor.cpp index 0e1accba16..43b210e450 100644 --- a/servers/audio/effects/audio_effect_compressor.cpp +++ b/servers/audio/effects/audio_effect_compressor.cpp @@ -32,7 +32,7 @@ #include "servers/audio_server.h" void AudioEffectCompressorInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) { - float threshold = Math::db2linear(base->threshold); + float threshold = Math::db_to_linear(base->threshold); float sample_rate = AudioServer::get_singleton()->get_mix_rate(); float ratatcoef = exp(-1 / (0.00001f * sample_rate)); @@ -42,7 +42,7 @@ void AudioEffectCompressorInstance::process(const AudioFrame *p_src_frames, Audi float atcoef = exp(-1 / (attime * sample_rate)); float relcoef = exp(-1 / (reltime * sample_rate)); - float makeup = Math::db2linear(base->gain); + float makeup = Math::db_to_linear(base->gain); float mix = base->mix; float gr_meter_decay = exp(1 / (1 * sample_rate)); @@ -64,7 +64,7 @@ void AudioEffectCompressorInstance::process(const AudioFrame *p_src_frames, Audi float peak = MAX(s.l, s.r); - float overdb = 2.08136898f * Math::linear2db(peak / threshold); + float overdb = 2.08136898f * Math::linear_to_db(peak / threshold); if (overdb < 0.0) { //we only care about what goes over to compress overdb = 0.0; @@ -94,7 +94,7 @@ void AudioEffectCompressorInstance::process(const AudioFrame *p_src_frames, Audi } float gr = -overdb * (cratio - 1) / cratio; - float grv = Math::db2linear(gr); + float grv = Math::db_to_linear(gr); runmax = maxover + relcoef * (runmax - maxover); // highest peak for setting att/rel decays in reltime maxover = runmax; diff --git a/servers/audio/effects/audio_effect_delay.cpp b/servers/audio/effects/audio_effect_delay.cpp index ae8c58f654..f71ff05b23 100644 --- a/servers/audio/effects/audio_effect_delay.cpp +++ b/servers/audio/effects/audio_effect_delay.cpp @@ -53,13 +53,13 @@ void AudioEffectDelayInstance::_process_chunk(const AudioFrame *p_src_frames, Au float mix_rate = AudioServer::get_singleton()->get_mix_rate(); - float tap_1_level_f = base->tap_1_active ? Math::db2linear(base->tap_1_level) : 0.0; + float tap_1_level_f = base->tap_1_active ? Math::db_to_linear(base->tap_1_level) : 0.0; int tap_1_delay_frames = int((base->tap_1_delay_ms / 1000.0) * mix_rate); - float tap_2_level_f = base->tap_2_active ? Math::db2linear(base->tap_2_level) : 0.0; + float tap_2_level_f = base->tap_2_active ? Math::db_to_linear(base->tap_2_level) : 0.0; int tap_2_delay_frames = int((base->tap_2_delay_ms / 1000.0) * mix_rate); - float feedback_level_f = base->feedback_active ? Math::db2linear(base->feedback_level) : 0.0; + float feedback_level_f = base->feedback_active ? Math::db_to_linear(base->feedback_level) : 0.0; unsigned int feedback_delay_frames = int((base->feedback_delay_ms / 1000.0) * mix_rate); AudioFrame tap1_vol = AudioFrame(tap_1_level_f, tap_1_level_f); diff --git a/servers/audio/effects/audio_effect_distortion.cpp b/servers/audio/effects/audio_effect_distortion.cpp index 6820d796a4..5987ed7bb2 100644 --- a/servers/audio/effects/audio_effect_distortion.cpp +++ b/servers/audio/effects/audio_effect_distortion.cpp @@ -41,8 +41,8 @@ void AudioEffectDistortionInstance::process(const AudioFrame *p_src_frames, Audi float lpf_ic = 1.0 - lpf_c; float drive_f = base->drive; - float pregain_f = Math::db2linear(base->pre_gain); - float postgain_f = Math::db2linear(base->post_gain); + float pregain_f = Math::db_to_linear(base->pre_gain); + float postgain_f = Math::db_to_linear(base->post_gain); float atan_mult = pow(10, drive_f * drive_f * 3.0) - 1.0 + 0.001; float atan_div = 1.0 / (atanf(atan_mult) * (1.0 + drive_f * 8)); diff --git a/servers/audio/effects/audio_effect_eq.cpp b/servers/audio/effects/audio_effect_eq.cpp index 500abd3a6f..14ece8d93e 100644 --- a/servers/audio/effects/audio_effect_eq.cpp +++ b/servers/audio/effects/audio_effect_eq.cpp @@ -38,7 +38,7 @@ void AudioEffectEQInstance::process(const AudioFrame *p_src_frames, AudioFrame * EQ::BandProcess *proc_r = bands[1].ptrw(); float *bgain = gains.ptrw(); for (int i = 0; i < band_count; i++) { - bgain[i] = Math::db2linear(base->gain[i]); + bgain[i] = Math::db_to_linear(base->gain[i]); } for (int i = 0; i < p_frame_count; i++) { diff --git a/servers/audio/effects/audio_effect_limiter.cpp b/servers/audio/effects/audio_effect_limiter.cpp index 7bcd68d48b..99653cf5b6 100644 --- a/servers/audio/effects/audio_effect_limiter.cpp +++ b/servers/audio/effects/audio_effect_limiter.cpp @@ -32,11 +32,11 @@ void AudioEffectLimiterInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) { float threshdb = base->threshold; - float ceiling = Math::db2linear(base->ceiling); + float ceiling = Math::db_to_linear(base->ceiling); float ceildb = base->ceiling; - float makeup = Math::db2linear(ceildb - threshdb); + float makeup = Math::db_to_linear(ceildb - threshdb); float sc = -base->soft_clip; - float scv = Math::db2linear(sc); + float scv = Math::db_to_linear(sc); float peakdb = ceildb + 25; float scmult = Math::abs((ceildb - sc) / (peakdb - sc)); @@ -49,14 +49,14 @@ void AudioEffectLimiterInstance::process(const AudioFrame *p_src_frames, AudioFr float sign1 = (spl1 < 0.0 ? -1.0 : 1.0); float abs0 = Math::abs(spl0); float abs1 = Math::abs(spl1); - float overdb0 = Math::linear2db(abs0) - ceildb; - float overdb1 = Math::linear2db(abs1) - ceildb; + float overdb0 = Math::linear_to_db(abs0) - ceildb; + float overdb1 = Math::linear_to_db(abs1) - ceildb; if (abs0 > scv) { - spl0 = sign0 * (scv + Math::db2linear(overdb0 * scmult)); + spl0 = sign0 * (scv + Math::db_to_linear(overdb0 * scmult)); } if (abs1 > scv) { - spl1 = sign1 * (scv + Math::db2linear(overdb1 * scmult)); + spl1 = sign1 * (scv + Math::db_to_linear(overdb1 * scmult)); } spl0 = MIN(ceiling, Math::abs(spl0)) * (spl0 < 0.0 ? -1.0 : 1.0); |