Callback custom function

Hi everyone, I just have started experimenting with Renoise. I am trying to figure out if it is possible for Renoise to call my function at an event. As an example, I have a pattern with length 64 and I want to get a notification when the position in the pattern is 0.

Is this possible?

Best regards

Yes, if you write some code.

Some (maybe correct) snippets that might help:

current_pattern =[] - 1

current_line =

You need to have Renoise automatically invoke the code by registering a function that does the pattern-position checking:

renoise.tool():add_timer(function_name, timer_interval) -- An interval of 100 or so should be OK. Need to experiment

Something like that.

Cool! I thought I was fairly up-to-date, but didn’t know until now that Renoise had a timer.

I am guessing that this is a more forceful and predictable way than using the good old app_idle_observable trick for this task? (which on the other hand probably has the advantage of being more transparent in terms of cpu load, and might be better if your need for correct timing is not crucial).

Click to view contents

In any case, for the no0bs (myself included) it’s worth a mention that it’s a good idea to as quickly and efficiently as possible filter out any irrelevant function calls caused by these timers by using some simple if statement.

local rns =
local cached_value_from_last_timer_cycle
function timer_function()
 if not rns.transport.playback_pos.line == cached_value_from_last_timer_cycle then
   cached_value_from_last_timer_cycle = rns.transport.playback_pos.line 
 -- code to execute here. happens once when playback_pos.line is changing.

I’ve no idea what’s the best way to do this. My experience is largely from hacking about, getting something that appears to work, often by copying bits of code form other people’s tools or comments.

In my case I was working on a script that would track position in patterns, count how often a loop has executed, and schedule new looping points. Although there was constant position tracking I didn’t notice any side-effects from CPU load.

I did use some flags to track previous state,

Thanks everyone, especially @Neurogami

Thanks everyone, especially @Neurogami

Let us know how this works out. New tools always welcome!