Linking Multiple LFO Sync Rates via Scripting

Hi all,

I’ve got an instrument with multiple LFOs but I want to control the frequency rate of each with one knob. I’ve seen this post (https://www.steinberg.net/forums/viewtopic.php?f=269&t=121026) about how to script multiple parameters to one knob. I’ve tried implementing this into my script changing the necessary but my script is falling flat.

One thing I know I can’t be doing right is the defineparameter, where I need to specify the default, min, max, and increments. I need to make these reflect a note rate (like 1/64,64/4,1/4). But I can’t get this to respond correctly.

Help? I’ll be more than happy to elaborate and clarify.

Thanks,
rmjmusic

Here is the script I’ve been working with if this helps clarify where I’m at:

-- define the filter types
defineSlotLocal("ratesyncTypes")
ratesyncTypes = {
				{ name = "1/64", 		index = 1 },
				{ name = "1/32", 		index = 2 },
				{ name = "1/16T", 		index = 3 },
				{ name = "1/16", 		index = 4 },
				{ name = "1/8T", 		index = 5 },
				{ name = "1/16D", 		index = 6 },
				{ name = "1/8", 		index = 7 },
				{ name = "1/4T", 		index = 8 },
				{ name = "1/8D", 		index = 9 },
				{ name = "1/4", 		index = 10 },
				{ name = "1/2T", 		index = 11 },
				{ name = "1/4D", 		index = 12 },
				{ name = "1/2", 		index = 13 },
				{ name = "1/1T", 		index = 14 },
				{ name = "1/2D", 		index = 15 },
				{ name = "4/4", 		index = 16 },
				{ name = "5/4", 		index = 17 },
				{ name = "6/4", 		index = 18 },
				{ name = "7/4", 		index = 19 },
				{ name = "8/4", 		index = 20 },
				{ name = "16/4", 		index = 21 },
				{ name = "32/4", 		index = 22 },
				{ name = "64/4", 		index = 23 }
			  }

-- create table with the names of the ratesync types
function getRatesyncTypeNames()
	ratesyncTypeNames = {}
	for i=1, #ratesyncTypes do
		ratesyncTypeNames[i] = ratesyncTypes[i].name
	end
end

getRatesyncTypeNames()

-- parameter change callbacks for the ratesync parameters
function onRatesyncTypeChanged()
	this.parent:getMidiModule(lfo1):setParameter("RateSync", ratesyncTypes[RatesyncType].index)
	this.parent:getMidiModule(lfo2):setParameter("RateSync", ratesyncTypes[RatesyncType].index)
	this.parent:getMidiModule(lfo3):setParameter("RateSync", ratesyncTypes[RatesyncType].index)
	this.parent:getMidiModule(lfo4):setParameter("RateSync", ratesyncTypes[RatesyncType].index)

end

defineParameter("RatesyncType", 	  "Rate Sync Type", 	 1, ratesyncTypeNames, 	onRatesyncTypeChanged)

Thanks,
rmjmusic

Nvm, I got it to work. Just changed what was in the parenthesis of the getMidiModule function to the number of the midi module from the name of the midi module and it worked.

Thanks,
rmjmusic

Hi rmjmusic,

The getMidiModule function accepts string or number as optional arguments. Most likely you are missing quotation marks.
(Unless lfo1 is a variable which has a string or a number assigned to it)

this.parent:getMidiModule("lfo1"):setParameter("RateSync", ratesyncTypes[RatesyncType].index)

Assuming you have four mono lfos named lfo1, lfo2 … it should work.

I think the index numbers for the actual values of the rateSync parameter should start at 0 so you get the range of 0 to 22.
You can quickly check this like this:

rateDef = this.parent:getMidiModule("lfo1"):getParameterDefinition("RateSync")
print(rateDef.min, rateDef.max)

Apart from that the script should work fine.

Hi Misohoza,

Thanks for your reply.
You’re right. I just got this working a few minutes ago with the numbers. However, after reading your comment, if I wanted to use the name of the lfos I realized I did forget to put it in quotations ( :confused: ).

And thank you for correcting me on the index numbers! I didn’t notice that.

As always, thanks!

rmjmusic