Page 1 of 1

Multisample/Zone selector or dropdown?

Posted: Tue May 02, 2017 10:49 am
by MarcoScherer
Hi guys,

is it possible to include a multisample or zone selector within a preset or layer? I want to design a simple instrument that enables the user to combine two multisamples, that he selects from a given bunch.

Thanks,
Marco

Re: Multisample/Zone selector or dropdown?

Posted: Tue May 02, 2017 4:40 pm
by misohoza
Hi Marco.

I was trying to do something similar.
I still don't know how to make the sample selector to work (macro page template from Studio Strings).

But I managed to create a menu that lets me load a layer preset within a program.
viewtopic.php?f=268&t=114073

Re: Multisample/Zone selector or dropdown?

Posted: Tue May 02, 2017 6:41 pm
by MarcoScherer
Thanks, I'll check that. Maybe it gives an idea...

Re: Multisample/Zone selector or dropdown?

Posted: Tue May 23, 2017 12:36 pm
by MarcoScherer
Today I managed to create dropdowns for existing layers that contains multisamples (or other zones). Thought I share it with you. Find the code below.

My program contains TWO main layers which contains SUB layers, which finally represent multisamples. The script searches for the TWO main layers and then adds their SUB layers into corresponding dropdowns. When the user selects an instrument from the layers, all others get muted.

Code: Select all

function muteLayers(layers)
	if layers[1] then
	    for i, layer in ipairs(layers) do
		   layer:setParameter("LayerMute", true)
	    end
		layers[1]:setParameter("LayerMute", false)
	end
end


function onLayerSelectChanged(parameter, layers)
   if layers[1] then
       for i, layer in ipairs(layers) do
		   layer:setParameter("LayerMute", true)
       end
   end
   
   s = this:getParameter(parameter)
   layers[s]:setParameter("LayerMute", false)
end


-- Find all layers
mainLayers = getElement():findLayers(false)
syntheticLayers = mainLayers[1]:findLayers(false)
traditionalLayers = mainLayers[2]:findLayers(false)
muteLayers(syntheticLayers)
muteLayers(traditionalLayers)

-- Prepare option arrays
synthLayersArray = {}
for i, layer in ipairs(syntheticLayers) do
	synthLayersArray[i] = layer.name
end
defineParameter("syntheticOptions", nil, 1, synthLayersArray, function() onLayerSelectChanged("syntheticOptions", syntheticLayers) end)

tradiLayersArray = {}
for i, layer in ipairs(traditionalLayers) do
	tradiLayersArray[i] = layer.name
end
defineParameter("traditionalOptions", nil, 1, tradiLayersArray, function() onLayerSelectChanged("traditionalOptions", traditionalLayers) end)