Create_sample_data() resets/changes loop settings ..

When calling create_sample_data() it seems to keep all sample settings (sample.volume, .panning, .autoseek etc) besides the loop settings.

The following code enables loop mode (“forward”) for the second sample, even though it’s not enabled in the first sample.

(Needs a instrument with at least two samples).

TestPad:

local sample1 = renoise.song().selected_instrument.samples[1]
local buffer = sample1.sample_buffer
local sample2 = renoise.song().selected_instrument.samples[2]

sample2:copy_from(sample1)

sample2.sample_buffer:create_sample_data(
      buffer.sample_rate,
      buffer.bit_depth,
      buffer.number_of_channels,
      buffer.number_of_frames)

That’s intended. Loop ranges and modes are closely “tied” to the sample waveform data. So if you set up a new buffer, you should set up new loops as well.

If you want to retain them while copying, do so manually by memorizing them before recreating the buffer and then applying them again on the new buffer.

Ya, i realized it makes sense after posting, since the loop points are likely to be invalid x)

I still feel it would be a little more convenient to default to loop-mode “off”, but certainly no problem there.

Cheers

Ya, i realized it makes sense after posting, since the loop points are likely to be invalid x)

I still feel it would be a little more convenient to default to loop-mode “off”, but certainly no problem there.

Cheers

You can store the loop-points in an array if you need to restore those. Just make sure you add a sanity check that the stored loop point positions can actually be set into the newly created sample or not.