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

clone(object)

Description

Function to create a copy of the specified object. If you want to modify an object, and you want to keep the original object, you can clone the object before modifying it. The allowed objects are BusEffectEvent, LayerMidiModuleProgram and Zone. Event objects can be cloned in the processor or the controller thread. All other objects can only be cloned in the controller thread.

Available in: Controller, Processor.

Arguments

eventThe object to be cloned. The allowed objects are BusEffectEvent, LayerMidiModuleProgram and Zone.object

Return Values

Returns a copy of the specified object.

Example

-- create a copy of the event and transpose it
function onNote(event)
    eventCopy = clone(event)
    eventCopy.note = event.note + 12
    local id = postEvent(eventCopy)
    waitForRelease()
    releaseVoice(id)
end
-- create a copy of the program
function cloneProgram()
  local prg = this.parent
  assert(type(prg) == 'Program')
  local copy_prg = clone(prg)
  assert(type(copy_prg) == 'Program')
  assert(#(copy_prg:findZones(true)) == #(prg:findZones(true)))
end

cloneProgram()


1 Comment