Is there any way to create a midi mapping for the functions of the delete key and the caps lock key? I’ve spent some time looking through the api documentation but it is very possible I just missed it.
hi… so… are you looking for a method of going to row 03 and overwriting the note on there with note off?
or… something else?
yes, inserting note offs is definitely possible with API functions, and i’ve done it multiple times with different configurations.
if there’s something very specific you’re looking for, please let me know. i also tend to also make these available as midimappings.
are you simply looking for “clear note in current note column on current row” midimapping, and “insert note off to current row” midimapping, and “clear note in all note columns on current row” and “insert note off to all note columns on current row”, i’ll just add them right now into Paketti.
i can also walk you through how these are done.
EDIT: there. they’re in now.
So, what we’re looking for, is this:
note_string == "OFF"
and here’s how you write it using the Scripting Terminal & Editor:
renoise.song().selected_pattern.tracks[renoise.song().selected_track_index].lines[1].note_columns[1].note_string = "OFF"
this will write to the current pattern, to the selected track, to the first line, to the 1st note column, the note_string "OFF"
. which is a good start.
but what you want, is being to say, to current line index, to current note column, which are like this:
those details are in these:
renoise.song().selected_line_index
renoise.song().selected_note_column_index
so the modification would be this:
renoise.song().selected_pattern.tracks[renoise.song().selected_track_index].lines[renoise.song().selected_line_index].note_columns[renoise.song().selected_note_column_index].note_string = "OFF"
now, the best way is to actually map this into a variable, such as
local currentRow=renoise.song().selected_pattern.tracks[renoise.song().selected_track_index].lines[renoise.song().selected_line_index].note_columns[renoise.song().selected_note_column_index].note_string
after which you can just say
currentRow = "OFF"
now, there are certain details here that are good to keep in mind.
- a Group Track does not have a Note Column.
- a Send Track does not have a Note Column.
- a Master Track does not have a Note Column.
- If you’re not on a Note Column, i.e. you’re on an Effect Column, the
selected_note_column_index
will be nil.
So you need to write protection to evade those. i.e. basically, how i’d describe it, “if selected_note_column_index == nil then return else run code
”
and then in the run code there needs to be a detection for the track type.
the way to get a track type is to query renoise.song().selected_track.type
- like this
>>> oprint (renoise.song().selected_track.type)
1
if the response is 1, then you’re on a regular Sequencer Track, not on a Group, Master or Send.
So what you need to do, is simply this:
function writeNoteOffToCurrentRow()
if renoise.song().selected_note_column_index == nil then
renoise.app():show_status("You are not on a Note Column, doing nothing.")
return
end
if renoise.song().selected_track.type == 1 then
local currentRow=renoise.song().selected_pattern.tracks[renoise.song().selected_track_index].lines[renoise.song().selected_line_index].note_columns[renoise.song().selected_note_column_index].note_string
currentRow = "OFF"
else
renoise.app():show_status("You are on a Group, Master or Send track, it does not have Note Columns, doing nothing."
end
end
renoise.tool():add_midi_mapping{
name = "Pattern Editor:Paketti:Write Note Off to Current Row [Trigger]",
invoke = function(message)
if message:is_trigger() then
writeNoteOffToCurrentRow()
end
end
}
what this does, is create a Midi Mapping with the path that ends with Write Note Off to Current Row [Trigger]
- when it is run, it detects if selected_note_column_index is nil, then does nothing. if it’s not nil, then it detects if you’re on the correct track type
and writes, to the current row, current line, current track, current pattern, the Note Off message. (OFF
).
multiple ways how this could be improved:
- You could modify it so that if there’s already an
OFF
there, it instead wipes it i.e. replaces with---
. so it would be a toggle instead of a hard set. - You could detect if there’s a selection in the pattern, and write
OFF
to each and every row in the selection. And if no selection, then to current row. - You could optimize the detection so that it detects both if the selected note column index is not nil, and if the track type is 1 → and then just go onwards.
and so on.
the possibilities are endless.
Thank you! i understand how the tools & scripting work a bit better now, that being said im struggling to actually make it work; i’ll just install paketti if i cant figure it out when i have time again. if i do manage to get it working, would creating a midi function to always insert “—” wipe the column like the delete key does?
if only it were that simple…
if you do the ---
… it only does that.
so this:
becomes this:
so need to wipe all of it.
for that, we have a nice little thing for wiping the whole row:
renoise.song().selected_line:clear()
so it’s easy to just wrap that into a script.
but also there’s this
renoise.song().selected_note_column:clear()
I’ve made a version that obeys editstep, so it’ll advance, by editstep amount, and wrap around the pattern.
anyway, I’ve tweaked my stuff to have all these 3 flavors as shortcut and as midimappings. thanks!
oh and here’s the snippets
function SelectedNoteColumnClear()
if renoise.song().selected_note_column_index ~= nil then
renoise.song().selected_note_column:clear()
else
renoise.app():show_status("You are not on a Note Column, doing nothing.")
end
end
renoise.tool():add_midi_mapping{name = "Paketti:Delete/Clear/Wipe Selected Note Column x[Toggle]",
invoke = function(message) if message:is_trigger() then SelectedNoteColumnClear() end end}
renoise.tool():add_keybinding{name = "Global:Paketti:Delete/Clear/Wipe Selected Note Column",
invoke = function() SelectedNoteColumnClear() end}
so this protects against you not being in a note column index and does nothing, otherwise, it clears it.
anyway, I’ve made an update to Paketti
but thanks for making me tune these up, it was time to finish up this segment of Paketti too.
EDIT:
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.