as long as there eventually are results, I wont hold it against you
Here’s a start. I’m too lazy to package this as a Tool. “Can’t someone else do it? -Homer Simpson” Also, consider changing the shortcut from “For Jonas” to something else.
I reread what Jonas wrote. I have a bad habit of posting crap before actually thinking it through. The code is a bit different than when I started. To use:
-
- Select an Instrument
-
- Click/Shortcut “For Jonas”
The script will look in the cursor’s note column for two matching instruments for which the cursor is the center, change the Edit Step value, and update the Status Bar.
Enjoy?
[luabox]
function main()
local rns = renoise.song()
local my_iter = rns.pattern_iterator:lines_in_pattern_track(rns.selected_pattern_index, rns.selected_track_index)
local my_col = rns.selected_note_column_index
local my_line = rns.selected_line_index
local my_inst = rns.selected_instrument_index
local start = -1
local finish = -1
for pos,line in my_iter do
local col = line.note_columns[my_col]
if col and not col.is_empty then
if pos.line < my_line and col.instrument_value + 1 == my_inst then
start = pos.line
elseif col.instrument_value + 1 == my_inst then
finish = pos.line
break
end
end
end
my_inst = string.upper(string.format("%02x", my_inst - 1))
if start ~= -1 and finish ~= -1 then
rns.transport.edit_step = finish - start
renoise.app():show_status(
"Selected Instrument " … my_inst … “, Edit Step changed to " … (finish - start) … “.”
)
else
renoise.app():show_status(
“Selected Instrument " … my_inst …”, unable to calculate Edit Step!”
)
end
end
renoise.tool():add_keybinding {
name = “Pattern Editor:Edit Step:For Jonas”,
invoke = main
}
renoise.tool():add_menu_entry {
name = “Main Menu:Tools:For Jonas”,
invoke = main
}
[/luabox]
I will not be improving this. Life is like a relay race. I’m passing the baton?
If this works, you sir are legendary … how would I pack something like this myself? I have the tool browser / editor enabled in the config and also Bantais easy tool tool installed. Pasting yer code & running it in the lua testpad throws up an error. Is there a packing howto somewhere for n00bs like me?
about:
Does one always have to select an instrument in the instrument list before running the script on a particular track? If so, this might defeat the purpose of the request / a quick way to automatically set the step length. I’d like to apply the shortcut without having to check if I’m on the correct instrument. Is there no way to auto fetch this info? If too much of a hassle I can live with the script taking any 2 succeeding note events in a track.
It’s probably faster for me to package it. Attached.
2442 test.xrnx
In the future, just rename test.xrnx to text.zip, unzip it and look at it. You’ll need the manifest.xml and the main.lua file for it to work.
The “Select instrument” is so that if you have something like
C-4 - 00
C-4 - 01
Cursor is here
C-4 - 00
And instrument 00 selected, the edit step caclulation will skip C-4 01.
If you want just “two events” change line ~16 to ~21 from:
if pos.line < my_line and col.instrument_value + 1 == my_inst then
start = pos.line
elseif col.instrument_value + 1 == my_inst then
finish = pos.line
break
end
to:
if pos.line < my_line then
start = pos.line
else
finish = pos.line
break
end
Then, reload all Tools.
The Status bar output will be garbage (Insrument selection will be ignored) but it’s a starting point for more feedback?
Cheers.
Here’s a more automatic version. Paste into the main.lua file of trotch.com.test.xrnx
[luabox]
function main()
local rns = renoise.song()
local my_pattern = rns.selected_pattern_index
local my_track = rns.selected_track_index
local my_col = rns.selected_note_column_index
local my_line = rns.selected_line_index
local my_inst = rns.selected_instrument_index
local my_iter = rns.pattern_iterator:lines_in_pattern_track(my_pattern, my_track)
for pos,line in my_iter do
local col = line.note_columns[my_col]
if col and not col.is_empty then
if pos.line < my_line then
my_inst = col.instrument_value + 1
else
break
end
end
end
local start = -1
local finish = -1
my_iter = rns.pattern_iterator:lines_in_pattern_track(my_pattern, my_track)
for pos,line in my_iter do
local col = line.note_columns[my_col]
if col and not col.is_empty then
if pos.line < my_line and col.instrument_value + 1 == my_inst then
start = pos.line
elseif col.instrument_value + 1 == my_inst then
finish = pos.line
break
end
end
end
my_inst = string.upper(string.format("%02x", my_inst - 1))
if start ~= -1 and finish ~= -1 then
rns.transport.edit_step = finish - start
renoise.app():show_status(
"Selected Instrument " … my_inst … “, Edit Step changed to " … (finish - start) … “.”
)
else
renoise.app():show_status(
“Selected Instrument " … my_inst …”, unable to calculate Edit Step!”
)
end
end
renoise.tool():add_keybinding {
name = “Pattern Editor:Edit Step:For Jonas”,
invoke = main
}
renoise.tool():add_menu_entry {
name = “Main Menu:Tools:For Jonas”,
invoke = main
}
[/luabox]
Better? Discuss amongst yourselves and hack away! I’m dropping out for real now
Amazing works beatifully! Thanks!
Ey Conner,
is it possible you hack this script so it can work between two volume (or pan) column values, but instead of changing the amount of editstep, selects the range in the pattern editor?
I often make a selection between two volume or pan column values and use interpolate in the advanced editor, this new script would definitely beat the fidgety mouse selecting with the press of a keyboard shortcut.