Page tree
Skip to end of metadata
Go to start of metadata
fade(noteID, startValue, targetValue, duration, killVoice)

Description

Function to fade the volume of a specific note. The fade is performed from the start to the target value with the specified duration in milliseconds and affects all voices that are triggered by the note. You can start a fade from the current value of a running fade by setting the start value to nil. You can kill the triggered voices if the target value is reached by setting killVoice to true. The fade is applied in addition to any changes from changeVolume, changeVolumedB and changeNoteExpression.

If you start a fade from the current value of a running fade that has not reached its target value yet, the duration of this fade will be shorter. See the second example below for details.

Available in: Processor.

Arguments

noteIDThe ID of the note you want to fade.number
startValueThe start value of the fade in the range of 0 to 1.0. Set this to nil to start the fade from the current value of a running fade.number or nil
targetValueThe target value of the fade in the range of 0 to 1.0.number
durationThe length of the fade in milliseconds. The target value is set instantaneously if this is set to <= 0.number
killVoiceSet this to true to kill the note when the target value reached. The default is false.boolean

Examples

-- simple fade out with kill voice
function onNote(event)
    id = playNote(event.note, 100, 0) -- the fades affect all voices that are triggered by this note
    fade(id, nil, 0.0, 1000, true)    -- start to fade out
end
function onRelease(event)
    -- postEvent(event), eat the release
end
-- play note, then fade out and in and kill the triggered voices
function onNote(event)
  id = playNote(event.note, 100, 0)	-- the fades affect all voices that are triggered by this note
  fade(id, 1.0, 0.0, 1000)          -- start to fade out
  wait(500)                         -- wait for 500 ms, which is only half of the fade out
  fade(id, nil, 1.0, 1000, true)    -- the fade in is only 500 ms long, because it has to go only half of the way
end

function onRelease(event)
    -- postEvent(event), eat the release
end

2 Comments