Changing parameter increments

Hey, I’m writing a bit of code that has me perplex on what I could be doing wrong. My goal is to Simple make the modmatrix depth move by whole numbers. I admit I’m a novice coder but I try anyway. I wrote this. It doesn’t give me any sort of error but it also doesn’t seem to move any parameter. A little help please.

--Modulation whole number values
zone1=this.parent:getZone("Synth")

function onModAmountChange()
	AmountChange = wholenumber

   zone1:setParameter("Mod 1.Depth", AmountChange)

end
defineParameter("01ModAmount", "01ModAmount", 0, -100, 100, 1, onModAmountChange)

Hi abject39.

There are couple of issues with your script.

Within your function you want to set parameter “Mod 1.Depth”, such parameter doesn’t exist unless you create it. The “AmountChange” is nil because you never assigned any value to it. To access the modulation matrix parameters you need to use getModulationMatrixRow()
Your parameter “01ModAmount”, it’s probably not a good idea to have a parameter name start with a number. I would do it other way around. (“ModAmount01”)

Do you want to do this for a specific modulation row or for all of them? What if the destination is pitch. Do you still want to use the range of -100/+100 ?


You can try this. It should work for first modulation row.

--Modulation whole number values
zone1=this.parent:getZone("Synth")

function onModAmountChange()
  zone1:getModulationMatrixRow(1):setParameter("Destination.Depth", ModAmount1)
end

defineParameter("ModAmount1", "ModAmount1", 0, -100, 100, 1, onModAmountChange)

Or if you want you can create several parameters at once using loop.

--Modulation whole number values
zone1=this.parent:getZone("Synth")

for i=1,8 do
  defineParameter("ModAmount"..i, nil, 0,-100,100,1, function() onModAmountChange(i) end)
end

function onModAmountChange(i)
  zone1:getModulationMatrixRow(i):setParameter("Destination.Depth",_G["ModAmount"..i])
end

Thank you so very much! Clearly I have a lot to learn when it comes to coding. I try to write it but thus far modifying what already exist seems to what I’m best at. I can read it and mostly understand it but I guess I’m just not there yet.

So, I took that code and changed it up to change the increments on the ADSR but I ran into a new issue. The defined parameter literally goes from 0 to 100. My goal was to convert the original -100 to 100 to 0-100 (instead it gave me half the range) so that the end user didn’t see negative numbers. Do you know what function I can use to convert this?

--ADSR for Amplitude Enevelope
print ("ADSR AMPlitude Envelope +++++++++++++++++++++++++++")

--Convert AMP Attack incrments
zone1=this.parent:getZone("Synth")

function onAmpAttackChange()
  zone1:setParameter(200, AmpAttack)
end

defineParameter("AmpAttack", "AmpAttack", 50, 0, 100, 1, onAmpAttackChange)

--Convert AMP Decay incrments
zone1=this.parent:getZone("Synth")

function onAmpDecayChange()
  zone1:setParameter(201, AmpDecay)
end

defineParameter("AmpDecay", "AmpDecay", 50, 0, 100, 1, onAmpDecayChange)

--Convert AMP Sustain incrments
zone1=this.parent:getZone("Synth")

function onAmpSustainChange()
  zone1:setParameter(202, AmpSustain)
end

defineParameter("AmpSustain", "AmpSustain", 50, 0, 100, 1, onAmpSustainChange)

Multiply by 2 minus 100

zone1=this.parent:getZone("Synth")

function onAmpAttackChange()
  zone1:setParameter(200, AmpAttack*2-100)
end

defineParameter("AmpAttack", "AmpAttack", 50, 0, 100, 1, onAmpAttackChange)

This should change the amp attack offset -100/+100% in 2% steps.

This worked completely but I have to ask one question… How? I just don’t quite understand how this math worked. For example “-100*2-100= -300”. How does this manage to work perfectly when defined? I just don’t seem to grasp it. Sorry to bug but as a novice eager to learn as much as possible, I can’t help but to ask.

Your script parameter doesn’t have negative values.

Minimum value: 02-100=-100
Default value: 50
2-100=0
Max value: 100*2-100=100

Well that makes sense lol. Thanks!