Sample.Loop_End Can Temporarily Be < Loop_Start In Notifiers

I think I may have discovered some strange behavior with the sample.loop_end and .loop_start fields. Here’s what I did:

  1. Load a sound, set a loop only 1 sample long.
  2. Execute this code:
  
local function loop_endpoints_changed()  
 local samp = renoise.song().selected_sample  
 print("Loop start: " .. samp.loop_start .. " Loop end: " .. samp.loop_end)  
end  
  
renoise.song().selected_sample.loop_start_observable:add_notifier(loop_endpoints_changed)  
  
renoise.song().selected_sample.loop_end_observable:add_notifier(loop_endpoints_changed)  
  
  1. In the sample editor, drag the loop end marker to the left.

  1. I get this in the terminal:
  
Loop start: 200 Loop end: 199  
Loop start: 200 Loop end: 200  
Loop start: 200 Loop end: 199  
Loop start: 200 Loop end: 200  
Loop start: 200 Loop end: 199  
Loop start: 200 Loop end: 200  
...  
  

Every time I move the mouse another pixel to the left while dragging, another two of those lines come out in the terminal.

I think it’s odd that sample.loop_end is ever less than sample.loop_start, as its (loop_end’s) value usually indicates the index of the last sample in the loop; of course, it corrects itself (hence the “Loop start: 200 Loop end: 200” lines), but this sort of behavior could be difficult for a script to deal with, e.g. if it had a notifier on loop_start_observable or loop_end_observable. Also note that this behavior only occurs when dragging the loop end marker past the loop start marker, not the other way around. Dragging the loop start marker past the loop end marker does not trigger any notifications on loop_start_observable - even if this isn’t considered a bug, it’s inconsistent like that.

Hey Cocoa,

thanks for the detailed report. The loop end and start’s are not set atomically in Renoise. When attaching to both, the loop start and end, it indeed may happen (within notifiers only though) that the loop end is smaller than the loop start.

I understand that this may cause troubles in scripts, so we will try to fix this for the next update.

If you have troubles with this in one of your scripts let me know where exactly, and I’ll try to help with a workaround.