Can't set LFO MidiModule in a ModMatrix slot (with list script)

Hi, I hope someone can help me… I tried everything, but without success. I am sure the problem is in the function to get the lfo3. Thanks in advance.

-- MATRIX SOURCES MENU

function assignLfo3(source)
  local lfo3 = this.parent:getMidiModule("LFO3OSC")
  if lfo3 then
    setSource(source, ModulationSource.modulationModule, lfo3)
  else
    setSource(source, ModulationSource.unassigned)
  end
  end

SourcesType={

  {name="Off",   index=0},
  {name="LFO1",   index=1},
  {name="LFO2",   index=2},
  {name="LFO3",   assignFunc = assignLfo3},

}

function getSourceTypeNames()
  SourceTypeNames={}
  for i=1,#SourcesType do
    SourceTypeNames[i]=SourcesType[i].name
  end
end

getSourceTypeNames()

last = {}

function SourceTypeChanged()
  this:setParameter('MatrixSourceDest', SourceType)
end

defineParameter("SourceListParam",nil,1,SourceTypeNames,SourceTypeChanged)

function MatrixSourceDestChanged()
  this.parent:getLayer("Core"):getLayer("OSC Zone"):getZone("OSC Zone"):getModulationMatrixRow(5):setParameter("Source1.Source",SourcesType[MatrixSourceDest].index)
end

defineParameter("MatrixSourceDest",nil,1,SourceTypeNames,MatrixSourceDestChanged)

Hi @FedericoS

Your assignLfo3 function isn’t called anywhere in the script. Apart from that you should use setSource1 function instead as some of the modulation sources require additional info.

setSource1 - HALion 7.0.0 (steinbergmedia.github.io)

There are several ways how to do this. You could try something like this:

-- MATRIX SOURCES MENU
lfo3 = this.parent:getMidiModule("LFO3")
assert(lfo3, "Missing LFO3")

SourcesType={
	{name = "Off",	polarity = 0,	source = ModulationSource.unassigned},
	{name = "LFO1",	polarity = 1,	source = ModulationSource.lfo1},
	{name = "LFO2", polarity = 1,	source = ModulationSource.lfo2},
	{name = "LFO3", polarity = 1,	source = ModulationSource.modulationModule, sourceInfo1 = lfo3, sourceInfo2 = 1},
}

function getSourceTypeNames()
	SourceTypeNames={}
	for i=1,#SourcesType do
		SourceTypeNames[i]=SourcesType[i].name
	end
end

getSourceTypeNames()

function MatrixSourceDestChanged()
	local row = this.parent:getLayer():getLayer():getZone():getModulationMatrixRow(5)
	local source = SourcesType[MatrixSourceDest]
	row:setSource1(source.source, source.sourceInfo1, source.sourceInfo2)
	row:setParameter("Source1.Polarity", source.polarity)
end

defineParameter("MatrixSourceDest", nil, 1, SourceTypeNames, MatrixSourceDestChanged)

MM LFO.vstpreset (8.8 KB)

Hi @misohoza ,
Thanks you very much. It works perfectly!

I try to ask you an “upgrade”… maintaining this type of code, is it possible to have 3 “disable” parameters for each LFO. I would like only the selected LFO to be visible, the others hided by disable template connected to this parameter. Probably I will also add some rows in the future, I would like it will work independently of the selected row.