Copy track to buffer, copy buffer to track

Hi,

I would like to copy a track content (notes, fx,…) to a buffer/table, and then later copy contents from buffer to track again.

My questions are:

  1. Does this copy the contents of track with num “tracked” in the current pattern to the buffer or just the reference or nothing?:

local buffer = s.patterns[s.selected_pattern_index].tracks[trackid] -

  1. Does this copy contents from buffer to the track of the current pattern?

s.patterns[s.selected_pattern_index].tracks[trackid].copy_from(buffer)

  1. Is the syntax above right? I didn’t get this difference between pattern track object and track object.

Thanks for help

And 4.

Is it possible to get the xml data from a track node, like tracks[num].to_xml() ? Istracks[num] return a xml string?

If 1. is just a reference, can I duplicate the object using a standard lua recursive duplication function for objects? This would I guess only work if there were magic methods defined for each kind of object, right?

  1. Does this copy the contents of track with num “tracked” in the current pattern to the buffer or just the reference or nothing?:

local buffer = s.patterns[s.selected_pattern_index].tracks[trackid] -

  1. Does this copy contents from buffer to the track of the current pattern?

s.patterns[s.selected_pattern_index].tracks[trackid].copy_from(buffer)

  1. Is the syntax above right? I didn’t get this difference between pattern track object and track object.

Thanks for help

  1. You are creating a reference to “live” userdata (C+object), but not a new instance.

You can’t create new instances of these objects that are not tied to the song, somehow.

So, your code might do the mistake of assuming that the source pattern is still around when it’s time to copy to the target.

But, at this time the source pattern might actually be gone, or have changed somehow.

If you need to copy an entire pattern, I would recommend using a temp pattern to hold the results - so, that temp pattern essentially becomes the “buffer”

Is it possible to get the xml data from a track node, like tracks[num].to_xml() ?

If 1. is just a reference, can I duplicate the object using a standard lua recursive duplication function for objects? This would I guess only work if there were magic methods defined for each kind of object, right?

XML support in the API would be very nice to see. But right now, answer would be no :smiley:

PS: If you are planning to do recursive copies of tables, don’t forget the ‘extended’ table.rcopy method - it’s part in the Renoise API, but not standard Lua…

https://github.com/renoise/xrnx/blob/master/Documentation/Lua.Standard.API.lua#L123

Thanks for the info!

Yes, .toXML() would be a dream wouldn’t? As far as I understand, your simply could then copy any content to a variable and later insert the xml to the renoise xml song data…?

And a .revertToObject() of course :slight_smile:

One problem do I have now:

I want to make a pattern copy-paste functionality / shortcuts that takes care of track names and also works for two Renoise app instances…

Like I have opened a song in an older version in Renoise A, and a newer version of the song in Renoise B. The newer song has some additional tracks, but the naming of the old tracks is identical with the naming in the old song version.

So I would like to copy each track data (including commands + automation) to a table with track name keys and then somehow then… convert to xml ?

I think this idea won’t work by using lua for cross-instance-copying, since

  1. .copy_from() only works with a track object instance in the same app

  2. No way to transfer custom copy-buffer data?

Any ideas here?

Wouldn’t it be cool to have to more shortcuts" Pattern Editor:Pattern Operations:Copy by track names" and" Pattern Editor:Pattern Operations:Paste by track names" that would work cross-app-instance? I would set those to super-ctrl-F4 and super-ctrl-F5 then…

So I would like to copy each track data (including commands + automation) to a table

If you are copying from one song to another, how would you go about copying the automation data?

I mean, this would only work if you re-create the devices being automated in the target song as well.

Or are you somehow assuming that the two songs are identical?

no, songs would be almost identical, assuming that identical named tracks would be have identical devices. (btw i think copy paste patterns, internally the automation is already copied by device name, not by device position). Currently if copy-paste pattern, it will simply paste the tracks contents in the order of the source song. So if a new track was inserted later, the pasting doesn’t fit anymore. I would like this by track name…

…or the internal copy-paste-pattern function of Renoise should be improved that it takes care of source and target track names, instead just positions. This would not change anything while copying within one song, but improve transferring between songs! If track names/ids not match = no copying.

But I won’t write a feature request. Seems not make sense.

<?xml version="1.0" encoding="UTF-8"?>

<PatternClipboard.PatternBuffer doc_version=“0”>

**Trackname**

-1

Init
false
false
0,0,0

...