yes, and the sorting thing is also a nice idea, while I often have huge gabs between the slots.
EDIT: I was thinking a bit about the sorting stuff.
sorting on name is not a good Idea I think, because you may have grouped your samples already like:pads,percussion,ect.
instead just get rid of the gabs like this:
BEFORE:
Piano
Drumkit
–empty–
cowbell
–empty–
–empty)–
grandma farting
Here’s something I hacked together, which you could in theory use to sort samples by any available sample property. Just write your own comparator and call sort_samples() with that function name as an argument:
-- Comparator functions
-----------------------
local comparator_name_asc = function (s1, s2)
return s1.name < s2.name
end
local comparator_name_desc = function (s1, s2)
return comparator_name_asc(s1, s2) == false
end
--
local comparator_length_asc = function (s1, s2)
if s1.sample_buffer.has_sample_data == true and s2.sample_buffer.has_sample_data == false then
return false
elseif s2.sample_buffer.has_sample_data == true and s1.sample_buffer.has_sample_data == false then
return true
elseif s1.sample_buffer.has_sample_data == true and s2.sample_buffer.has_sample_data == true then
return s1.sample_buffer.number_of_frames < s2.sample_buffer.number_of_frames
else
return false
end
end
local comparator_length_desc = function (s1, s2)
return comparator_length_asc(s1, s2) == false
end
-- Primary sort function
------------------------
function sort_samples( comparator )
local tbl = renoise.song().selected_instrument.samples
local num_swaps = 0
--[[ INSERTION SORT ]]
for i = 2, #tbl do
local k = i
while ( k > 1 and comparator(tbl[k], tbl[k-1]) ) do
renoise.song().selected_instrument:swap_samples_at(k, (k-1))
tbl = renoise.song().selected_instrument.samples
num_swaps = num_swaps + 1
k = k-1
end
end
-- iterate if needed
if num_swaps > 0 then sort_samples(comparator) end
end
-- Calling
----------
-- By name, ascending
sort_samples( comparator_name_asc )
-- By name, descending
-- sort_samples( comparator_name_desc )
-- By sample length, shortest to longest
-- sort_samples( comparator_length_asc )
-- By sample length, longest to shortest
-- sort_samples( comparator_length_desc )
It uses the insertion sort algorithm, which may not be the fastest in the world, but it gets the job done. If enough people care enough, I might put together a tool to add items to the right-click menu in the instrument’s sample list.