Page tree
Skip to end of metadata
Go to start of metadata

insertBus(bus, position)

Description

Function to insert a bus at the specified position in the destination layer. The bus to be inserted is determined by its Bus object. You can use getBus or findBusses to determine the bus. The destination layer is determined by its Layer object. For example, this.parent sets the parent layer of the script module as destination layer. The position is the number indexing the existing busses in the destination layer. The new bus will be inserted before the specified position. To add the bus at the end, use appendBus instead.

An Element object can only have one parent. It cannot be child of multiple parents. Therefore, an Element object 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

busThe Bus object of the bus that you want to insert.Bus
positionThe position where the bus is inserted.number

Example

To explore the following script:

  1. Download Program.vstpreset.
  2. Drag the preset on the MediaBay to import it to the user folder for VST presets.
  3. Create an empty program and add a script module.
  4. Paste the script into the text editor of the script module and execute the script.

 

-- insert bus from Program.vstpreset into the current program
 
-- get the file path for user VST presets
path = getUserPresetPath()
 
-- load VST preset
loadedProgram = loadPreset(path.."/Program/Program.vstpreset")
 
-- get the first bus from the loaded program
bus = loadedProgram:getBus()
 
-- insert bus
if bus then
    this.program:insertBus(bus, 1)
end

3 Comments

  1. To Sabine Pfeifer

    Several changes. Please proof read again. Thanks!