Creating a unit when defining a parameter.

Post topics about HALion scripting.
Post Reply
User avatar
abject39
Member
Posts: 317
Joined: Sat Jan 17, 2015 8:20 pm
Location: Ventura, Ca
Contact:

Creating a unit when defining a parameter.

Post by abject39 » Sun Jan 07, 2018 4:14 am

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?
My vision is uncompromising: to transcend my clients dreams by mesmerizing their audience with the world's finest audio arrangements and products.

misohoza
Member
Posts: 860
Joined: Sun Oct 05, 2014 12:18 am
Contact:

Re: Creating a unit when defining a parameter.

Post by misohoza » Sun Jan 07, 2018 7:26 pm

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
Win 10 Home, 64 bit, 8 gb ram,
Cubase Pro 9, Wavelab Pro 9, Halion 6, Dorico,
NI Komplete 10 Ultimate, Ozone 7,
UR 44

User avatar
abject39
Member
Posts: 317
Joined: Sat Jan 17, 2015 8:20 pm
Location: Ventura, Ca
Contact:

Re: Creating a unit when defining a parameter.

Post by abject39 » Mon Jan 15, 2018 3:46 am

Thanks! I was hoping there was an alternate way besides making secondary displays. I guess not. I appreciate the help.
My vision is uncompromising: to transcend my clients dreams by mesmerizing their audience with the world's finest audio arrangements and products.

Post Reply

Return to “Halion Scripting”

Who is online

Users browsing this forum: No registered users and 1 guest