hi. I’m trying to make something which outputs a note to the current_track. got that working fine, but decided to go for improvements. so now if note_column (NC from now on) [1-12] are full, it doesn’t put a note to the lines[1].notecolumn. if notecolumn2 is empty, it will write to notecolumn2. so the point of the script is to put a c-4 (+specific instrument) to an empty notecolumn on the selected_track. i did a load of elseif’s and ands and got it working.
but what broke was when i tried to control visible_note_columns. easiest method would be to just make 12 notecolumns visible at the start of the scrip, but that’s just not really required, especially if then you’ll have a 12 notecolumn track which only has stuff on one note column.
so then i tried to “if this many are empty, then make this visible and write to this notecolumn”, but obviously if you have notes on 1, 2, 3, 5-12, inputting a note via script to #4 will change visibility to 1-4.
so what i’m after is a method of recognizing NC.is_empty in such a way that it will display the amount of notecolumns that have information and nothing else.
how would i go about doing something like this? What I have right now (and which seems to work after a fashion, but is clunky), is really clunky.
[details=“Click to view contents”] ```lua
function recordtocurrenttrack()
local s=renoise.song()
local ss=s.selected_sample
local nol=s.selected_pattern.number_of_lines
local t=renoise.song().transport
local w=renoise.app().window
local currInst = s.selected_instrument_index
local currTrak = s.selected_track_index
local currPatt = s.selected_pattern_index
w.sample_record_dialog_is_visible=true
s.transport:start_stop_sample_recording()
s.patterns[currPatt].tracks[currTrak].lines[1].effect_columns[1].number_string=“05”
s.patterns[currPatt].tracks[currTrak].lines[1].effect_columns[1].amount_string=“01”
local tulos=renoise.song().selected_instrument_index -1
local nc=s.patterns[currPatt].tracks[currTrak].lines[1].note_columns
local place=nil
local zero=nil
print (renoise.song().tracks[currTrak].visible_note_columns)
print (“start of:”)
for i=1,12 do
print (renoise.song().patterns[currPatt].tracks[currTrak].lines[1].note_columns[i].is_empty)
end
–if renoise.song().patterns[currPatt].tracks[currTrak].lines[1].note_columns[1].is_empty==true then
if nc[1].note_string==“C-4” and
nc[2].note_string==“C-4” and
nc[3].note_string==“C-4” and
nc[4].note_string==“C-4” and
nc[5].note_string==“C-4” and
nc[6].note_string==“C-4” and
nc[7].note_string==“C-4” and
nc[8].note_string==“C-4” and
nc[9].note_string==“C-4” and
nc[10].note_string==“C-4” and
nc[11].note_string==“C-4” and
nc[12].note_string==“C-4” then
renoise.app():show_status(“I think you should switch to a different channel already”)
renoise.song().tracks[currTrak].visible_note_columns=12
place=nil
elseif nc[1].note_string==“C-4” and
nc[2].note_string==“C-4” and
nc[3].note_string==“C-4” and
nc[4].note_string==“C-4” and
nc[5].note_string==“C-4” and
nc[6].note_string==“C-4” and
nc[7].note_string==“C-4” and
nc[8].note_string==“C-4” and
nc[9].note_string==“C-4” and
nc[10].note_string==“C-4” and
nc[11].note_string==“C-4” then
place=12
renoise.song().tracks[currTrak].visible_note_columns=place
elseif nc[1].note_string==“C-4” and
nc[2].note_string==“C-4” and
nc[3].note_string==“C-4” and
nc[4].note_string==“C-4” and
nc[5].note_string==“C-4” and
nc[6].note_string==“C-4” and
nc[7].note_string==“C-4” and
nc[8].note_string==“C-4” and
nc[9].note_string==“C-4” and
nc[10].note_string==“C-4” then
place=11
renoise.song().tracks[currTrak].visible_note_columns=place
elseif nc[1].note_string==“C-4” and
nc[2].note_string==“C-4” and
nc[3].note_string==“C-4” and
nc[4].note_string==“C-4” and
nc[5].note_string==“C-4” and
nc[6].note_string==“C-4” and
nc[7].note_string==“C-4” and
nc[8].note_string==“C-4” and
nc[9].note_string==“C-4” then
place=10
renoise.song().tracks[currTrak].visible_note_columns=place
elseif nc[1].note_string==“C-4” and
nc[2].note_string==“C-4” and
nc[3].note_string==“C-4” and
nc[4].note_string==“C-4” and
nc[5].note_string==“C-4” and
nc[6].note_string==“C-4” and
nc[7].note_string==“C-4” and
nc[8].note_string==“C-4” then
place=9
renoise.song().tracks[currTrak].visible_note_columns=place
elseif nc[1].note_string==“C-4” and
nc[2].note_string==“C-4” and
nc[3].note_string==“C-4” and
nc[4].note_string==“C-4” and
nc[5].note_string==“C-4” and
nc[6].note_string==“C-4” and
nc[7].note_string==“C-4” then
place=8
renoise.song().tracks[currTrak].visible_note_columns=place
elseif nc[1].note_string==“C-4” and
nc[2].note_string==“C-4” and
nc[3].note_string==“C-4” and
nc[4].note_string==“C-4” and
nc[5].note_string==“C-4” and
nc[6].note_string==“C-4” then
place=7
renoise.song().tracks[currTrak].visible_note_columns=place
elseif nc[1].note_string==“C-4” and
nc[2].note_string==“C-4” and
nc[3].note_string==“C-4” and
nc[4].note_string==“C-4” and
nc[5].note_string==“C-4” then
place=6
renoise.song().tracks[currTrak].visible_note_columns=place
elseif nc[1].note_string==“C-4” and
nc[2].note_string==“C-4” and
nc[3].note_string==“C-4” and
nc[4].note_string==“C-4” then
place=5
renoise.song().tracks[currTrak].visible_note_columns=place
elseif nc[1].note_string==“C-4” and
nc[2].note_string==“C-4” and
nc[3].note_string==“C-4” then
place=4
renoise.song().tracks[currTrak].visible_note_columns=place
elseif nc[1].note_string==“C-4” and
nc[2].note_string==“C-4” then
place=3
renoise.song().tracks[currTrak].visible_note_columns=place
elseif nc[1].note_string==“C-4” then
place=2
renoise.song().tracks[currTrak].visible_note_columns=place
elseif nc[1].note_string==“—” then
place=1
renoise.song().tracks[currTrak].visible_note_columns=place
end
if place==zero then return
else s.patterns[currPatt].tracks[currTrak].lines[1].note_columns[place].note_string=“C-4”
s.patterns[currPatt].tracks[currTrak].lines[1].note_columns[place].instrument_value=tulos
end
ss.autoseek=true
ss.sample_buffer_observable:add_notifier(function() w.sample_record_dialog_is_visible=false end)
end
renoise.tool():add_menu_entry {name = “Pattern Editor:RecordToCurrent”, invoke = function() recordtocurrenttrack() end}