Transpose One Octave Up When Nothing Selected

Hi. I’ve got CMD-Q mapped to Transpose selection up by octave. CMD-A for Transpose selection down by octave.
is there some way i could make it so that if nothing is selected, the whole track is transposed up by cmd-q, and down by cmd-a? how would one go about doing something like this? i just think it’d be fairly handy :)

  
if (renoise.song().selection_in_pattern ~= nil) then  
 -- transpose renoise.song().selection_in_pattern  
else  
 -- transpose renoise.song().selected_pattern_track  
end  
  

And make the fastest possible loop when you inc/dec note_value. Use patterntrack iterator and .is_empty at all levels possible :)

Yeah, it seems that if i +12 a D-3 up until it’s D-9, the next +12 will be 122 so basically if it goes over 121 it should revert back down to octave 0 to d-0 (note_value=2). . this would make it into a looping octave transposer and that could be real neat.

not sure about this pattern iterator stuff tho. obviously is_empty has to be ignored, otherwise it’ll try and transpose empty all 12 note columns of a 512 row pattern and just clunk down.

is a for-loop the way to go about this?
after making

renoise.song().patterns[renoise.song().selected_pattern_index].tracks[renoise.song().selected_track_index].lines[renoise.song().selected_line_index].note_columns[renoise.song().selected_note_column_index].note_value=renoise.song().patterns[renoise.song().selected_pattern_index].tracks[renoise.song().selected_track_index].lines[renoise.song().selected_line_index].note_columns[renoise.song().selected_note_column_index].note_value+12  

it kind of occurred that this is actually like doable. of course that’s only the selected note column index and the selected line index, instead of the selection, but i think i can wrangle some horrific nightmarish code out of this when i get back home tomorrow from a gig.

esaruoho,

Always use :track() instead of .tracks[] (the same goes for patterns, lines et c). They are faster. And use a pattern iterator (it’s in the docs).

If you make a loop the simple way I can sanitize and speed it up for you if you want to.

Holy crap, man! This mess is completely unnecessary :)

This will do exactly the same thing:
(Not completely safe since it performs no bounds checking and will eventually result in an error)

  
local note_column = renoise.song().selected_note_column  
  
note_column.note_value = note_column.note_value + 12  
  

If you want to include the note/octave wrapping behaviour you mentioned, then use this instead:
(Pretty safe since it will always wrap to a valid note value)

  
local note_column = renoise.song().selected_note_column  
  
note_column.note_value = (note_column.note_value + 12) % 120  
  

Ok, Hi, I’m back. Decided to mash both octup and octdn together so it’s easier to just get the whole thing working instead of having two, where one might work and the other mightn’t.

  
function OctTranspose(UpOrDown)  
local note_column = renoise.song().selected_note_column   
note_column.note_value = (note_column.note_value +UpOrDown) % 120  
end  
renoise.tool():add_keybinding {name = "Global:Paketti:Transpose Octave Up", invoke = function() OctTranspose(12) end}  
renoise.tool():add_keybinding {name = "Global:Paketti:Transpose Octave Down", invoke = function() OctTranspose(-12) end}  
  

so far, so good, both work. the main reason i posted this minor update was to remind myself that i was supposed to be doing this, and to ask if i’m already doing something terribly wrong ;)