If you are interested, this tool was designed to work in conjunction with my autocapture tool which in most scenarios speeds this up further as the target instrument is already selected for you. This fits my workflow of “one instrument only” per track.
I am not too sure if this is possible to get the selection in a pattern. I just check the API docs and could not find anything obvious. I will go and ask in Q+A.
edit: just found this and adding link here as a personal reference.
It is possible. I do it in NotesRandomizer. The thread you linked is about moving the selection block around. Here’s a a simpler example snippet:
-- Toggle this variable accordingly
local constrain_to_selected = true
-- Define iter, Can be any valid iterator, does not matter which one example:
-- renoise.song().pattern_iterator:lines_in_pattern(renoise.song().selected_pattern_index)
local iter = nil
for pos,line in iter do
for cur_col,note_col in ipairs(line.note_columns) do
if
(
not constrain_to_selected or
constrain_to_selected and note_col.is_selected
)
then
-- Do something here
end
end
end
The procedure revolves around theconstrain_to_selected boolean.