Filmstrip knob value display
-
Hi all,
I know this has been covered before, but I could not make any sense from previous posts. I am trying to pull out values from filmstrip knobs and display them on a label. However, it does not seem to connect. I tried to customise similar code posted before and adapt it to my needs. I would appreciate if someone could take a look and provide some guidance, as my coding skills are far from from good. :D Also, i would like to know how to display time values from delay speed (e.g. 1/4, 1/2 etc.). Please see below the code, and see if you could help with it. Much appreciated. :)
// [/JSON Knob] const var ReverbRoomSize = Content.addKnob("ReverbRoomSize", 558, 58); // [JSON Knob] Content.setPropertiesFromJSON("ReverbRoomSize", { "text": "ReverbRoomSize", "width": 56, "height": 57, "min": 0, "max": 1, "stepSize": 0.01, "processorId": "Reverb 12", "parameterId": "RoomSize", "filmstripImage": "{PROJECT_FOLDER}SmallKnob128frames.png", "numStrips": "128" }); // [/JSON Knob] inline function onReverbRoomSizeControl(component, value) { Label.set("text", ReverbRoomSize.getValue()); }; ReverbRoomSize.setControlCallback(onReverbRoomSizeControl); const var Label = Content.addLabel("Label", 30, 50); // [JSON Label] Content.setPropertiesFromJSON("Label", { "editable": false, "saveInPreset": false }); // [/JSON Label]
-
Hi,
the code you posted works, but it's ugly:
- Don't use these autogenerated JSON blobs. They are so 2017 :)
- You need to somehow process the raw value, or it will look ugly on the label. The function
Engine.doubleToString()
was added for exact this purpose. - Did you check out the value popup feature? It does something similar and requires no coding plus it shows the correct value including suffixes and tempo names.
-
Thanks, @Christoph-Hart for your reply.
As i mentioned before, I am new to all this. :) I managed to make it work, it now connects to the FX module and displays number values. But what if i would want to display TimeSync values, such as 1/4, 1/2, 1/8 etc? This is the code I ended up with:
// const var room = Content.addKnob("room", 558, 58); // [/JSON room] Content.setPropertiesFromJSON("room", { "text": "RevRoom", "width": 56, "height": 57, "min": 0, "max": 1, "filmstripImage": "{PROJECT_FOLDER}SmallKnob128frames.png", "numStrips": "128" }); // [/JSON room] const var Reverb = Synth.getEffect("Reverb 12"); inline function onroomControl(component, value) { local v = Engine.doubleToString(value, 2); Reverb.setAttribute(Reverb.RoomSize, value); roomLabel.set("text", v); }; room.setControlCallback(onroomControl); const var roomLabel = Content.addLabel("roomLabel", 28, 105); // [JSON roomLabel] Content.setPropertiesFromJSON("roomLabel", { "saveInPreset": false, "editable": false, "multiline": false }); // [/JSON roomLabel]
-
Worth mentioning that the TimeSync value that is displayed on a label would also have to change between ms and time signature values on "SynctoHost" button control.