I’m trying to copy lines from one pattern to another. Everything works fine until I’ve got track with four or more columns. In such case only first three columns are copied, but not the 4th on.
First I’ve tried following Lua approach:
local song = renoise.song()
local srcLines = song.patterns[self.patterValueBox.value + 1].tracks[i].lines
local destLines = song.selected_pattern.tracks[i].lines
local stepPitch = #srcLines / self.numSteps
for x = (j - 1) * stepPitch + 1, j * stepPitch - 1 do
print(x)
if val then
destLines[x]:copy_from(srcLines[x])
else
destLines[x]:clear()
end
end
I’ve also tried to copy values directly as workaround, but having same issues (only first three columns copied):
local song = renoise.song()
local srcLines = song.patterns[self.patterValueBox.value + 1].tracks[i].lines
local destLines = song.selected_pattern.tracks[i].lines
local stepPitch = #srcLines / self.numSteps
for x = (j - 1) * stepPitch + 1, j * stepPitch - 1 do
print(x)
if val then
for k,nc in ipairs(srcLines[x].note_columns) do
print(k)
--destLines[x].note_columns[k]:copy_from(nc)
destLines[x].note_columns[k].note_value = nc.note_value
destLines[x].note_columns[k].instrument_value = nc.instrument_value
destLines[x].note_columns[k].volume_value = nc.volume_value
destLines[x].note_columns[k].delay_value = nc.delay_value
destLines[x].note_columns[k].panning_value = nc.panning_value
end
else
destLines[x]:clear()
end
end
I’m encountering this behaviour in Renoise 2.8.0 and 2.8.1 on Mac.
No it gives me 1 2 3 4 … 12, but the assign statement takes effect only for first three columns.
You can easily replicate this if you try to copy note in 4th columns (or whole line with note in 4th column) from one pattern to another either like this
local srcLines = renoise.song().patterns[1].tracks[1].lines
local destLines = renoise.song().selected_pattern.tracks[1].lines
destLines[1]:copy_from(srcLines[1])
I cannot replicate this behaviour, because these statements don’t even run. Say “function arguments expected…”
My guess is that, since your trying to invoke ‘copy_from’ on a casual array instead of renoise objects, this fails.
e.g. I tried this line
and it worked entirely as expected copying the 4 note line from line #00 (in gui) to #12 (in gui) perfectly.
One more thing that you are using; whenever you know the pattern number, track number, line number or other try to use the function instead of array index; ie
rs:pattern(1):track(1):line(1)
gives zillion times faster (dermatologically tested) readout then
rs.patterns[1].tracks[1].lines[1]
EDIT; pardon me, those lines do run. And copy all 4 notes.
rzo’s original code snippet worked for me, after I took a few moments to guess and fill in the missing variables/objects.
His “you can easily replicate this” code snippet also worked fine.
As an added sanity check, I wrote some new code myself to do the same thing in a slightly different way, and that also simply worked.
Seems like there’s something else at play here, but I have no idea what. Perhaps another chunk of code in rzo’s script (that we cannot see) is to blame?
This works for me flawlessly also… Could you put this below in your TestPad.lua and execute? (Oh, and have more than three columns of data in pattern 1 track 1 line 1)
local rs = renoise.song()
local sp = rs.selected_pattern
local st = sp:track(1)
local sl = st:line(1)
local dp = rs.selected_pattern
local dt = dp:track(2)
local dl = dt:line(1)
dl:copy_from(sl)
If this doesn’t work even on test pad, then it’s really something very, very bizarre you’ve ran into.
Thanks for your help! I finally realized that the problem is actually in loop boundaries, than in disfuncitonal copy_from. As the boundary didn’t contain last line, it didn’t copy note in forth slot in my case, my stupid mistake…
Anyway thanks for helpful replies, really appreciate it!