From 17edbab002193267092145035bed70178247be3a Mon Sep 17 00:00:00 2001 From: gregrecco67 <127459177+gregrecco67@users.noreply.github.com> Date: Fri, 16 Aug 2024 09:10:44 -0400 Subject: [PATCH] correctly handle 0 --- scripts/convert-presets.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/convert-presets.py b/scripts/convert-presets.py index ad1a09c..16dd79a 100644 --- a/scripts/convert-presets.py +++ b/scripts/convert-presets.py @@ -10,14 +10,18 @@ def process_xml_file(file_path): uid = elem.get('uid') if uid and uid.startswith("osc") and "volume" in uid: gain = elem.get('val') - if gain and float(gain) >= 0.0: + if gain and float(gain) > 0.0: db_value = 20 * log10(float(gain)) elem.set('val', str(db_value)) + if gain and float(gain) == 0.0: + elem.set('val', "-40.0"); if uid and uid.startswith("env") and "sustain" in uid: sustain = elem.get('val') - if sustain and float(sustain) >= 0.0: + if sustain and float(sustain) > 0.0: db_value = 20 * log10(float(sustain)/100.0) elem.set('val', str(db_value)) + if sustain and float(sustain) == 0.0: + elem.set('val', "-40.0"); tree.write(file_path) def main(directory):