Removing dotted/triplet LFO rates via Lua script

I am trying to create a Lua script to disable dotted and triplet rates from LFO1 so that only 1/8, 1/16, 1/32 etc remain. The second part to this will be assigning a button to the bypass parameter of the script to reenable them should the user wish. The second part is easy and it’s only the script itself I’m having issue with.

misohoza kindly helped me with one relating to another function so I copied and then started to edit that. Essentially I was simply renaming where logical but without much confidence that it would actually work.

Am I on the right track though? I don’t think the LFO is considered a MIDI module though right? Instead that section should read get Zone1(“LFO1”)?

You are right, zone lfo is not a midi module.

So instead of lfo midi module you need to address the zone object. This can be something like:

local zone = this.parent:getZone()

That is if the zone is in the same layer as the script module.

Lfo doesn’t have 8 variations like flexphraser so you only need one temposcale parameter. The tempoScaleChanged function can also be simplified a bit.

function tempoScaleChanged()
    zone:setParameter("LFO 1.RateSync", Frequency[TempoScale].index)
end

defineParameter("TempoScale", nil, 4, tempoScaleNames, tempoScaleChanged)

Great, thanks misohoza. This is how it currently looks and there is no error showing, however it isn’t affecting the LFO at all. I can confirm the LFO is indeed in the same layer as the script.

When you say the LFO doesn’t have 8 variations I assume the local Frequency naming/index remains because it’s in this section we define what stay and what goes.

Also, I’m unsure what the 4 in define parameter is denoting.

local zone = this.parent:getZone()

local Frequency = {
{name = “1/64”, index = 0},
{name = “1/32”, index = 1},
{name = “1/16”, index = 3},
{name = “1/8”, index = 6},
{name = “1/4”, index = 9},
{name = “1/2”, index = 12},
{name = “4/4”, index = 15},

}

function tempoScaleChanged()
zone:setParameter(“LFO 1.RateSync”, Frequency[TempoScale].index)
end

for i = 1, 7 do
defineParameter(“TempoScale”, nil, 4, tempoScaleNames, tempoScaleChanged)

end

Do you use a Mono LFO midi module or do you want this to affect the zone LFO? In this case LFO 1.

You don’t need the “for” loop when defining the parameter. It doesn’t hurt anything but it makes no sense. You just re-define the same parameter 7 times.

The number 4 is just the default value for the parameter.

I’m flexible on whether I use a Mono LFO midi module or zone LFO, however I currently have it configured using zone LFO.

Re “for” loop: yes, that’s what I thought however when removing it I receive the following error.

image

It seems straightforward enough and is requesting another “end” be entered at the end of line 20 however that isn’t it.

local zone = this.parent:getZone()

local Frequency = {
{name = “1/64”, index = 0},
{name = “1/32”, index = 1},
{name = “1/16”, index = 3},
{name = “1/8”, index = 6},
{name = “1/4”, index = 9},
{name = “1/2”, index = 12},
{name = “4/4”, index = 15},

}

function tempoScaleChanged()
zone:setParameter(“LFO 1.RateSync”, Frequency[TempoScale].index)
end

defineParameter(“TempoScale”, nil, 4, tempoScaleNames, tempoScaleChanged)

end

Although removing the “end” above that one clears the error.

However, still doesn’t affect the LFO though unfortunately.

local zone = this.parent:getZone()

local Frequency = {
{name = “1/64”, index = 0},
{name = “1/32”, index = 1},
{name = “1/16”, index = 3},
{name = “1/8”, index = 6},
{name = “1/4”, index = 9},
{name = “1/2”, index = 12},
{name = “4/4”, index = 15},

}

function tempoScaleChanged()
zone:setParameter(“LFO 1.RateSync”, Frequency[TempoScale].index)

defineParameter(“TempoScale”, nil, 4, tempoScaleNames, tempoScaleChanged)

end

I think it’s interesting I have no parameters defined in the paramslist. That has to be the issue:

If you try like this?

local zone = this.parent:getZone()

local Frequency = {
    {name = "1/64", index = 0},
    {name = "1/32", index = 1},
    {name = "1/16", index = 3},
    {name = "1/8", index = 6},
    {name = "1/4", index = 9},
    {name = "1/2", index = 12},
    {name = "4/4", index = 15},
}

function getTempoScaleNames()
    tempoScaleNames = {}
    for i = 1, #Frequency do
        tempoScaleNames[i] = Frequency[i].name
    end
end

getTempoScaleNames()

function tempoScaleChanged()
    zone:setParameter("LFO 1.RateSync", Frequency[TempoScale].index)
end

defineParameter("TempoScale", nil, 4, tempoScaleNames, tempoScaleChanged)

It should work for zone LFO 1.

1 Like

Fantastic. Thank-you!!!

Working perfectly now.