diff options
-rwxr-xr-x | faust2axo.py | 25 |
1 files 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"<frac32 name=\"{label}\" />\n" - params += f"<frac32.u.map name=\"{label}\" />\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) |