Page 1 of 1

Default values of the default macro/connect parameters?

Posted: Sat Feb 18, 2017 8:19 pm
by ggc

So.. When one connects "default" parameters to stuff on the macro page:

Where can we define what the default value is? - ctrl+clicking on some default parameters makes them jump to a value of 50...

Cant we define the "default value" somewhere?

(Yes, it is possible with the defineParameter.... But.....only numbers so far (for me) without some table or so... Sooo... If one wants to directly connect a knob with values of 1/2, 1/8t , etc, it would be nice to simply be able to set a default value somewhere?)

Thanks for your help:)

(OT- Nice would also be to perform jumps from a-> c ->f instead of going a>b>c>d>e>f) - but thats still cloudy too)

Re: Default values of the default macro/connect parameters?

Posted: Mon Feb 20, 2017 3:44 pm
by Matthias Klag

Here is an example for you. Anima uses only a subset of the filter types. Legacy filter types like HALion 3 or Waldorf are not used.

Below, you find script code how to do this. I copied this code from the "Anima" script module.

Code: Select all

-- define the filter types
filterTypes = {
				{ name = "Tube", 					  index = 2 },
				{ name = "Hard Clip", 				  index = 3 },
				{ name = "Bit Reduction", 			  index = 4 },
				{ name = "Rate Reduction", 			  index = 5 },
				{ name = "Rate Reduction Key Follow",      index = 6 },

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

-- parameter change callback
function onFilterTypeChanged()
    this.parent:getZone():setParameter("Filter.Type", filterTypes[FilterType].index)

-- define parameters for the filter section
defineParameter("FilterType", 	  "Filter Type", 	 1, filterTypeNames, onFilterTypeChanged)
Here is the basic idea behind this:
  • filterTypes is an array that contains one table for each filter type. Each of these tables has the keys name and index with the desired values.
  • The function getFilterTypeNames creates the table "filterTypeNames" by reading the names from the filterTypes table. filterTypeNames is used as the strings table in defineParameter.
  • The change callback "onFilterTypeChanged" uses setParameter. The correct value is read from the index field of the filterTypes table.
This might look complicated, but the advantage is that if you change the table filterTypes, the rest of your code will still work.