Creating Multiple Parameters

Post topics about HALion scripting.
Post Reply
AposMus
Junior Member
Posts: 196
Joined: Fri Nov 14, 2014 11:41 am
Contact:

Creating Multiple Parameters

Post by AposMus » Wed Mar 01, 2017 10:20 am

I have 4 controllers in 3 rows I wanted linked to the relevant layer QCs. The 4 controllers do exactly the same thing on each layer, so I thought this is a good time to use loops to create the parameters and change call.

This script does work:

My question is, is this a good way of doing it. I'm worried that the nested for loops and using a single change function for all 12 parameters is bad practice / bad for CPU usage.

One "end)" is moved to the next line in the code display, so it looks a bit funny.

Code: Select all

masterLayer = this.parent:getLayer()
noiseLayers = masterLayer:findLayers()

	-- Modulation parameter names and controllers

modSetup = {
	{name = "pitch", 				control = "QuickControl.QC3"},
	{name = "toPitchEnv", 			control = "QuickControl.QC4"},
	{name = "pitchLfoDepth",			control = "QuickControl.QC6"},
	{name = "filtLfoDepth",			control = "QuickControl.QC7"},
	{name = "volLfoDepth",			control = "QuickControl.QC8"}
	}

	-- Create modulation parameters

modSetupNames = {}

for i = 1, #modSetup do
	modSetupNames[i] = modSetup[i].name
end

for i, noiseLayer in ipairs(noiseLayers) do
   for j, modSetupName in ipairs(modSetupNames) do
      local paramName = noiseLayer.name.." "..modSetupName
      defineParameter(paramName, nil, 0, -50, 50, 0.1, function() modChange(i, j, _G[paramName]) end)
   end
end

	-- Modulation change call

modSetupControls = {}

for i = 1, #modSetup do
	modSetupControls[i] = modSetup[i].control
end

function modChange(layer, param, modVal)
	local modLayer = noiseLayers[layer].name
	local modParam = modSetupControls[param]
	masterLayer:getLayer(modLayer):setParameter(modParam, modVal + 50)
end
Cubase Pro 8.5.2
Halion 6
HSO
Padshop Pro
Dark Planet

Matthias Klag
Steinberg Employee
Posts: 36
Joined: Sat Feb 23, 2013 9:33 am

Re: Creating Multiple Parameters

Post by Matthias Klag » Thu Mar 02, 2017 5:34 pm

Hi AposMus,

since the loop for defineParameter is only called during the initalization of your script, I see no reason why you shouldn't do so.

Please notice that all the things you do with the quick controls, could also be done with the script. But, that's up to you, of course.

Cheers,

Matthias
Matthias Klag - HALion Developer
Steinberg Media Technologies GmbH
Hamburg, Germany
Checkout Steinberg on YouTube, Twitter and Facebook!

AposMus
Junior Member
Posts: 196
Joined: Fri Nov 14, 2014 11:41 am
Contact:

Re: Creating Multiple Parameters

Post by AposMus » Mon Mar 06, 2017 11:10 pm

Thanks.

The quick controls are used because I started making this as a sound in Halion 5 so they where my only option at the time.

When I heard Halion 6 is coming, I stopped working on the program to see what new features could be used to improve it. I didn't want to undo all my QC connections, but for some of the functions I think it might be beneficial to do so.

I'm putting a lot of work into a very, very simple instrument, but it has become more important to me to learn how to do things correctly, rather than push something out for the sake of having it.
Cubase Pro 8.5.2
Halion 6
HSO
Padshop Pro
Dark Planet

Post Reply

Return to “Halion Scripting”

Who is online

Users browsing this forum: No registered users and 1 guest