New Tool 2.7:Capture Octave

Improved instrument capture which captures both octave and instrument.
Install and bind this to some key: Pattern Editor:Navigation:Capture Nearest Instrument and Octave.

Version 1.1: Changed so it only captures in the current pattern. Looking through the whole song took to much time for larger songs.

thanks :)

tänkx!

hi, did a minor modification to this. If you are in trackDSP view and say in the pattern editor, the first “return”-key will take you to instrument settings at the bottom (enabling display of the lower layeR) - second will take you to instrument_settings+sample_editor+disk_browser.

  
 local w = renoise.app().window  
  
if w.active_lower_frame==1 then w.lower_frame_is_visible=true  
 w.active_lower_frame = 3  
 else   
 w.active_upper_frame = 1  
 w.upper_frame_is_visible=true  
 w.active_middle_frame = 4   
end   

I have a feeling this could be done in a better way - but couldn’t for the life of me figure out how to do a “if state -= 3” (if state is anything other than 3)

p.s. so far the best functionality I can envision for this is to first capture octave+instrument, then switch to instrument settings, then to sample editor + disk browser, then back to pattern editor. It will thusly be a global command, at least in this version

“Not equal” in Lua is represented as “~=”

Thanks! This’ll help.

I guess I can’t use 1-2 IF statements to get a function to run in 3 different ways. Maybe it’s time for elseif?

Any if-elsif-else structure may be transformed into nested if-else structures. Sorry my example isn’t LUA, but I think this will work in LUA as in any other programming language I know.

If you need this

  
if (A) then  
 //do a  
elsif ( ![B)](https://files.renoise.com/forum/emoticons/default/cool.gif) then  
 // do b  
else  
 // do else  
end  
  

try this

  
if (A) then  
 //do a  
else  
 if ( ![B)](https://files.renoise.com/forum/emoticons/default/cool.gif) then  
 // do b  
 else  
 // do else  
 end  
end  
  

Edit: Oops, probably I misunderstood you – there is “elseif” in LUA.

Hmm. Can I use if/elseif stuff to detect multiple conditions? i.e. if x=1, y=1 and b=1, then x=2, y=3, b=22 elseif x=4, y=6, b=9 then …
type stuff?

if X==1 and Y==1 and B==1 then  
x=2  
y=3  
b=22   
elseif x==4 and y==6 and b==9 then  
x=4  
y=6  
b=9  
end  

http://www.casiocalc…?showtopic=2693

You copied URL with the dots, not full URL. Sure you’re example above will make sense to Esaruono anyway though, it did to me.

Bug report: this tool seems to bug out when facing ghost notes.

–EDIT:
Possible workaround: seek nearest octave and nearest instrument separately. Only change octave if no instrument is found in column…?

Like so…? Possible update?

–EDIT:
BAH I made broken. Uhm. Somebody fix it quick!

–EDIT:
Yes It works again. I. Think.

  
--[[  
program: CaptureOctave v1.1  
author: cortex (+some fixing by KMaki)  
]]--  
  
renoise.tool():add_keybinding {  
 name = "Pattern Editor:Navigation:Capture Nearest Instrument and Octave",  
 invoke = function(repeated) capture_ins_oct() end  
}  
  
  
function capture_ins_oct()  
  
 local closest_note = {}   
 local current_track=renoise.song().selected_track_index  
 local current_pattern=renoise.song().selected_pattern_index  
  
 for pos,line in renoise.song().pattern_iterator:lines_in_pattern_track(current_pattern,current_track) do  
 if (not line.is_empty) then  
 local t={}  
 if (renoise.song().selected_note_column_index==0) then  
 for i=1,renoise.song().tracks[current_track].visible_note_columns do  
 table.insert(t,i)  
 end  
 else  
 table.insert(t,renoise.song().selected_note_column_index)   
 end   
  
 --Get octave  
 for i,v in ipairs(t) do  
  
 local notecol=line.note_columns[v]  
  
 if ( (not notecol.is_empty) and (notecol.note_string~="OFF")) then  
 if (closest_note.oct==nil) then  
 closest_note.oct=math.min(math.floor(notecol.note_value/12),8)  
 closest_note.line=pos.line  
 elseif ( math.abs(pos.line-renoise.song().transport.edit_pos.line) < math.abs(closest_note.line-renoise.song().transport.edit_pos.line) ) then  
 closest_note.oct=math.min(math.floor(notecol.note_value/12),8)  
 closest_note.line=pos.line  
 end  
 end  
  
 end   
 end  
 end  
  
 for pos,line in renoise.song().pattern_iterator:lines_in_pattern_track(current_pattern,current_track) do  
 if (not line.is_empty) then  
 local t={}  
 if (renoise.song().selected_note_column_index==0) then  
 for i=1,renoise.song().tracks[current_track].visible_note_columns do  
 table.insert(t,i)  
 end  
 else  
 table.insert(t,renoise.song().selected_note_column_index)   
 end   
  
  
 --Get instrument  
 for i,v in ipairs(t) do  
  
 local notecol=line.note_columns[v]  
  
 if ( (not notecol.is_empty) and (notecol.note_string~="OFF") and (notecol.instrument_value ~= renoise.PatternTrackLine.EMPTY_INSTRUMENT) ) then  
 if (closest_note.ins==nil) then  
 closest_note.ins=notecol.instrument_value+1  
 closest_note.line=pos.line  
 elseif ( math.abs(pos.line-renoise.song().transport.edit_pos.line) < math.abs(closest_note.line-renoise.song().transport.edit_pos.line) ) then  
 closest_note.ins=notecol.instrument_value+1  
 closest_note.line=pos.line  
 end  
 end  
  
 end   
  
 end  
 end   
  
 if (closest_note.oct~=nil) then  
 renoise.song().transport.octave=closest_note.oct  
 end   
 if (closest_note.ins~=nil) then  
 renoise.song().selected_instrument_index=closest_note.ins  
  
 end   
  
end