diff options
author | Volker Fischer <corrados@users.noreply.github.com> | 2023-05-03 17:23:12 +0200 |
---|---|---|
committer | Volker Fischer <corrados@users.noreply.github.com> | 2023-05-03 17:23:12 +0200 |
commit | d08840a61f405bc89e730c0cef51537e89e6dbb5 (patch) | |
tree | f1778d811f863fd45acb57f24af34491ea9a83d4 | |
parent | c69ebdce624393d4ff23fdbce6856065eff9f6a8 (diff) |
replace sqrt scaling of normalized input velocity by a curve function similar to what is implemented in Edrumulus
-rw-r--r-- | src/inputprocessor.cc | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/inputprocessor.cc b/src/inputprocessor.cc index a15c9c1..f0b2935 100644 --- a/src/inputprocessor.cc +++ b/src/inputprocessor.cc @@ -298,9 +298,12 @@ auto target_max_power_db = 10 * log10(instr->getMaxPower()); auto sel_power_db = 10 * log10(sample->getPower()); auto target_dynamic_db = 40.0; // dB -auto target_power_db = sqrt(event.velocity) * target_dynamic_db + target_max_power_db - target_dynamic_db; -auto diff_power_db = target_power_db - sel_power_db; -event_sample.scale = pow(10.0, diff_power_db / 20); +static auto a = 0.981; +static auto factor = 126.0f / (pow(a, 126.0f) - 1.0f); +auto y = (factor * (pow(a, event.velocity * 127.0f - 1.0f) - 1.0f) + 1.0f) / 127.0f; +auto target_power_db = y * target_dynamic_db + target_max_power_db - target_dynamic_db; +auto diff_power_db = target_power_db - sel_power_db; +event_sample.scale = pow(10.0, diff_power_db / 20); //printf("event_sample.scale: %f, diff_power_db: %f, target_power_db: %f, sel_power_db: %f\n", event_sample.scale, diff_power_db, target_power_db, sel_power_db); |