Shortlisting Filter Type via LuaScript (inc pt2: delay rates)

I recently asked for help on how to shortlist LFO Destinations via a script and I have this working perfectly. However I now wish to create another shortlist for the filter type so I copied and modified that script however it isn’t working just yet.

This is what I have so far:

local zone = this.parent:getZone()

local FilterVariation = {
{name = “Off”, index = 0},
{name = “Classic”, index = 1},
{name = “Tube Drive”, index = 2},
{name = “Hard Clip”, index = 3},
{name = “Bit Red”, index = 4},
{name = “Rate Red”, index = 5},
{name = “Rate Red KF”, index = 6},
{name = “HALion3”, index = 7},
{name = “Waldorf”, index = 8},
{name = “Eco”, index = 9},


function getFilterType()
FilterType = {}
for i = 1, #FilterType do
FilterType[i] = FilterType[i].name


function FilterTypeChanged()
zone:getFilterType:setParameter(“FilterType.FilterVariation”, FilterType[FilterVariation].index)

Note the LuaScript is called “FilterVariation” and the error received is as follows:

Syntax Error: Line 27: function arguments expected near ‘:’: zone:getFilterType:setParameter(“FilterType.FilterVariation”, FilterType[FilterVariation].index)


Hi @Mushy_Mushy ,

For this to work you need a couple of things.

You need a table with names and values. You have this done ok. That’s your FilterVariation table.

Then you need a table with only names. You could do that manually:

filterTypeNames = {"Off", "Classic", "Tube Drive"}

Or you can use a function to do that. That’s your getFilterType function.

function getFilterTypeNames()
    filterTypeNames = {} -- table for filter type names 
    for i = 1, #FilterVariation do -- length of FilterVariation table
        filterTypeNames[i] = FilterVariation[i].name -- copy the names to filterTypeNames table

Then you call that function to actually create that table with filter names.


Then you need a script parameter and its callback function.

function filterTypeChanged()
    zone:setParameter("Filter.Type", FilterVariation[FilterType].index)

defineParameter("FilterType", nil, 1, filterTypeNames, filterTypeChanged)

You use the table with names to create the script parameter. It will display the names but the actual value of the parameter is a number (integer). Then the callback function looks up the FilterVariation table. Key (which row in that table) is determined by the FilterType parameter and then it checks the index from the sub table.


You could also do it like this:

filterTypeValues = {0, 1, 2}
filterTypeNames = {"Off", "Classic", "Tube Drive"}

zone = this.parent:getZone()

function filterTypeChanged()
    zone:setParameter("Filter.Type", filterTypeValues[FilterType])

defineParameter("FilterType", nil, 1, filterTypeNames, filterTypeChanged)

While this script is shorter you need to keep track of 2 tables and make sure the values are correct in both of them.

The other solution is slightly longer but if you need ta make any changes you just change it in 1 table (FilterVariation). The rest of the code should work fine. As the names are created automatically from that table.

Hi misohoza,

This was very helpful, as always.

Thanks for taking the time to explain it so clearly and logically. I was able to step through each stage and understand what each is doing and I therefore have the filter variation working perfectly now.

I then tried to apply that logic to another script but wasn’t successful for that one.
In this I’m looking to shortlist the delay rates on the aux send Multi Delay. By way of background the Multi Delay is the fourth effect in the FX Bus (first screenshot) and is bus type Aux1 (second screenshot).



Based on the Bus section in the developer guide (Bus - HALion Script - Steinberg Developer Help) I think I have the naming correct (ie, aux1) however can’t be certain of that.

Note: I only have 3 shortlisted delay rates included in the list for now just while I test it.

delayRateValues = {0, 1, 2}
delayRateNames = {“1/64”, “1/32”, “1/16T”}

Aux1 = Effect(‘Multi Delay’)

function delayRateChanged()
Aux1:setParameter(“Delay.Rate”, delayRateValues[syncnote1])

defineParameter(“DelayRate”, nil, 1, delayRateNames, delayRateChanged)

It’s not returning any error so that’s a good sign however doesn’t seem to be connected to the Multi Delay.

That’s good. :grinning:

Whenever you use setParamater you need to address the object first. Same like you did with the zone.

zone = this.parent:getZone()

It’s the same with layers, busses, effects, midi modules. So you need to get the delay effect object first. Looking at the screenshot it will probably be:

delay = this.parent:getBus("FX Bus"):getEffect("Multi Delay")

this.parent is the parent layer of the script module. The rest is just “walking through” the program tree until you reach the object you want.

Then open the parameter list and check the name of the parameter. You can’t just make it up. It needs to be exactly as it appears in parameter list. Some parameters are grouped in folders. In that case use Folder.Parametername. Otherwise just the parameter name.

Amazing!!! Working perfectly now.

I also took the opportunity to change the naming from 4/4 to 1/1, 8/4 to 2/1, etc.

I have one more script remaining before the build is done and then only the recording of samples is left :partying_face: