Set Pattern Loop Start/End shortcuts

I think title says it all

Yes, that would definetely be a time-saviour. Got a nice reply from vV regarding a somewhat similar topic: Play Again From Last Line Choosen
It’s probably possible in Lua but ask one of the gurus.

I’ll try and add these to my Kazakore Live Shortcuts tool when I get around to the Looping Sections I want to add…

[s]Or maybe not…

From the API documentation:

So I would expect to be able to modify the range array. But

print (renoise.song().transport.loop_sequence_range[1])  
  
renoise.song().transport.loop_sequence_range[1] = 1  
  
print (renoise.song().transport.loop_sequence_range[1])  

shows that the start positions is not changing to what I set it to. (Start with the first sequence of the loop as not the first pattern of the sequence.)

Am I being an idiot or is this not possible with the API? Seems a very simple feature which should be included! (Along with the Loop options which are set in Beats and in SongPos object as well. Even if all of them only through the Range array, although why not give access via the Read Only objects I’m not sure…)[/s]

OK I have it! Seems a bit of a mess though!

To change Start pattern of the loop range:

a = renoise.song().transport.loop_range  
a[1].sequence = Start  
renoise.song().transport.loop_range = a  

Use a[2].sequence for last pattern of the loop.

My guess is that you can modify the range array. but more like

  
renoise.song().transport.loop_sequence_range = {1, renoise.song().transport.loop_sequence_range[2]}  
  

Just like play pos and edit pos where you have to construct a new SongPos object instance…

I did try something similar to that but maybe I got my syntax wrong. As you can see from my above edit I have found a way, using the larger array of renoise.song().transport.loop_range (which uses EditPos objects for each entry of the array, so you have a .line and a .sequence) A bit messier but at least it seems to work…

But just checked and your way does work, so I must have done something wrong. Plus it is much neater for what I want to do so I will definitely be going with your method!

I think I’m coming up against race conditions or something weird now! (Although thought I had it work once briefly…)

I am trying to put in a if check to see if the start/end of the loop has changed and if it is the only one selected so pressing a button to set the start/end sequence would clear the loop selection if only a single pattern was looping before. Problem is that it appears to be reading my values as they were before they’ve been edited.

See the below has two While Loops used to freeze processing for moment, before printing the value. If they are commented out then the changes in value do not get printed correctly.

local rns = renoise.song  
 rns().transport.loop_sequence_range = {2, 8}  
 local timer = os.clock()  
 while timer > (os.clock() - 0.1) do end  
 print (rns().transport.loop_range[1].sequence)  
 rns().transport.loop_sequence_range = {3, 8}  
 while timer > (os.clock() - 0.2) do end  
 print (rns().transport.loop_range[1].sequence)  
  

I should not have to lock up the script to get it to use the updated values! Am I doing something remarkably wrong?

(Although I seem to have somehow made it also throw an error I can’t spot too now…)

Right I give up why I have an error here. Please help. Still doesn’t solve the strange race conditions I seem to be experiencing above though.

Give me an error on the bold line of:

I really don’t know what it’s referring to!

Especially if I leave out the second condition (after the AND) I don’t get the error. But then it still doesn’t work due to the race condition and thus always clears the loop selection.

Stumped, getting a headache, and less than 15min left of work for the day!

Your last rns(). Is written as rns.()
:ph34r:

Knew there must be something simple I had overlooked with my staring at it!

Now what about the fact the values don’t update it time without adding what is basically a While Wait line??

Well here are the functions I’ve written for setting loop start and end. I’m not going to publish within a my shortcuts tool until I know if there is anything that can be done about the timer bodge I am currently using though. Feel free to make a little one yourself from it if you so desire.

  
 local tool = renoise.tool()  
 local rns = renoise.song  
 local timer = os.clock()  
  
 local function lstart()  
 local a = rns().transport.loop_sequence_range[1]  
 if a == 0 then rns().transport.loop_sequence_range = {rns().transport.edit_pos.sequence, rns().transport.edit_pos.sequence}  
 else rns().transport.loop_sequence_range = {rns().transport.edit_pos.sequence, rns().transport.loop_sequence_range[2]}  
 timer = os.clock() while timer > (os.clock() - 0.01) do end -- BODGE THAT SHOULDN'T BE NEEDED!!!  
 if rns().transport.loop_sequence_range[1] == a and rns().transport.loop_sequence_range[1] == rns().transport.loop_sequence_range[2] then   
 rns().transport.loop_sequence_range = {0, 0}   
 else   
 end  
 end  
 end  
  
 local function lend()  
 local a = rns().transport.loop_sequence_range[2]  
 if a == 0 then rns().transport.loop_sequence_range = {rns().transport.edit_pos.sequence, rns().transport.edit_pos.sequence}  
 else rns().transport.loop_sequence_range = {rns().transport.loop_sequence_range[1], rns().transport.edit_pos.sequence}  
 timer = os.clock() while timer > (os.clock() - 0.01) do end -- BODGE THAT SHOULDN'T BE NEEDED!!!  
 if rns().transport.loop_sequence_range[2] == a and rns().transport.loop_sequence_range[1] == rns().transport.loop_sequence_range[2] then   
 rns().transport.loop_sequence_range = {0, 0}   
 else   
 end  
 end  
 end  
  
-- Keybindings  
 tool:add_keybinding {  
 name = "Global:Kazakore's Sequence Shortcuts:Set Loop Start Sequence",  
 invoke = function() lstart() end  
 }  
  
 tool:add_keybinding {  
 name = "Global:Kazakore's Sequence Shortcuts:Set Loop End Sequence",  
 invoke = function() lend() end  
 }  
  
-- MIDI Mappings   
 tool:add_midi_mapping{  
 name = "Kazakore's Live Functions:Sequence:Set Loop Start Sequence",  
 invoke = function(message)  
 if (message:is_trigger()) then  
 lstart ()  
 end  
 end  
 }  
  
 tool:add_midi_mapping{  
 name = "Kazakore's Live Functions:Sequence:Set Loop End Sequence",  
 invoke = function(message)  
 if (message:is_trigger()) then  
 lend ()  
 end  
 end  
 }  
  

(Think that is everything needed for the Tool, as I’ve extracted it from my larger one…)