[Solved] Help LUA: print in real time the value of selected Track insi

From the top of my head, some of what I mentioned is used in https://forum.renoise.com/t/tool-3-1-capture-track-from-instrument/34036

The app_new_document_observable should simply be put in the outermost scope of the script (like I do in this script - not within a function). Let it trigger a function that will initialize all other notifiers.

This is what will happen:

  1. User is closing a song in Renoise
  2. This always make all renoise.song() notifiers destruct automatically (AFAIK)
  3. User loads new song
  4. app_new_document_observable is banging, if you have set it up. Simply speaking it’s running the function you have told it to run. Here we have the chance to “reinitialize” the script when a new song is loaded. This is especially needed if your script uses various notifiers in renoise.song().

If you just let the notifiers be, and don’t “reinitialize” them on song change, things will go bananas. I don’t 100% know the technical details, but I am guessing the notifiers will believe that you are still in the old song and things will quickly start generating errors.

Common practice example for adding a notifier:

if not renoise.song().selected_instrument_index_observable:has_notifier(a_function_name) then
 renoise.song().selected_instrument_index_observable:add_notifier(a_function_name)
end

For removing a notifier:

if renoise.song().selected_instrument_index_observable:has_notifier(a_function_name) then
 renoise.song().selected_instrument_index_observable:remove_notifier(a_function_name)
end

Good thing to put at the end of your script :slight_smile:

renoise.tool().app_new_document_observable:add_notifier(my_initialization_function_on_song_load)

– Invoked each time a new document (song) was created or loaded.
renoise.tool().app_new_document_observable:add_notifier(function() handle_app_new_document_notification() end)

Hmm. I wonder if that syntax works. Perhaps it does, but it seems redundant. This is how I would write it:

renoise.tool().app_new_document_observable:add_notifier(handle_app_new_document_notification)