Lua: Slice Markers Beyond Sample Length

- This topic has similarities to a previous one.

This video demonstrates how it’s possible to move existing slice markers and insert new ones beyond the sample length. When a sample is edited, any slice markers are moved first and then the sample buffer is changed. So a slice_markers notifier can be used to place slices into the section that will not exist afterwards.

As the video shows, this can lead to some garbled or non-existent samples. The real problem is that they’re completely inaccessible and cannot be moved/deleted.

While these extraneous slices might seem harmless in this small example, in more complex code they can cause hard crashes. If there’s changes to the sample buffer, Renoise should probably check for any slice markers that are beyond the sample length and delete them.

Code from the video:

bypass = false
sample = renoise.song():instrument(1):sample(1)
sample:insert_slice_marker(1000)
sample:insert_slice_marker(2000)
a = sample.slice_markers[1]

sample.slice_markers_observable:add_notifier(function()
  if bypass == false then
    if a ~= sample.slice_markers[1] then marker_stuff() end
  end
end)

function marker_stuff()
  bypass = true
  sample:move_slice_marker(sample.slice_markers[2], 2500)
  sample:insert_slice_marker(2600)
  bypass = false
  rprint(sample.slice_markers)
end
3 Likes

Yeah, looks like the same issue you’ve run into there. Like you say probably some internal bounds checking that needs a fix.

1 Like