Well, I remember when I started learning these things, I also had similar doubts.I would say that the main problem is knowing how to interpret the available API, that is, the available documentation…
To access the note column, you can do it in 3 ways. The documentation is this:
1)For the selected note column (this is the most direct way):
renoise.song().selected_note_column
–Find this line in the documentation and have it located!!!
Thus, you can modify any property of the selected note column:
renoise.song().selected_note_column:clear()
renoise.song().selected_note_column.note_value = 48
renoise.song().selected_note_column.instrument_value = 0
etc.
- Now, if you want to access a specific note column (not precisely the selected note column):
renoise.song().patterns.tracks.lines.note_columns
–Find this line in the documentation and have it located!!!
renoise.song().patterns[index].tracks[index].lines[index].note_columns[index]
This is what you will usually see in the documentation. In this case, you have access to the configuration of all the parts of which note_column depends,but access to them is much slower, since you will have to search each table, by using the brackets s[].
- So it is not advisable to use the code in this way. It is better to do it as Joule indicates, using **( ):**without the “s”, whose access is direct and fast:
renoise.song():pattern(index):track(index):line(index):note_column(index)
If you also want to have access to the selected line, directly, you can do this:
renoise.song().selected_line:note_column(index)
So you substitute**:pattern(index):track(index):line(index)**for .selected_line
And you can continue with all the dependents:
renoise.song().selected_pattern_track:line(index):note_column(index)
It is strange to want to change a property (note value, instrument value, volume value…) of the note column that is not selected.So, one way to understand the code is that, by using renoise.song ().selected_note_column, you’re acting on:
- the current song
- the selected pattern
- the selected track
- tle selected line
- and the selected note_column
Now, to avoid errorsthe function should always check that you are on a track of type SEQUENCE and are not selecting any of its effect columns.The best way to do this is to verify that the cursor is selecting a note column:
local song=renoise.song()
if (song.selected_note_column) then
–your code
end
A typical function would be (the definition of the function and its execution):
local function change_nte_ins(nte,ins)
local nte_col=renoise.song().selected_note_column
if (nte_col) then
nte_col.note_value=nte
nte_col.instrument_value=ins
end
end
change_nte_ins(48,0)
This function will only work if a note column is selected, by the if (nte_col) then. You can apply all this and combine it as you like also for the effect columns, valid for any type of track.
On the other hand, it is good to remember to be careful with the indexes.For example, pattern 0 does not exist, note value 122 does not exist…
Edit: so I review all this for myself too