How To Get The Keyb Octave Value

Hi People,

I’m new in this Lua Stuff, and i’m searching a way to set a variable with the value of the keyb octave. I need the value.


found the solution in #renoise : print(

swell question. thought about it a little while and here:

function KeybOctave(amount)  
if t.octave==0 and amount == -1 then t.octave=8 return end  
t.octave = math.max(0, math.min(9, t.octave + amount)) %9  
renoise.tool():add_keybinding {name = "Global:Paketti:KeybOctave Up", invoke = function() KeybOctave(1) end}  
renoise.tool():add_keybinding {name = "Global:Paketti:KeybOctave Down", invoke = function() KeybOctave(-1) end}  

this allows for KeybOctave up and KeybOctave Down in such a way that when you keyoctave up at octave8, it goes to octave0, and when you keyboctave down at octave0, you get transported to octave 8 :)
cheers! was fun

You can simplify this quite a bit:

t.octave = (t.octave + amount) % 9  

Then it doesn’t matter what the amount is or whether it’s positive or negative. It will always wrap around to a valid value from 0 to 8.

wahey! i should really have looked closer at the % stuff you told me earlier, i only half-heartedly used it for a quick scrip
thanks again dblue!