Page 1 of 1

Creating a unit when defining a parameter.

Posted: Sun Jan 07, 2018 4:14 am
by abject39
Bare with me. I'm a novice programmer. There are several places throughout my interface where I would like to define a custom unit. I'm having trouble understanding how this can be done. The manual shows that unit is a parameter definition but it doesn't show how to define a unit on the creating parameters page. I assume I may be doing this wrong by trying to define the unit within the parameter definition. For example if I create a parameter for panning...

Code: Select all

Zone=this.parent:getZone("Synth")

function onOsc1PanChange()
  Zone:setParameter(3932163, Osc1Pan)
end

defineParameter("Osc1Pan", "Osc1Pan", 0, -100, 100, 1, onOsc1PanChange)
This will indeed give me a working parameter for pan displaying -100 to 100. Now, what if I also want units to go from L to C to R as it moves like a typical pan pot would? I could create...

Code: Select all

function onPanLCRChange()
    if Osc1Pan<=0
        UnitValue1=L
    elseif Osc1Pan>=0
        UnitValue1=R
    else
        UnitValue1=C
    end
The question is how do I plug this second function in so that the defined parameter displays both the set parameter function and the unit function?

Re: Creating a unit when defining a parameter.

Posted: Sun Jan 07, 2018 7:26 pm
by misohoza
Hi abject39,
The manual shows that unit is a parameter definition but it doesn't show how to define a unit on the creating parameters page.
I don't think you can define a unit when creating a parameter as they seem to be read only.
Most knob templates let you define Unit if you want something like Hz, dB, % to be displayed next to the value of your parameter.

With your pan example you could create the parameter using Parameter Definition. This lets you "clone" an existing parameter and its behaviour.
Downside is you can't modify the min, max, default... At least not easily. But if you're happy with how the parameter works this can be a good solution.

Code: Select all

Zone=this.parent:getZone("Synth")

function onOsc1PanChange()
  Zone:setParameter(3932163, Osc1Pan)
end

defineParameter("Osc1Pan", "Osc1Pan", this.parent:getParameterDefinition("Pan"), onOsc1PanChange)

What you are were trying to do could also work. Maybe try something like this:

Code: Select all

Zone=this.parent:getZone("Synth")

function onOsc1PanChange()
  Zone:setParameter(3932163, Osc1Pan)
  if Osc1Pan == 0 then
    Osc1PanDisplay = "C"
  elseif Osc1Pan > 0 then
    Osc1PanDisplay = "R"..tostring(Osc1Pan)
  else
    Osc1PanDisplay = "L"..tostring(math.abs(Osc1Pan))
  end
end

defineParameter("Osc1Pan", "Osc1Pan", 0, -100, 100, 1, onOsc1PanChange)
defineParameter("Osc1PanDisplay", nil, "")

onOsc1PanChange()
You need to edit macro page knob template for this to work. Connect Osc1Pan to the knob and Osc1PanDisplay to the text field displaying the value of the parameter.

Image

Re: Creating a unit when defining a parameter.

Posted: Mon Jan 15, 2018 3:46 am
by abject39
Thanks! I was hoping there was an alternate way besides making secondary displays. I guess not. I appreciate the help.