Updated Tool (3.1): Sort Instruments

I don’t know about others, but for me this would be useful. Especially the possibility to randomize the sample list. I’m looking for efficient ways to build lively acoustic drum instruments with multisampled sample material. I’d use the randomize in conjunction with Velocity Layerer and Grab Sample Keyzones for some hardcore layering. :)

If you see it fit to take this on, I’d figure the best place to put the tool would be the sample list context menu, as the Organize instruments -tool appears in the instrument list context menu. I’d figure the feasible organization methods in the instrument organizer tool, that would correlate for samples would be:

-Name
—just for general neatness, maybe some specific purposes such as ordering a botched up list of samples,

-Most used
—for clarity, I guess this could be useful

-Size
—possibly? there might be some weird usage scenario for that, but cannot think one up right now… :wacko:

-Random
—yes! this is the one for me. Especially to use with the tools i mentioned.

-Reverse
—I actually have a tool for that already, but it would be SO cool if your thorough instrument organizing code could be used here also…

The appearance order -stuff seems a bit far fetched… Cannot think why someone would do that. Maybe? Consider someone that stuffs all his speech samples as a drum kit into a single instrument, then composes, then wants to order the samples. So maybe, but that’s probably a rare scenario. (Not to mention that this would demand a lot of coding…)

One other option, that I think could be useful would be the possibility to reorder samples somehow based on the key zones. (left to right, up to down?) I don’t know.

For me the true killer feature, as I’ve said too many times already (sorry bout that…) would be: randomize.

That seems doable. I would make the tool updating the keyboard mapping as well, but I’d put a toggle for that in case you want true randomization then.

-Name
-Most used (in patterns then)
-Size
-Random
-Reverse
-By keymapping

I’m kind of on a musical period right now but this could be my next thing. “Sample organizer” :)

Great tool. Would love an update for 2.8.

Updated for 3.1 with speed optimizations et c. It’s all in the original post!

1 Like

Very useful. Always when tracking there’s some unused sounds left between tons of used. There was no way to find them. Now just enough to sort them with this tool by most used, and I got them. Salvation. Cheers. :slight_smile:

Bit of a bug when three instruments have the same name , they don`t sort properly:

Start with simple reversed order of instruments to tracks:

00: a_sample --on track 3
01: a_sample --on track 2
02: a_sample --on track 1

goes to

00: a_sample --on track 1 --right
01: a_sample --on track 3 --wrong
02: a_sample --on track 2 --wrong

after horizontal sort

7781 Sort Horizontal Bug.xrns

Thanks, I was looking for this. I sorted it by hand all the time :confused: Should be natively available in Renoise.

Mh… the horizontal and vertical sort feature doesn’t work under Linux or I don’t get it.
Is it supposed to work for sample based instruments and plugins?

Yes. What is happening?

The horizontal sorting will sort the instrument list according to the first track an instrument is found in (left to right). Example: If instrument 2 is used in track 1 and instrument 1 is used in track 2, they will switch place.

The vertical sorting will sort the instrument list according to the first line an instrument is used on.
Example: The very first note found in a song would always refer to instrument 00. The very last note found in a song would always refer to the last used instrument in the instrument list.

Ok, then I got it. I’ll post an example xrns the next days and play with it again.
Sometimes it’s doing nothing. Does it matter if Track name is the same as instrument name?

No, that doesn’t matter. Let me know what bugs you find! The tool was released for Renoise 2.8 and it’s possible that I should revisit the code :slight_smile:

This is what I get when sorting horizontally:

Sorting vertically and according to name works though.sort.xrns (143.5 KB)

Testet in version 3.1 and 3.1.1

1 Like

@joule: could you reproduce it or am I missing something?

Yes! (that’s why i liked your comment). I’m refactoring the code. I can’t say how long that will be, but I’m guesssing it’s not crucial anyway :slight_smile:

1 Like

Cool thanks :slight_smile:

Still use this one a lot, ordering the instrument names after tracks get towards finishing.

I needed an extra option to append the length of the samples to the instrument name in seconds (multi instrument samples excluded), so dit a few query’s in chatgpt which came up with the following;

-- Append or update the sample length in the instrument name (for single-sample instruments)
function append_sample_length_to_name()

  for i, instrument in ipairs(renoise.song().instruments) do
    local samples = instrument.samples

    -- Skip multi-sampled instruments
    if #samples == 1 and samples[1].sample_buffer.has_sample_data then
      local sample = samples[1]
      local sample_buffer = sample.sample_buffer

      -- Calculate the length in seconds
      local sample_rate = sample_buffer.sample_rate
      local length_in_seconds = sample_buffer.number_of_frames / sample_rate

      -- Format to 2 decimal places
      local formatted_length = string.format("%.2f", length_in_seconds)

      -- Remove any existing appended length before adding the updated length
      local new_name = instrument.name:gsub("%s%[%d+%.%d+s%]", "")

      -- Append the updated length to the instrument name
      new_name = new_name .. " [" .. formatted_length .. "s]"
      instrument.name = new_name
    end
  end

end

-- Add the function to the tool menu
renoise.tool():add_menu_entry {
  name = "Instrument Box:Sort Instruments...:Update Sample Length",
  invoke = function() append_sample_length_to_name() end
}

1 Like