- 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] -
- Does this copy contents from buffer to the track of the current pattern?
- Is the syntax above right? I didn’t get this difference between pattern track object and track object.
Thanks for help
- 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
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…