Page tree
Skip to end of metadata
Go to start of metadata
removeEnvelopePoint(envelopeArray, index)

Description

Function to remove an envelope point from the specified envelope. You specify the envelope by calling getParameter with the EnvelopePoints parameter of the desired envelope as argument. If you call getParameter with the EnvelopePoints parameter as argument, an array with the current envelope points will be returned. Each index of the array represents an envelope point with the fields .level.duration and .curve. The removeEnvelopePoint function modifies this array. To apply the changes, you must use setParameter with the EnvelopePoints parameter of the envelope as argument and the array as value.

Available in: Controller, Processor.

Arguments

envelopeArrayAn array with envelope points. Each index of the array represents an envelope point with the fields .level, .duration and .curve. To obtain the envelope array of an envelope, use getParameter with the EnvelopePoints parameter of the desired envelope as argument.table
indexThe index of the point to be removed.number

Example

 -- reset the amplitude envelope
 
-- default envelope times in seconds
attack = 0
decay = 1
sustain = 1
release = 1
 
zone = this.program:getZone()
 
-- get the envelope points of the amplitude envelope
ampEnvPoints = zone:getParameter("Amp Env.EnvelopePoints")
ampSustainPoint = zone:getParameter("Amp Env.SustainIndex")
 
-- set the envelope points to 4
while #ampEnvPoints > 4 do
    removeEnvelopePoint(ampEnvPoints, #ampEnvPoints)
end

while #ampEnvPoints < 4 do
    insertEnvelopePoint(ampEnvPoints, #ampEnvPoints, 0, 1, 0)
end
 
-- adjust the position of the sustain point
ampSustainPoint = #ampEnvPoints - 1
 
-- set first point
ampEnvPoints[1].level = 0
ampEnvPoints[1].duration = 0
ampEnvPoints[1].curve = 0
 
-- set second point
ampEnvPoints[2].level = 1
ampEnvPoints[2].duration = attack
ampEnvPoints[2].curve = 0
 
-- set third point
ampEnvPoints[3].level = sustain
ampEnvPoints[3].duration = decay
ampEnvPoints[3].curve = 0
 
-- set fourth point
ampEnvPoints[4].level = 0
ampEnvPoints[4].duration = release
ampEnvPoints[4].curve = 0
 
-- set the envelope points of the amplitude envelope
zone:setParameter("Amp Env.EnvelopePoints", ampEnvPoints)
zone:setParameter("Amp Env.SustainIndex", ampSustainPoint)

See Also: insertEnvelopePoint

1 Comment