How can I track song progress?

I’ve been playing around with pattern juggling via OSC (triggered by my use of a controller), and realized I can create a song that consists of some set of patterns and filters controlled by an external program that sends OSC commands to move the playback point, looping parameters, muting, filters settings, and so on. Basically, the external program takes the place of a human triggering the OSC commands.

What I need, though, is a way to find out how many bars or measures (or patterns or ticks) have been played since the song was started. I’ve been searching the forum and looking through the scripting docs but have not found a way to ask Renoise, “How many ticks have passed since the song started?”, or “How many lines have been played so far?”

Is this possible?

local song_pos = renoise.song().transport.edit_pos
print (song_pos.sequence)
print (song_pos.line)

Also try:
renoise.song().transport.edit_pos_beats

Get total ammount of patterns in the sequence:
local sequence_range = #renoise.song().sequencer.pattern_sequence

the song.API speaks of song_pos.line and song_pos.sequence, but doesn’t make clear where to exactly find it.

Thanks for your reply. Unfortunately these do not seem to offer what I need.

Each of these reports information relative to a particular pattern or sequence, but not about the overall duration of the song so far.

For example, if I have a single pattern of 16 lines and have it loop, none of these will tell me when there have been over 100 lines played.

My whole goal is to be able to dynamically move the playback position to different patterns and lines, so knowing the current position doesn’t appear to help me.

I basically need some sort of counter that knows how many lines have been played.

That is where the real script-programming starts.
You can calculate the exact amount of played lines if you involve a couple of things, including the sizes of each pattern in the sequences once you poll the current position. I recon, the pattern sizes don’t change, so you can request those quickly.

renoise.song().patterns[1].number_of_lines

If you are looping specific patterns or positions, then you also need to add a routine that sets a time-stamp for you so that you can do a calculation of how many lines have passed since that loop moment.
You need a buffered counter to add these calculations into:

-One buffer that contains the total sum of played lines.
-One routine you can instantly calculate amount of played lines according to where edit_pos is right now. (add to the grand line buffer)
-And a routine that calculates the amount of lines played for that loop (add to the grand line buffer)

Here is the trick i had in mind for getting up to the actual line:

  
local lines_passed = 0 --global buffer!  
local song = renoise.song()  
local edit_pos = song.transport.edit_pos  
local patterns = song.patterns  
local sequence_pos = renoise.song().sequencer.pattern_sequence  
  
for _ = 1, edit_pos.sequence-1 do  
 lines_passed = lines_passed + patterns[sequence_pos[_]].number_of_lines  
next  
  
lines_passed = lines_passed + edit_pos.line  
  

If you want to add to the lines_passed using loops, then think of a clever routine that will calculate ahead the amount of lines that will be played to loop a certain section x times and add this to the lines_passed buffer.
I consider that this particular routine is based on an OSC command that you send to Renoise so that routine controls both the loop and the information stream between your other OSC host and Renoise (otherwise you have no chance of getting any orientation where Renoise is songwise).
If you want to use a midi device that sends a CC command to do the looping, then this routine has to be embedded in the Lua script that pipes the CC command through yet still sends the information through OSC.

This was what i had in mind when giving you those few clues…

Thanks again, but this was what I was trying to avoid :)

I was hoping there was a built-in tick counter or line counter I could access.

There could have been someone who had coded these functions before, but there is always someone who needs to be the first to do it.
There may be internal counters, but they are not available API wise.

Yeah so I guess, you would have to add+save the number of lines every time you change the playback position from OSC.