Observer when renoise has fully initialized

My tool throws an error because it’s trying to do something before Renoise has fully initialized. I know of

renoise.tool().tool_finished_loading_observable and renoise.too().app_new_document_observable but both of those fire too early when Renoise is loading.

Question: what callback or variable can I use to know that Renoise has fully loaded?

Interesting because I had a similar need and app_new_document_observable worked fine, executing only after a song was fully loaded.

What error do you get?

I’m trying to save the song via renoise.app():save_song_as(filename) as soon as Renoise has finished initializing. The error I’m getting is:

std::logic_error: 'can not save documents while the application initializes.'
stack traceback:
  [C]: in function 'save_song_as'
  main.lua:27: in function 'main'
  main.lua:32: in function <main.lua:32>

Maybe I should put a timer in front of my save_song_as() call…

Note, this only happens when Renoise first starts. Everything works as expected after that.

Well I found a work around. Would love to have a better solution in the API but for any future travelers, this works:

function main()
  if renoise.tool():has_timer(main) then
    renoise.tool():remove_timer(main)
  end
  -- do stuff here
end

-- wait a couple seconds for the app to be ready after init
renoise.tool():add_timer(main, 2000)
1 Like

Can you show me your code? Using a timeout surely is not a good idea…

You also could try to observe the idle observer in your in app_new_document_observable. If Renoise idles, everything is ready.

I tried the idle approach but no joy.

I agree that timer isn’t ideal. I think the real shame here is that Renoise doesn’t offer something like
renoise.app().initialize_complete_observable

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.