Applying a function to multiple selected samples?


(muckleby) #1

I have a simple function that adusts the finetune property of an instruments samples -

function sample_finetune_up()
 for i=1,#renoise.song().selected_instrument.samples do    
  renoise.song().selected_instrument.samples[i].fine_tune = renoise.song().selected_instrument.samples[i].fine_tune + 1
 end
end

What I’d like to do is apply this to only selected samples, much in the same way that adjusting the Sample Properties via the GUI functions.

Is this possible via the API?


#2

Probably along similar lines muckleby (only the thread is applied to the instruments slots rather than sample slots) -> https://forum.renoise.com/t/multiple-instrument-selections/38196


(joule) #3

Like 4Tey says. But it’s not terribly difficult making your own GUI (sample list) to allow this.

Here is a snippet for VBSandbox showing a principle (it acts on the selected instrument):

Click to view contents
local vb = renoise.ViewBuilder()
local selected_samples = { }
local main_content = vb:column { }
local sample_list_container = vb:row { }
local toolbar_container = vb:row { }
local sample_list = vb:column { }
local fine_tune_element = vb:row {
 vb:text {
 text = "Finetune"
 },
 vb:button {
 text = "-", width = 20,
 notifier = function()
 for k, v in ipairs(selected_samples) do
 renoise.song().selected_instrument:sample(k).fine_tune = renoise.song().selected_instrument:sample(k).fine_tune - 1
 end
 end
 },
 vb:button {
 text = "+", width = 20,
 notifier = function()
 for k, v in ipairs(selected_samples) do
 renoise.song().selected_instrument:sample(k).fine_tune = renoise.song().selected_instrument:sample(k).fine_tune + 1
 end
 end
 }
}
toolbar_container:add_child(fine_tune_element)
sample_list_container:add_child(sample_list)

for sample_index, sample in ipairs(renoise.song().selected_instrument.samples) do
 local sample = vb:row {
 vb:text {
 text = string.format("%02d", sample_index),
 },
 vb:text {
 text = sample.name,
 width = 100,
 },
 vb:checkbox {
 notifier = function(v)
 selected_samples[sample_index] = v or nil
 end
 }
 }
 sample_list:add_child(sample)
end
main_content:add_child(toolbar_container)
main_content:add_child(sample_list_container)
return main_content

(muckleby) #4

ahah thanks thats food for thought!
thanks for the code example Joule, admittedly its a bit over my head - not entirely sure how to implement it at the moment but will be handy to come back to when Ive got a bit more scripting experience!


(joule) #5

NP. It took me a long time to start using Viewbuilder, because I thought it was too difficult for me. But it’s quite simple and consistent once you know the fundamentals. Don’t hesitate to ask questions if you get stuck or need some starting points!