Sample_Mappings For The Keyzone

I want to figure out how automate the size of keyzones of a bunch of samples so I can automate the areas.

So far I found this:

new_mapping = selected_instrument:insert_sample_mapping(
LAYER_NOTE_ON, 3, 49, {49,49}, {0,32})

and from that I was able to find some more of it in TestSamples.lua

so this is what I have so far:

  
-- add your test snippets and other code here, that you want to quickly  
-- try out without writing a full blown 'tool'...  
  
do  
  
 ----------------------------------------------------------------------------  
 -- tools  
  
 local function assert_error(statement)  
 assert(pcall(statement) == false, "expected function error")  
 end  
  
 function float_cmp(f1, f2)  
 return math.abs(f1 - f2) < 0.0001  
 end  
  
  
 ----------------------------------------------------------------------------  
 -- insert/delete/swap  
  
 local song = renoise.song()  
 local selected_instrument = song.selected_instrument  
  
local LAYER_NOTE_ON = renoise.Instrument.LAYER_NOTE_ON  
  
  
-- new_mapping = selected_instrument:insert_sample_mapping(  
-- LAYER_NOTE_ON, 1, 36, {0,48})  
  
  
new_mapping = selected_instrument:insert_sample_mapping(  
 LAYER_NOTE_ON, 2, 49, {49,59}, {4,127})  
-- dummy: recursively prints all available functions and classes  
-- rprint(_G)  
end  
  

this works, but I’m unsure what this part is completely referring to:

“2, 49, {49,59}, {4,127}”

I gather what this “{49, 59}” is doing.
49 is the beginning of the keyzone and 59 is the end of the keyzone.
but the rest of it is giving me trouble telling me what it’s for.

the “2” only accepts 1 or 2, but don’t understand it.
the “49” I can’t figure out really at all.
“{49, 59}” should be the table for the keyzone, the main thing I want to mess with.
and “{4,127}” is a table for key/velocity, but if I change “4” it doesn’t seem to do anything

somewhere is the sample index.

either way this is fuckin awesome.

okay, I figured out what all of it does.

new_mapping = selected_instrument:insert_sample_mapping(
LAYER_NOTE_ON, 2, 10, {19,89}, {50,127})

“2, 10, {19,89}, {50,127}”

“2” is the sample index of the instrument
“10” is basenote.
“{19, 89}” is the note-range (keyzone layer) table.
“{50, 127}” is the velocity range table.

:)

think I’m going to have to post about this in the ideas/suggestions to see if anyone can suggest a great or better way of usage.

I would prefer OSC but MIDI would be much more useful for everyone I guess.
the problem arises with limits of naming things in MIDI CC and the 127 limit.
i want to use the 256 limit on the instruments.
With MIDI it could be completely self contained and not need a loopback, but would be heavy on limits.
also would be much easier to add 4 OSC function entries into the GlobalOscActions.lua
hmm.
easier to setup with midi but much more powerful with OSC.

seems I have this a little wrong.
read I need to be using “sample_mappings” to read a table.