song.selected_sample behavior in r3

Many thanks for this. I can’t figure out what to use instead of the ‘selected_sample’ function.

I’m not a programmer but I was able to ‘hack’ around the code that user ‘Cas’ shared with me from his ‘Sloper’ tool, to get what I wanted.
This is a version with the gui removed, that does a parabolic volume boost to the middle of the currently selected sample. It obviously fails on the ‘selected_sample’ statements in RNS 3 beta.

-- Main --  
 local SLOPE_FORMULAS = { "X", "X^Y", "X^(1/Y)", "(math.cos((1-X)*math.pi)/2+.5)^Y", "(math.atan(1-X*2)/2+.5)^Y" }  
 local STEREO = renoise.SampleBuffer.CHANNEL_LEFT_AND_RIGHT  
 local lo = 100  
 local hi = 100  
 local sp = 1  
 local function BoostMiddle()  
 local rs =  
 local sb = rs.selected_sample.sample_buffer  
 if not sb.read_only then  
 local step = 0.0  
 local flo = lo/100.0  
 local fhi = hi/100.0"BoostMiddle")  
 local ch = sb.selected_channel  
 local slope_func = function(X, Y) return math.sin(X*math.pi) end  
 local sc = (sb.selection_end - sb.selection_start)+1  
 for i = 1, sc do  
 if io == 2 then  
 step = 1.0-i/sc  
 step = i/sc  
 if ch == STEREO and sb.number_of_channels == 2 then  
 sb:set_sample_data( 1, sb.selection_start+i-1,  
 sb:sample_data(1, sb.selection_start+i-1)*(1+0.15*slope_func(step, sp)) )  
 sb:set_sample_data( 2, sb.selection_start+i-1,  
 sb:sample_data(2, sb.selection_start+i-1)*(1+0.15*slope_func(step, sp)) )  
 if ch == STEREO then ch = 1 end  
 sb:set_sample_data(ch, sb.selection_start+i-1,  
 sb:sample_data(ch, sb.selection_start+i-1)*(1+0.15*slope_func(step, sp)) )  
renoise.tool():add_menu_entry {  
 name = "Sample Editor:Process:BoostMiddle",  
 invoke = BoostMiddle  
renoise.tool():add_keybinding {  
 name = "Sample Editor:Fade:BoostMiddle",  
 invoke = BoostMiddle  
_AUTO_RELOAD_DEBUG = function()  

Thanks for any pointers, and sorry if this is posted in the wrong place.

Best Regards,


The current selected sample as global API option has been removed, you now always have to define which instrument and sample it involves.
Luckily selected_instrument_index and selected_sample_index are still present:

try adding
rs = rs.instruments[rs.selected_instrument_index].samples[rs.selected_sample_index]
directly beneath:
local rs =

If that fails just replace the last line with:
local rs =[].samples[]

Thanks, vV!

That’s a great help, I reckon I can get all my tools working again!

Really appreciate the quick reply…



“selected_sample” is still there. The only difference in Renoise 3 is that it can be nil now. An instrument has no samples by default in Renoise 3.
So either simply check for ~= nil or/and create a new blank sample then via the API.

Yes indeed it is still there.
It didn’t popped up because i was doing a list-tracing on “selection_start” which seemed possible to ask for selected_sample(.selection_start) in 2.8 and this option is no longer available.
Nice to warn about the nil value, i have overlooked that one.