Playback Position Problems

I want to make a script where I can set a bookmark anywhere in the song and playback from that position. The reason for this is that I want to set the bookmark before a short section that I wish to edit, and then be able to playback only that section without jumping back with the edit cursor.

But I ran into some problems. The question is if these problems are problems with my script or with Renoise’s scripting system.

When I save a bookmark I just copy renoise.song().transport.edit_pos to a local varible bookmark_pos. On playback I set renoise.song().transport.playback_pos to bookmark_pos. This always plays from the correct line but ignores the sequence and just starts at the current pattern. The code for this is shown below.

  
  
renoise.tool():add_keybinding {  
 name = "Global:Transport:Play/Stop from Bookmark",  
 invoke = function(repeated) play_from_bookmark() end  
}  
  
renoise.tool():add_keybinding {  
 name = "Global:Transport:Set Bookmark",  
 invoke = function(repeated) set_bookmark() end  
}  
  
local bookmark_pos  
function play_from_bookmark()  
  
 renoise.song().transport.playback_pos = bookmark_pos   
 renoise.song().transport:start(2)  
  
end  
  
function set_bookmark()  
 bookmark_pos = renoise.song().transport.edit_pos  
end  
  

But it is possible to change playback position across patterns sometimes, which the code below does (but it has some other problems)

  
renoise.tool():add_keybinding {  
 name = "Global:Transport:Play/Stop from Bookmark",  
 invoke = function(repeated) play_from_bookmark() end  
}  
  
renoise.tool():add_keybinding {  
 name = "Global:Transport:Set Bookmark",  
 invoke = function(repeated) set_bookmark() end  
}  
  
local bookmark_pos  
  
function play_from_bookmark()  
  
 renoise.song().transport.playback_pos = bookmark_pos   
  
 if ( renoise.song().transport.playing ) then  
 renoise.song().transport:stop()  
  
 else  
 renoise.song().transport:start(2)  
 end   
end  
  
function set_bookmark()  
 bookmark_pos = renoise.song().transport.edit_pos  
 renoise.app():show_status(string.format("seq:%d line:%d",bookmark_pos.sequence,bookmark_pos.line))  
end  
  
  

I think it is a problem in Renoises scripting system. In the code below the playback position sequence gets correctly updated because I add a pause between changing it and starting playback. The code works but if the timer value is set to one it will not work.

  
  
renoise.tool():add_keybinding {  
 name = "Global:Transport:Play/Stop from Bookmark",  
 invoke = function(repeated) play_from_bookmark() end  
}  
  
renoise.tool():add_keybinding {  
 name = "Global:Transport:Set Bookmark",  
 invoke = function(repeated) set_bookmark() end  
}  
  
  
local bookmark_pos  
  
function play_from_bookmark()  
 if ( renoise.song().transport.playing ) then  
 renoise.song().transport:stop()  
 else  
 renoise.song().transport.playback_pos = bookmark_pos   
 renoise.tool():add_timer(play_continue,50)  
 end   
end  
  
function play_continue()  
 renoise.song().transport:start(2)  
 renoise.tool():remove_timer(play_continue)  
end  
  
function set_bookmark()  
 bookmark_pos=renoise.SongPos(renoise.song().transport.edit_pos.sequence,renoise.song().transport.edit_pos.line)  
end  
  
  

I’m away from my Renoise this week, but I still login to the forums and read; so I can’t test the code.

You’re saying it has something to do with renoise.tool():add_timer(play_continue,1), right?

Can you post a reduced code snippet that showcases the problem / is easier to read?

The problem is that renoise.song().transport.playback_pos does not get updated correctly. The code below will not work if the playback position is in the first pattern when the code is run. Adding a pause between the two lines makes it work correctly (thats what the timer is for above).

  
renoise.song().transport.playback_pos = renoise.SongPos(2,2)  
renoise.song().transport:start(2)  
  

Indeed needs a bit of time to get the “playback_pos = something” applied when immediately starting the song afterwards. Will fix this for the next 2.7 beta. Thanks for the detailed description.