Sample loop mode lost on buffer write

I’m making a tool for batch-converting a sample’s bit depth, which requires copying the sample buffer data into a table and rewriting it into a new buffer of the same size.

For some reason, the sample’s loop mode is getting erased when I do this. Additionally, the loop’s end point is always reset to the last sample. This is weird for two reasons:

  1. The loop mode has nothing to do with a renoise.SampleBuffer, so I dunno why it should be affected.
  2. The length of the new buffer is copied from the old one, so the original loop end point shouldn’t be out of bounds (which was my original guess as the the problem).

Is this a bug? If not, I will just copy the loop values to the sample after writing.

Does not sound as if this is intended. Could you give us a small example where this happens?

The exact code I made is here in the adjust_sample_bit_depth function:

(In the above I do manually copy over the loop mode / loop end as a workaround.)

Basically it…

  1. copies the buffer data into a Lua table
  2. calls create_sample_data() with the same number_of_frames
  3. writes in the old buffer data

IC. Sample.create_sample_data indeed resets loop points. Loop points are bound to their buffer, only make sense with “their” buffer.
It does in general not really make sense to retain/copy them over when recreating sample buffers. So if you want to reuse the old ones, simply copy them over too. As you’ve done it now.

This post was helpful for me.
Handlings are different in ‘loop_mode’ enum and ‘loop_release’ boolean ,is this correct?