[Solved] .copy_device_chain_at(track_index1, track_index2) ???

Is there any easy way to copy a complete device chain from one track to another track?

It would be nice to have this:

1. renoise.song().copy_device_chain_at(track_index1, track_index2)

&

2. renoise.song().tracks[].device[]:copy_from(other device of other track)

Note: with device[i] would be possible to iterate to copy the entire device chain of the desired track, for example: for i = 1, max_number_devices do.Thus, it might be possible to discard some devices of the selection as well, checking the type of device with a if … then.

Existing related documentation:

-- Insert a new device at the given position. "device_path" must be one of
-- renoise.song().tracks[].available_devices.
renoise.song().tracks[]:insert_device_at(device_path, device_index)
  -> [newly created renoise.AudioDevice object]
-- Delete an existing device in a track. The mixer device at index 1 can not
-- be deleted from a track.
renoise.song().tracks[]:delete_device_at(device_index)
-- Swap the positions of two devices in the device chain. The mixer device at
-- index 1 can not be swapped or moved.
renoise.song().tracks[]:swap_devices_at(device_index1, device_index2)

-- Access to a single device by index. Use properties 'devices' to iterate 
-- over all devices and to query the device count.
renoise.song().tracks:device(index)
  -> [renoise.AudioDevice object]

My intention is simple. Being able to copy the entire device chain from one track to another track, and if possible, have some flexibility.It would include in a button for cloning entire track (which I have already built).

Any idea to do this?

Nope, not a track-wide copy function. The API is expecting you to iterate through, and copy each device, one by one.

However, it gets (a lot!) more tricky if you’re using meta-devices, as they can link to other devices - even devices outside the source track.

My xrni-merger tool contains code, which can identify such “networks” (multiple chains linked together with meta-devices) and can recreate the network in a different place.

Would be cool (actually, is planned) to extract this functionality and include it in the xLib library as a one-liner.

Nope, not a track-wide copy function. The API is expecting you to iterate through, and copy each device, one by one.

However, it gets (a lot!) more tricky if you’re using meta-devices, as they can link to other devices - even devices outside the source track.

My xrni-merger tool contains code, which can identify such “networks” (multiple chains linked together with meta-devices) and can recreate the network in a different place.

Would be cool (actually, is planned) to extract this functionality and include it in the xLib library as a one-liner.

Thanks!I would like to have a function that could also prevent the meta-devices (or not), have some control with the function.What I do not know is what code line you can use to copy a device from one track to another. In the documentation there does not seem to be such a thing.

Is it also necessary to store in a cache or something the parameters of each device in order to copy or duplicate it? Or is there a form of pure copy?

What I do not know is what code line you can use to copy a device from one track to another. In the documentation there does not seem to be such a thing.

You can use the ‘active_preset_data’ for this purpose.

As a reference, you can see how I’m doing it in the xrni-merger:

https://github.com/renoise/xrnx/blob/master/Tools/com.renoise.Xrni-Merger.xrnx/main.lua#L1784

You can use the ‘active_preset_data’ for this purpose.

As a reference, you can see how I’m doing it in the xrni-merger:

https://github.com/renoise/xrnx/blob/master/Tools/com.renoise.Xrni-Merger.xrnx/main.lua#L1784

Thanks! Ok,I’ll look at it in depth.Let’s see if I understood correctly: ’ active_preset_data’ are the configuration values of the individual selected devide, or all the values of the entire chain?Or is it something else?

Click to view contents
--------------------------------------------------------------------------------
-- renoise.AudioDevice
--------------------------------------------------------------------------------
-------- Functions
-- Access to a single preset name by index. Use properties 'presets' to iterate 
-- over all presets and to query the presets count.
renoise.song().tracks[].devices[]:preset(index)
  -> [string]
-- Access to a single parameter by index. Use properties 'parameters' to iterate 
-- over all parameters and to query the parameter count.
renoise.song().tracks[].devices[]:parameter(index)
  -> [renoise.DeviceParameter object]

-------- Properties
-- Devices.
renoise.song().tracks[].devices[].name
  -> [read-only, string, device identifier]
renoise.song().tracks[].devices[].display_name, observable 
  -> [string, custom name]
renoise.song().tracks[].devices[].is_active, _observable
  -> [boolean, not active = bypassed]
renoise.song().tracks[].devices[].is_maximized, _observable
  -> [boolean]
renoise.song().tracks[].devices[].active_preset, _observable
  -> [number, 0 when none is active or available]
renoise.song().tracks[].devices[].active_preset_data
  -> [string, raw serialized data in XML format of the active preset]
renoise.song().tracks[].devices[].presets[]
  -> [read-only, array of strings]
renoise.song().tracks[].devices[].is_active_parameter
  -> [read-only, renoise.DeviceParameter object]
renoise.song().tracks[].devices[].parameters[]
  -> [read-only, array of renoise.DeviceParameter objects]
-- Returns whether or not the device provides its own custom GUI (only 
-- available for some plugin devices)
renoise.song().tracks[].devices[].external_editor_available
  -> [read-only, boolean]
-- When the device has no custom GUI an error will be fired (see
-- external_editor_available), otherwise the external editor is opened/closed.
renoise.song().tracks[].devices[].external_editor_visible
  -> [boolean, true to show the editor, false to close it]
  
-- Returns a string that uniquely identifies the device, from "available_devices".
-- The string can be passed into: renoise.song().tracks[]:insert_device_at()
renoise.song().tracks[].devices[].device_path
  -> [read-only, string]

Ok, doubts resolved!! :smiley:

Thanks!

This is a crude function for clone the device chain in next track:

function clone_devices( song, sti, devices, device_path )
  song = renoise.song()
  sti = song.selected_track_index
  devices = #song.tracks[sti].devices
  
  --rprint (song.tracks[sti].available_devices)

  for dev = 1, devices do
    device_path = song.tracks[sti]:device( dev ).device_path
    if ( dev > 1 ) then
      song.tracks[sti + 1]:insert_device_at( device_path, dev )
    end
    song.tracks[sti + 1].devices[dev].active_preset_data = song.tracks[sti].devices[dev].active_preset_data
  end
end

If exist a problem with meta-devices, it would be possible to discard the device number inside the iterate.This is possible to insert inside a button for cloning entire track.

I suppose there is something similar to be able to clone the automation curves.I have created a multibutton with these characteristics:

  1. Principal button for clone track (without notes)
  2. A minibutton-checkbox for clone the notes to pattern-track
  3. A minibutton-checkbox for clone the notes to entire track
  4. A minibutton-checkbox for clone the entire device chain
  5. A minibutton-checkbox for clone the automation to pattern-track
  6. A minibutton-checkbox for clone the automation to entire track

Possible estructure:

[2] | | [5] | |

| 1 | | 4 |

[3] | | [6] | |

I still need to create the functions for buttons 5 and 6.