Linking Multiple LFO Sync Rates via Scripting

Post topics about HALion scripting.
Post Reply
rmjmusic
New Member
Posts: 26
Joined: Thu Jan 04, 2018 3:22 am
Contact:

Linking Multiple LFO Sync Rates via Scripting

Post by rmjmusic » Thu Apr 12, 2018 2:46 am

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 (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
Cubase Pro 9.5
HALioin 6
Windows 10 Pro 64bit

rmjmusic
New Member
Posts: 26
Joined: Thu Jan 04, 2018 3:22 am
Contact:

Re: Linking Multiple LFO Sync Rates via Scripting

Post by rmjmusic » Thu Apr 12, 2018 11:46 pm

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

Code: Select all

-- 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
Cubase Pro 9.5
HALioin 6
Windows 10 Pro 64bit

rmjmusic
New Member
Posts: 26
Joined: Thu Jan 04, 2018 3:22 am
Contact:

Re: Linking Multiple LFO Sync Rates via Scripting

Post by rmjmusic » Fri Apr 13, 2018 12:36 am

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
Cubase Pro 9.5
HALioin 6
Windows 10 Pro 64bit

misohoza
Member
Posts: 867
Joined: Sun Oct 05, 2014 12:18 am
Contact:

Re: Linking Multiple LFO Sync Rates via Scripting

Post by misohoza » Fri Apr 13, 2018 12:49 am

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)

Code: Select all

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:

Code: Select all

rateDef = this.parent:getMidiModule("lfo1"):getParameterDefinition("RateSync")
print(rateDef.min, rateDef.max)
Apart from that the script should work fine.
Win 10 Home, 64 bit, 8 gb ram,
Cubase Pro 9, Wavelab Pro 9, Halion 6, Dorico,
NI Komplete 10 Ultimate, Ozone 7,
UR 44

rmjmusic
New Member
Posts: 26
Joined: Thu Jan 04, 2018 3:22 am
Contact:

Re: Linking Multiple LFO Sync Rates via Scripting

Post by rmjmusic » Fri Apr 13, 2018 1:01 am

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 ( :/ ).

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

As always, thanks!

rmjmusic
Cubase Pro 9.5
HALioin 6
Windows 10 Pro 64bit

Post Reply

Return to “Halion Scripting”

Who is online

Users browsing this forum: No registered users and 1 guest