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 = renoise.song()
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
renoise.song():describe_undo("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
sb:prepare_sample_data_changes()
for i = 1, sc do
if io == 2 then
step = 1.0-i/sc
else
step = i/sc
end
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)) )
else
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)) )
end
end
sb:finalize_sample_data_changes()
end
end
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()
end
Thanks for any pointers, and sorry if this is posted in the wrong place.
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:
If that fails just replace the last line with:
local rs = renoise.song().instruments[renoise.song().selected_instrument_index].samples[renoise.song().selected_sample_index]
“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 renoise.song().selected_sample ~= 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.