how to convert renoise.song().selected_track to a string in order to be able to send it to a table, please?
These are native Lua functions existing, from the back of my head:numtostring? I have used these functions in several of my scripts. (E-Arpeggio for starters)
I suppose you mean the track object. Object serialization sounds hazardous. Try searching for lua object data dump. Perhaps a different approach is better for what you want to accomplish?
i meant renoise.song().selected_track_index
or renoise.song().selected_line_index
im not sure how to approach tables at all, to be honest. i’m trying to find a way of selecting the next 4, next 8, next 16, 32, 64, 128, 256, 512 rows below the cursor. or a way of detecting “max current pattern line amount” so one could make a script which selects the current track’s contents, and then detects if the current track’s contents are selected and selects the whole pattern.
and yes, “select current track” / " select whole pattern" are ALT-L and ALT-L *2 in ST3/IT2/Schism
and “select by LPB” / “then double the selected amount” is ALT-D in that tracker. it could be easily used so that one just keeps pressing ALT-D, first time it selects 4, then 8, then 16, then multiples of that.
the api makes it possible, but i dont understand tables at all.
i tried to do a “if table == (table content) then table = (table content2)” type stuff but i just couldn’t figure it out… at all.
I don’t think you should use any tables for that. You will need a function with a couple of conditions and calculations, doing different things to renoise.song().selection_in_pattern depending on what’s already in there. I could write you the snippet if you like.
well, see, i thought i need to use tables, because the tables are called like this:
renoise.song().selection_in_pattern = {
start_line=1,
end_line=4,
start_track=1,
end_track=1,
start_column=1,
end_column=2}
So since I didn’t really know how to talk to it, I just ended up making that. tried creating “local tables” or something and calling them, but then just realized… that… i must be doing something truly properly wrong…
What is interesting there is start_line and end_line. You need to double the difference between them.
Step 2 is to make an “intelligent” enough workaround for detecting when a completely new selection is intended (probably resetting a global variable acting as a multiplier/power).
Then I guess you want to implement editstep as well?
Nope, editstep is not used. (at least in trying to write an alt-d / alt-L emulation. editstep might be used somewhere else, tho, in another script, far far away)
the trick is to utilize one shortcut to run multiple things. i think the simplest would be to figure out how to read “number of lines in current pattern” and change it into a string, or a number value, that can be directly input into the end_line amount. i tried putting in end_line=max but of course that didn’t work.
end_line=renoise.song().* also does not work. so tables seem to be a different deal as to, for instance, renoise.app().show_status being capable of displaying both text and numbers like selected_track_index directly.
We’re on IRC but for reference:
renoise.song().selection_in_pattern = {
start_line=1,
end_line=renoise.song().selected_pattern.number_of_lines,
start_track=renoise.song().selected_track_index,
end_track=renoise.song().selected_track_index,
start_column=1,
end_column=2}
works.
Okay I must admit, I don’t know what I did wrong. joule helped set me straight, and this does work:
function hmmhem()
renoise.song().selection_in_pattern = {
start_line=renoise.song().selected_line_index,
end_line=renoise.song().selected_line_index+3,
start_track=renoise.song().selected_track_index,
end_track=renoise.song().selected_track_index,
start_column=1,
end_column=2}
end
also,
so does this:
function hmmhem()
local end_liner = renoise.song().selection_in_pattern.end_line
renoise.song().selection_in_pattern = {
start_line=renoise.song().selected_line_index,
end_line=end_liner*2,
start_track=renoise.song().selected_track_index,
end_track=renoise.song().selected_track_index,
start_column=1,
end_column=2}
end
now just need to figure out how to reset iit if start_line is not selected_line_index
Yeah, you will have to do some maths there Doubling the difference of end_line and start_line
Google if you’re encountering trouble with arithmetic precedence. gn!
edit#4:
okay, didn’t yet really start working with ALT-D (Quick mark n/2n/4n/… lines (n=Row Higlight Major), but ALT-L (Mark entire column /pattern) does now work, thanks to heaps of help from joule + snowrobot!
function MarkTrackMarkPattern()
local st=nil
local et=nil
local sl=nil
local el=nil
local s=renoise.song()
if s.selection_in_pattern ~= nil then
st = s.selection_in_pattern.start_track
et = s.selection_in_pattern.end_track
sl = s.selection_in_pattern.start_line
el = s.selection_in_pattern.end_line
if st == et and st == s.selected_track_index then
if sl == 1 and el == renoise.Pattern.MAX_NUMBER_OF_LINES then
s.selection_in_pattern = {
start_track = 1,
end_track = s.sequencer_track_count,
start_line=1,
end_line=renoise.Pattern.MAX_NUMBER_OF_LINES
}
else
s.selection_in_pattern = {
start_track = st,
end_track = et,
start_line = 1,
end_line = renoise.Pattern.MAX_NUMBER_OF_LINES
}
end
else
s.selection_in_pattern = {
start_track = s.selected_track_index,
end_track = s.selected_track_index,
start_line = 1,
end_line = renoise.Pattern.MAX_NUMBER_OF_LINES
}
end
else
s.selection_in_pattern ={
start_track = s.selected_track_index,
end_track = s.selected_track_index,
start_line = 1,
end_line = renoise.Pattern.MAX_NUMBER_OF_LINES}
end
end
renoise.tool():add_keybinding {name = "Global:Paketti:Mark Track / Mark Pattern", invoke = function() MarkTrackMarkPattern() end}
now to bed & hopefully ALT-D can be worked out next:)