Play Again From Last Line Choosen

Yes, for example pressing Shift+Space(play from cursor) from line number 12, entering some more notes and hitting “play from last line chosen” would be nice. It’s not that big a hurdle going back and choosing line number 12, but it would be nice to just go for example CTRL+Space and it would remember the last play position. Hope this makes sense.

Something like this?:
3611 com.vvoois.PlayFromLastPosition_Rns280_V1.xrnx

Keyshortcut to define:Globals -> Transport -> Play from last position

Perfect! Is it possible to avoid the “jumping back”? Example: Tweaking on line 40 etc. and playing from line 28 without changing the position.

Commenting – renoise.song().transport.edit_pos = edit_pos" seems to work. Way cool vV!

Glad i could get you on the right track.

Hi again. Just wondering if it’s possible to stop the track and then “play from last line”? Something like: if stopped use the old position value.

You might want to change the line
edit_pos = renoise.song().transport.edit_pos
into:
edit_pos = renoise.song().transport.playback_pos

Perhaps that works more properly or you need a specific fixed line to jump to?

Now I’m getting confused. It worked the first time but you couldn’t stop and edit and then “continue from last line played”. In “programming” terms it would be something like: Play from current line: register variable “linenumber”. Editing something. Play again from variable “linenumber.” That should make sense; kinda like a free Block Play.

Well, this function is called each time the playing is started or stopped:

  
  
local function isPlaying()  
 edit_pos = renoise.song().transport.edit_pos  
end  
  

Even though the position where the song starts playing is stored, the last position will be stored from the moment that you stop the song.

If you want this so called “edit_pos” to only contain the sequence position and line in that sequence when you “play” the song you could easily add a condition:

  
  
local function isPlaying()  
 if renoise.song().transport.playing then  
 edit_pos = renoise.song().transport.edit_pos  
 end  
end  
  
  

Now edit_pos will only register the position from where the playing starts. Remember that both the sequence position and line number reference are in edit_pos and you need to transfer from and to the edit_pos variable to allow to change the positions in Renoise itself.
If you want to lock down a specific position, you can always add a shortcut that simply records the current true edit position as the real offset that is being played from everytime you hit that shortcut to start from that specific line, rather than using the observable that calls the isPlaying function causing constantly changes to the last played position.

This works:

local my_pos = nil  
  
local function RegisterPosition()  
 local song = renoise.song()  
 my_pos = renoise.song().transport.edit_pos  
end  
  
local function PlayRegisteredPosition()  
 if my_pos == nil then  
 my_pos = renoise.song().transport.edit_pos  
 end  
 renoise.song().transport.playback_pos = my_pos  
 renoise.song().transport.playing = true  
end  

Would be nice though with one single shortcut.

Add a timer variant to it that measures how many times the shortcut is pressed within the same time.
If pressed two times in a row:register position, if pressed one time, play the position after 20msecs.
I haven’t tested this code, but you can try and fool around with it.

  
  
local grace_wait = 0  
local short_cut_pressed = 0  
local grace_turn = 0  
  
 if not renoise.tool().app_idle_observable:has_notifier(idle_handler) then  
 renoise.tool().app_idle_observable:add_notifier(idle_handler)  
 end  
  
function shortcut_pressed()  
 grace_wait = os.clock()  
 grace_turn = 1  
end  
  
  
function idle_handler()  
 if os.clock() - grace_wait > .1 and grace_turn ~= 0 then  
  
 if short_cut_pressed == 0 then  
 short_cut_pressed = 1  
 elseif short_cut_pressed == 1 then  
 short_cut_pressed = 0  
  
 local song = renoise.song()  
 my_pos = renoise.song().transport.edit_pos  
 end  
  
 end  
  
 if os.clock() - grace_wait > .2 and short_cut_pressed == 1 then  
 short_cut_pressed = 0  
 if my_pos == nil then  
 my_pos = renoise.song().transport.edit_pos  
 end  
 renoise.song().transport.playback_pos = my_pos  
 renoise.song().transport.playing = true  
 end  
 grace_turn = 0  
end  
  

Good idea

Been trying to fool around with something like below. Can’t get it to work and your example swooshes me.

local number = 0  
local aclock = nil  
local my_pos = nil  
  
local function SetMark()  
 my_pos = renoise.song().transport.edit_pos  
end  
  
local function PlayMark()  
 if my_pos == nil then  
 my_pos = renoise.song().transport.edit_pos  
 else  
 renoise.song().transport.playback_pos = my_pos  
 renoise.song().transport.playing = true  
 end  
end  
  
local function MarkAndPlayZZZZZ() -- doubleclicker test  
 number = number + 1  
 if number == 1 then -- start timer and play mark  
 aclock = os.clock()  
 PlayMark()  
 print("1")  
 elseif (number == 2) and (aclock < os.clock() -1) then  
 PlayMark()  
 print("2")  
 else -- set mark  
 number = 0  
 SetMark()  
 PlayMark()   
 print("3")  
 end  
end  

Time for sleep

You could try “os.clock() - aclock < .15” instead of “aclock < os.clock() -1”

But i experienced difficulties as well using such constructions, so used the idle notifier API function that takes care our designated function is called every 10msecs and responses are quicker handled if they are not caught the first time.

renoise.tool().app_idle_observable:add_notifier(idle_handler)