How Are Note-Off Keymaps Samplekeyzones Used?

hi… i’m not really familiar with ft2 instrument list, instrument keymapping or the lot. or renoise for that matter.
how do i copy current note-on keymappings to note-off keymappings? etc?

You can’t natively in Renoise…
However you can use scripting for that.

This script gives you two extra context-menu entries and functions to copy all keyzones from either note-on to note-off or vice versa:
2455 com.vvoois.Layer_exchange_Rns270_V1.2.xrnx
(Fixed target deletion, forgot to set step -1 for count down, also forgot to copy the map_velocity_to_volume and use_envelopes switch states to the new mappings)

[quote=“vV, post:2, topic:33936”]
You can’t natively in Renoise…
However you can use scripting for that.

This script gives you two extra context-menu entries and functions to copy all keyzones from either note-on to note-off or vice versa:

Attachment 2453 not found.

thank you. what do you think are my chances at looking at that and being able to make it so that the note-off keyzones are at a different pitch to the original sample? :)
ahh, i see this doesn’t work if one has created slices in a drumkit. I’ll try with one sample

Okay, kind of got it working:
minor alteration:

local oct_base_note=nil  
oct_base_note=base_note-12  
renoise.song().instruments[instrument]:insert_sample_mapping(target_layer, sample_index,oct_base_note,note_range,velocity_range)  
  

however, seems to result in a hung note…

thank you so much vV!! with the octave-up modification this is exactly what I was hoping to accomplish but lacked the resources and wits required to crack the two table thing that you seemed to knock out at a moment’s notice!!

I have removed one error in my script but i don’t think it has got any much to do with it.
A “hung note” probably means that the base_note for the note-off is probably wrong or perhaps need to be base_note-11. Just look what note-mapping the indicator is pointing at when releasing the key, you might see the note-off layer may not be referring to the note that you have set.
Or something different is going on.(Like the “use_envelopes” value should perhaps be different)

the actual pitch is correct (+12 transpose). but i guess the point is to use an envelope that kills the noteoff sample from playing. it works anyway, and it’s awesome. thank you very much.

Well, I guess my next question is: how to make the same thing happen with drumslices?
or are drumslices only available in the note-on layer?

im doing a modification to this that gives two context menu entries, one for ntoe-off +12 and one for note-off -12. :)

Don’t think you can do any kind of manual mapping of sliced sample at all!

The note-off layer isn’t used for slices, neither during playing the instrument, this is the reason i didn’t added keybindings because this would probably generate errors.
Fixed another forgotten object copy btw. so we’re now at version 1.2

im going at this in a really wack way, but it seems to work.

