Scripting To Emulate Direct Access To Octave Field And Mix-Paste Data

Digging into the scripting documentation.

My first thoughts are to emulate direct access to the octave field via a shortcut and numrow taking into account the current step length, and provide a direct shortcut(s) for mix-paste data methods without having to mouse click the little mixpaste check box to switch to mixpaste mode.

outline of process for direct octave access:

  • keybind+(0-9) pressed
  • get current edit step
  • get note+oct under cursor
  • change octave to selected
  • jump to next edit step

Important for emulating direct access to the octave column will be reading and changing the data currently under the cursor, however reading through the docs and other scripts, I only see ways to edit an entire track, or a current selection. What is under the cursor is not considered a selection unless it is clicked on or manually selected by holding shift and hitting an arrow key.

Currently I can read all the data currently under the cursor using:

notedata = renoise.song().selected_note_column  

but this is considered userdata, not string data which may be broken up and manipulated.

any tips?

You’re assigning an object to notedata, not any values. An “oprint(renoise.song().selected_note_column)” gives you the following output:

class: NoteColumn  
 properties:  
 delay_string  
 delay_value  
 instrument_string  
 instrument_value  
 is_empty  
 is_selected  
 note_string  
 note_value  
 panning_string  
 panning_value  
 volume_string  
 volume_value  
 methods:  
 __STRICT  
 __eq  
 __tostring  
 clear  
 copy_from  
  

So the correct way to access the properties, in this example as string, would be:

note = renoise.song().selected_note_column.note_string  

Methods are accessed using the double point. To clear a column for example:

renoise.song().selected_note_column:clear()  

Thanks! My main concern was that access to note data under the cursor, but not selected, might be neglected from being manipulated in ways I have seen other scripts use the various iteration methods to perform similar changes I have in mind. When googling info about userdata, most of the results read like: Userdata values cannot be created or modified in Lua, only through the C API.

some success:

[luabox]
– Thanks to suva for the function per octave declaration loop :)
http://www.protman.com

function ProcessOctave(new_octave)

local new_pos = 0
local song = renoise.song()
local editstep = renoise.song().transport.edit_step

new_pos = song.transport.edit_pos
if song.selected_note_column.note_value < 120 then
song.selected_note_column.note_value = song.selected_note_column.note_value % 12 + (12 * new_octave)
end
new_pos.line = new_pos.line + editstep
if new_pos.line <= song.selected_pattern.number_of_lines then
song.transport.edit_pos = new_pos
end

end

for oct=0,9 do
renoise.tool():add_keybinding {
name = "Pattern Editor:Pattern:Set Note to Octave " … oct,
invoke = function() ProcessOctave(oct) end
}
end

[/luabox]