Creating Multiple Parameters

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.

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

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

	-- Modulation change call

modSetupControls = {}

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

function modChange(layer, param, modVal)
	local modLayer = noiseLayers[layer].name
	local modParam = modSetupControls[param]
	masterLayer:getLayer(modLayer):setParameter(modParam, modVal + 50)

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.




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.