diff --git a/templates/web-demo/src/index.html b/templates/web-demo/src/index.html index 01c7cd0..cc01d37 100644 --- a/templates/web-demo/src/index.html +++ b/templates/web-demo/src/index.html @@ -63,6 +63,33 @@ function unmap(index, value) { return p.map == "logarithmic" ? Math.log(value / p.minimum) / (2.0 * Math.log(Math.sqrt(p.maximum * p.minimum) / Math.abs(p.minimum))) : (value - p.minimum) / (p.maximum - p.minimum); } +var units = { + "bar": "bars", + "beat": "beats", + "bpm": "BPM", + "cent": "ct", + "cm": "cm", + "coef": "", + "db": "dB", + "degree": "deg", + "frame": "frames", + "hz": "Hz", + "inch": "\"", + "khz": "kHz", + "km": "km", + "m": "m", + "mhz": "MHz", + "midiNote": "MIDI note", + "mile": "mi", + "min": "mins", + "mm": "mm", + "ms": "ms", + "oct": "octaves", + "pc": "%", + "s": "s", + "semitone12TET": "semi" +}; + var initState = 0; // 0 = not inited, 1 = in progress, 2 = inited window.addEventListener("load", function (e) { @@ -96,7 +123,8 @@ window.addEventListener("load", function (e) { var value = document.createElement("span"); value.setAttribute("id", "v" + i); - value.innerText = parameters[i].defaultValue; + var u = parameters[i].unit; + value.innerText = parameters[i].defaultValue + (u in units ? " " + units[u] : ""); var range = document.createElement("input"); range.setAttribute("type", "range"); @@ -121,7 +149,8 @@ window.addEventListener("load", function (e) { var p = node.parameters.get(parameters[index].name); var val = map(index, e.target.value); p.setValueAtTime(val, 0); - v.innerText = val; + var u = parameters[index].unit; + v.innerText = val + (u in units ? " " + units[u] : ""); }); }