Script option other than looping for performance improvement?

Post topics about HALion scripting.
Post Reply
User avatar
DodgingRain
Junior Member
Posts: 75
Joined: Tue Dec 16, 2014 4:41 am
Contact:

Script option other than looping for performance improvement?

Post by DodgingRain » Mon Nov 26, 2018 12:35 am

Greetings,
I'm running into a performance issue with one of my scripts. I have each key sampled separately for an instrument leading to a lot of zones. It works fine until I get into Halion Sonic 3 and load up 4 layers with my instrument and then tweak the knobs that are running code similar to below. I get crackles until I increase the buffer size when changing parameters in my macro designer with the knobs that have code similar to the below. Is there a more efficient way to set a parameter across all zones in a script other than doing a loop?

Code: Select all

-- remap the LFO1 cutoff depth from -100 to 100 to 0 to 100
function onParamCutoffDepthChanged()
    elements = this.program:findChildren(true)
    for i, element in ipairs(elements) do
        if type(element) == "Zone" then
 		--print(element.name)
		--print(element:getModulationMatrixRow(2).rowNumber)
	     if element:getModulationMatrixRow(2):hasParameter("Destination.Depth") then
              element:getModulationMatrixRow(2):setParameter("Destination.Depth",paramCutoffDepth)
	     end
        end
    end
end

-- remap the LFO2 pitch depth from -100 to 100 to 0 to 100
function onParamPitchDepthChanged()
    elements = this.program:findChildren(true)
    for i, element in ipairs(elements) do
        if type(element) == "Zone" then
	     if element:getModulationMatrixRow(1):hasParameter("Destination.Depth") then
              element:getModulationMatrixRow(1):setParameter("Destination.Depth",paramPitchDepth)
	     end
        end
    end
end
I hope there is a better way of doing this so I can keep the instrument running at low buffer sizes. Appreciate the advice/thoughts.
Mixing, Mastering, Remixing Services
Two Cat Audio Labs, llc
https://www.twocataudiolabs.com

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

Re: Script option other than looping for performance improvement?

Post by misohoza » Mon Nov 26, 2018 2:01 pm

Hi DodgingRain,

Does each of the layers in Halion Sonic has its own macro page and the same script?

I'm just wondering if using "this.program" is necessary. Maybe it is if you want to control all the layers from a single script module.

But I would try "findZones(true)" instead of "findChildren". This way you don't need to loop through all objects including layers, busses, effects, midi modules... You only loop through zones. It would also save you a few "ifs". You don't need to check if it is zone.

Also I don't think the line with "hasParameter" is necessary. Every zone has modulation matrix row parameter "Destination.Depth".

You can simplify the function to "findZones", "getModulationMatrixRow", "setParameter".
Depending on how many zones you have it might still not be as efficient as you'd like but worth a try.


***
Another option could be using a ui script. Create parameters with the range you want.

Code: Select all

defineParameter("destDepth1",nil,0,0,100)
defineParameter("destDepth2",nil,0,0,100)
Connect the ui script parameters to Destination.Depth parameters of the first and second modulation matrix row.

Code: Select all

@type:Zone/@id:100a0002
@type:Zone/@id:104a0002
destDepth.PNG
(37.72 KiB) Not downloaded yet
You won't be able to automate them though.
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

Post Reply

Return to “Halion Scripting”

Who is online

Users browsing this forum: No registered users and 1 guest