[details=“Click to view contents”] ```
–[[============================================================================
main.lua
============================================================================]]–

–Define the NOTE_ON layer and the NOTE_OFF layer
local NOTE_ON = renoise.Instrument.LAYER_NOTE_ON
local NOTE_OFF = renoise.Instrument.LAYER_NOTE_OFF

– Read from the manifest.xml file.
class “RenoiseScriptingTool” (renoise.Document.DocumentNode)
function RenoiseScriptingTool:__init()
renoise.Document.DocumentNode.__init(self)
self:add_property(“Name”, “Untitled Tool”)
self:add_property(“Id”, “Unknown Id”)
end

local manifest = RenoiseScriptingTool()
local ok,err = manifest:load_from(“manifest.xml”)
local tool_name = manifest:property(“Name”).value
local tool_id = manifest:property(“Id”).value


– Main functions

local function copy_note_layers_eh(source_layer,target_layer)
local instrument = renoise.song().selected_instrument_index

–delete target layers prior to copying (to prevent overlays)
if #renoise.song().instruments[instrument].sample_mappings[target_layer] > 0 then
–Note that when using the delete_sample_mapping, the index is changing on-the-fly
–So you have to remove the mappings from the last to the first entry instead of vice versa.
–Else you get errors half-way.
for i = #renoise.song().instruments[instrument].sample_mappings[target_layer],1,-1 do
renoise.song().instruments[instrument]:delete_sample_mapping_at(target_layer, i)
end

end

for i = 1,#renoise.song().instruments[instrument].sample_mappings[source_layer] do

local base_note = renoise.song().instruments[instrument].sample_mappings[source_layer][i].base_note
local map_velocity_to_volume = renoise.song().instruments[instrument].sample_mappings[source_layer][i].map_velocity_to_volume
local note_range = renoise.song().instruments[instrument].sample_mappings[source_layer][i].note_range
local sample_index = renoise.song().instruments[instrument].sample_mappings[source_layer][i].sample_index
local use_envelopes = renoise.song().instruments[instrument].sample_mappings[source_layer][i].use_envelopes
local velocity_range = renoise.song().instruments[instrument].sample_mappings[source_layer][i].velocity_range
local oct_base_note=nil
oct_base_note= base_note -12
renoise.song().instruments[instrument]:insert_sample_mapping(target_layer, sample_index,oct_base_note,note_range,velocity_range)
end
end

local function copy_note_layers(source_layer,target_layer)
local instrument = renoise.song().selected_instrument_index

–delete target layers prior to copying (to prevent overlays)
if #renoise.song().instruments[instrument].sample_mappings[target_layer] > 0 then
–Note that when using the delete_sample_mapping, the index is changing on-the-fly
–So you have to remove the mappings from the last to the first entry instead of vice versa.
–Else you get errors half-way.
for i = #renoise.song().instruments[instrument].sample_mappings[target_layer],1,-1 do
renoise.song().instruments[instrument]:delete_sample_mapping_at(target_layer, i)
end

end

for i = 1,#renoise.song().instruments[instrument].sample_mappings[source_layer] do

local base_note = renoise.song().instruments[instrument].sample_mappings[source_layer][i].base_note
local map_velocity_to_volume = renoise.song().instruments[instrument].sample_mappings[source_layer][i].map_velocity_to_volume
local note_range = renoise.song().instruments[instrument].sample_mappings[source_layer][i].note_range
local sample_index = renoise.song().instruments[instrument].sample_mappings[source_layer][i].sample_index
local use_envelopes = renoise.song().instruments[instrument].sample_mappings[source_layer][i].use_envelopes
local velocity_range = renoise.song().instruments[instrument].sample_mappings[source_layer][i].velocity_range
local oct_base_note=nil
oct_base_note= base_note +12
renoise.song().instruments[instrument]:insert_sample_mapping(target_layer, sample_index,oct_base_note,note_range,velocity_range)
end

end
local function note_on_to_note_off_eh()
copy_note_layers_eh(NOTE_ON, NOTE_OFF)
end

local function note_on_to_note_off()
copy_note_layers(NOTE_ON, NOTE_OFF)
end

local function note_off_to_note_on()
copy_note_layers(NOTE_OFF, NOTE_ON)
end


– Menu entries

renoise.tool():add_menu_entry {name=“Sample Mappings:Copy note-on to note-off layer -12”, invoke = note_on_to_note_off}
renoise.tool():add_menu_entry {name=“Sample Mappings:Copy note-on to note-off layer +12”, invoke = note_on_to_note_off_eh}

renoise.tool():add_menu_entry {
name = “Sample Mappings:Copy note-off to note-on layer”,
invoke = note_off_to_note_on
}


– Key Binding

–[[
renoise.tool():add_keybinding {
name = “Global:Tools:” … tool_name…"…",
invoke = show_dialog
}
–]]

Simply expand the function parameters?

  
local function copy_note_layers(source_layer,target_layer, offset)  
 local instrument = renoise.song().selected_instrument_index  
  
 --delete target layers prior to copying (to prevent overlays)  
 if #renoise.song().instruments[instrument].sample_mappings[target_layer] > 0 then  
 --Note that when using the delete_sample_mapping, the index is changing on-the-fly  
 --So you have to remove the mappings from the last to the first entry instead of vice versa.  
 --Else you get errors half-way.  
 for i = #renoise.song().instruments[instrument].sample_mappings[target_layer],1,-1 do  
 renoise.song().instruments[instrument]:delete_sample_mapping_at(target_layer, i)  
 end  
  
 end  
  
 for i = 1,#renoise.song().instruments[instrument].sample_mappings[source_layer] do  
  
 local base_note = renoise.song().instruments[instrument].sample_mappings[source_layer][i].base_note  
 local map_velocity_to_volume = renoise.song().instruments[instrument].sample_mappings[source_layer][i].map_velocity_to_volume  
 local note_range = renoise.song().instruments[instrument].sample_mappings[source_layer][i].note_range  
 local sample_index = renoise.song().instruments[instrument].sample_mappings[source_layer][i].sample_index  
 local use_envelopes = renoise.song().instruments[instrument].sample_mappings[source_layer][i].use_envelopes  
 local velocity_range = renoise.song().instruments[instrument].sample_mappings[source_layer][i].velocity_range  
 local oct_base_note=nil  
 oct_base_note= base_note + offset  
 renoise.song().instruments[instrument]:insert_sample_mapping(target_layer, sample_index,oct_base_note,note_range,velocity_range)  
 end  
  
  
end  
  
local function note_on_to_note_off()  
 copy_note_layers(NOTE_ON, NOTE_OFF, 12)  
end  
  
local function note_off_to_note_on()  
 copy_note_layers(NOTE_OFF, NOTE_ON, -12)  
end  
  

You can also simply generate some GUI element that simply calls these functions for you.

local function octdn()  
 copy_note_layers(NOTE_ON, NOTE_OFF, 12)  
end  
  
local function octup()  
 copy_note_layers(NOTE_ON, NOTE_OFF, -12)  
end  
local function octdntwo()  
 copy_note_layers(NOTE_ON, NOTE_OFF, 24)  
end  
  
local function octuptwo()  
 copy_note_layers(NOTE_ON, NOTE_OFF, -24)  
end  
  
  
--------------------------------------------------------------------------------  
-- Menu entries  
--------------------------------------------------------------------------------  
  
renoise.tool():add_menu_entry {name="Sample Mappings:Copy note-on to note-off layer -12", invoke = octdn}  
renoise.tool():add_menu_entry {name="Sample Mappings:Copy note-off to note-on layer +12", invoke = octup}  
  
renoise.tool():add_menu_entry {name="Sample Mappings:Copy note-on to note-off layer -24", invoke = octdntwo}  
renoise.tool():add_menu_entry {name="Sample Mappings:Copy note-on to note-off layer +24", invoke = octuptwo}  
  

This’ll do for now. works like a charm :)