function sampleslicesloopON()
local si=renoise.song().selected_instrument
local number = (table.count(si.samples))
for i=2,number do
--Set Loop_mode Forward & On
si.samples[i].loop_mode =2
--Set Loop_start to Loop_end - Loop_end/10 (Probably doesnt work as well as it should.
si.samples[i].loop_start = (si.samples[i].loop_end - si.samples[i].loop_end /10)
end
--Announce an informative Blöö.
renoise.app():show_status("blöö")
end
I don’t think the loop_start_setting is exactly where you want it to be, but this should at least show you the technique used. I can tweak this for you, but you’ll have to give more instructions regards how you want the start_loop to be placed.
edited code slightly for the sake of brevity. … It wouldn’t be that hard to set the loop_start to be the sample_length-aspecific_amount_maybe_even_a_percentage_count…
OK. So i couldn’t even execute this snippet, sorry I’m really not into text-based programming/scripting.
So i decided to draw some wireframes to explain my point here.
But a l33t coder could calculate the snap values manually, based on the song tempo and the sample rate of the sample (and also keep in mind the beatsync value, if necessary)
local sample = renoise.song().selected_sample
if (not sample.sample_buffer.has_sample_data) then
renoise.app():show_warning('No sample data!')
else
local samples_per_beat = nil
if (sample.beat_sync_enabled) then
local lpb = renoise.song().transport.lpb
local beats_in_sample = sample.beat_sync_lines / lpb
local frames_in_sample = sample.sample_buffer.number_of_frames
samples_per_beat = frames_in_sample / beats_in_sample
else
local seconds_per_beat = 60 / renoise.song().transport.bpm
samples_per_beat = sample.sample_buffer.sample_rate * seconds_per_beat
end
local samples_per_128th_note = samples_per_beat / 32
local samples_per_64th_note = samples_per_beat / 16
local samples_per_32nd_note = samples_per_beat / 8
local samples_per_16th_note = samples_per_beat / 4
local samples_per_8th_note = samples_per_beat / 2
end