Modifying an Bus Effect Filter Shape Menu


I’m attempting to modify the list in the Filter Shape Menu in the Morph filter. I feel like my code is pretty close but after I connect the parameter to a menu on the macro page I get the error “attempt to index a nil value”…Comparing it to other lists that work especially the Filter Type menu, I’m not sure what I’m doing wrong…any idea?

-- define the filter types
mffilterTypes = {
				{ name = "HP6", 					  index = 1 },
				{ name = "HP12", 				  index = 2 },
				{ name = "HP18", 			  index = 3 },
				{ name = "HP24", 			  index = 4 },

-- create table with the names of the filter types
function getmfFilterTypeNames()
	mffilterTypeNames = {}
	for i=1, #mffilterTypes do
		mffilterTypeNames[i] = mffilterTypes[i].name


-- parameter change callbacks for the filter parameters
function onmfFilterTypeChanged()
	local morphFilter = this.parent:getBus(15):getEffect("Morph Filter")
	morphFilter:setParameter("typeFilterB", mffilterTypes[mfFilterType].index)

-- define parameters for the filter section
defineParameter("mfFilterType", 	  "mfFilter Type", 	 1, mffilterTypeNames, 	onmfFilterTypeChanged)

As always, Thanks!

Most likely cause of the error is that it didn’t find the bus. If the getBus() returns nil and you try to use the getEffect() it gives you error. Does the parent layer of the script module have 15 busses?

You can also use findEffects() without specifying the bus.


Also the filter type parameter minimum value is 0 not 1. So you probably want to change your index values in your mffilterTypes table.

Apart from that the script should work fine.

Thanks for your quick reply and your help! I finally got the script to work. And the “15” in the getBus(15) was a typo when I pasted in here. Originally when I was working the script it was “1”. Either way, I omitted the getBus() function and just used the getEffect() as you recommended and it worked fine.

Thanks again!