Perform Operations On The Current Selection In Sample?

Just bought Renoise and have been looking through the scripting API.

Maybe I just missed it, but is there a way to perform operations on the current selection in the sample editor? It would be ideal for what I’d like to do to be able to perform the same basic operations on the selection that we can currently do for the whole sample (save, load/replace, edit values directly).

See https://code.google.com/p/xrnx/source/browse/trunk/Tools/deprecated/com.renoise.SampleChannelsSwapper.xrnx/main.lua for a simple example

Right, I had seen that it was possible to modify the sample values, I guess what I’m asking about is more:

  1. How would you go about saving a sample selection as a wav file?
  2. Can you load a wav file into a temporary buffer (not the current sample buffer) to then do more processing on?
  3. Can values be added / removed from the current sample buffer at a specified location, resulting in a shorter or longer buffer?

What I’m trying to do right now would be similar to the rubberband plugin but to have it operate on the current selection instead.

Thanks!

You would need to save header information with that snippet, for that i would suggest you to look at documentation you can find on for instance www.wotsit.org
Simply form the string with all the required characters and then attach the buffer contents behind it i guess. I don’t know someone having done this before in Lua here…

… or use:

  
-- Export sample data to a file. Possible errors are shown to the user,  
-- otherwise success is returned. Valid export types are 'wav' or 'flac'.  
renoise.song().instruments[].samples[].sample_buffer:save_as(filename, format)  
 -> [boolean - success]  
  

Which will save the whole file, but you can create and use a temporary instrument or sample in Renoise programatically and use this as scratchpad. The attach tool “kinda” does something like that and maybe helps as inspiration…