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?”
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.
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
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…