R2->R3 "copy from note on to note off sample mapping" no

Hi, it would appear that I’m no longer able to use this:

--vV's wonderful sample keyzone noteon/noteoff copier + octave transposition for note-off:
local NOTE_ON = renoise.Instrument.LAYER_NOTE_ON
local NOTE_OFF = renoise.Instrument.LAYER_NOTE_OFF

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)
  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)

local function norm() copy_note_layers(NOTE_ON, NOTE_OFF, 0) end
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

renoise.tool():add_menu_entry {name="--Sample Mappings:Copy note-on to note-off layer +12", invoke = octup}
renoise.tool():add_menu_entry {name="Sample Mappings:Copy note-on to note-off layer +24", invoke = octuptwo}
renoise.tool():add_menu_entry {name="Sample Mappings:Copy note-on to note-off layer", invoke = norm}
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-on to note-off layer -24", invoke = octdntwo}

as it simply shoots errors at sample_index (which, when I switch “sample_index” with “sample”, it shoots errors on “use_envelopes”, which if i comment away, still shoots errors:

*** main.lua:59: unknown property or function 'insert_sample_mapping' for an object of type 'Instrument'
*** stack traceback:
*** [C]: in function '_error'
*** [string "do..."]:48: in function <[string "do..."]:35>
*** main.lua:59: in function 'copy_note_layers'
*** main.lua:65: in function <main.lua:65>

What should I do to get this back to working? Basically it’s a “duplicate current note-on data to note-off, but with a user-specific transposition value…” thing.

As of Renoise 3.0 (API version 4), a sample may only have a single keyzone mapping, in either the note-on layer or the note-off layer.

To duplicate mappings, you must therefore duplicate the sample itself, and assign the appropriate mapping and layer properties to the copy.

1 Like

Aha, so the steps would be…?

  1. Load sample (Note-On)
  2. Right-click on Note-On Keymapping area, run script
  3. Script copies sample to a new slot
  4. Script creates Note-Off Keymapping
  5. Script sets Note-Off Keymapping to one octave higher.

Is this correct?