-
Hello there, I am trying to make a modulator for an FM synth, this means ratios with decimal values. I created a Fixed sliders from the actual shown value. That is fine. What I'm wondering is, is it possible to have a lua script run once you click on the number that can process whatever the user has written? I see there are plenty of function when mouse is up or down, but this does not (I think) work in my scenario. Or is there an alternative for me to obtain fractional modulator values? Cheers For reference this is how I populated the fixed slider values:
|
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 31 replies
-
Beta Was this translation helpful? Give feedback.
-
Oh I didn't know it didn't have any effect (I mean I kinda realized but was not sure). And yeah that is why I'm using fixed slider for, also cause I have two different step sizes for values <0. I was just wondering for the actual typing in values. Thanks for the website but I was already using table.concat() in the code to do that, also because based on a button the values will change (ratio or fixed frequency). Anyway I guess for now it just won't be possible to type in values to change the slider value and that is it, thank you very much for the quick replies! |
Beta Was this translation helpful? Give feedback.
-
I don't think you can put statements in the expression box. you would need to do it via a LUA script. here is the note from the source code for expressions :
|
Beta Was this translation helpful? Give feedback.
-
This was difficult. I created a copy of the table that this function accesses, which is a reverse of your table I think this must be inefficient (creating three tables of the same data). Would be interesting to find a more elegant solution, but it works as far as I can tell and it is quite a useful feature. I can see why you wanted to implement this. init (constructor)init = function(--[[ CtrlrInstance --]] type) values = {} -- Define the start value, end value, and step local start_value = 0.500 local end_value = 1 local step = 0.005 -- Fill the table with values from 0.500 to 0.995 for value = start_value, end_value, step do table.insert(values, string.format("%.3f", value)) end --Define the new start value, end value, and step local start_value = 1 local end_value = 32 local step = 0.01 -- Fill the table with values from 1 to 31.99 for value = start_value, end_value, step do table.insert(values, string.format("%.2f", value)) end -- Concatenate the strings of values with newline characters local concatenatedStrings = table.concat(values, "\n") panel:getComponent("fader"):setProperty("uiFixedSliderContent", concatenatedStrings, false) for i, v in ipairs(values) do reverse[v] = i - 1 end proxy = {} for k, v in pairs(reverse) do proxy[k] = v end end Find nearest value in table and update modulatormeta = {} meta.__index = function(t, k) k = tonumber(k) local rec, value = 0, 0 local r = proxy for key, v in pairs(r) do if math.abs(k - key) < math.abs(k - rec) then rec = key value = v end end t[k] = value return t[k] end meta.__call = function(t, k) return t[k] end reverse = setmetatable({}, meta) uiLabel callbackupdateFader = function(--[[ CtrlrLabel --]] label --[[ String --]], newContent) if panel:getBootstrapState() then return end if USERENTRY then if type(tonumber(newContent)) ~= "number" then utils.warnWindow("Illegal Input", "Please enter valid number") return end local x = reverse(newContent) panel:getModulatorByName("fader"):setModulatorValue(x, false, true, false) USERENTRY = false end end |
Beta Was this translation helpful? Give feedback.
-
Here is version 2.0 which writes the |
Beta Was this translation helpful? Give feedback.
-
Can you show me visually what you are trying to achieve? It sounds like you want the value to be in the middle of the If there’s a problem with overlap, there is a solution. But it would involve |
Beta Was this translation helpful? Give feedback.
-
Here is solution using The modulator |
Beta Was this translation helpful? Give feedback.
Here is version 2.0 which writes the
uiSlider
value to theuiLabel
.yamaha slider devur_2_0.zip