Is This A Correct Way To Use Notifiers?

I have a script with no GUI and I have added two notifiers at the top like this:

  
----------------------------------------------------------------------  
--notifiers  
----------------------------------------------------------------------  
function start()   
renoise.song().selected_track_index_observable:add_notifier(function()  
 my_main_func()   
 end)  
end  
----------------------------------------------------------------------  
renoise.tool().app_new_document_observable:add_notifier (  
 function() start() end  
)  
  
  
----------------------------------------------------------------------  

It is followed by keybinding and the a couple of functions including the main one.

Is this a legitimate way of using notifiers to get the tool to run on start-up? It seems to run fine but I just wanted to check before uploading an xrnx as I couldn`t find a comparable example.

Yes, and no. In your example “start” will be called for every new song, and also on startup, because your script first gets loaded without a song, then “start()” is called for the very first song that gets activated (a clean song or autosaved song and what you’ve passed to Renoise as argument to load as initial song).

I do want this script to run in every song aswell (i.e. all the time as it is a new form of auto capture) so is what I have done necessary, or excessive?

… and mainly not to break/bug anything :)

thanks

Then its just fine. The only thing you could “simplify” in there is maybe something like this:

  
----------------------------------------------------------------------  
-- notifiers  
----------------------------------------------------------------------  
  
function selected_track_index_changed()   
 -- my_main_function()...  
end  
  
  
----------------------------------------------------------------------  
  
function attach_to_song()   
 renoise.song().selected_track_index_observable:add_notifier(  
 selected_track_index_changed)  
end  
  
  
----------------------------------------------------------------------  
  
renoise.tool().app_new_document_observable:add_notifier(  
 attach_to_song)  
  
  

But that just a matter of taste and depends on what else you do in there. Does exactly the same like your version…

Ok thanks!

will check this out too.