/ HALion Developer Resource / HALion Script / Reference /
insertEffect
insertEffect(effect, position)
Description
Function to insert an effect at a specific position in a destination bus. The effect to be inserted is determined by its Effect object. You can use getEffect or findEffects to determine the effect. The destination bus is determined by its Bus object. You can use getBus or findBusses to determine the destination bus. The position is the number indexing the effects in the destination bus. The new effect will be inserted before the specified position. To add the effect at the end, use appendEffect instead.
❕ An Element object can only have one parent. It cannot be child of multiple parents. Therefore, an Element object that you retrieved from the running plug-in instance must be removed before it can be inserted again. The Element objects that you retrieve through loadPreset or loadPresetAsync can be inserted freely, because these functions create a copy of the Element objects when reading them.
Available in: Controller.
Arguments
Argument | Description | Value Type |
---|---|---|
effect | The element object of the effect that you want to insert. | Effect |
position | The position where the effect is inserted. | number |
Example
To explore the following script:
- Download Program.vstpreset.
- Drag the preset on the MediaBay to import it to the user folder for VST presets.
- Create an empty program and add a script module.
- Paste the script into the text editor of the script module and execute the script.
-- Insert an effect from Program.vstpreset into the current program.
-- Get the file path for user VST presets.
path = getUserPresetPath()
-- Load the VST preset.
loadedProgram = loadPreset(path.."/Program/Program.vstpreset")
-- Get the first effect from the loaded program.
effect = loadedProgram:getBus():getEffect()
-- Get the first bus of this program.
bus = this.program:getBus()
-- Insert the effect.
if (effect and bus) then
bus:insertEffect(effect, 1)
end
See also: insertBus, insertLayer, insertLayerAsync, insertMidiModule, insertZone, Effect