Jump to content


Paste a reverse on to the end of a sample.

  • Please log in to reply
2 replies to this topic

#1 Mykra



  • Normal Members
  • PipPip
  • 41 posts

Posted 29 January 2017 - 11:21



I've been trying to hack the symmetrical waveform code by user toblerpone into pasting a reverse on to the end of a sample.

local function make_symm()

  -- Sample properties.
  local buffer        = renoise.song().selected_sample.sample_buffer
  local smp_len       = buffer.number_of_frames
  -- sample length odd or even
    local smp_mid      = smp_len
  local sel_channel   = buffer.selected_channel
  -- Determine which channel(s) to process.
  local first_channel = sel_channel
  local last_channel  = sel_channel
  if sel_channel == renoise.SampleBuffer.CHANNEL_LEFT_AND_RIGHT then
    first_channel = 1
    last_channel  = buffer.number_of_channels

  -- Process.
  for f = 1, smp_mid do
    for c = first_channel, last_channel do  
      buffer:set_sample_data(c, smp_len - f+1, buffer:sample_data(c, f))


This code nearly does what I'm after, but it overwrites the second half of the sample. I'm struggling to double the amount of frames in a sample.

I tried to use part of It-alien's 'add silence' code, but I couldn't work it out.


Ultimately, I'm trying to create a tool which goes through every sample in an instrument, adds a reversed tail, fades out the tail and then sets note-off properties to 'continue'. This would save me loads of time when chopping up my breaks!


I know there's sample slicers which kind of do this, but I prefer using individual samples rather than pingpong-looped slices.


Thanks for any help!

#2 joule


    Guruh Motha Fakka is Levitating and Knows Everything About Renoise Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPip
  • 1863 posts
  • Gender:Not Telling

Posted 31 January 2017 - 15:48

I'm pretty sure that you can't change the sample length in the API - "property 'number_of_frames' is read only".


1) Save all frames to a lua table

2) Do what you want in that table.

3) Create a new sample with sample_buffer:create_sample_data() (overwrite the old one, if you want to).

4) Copy all frame values from lua table to the new samples "sample_buffer".


You might want to store/restore slice markers (and other properties?), if you need them.

#3 Mykra



  • Normal Members
  • PipPip
  • 41 posts

Posted 31 January 2017 - 23:11

Thanks very much for the reply, Joule!


I think I can use your steps to understand what It-Aliens code is doing now.