From 0eee953a79e8ee8deb86b9ec2ff18dbbf3afb11e Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Tue, 30 Apr 2024 08:52:23 +0200 Subject: Generate pitch parameter when unit is Hz. --- faust2axo.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/faust2axo.py b/faust2axo.py index 71a6078..7a65001 100755 --- a/faust2axo.py +++ b/faust2axo.py @@ -32,18 +32,27 @@ def process_sliders(xml): inlets = "" params = "" output = "" - sliders = xml.findall(".//ui/activewidgets/widget[@type='hslider']") - for slider in sliders: - attributes = slider.attrib - varname = slider.find("varname").text - label = slider.find("label").text - max = slider.find("max").text + widgets = xml.findall(".//ui/activewidgets/widget[@type='hslider']") + for widget in widgets: + varname = widget.find("varname").text + label = widget.find("label").text + max = widget.find("max").text + maybe_unit = widget.find("meta[@key='unit']") + pitch = isinstance(maybe_unit, ET.Element) and maybe_unit.text == "Hz" + + if pitch: + param_type = "frac32.s.map.pitch" + else: + param_type = "frac32.s.map" inlets += f"\n" - params += f"\n" + params += f"<{param_type} name=\"{label}\" />\n" # TODO: summation and conversion based on type - output += f"int32_t {label} = mtof48k_ext_q31(param_{label} + inlet_{label});\n" + if pitch: + output += f"uint32_t {label} = mtof48k_ext_q31(param_{label} + inlet_{label});\n" + else: + output += f"uint32_t {label} = param_{label} + inlet_{label};\n" output += f"mdsp.{varname} = fminf(1.0f, q27_to_float({label})) * {max};\n" return (inlets, params, output) -- cgit v1.2.3