noteTone = {} noteLength = {} noteLine = {} noteColumn = {} lineValues = song.selected_pattern.tracks[trackId].lines local columns = song.tracks[trackId].visible_note_columns for c = 1, columns do for s = 1, steps do local note = lineValues[s].note_columns[c].note_value if note < 120 then --120 is off, 121 is empty table.insert(noteTone, note) table.insert(noteLine, s) table.insert(noteColumn, c) end end end
For accessing some song values there is a faster way than the standard table indexing:
-- Access to a single line by index. Line must be [1-MAX_NUMBER_OF_LINES]).
-- This is a !lot! more efficient than calling the property: lines[index] to
-- randomly access lines.
renoise.song().patterns[].tracks[]:line(index)
-> [renoise.PatternLine]
It is a method call so it uses the colon operator and curved parenthesis. You also lose the s , so
tracks becomes :track ()
lines becomes :line ()
columns becomes :column ()
etc.
So for your code above it becomes:
(see changes lines 7,9,13)
noteTone = {}
noteLength = {}
noteLine = {}
noteColumn = {}
lineValues = song.selected_pattern:track(trackId).lines --.tracks[] changed to :track() method
local columns = song:track(trackId).visible_note_columns --.tracks[] changed to :track() method
for c = 1, columns do
for s = 1, steps do
local note = lineValues[s]:note_column(c).note_value --.note_columns[] changed to :column() method
if note < 120 then --120 is off, 121 is empty
table.insert(noteTone, note)
table.insert(noteLine, s)
table.insert(noteColumn, c)
end
end
end
Should add some speed boost.