summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2024-04-30 08:52:23 +0200
committerRicardo Wurmus <rekado@elephly.net>2024-04-30 08:52:23 +0200
commit0eee953a79e8ee8deb86b9ec2ff18dbbf3afb11e (patch)
treed50545a229773b337e794c920ff923bb5740e31e
parent8941255c4344c0de5d29cd735e5eeb1d018371af (diff)
Generate pitch parameter when unit is Hz.
-rwxr-xr-xfaust2axo.py25
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)