Need Help With Error

I created arpeggiator it works fine but when i start renoise it gives me error pop ups (4 times)
i tryed to check if renoise is nil but this does not work.

i attached error msg

thanks for your help

where the error occurs (see error dialog) you should add an

  
if (renoise.song)  
  

check to see if the song has already been created. looks like the script is called before song creation

ok i added this to main function witch calls all other functions
like

  
function render()  
if (renoise.song) then   
  

but still get errors.

OK the problem seems to be with controls notifiers i use valuebox and i if its values are changes render() function is called so i think when renoise first load script it creates controls and set values to them and then the event is raised before there is renoise.song object.

When the tool is loaded there is no song, yet:

mytool.lua ->

  
local bpm = renoise.song().transport.bpm -- error  
  
-- access the song only in your process functions or the GUI, like for example:  
local do_something_called_from_a_menu_entry()  
 bpm = renoise.song().transport.bpm -> OK  
end  
  
local do_something_called_from_a_key_binding()  
 bpm = renoise.song().transport.bpm -> OK  
end  
  

Tools are instantiated only once when the app starts. They are not loaded for every song, so you have to deal with the fact that the song changes while your script is still loaded, and also that there is none when the tool gets instantiated.

If you need want to do something in a tool on a song scope, want to do something for each “new song”, then you can add notifiers to:

  
-- invoked each time a new document (song) was created or loaded  
renoise.tool().app_new_document_observable:add_notifier(function()  
 print("a new song was loaded or created, or the initial one was loaded/created")  
end)  
  

tnx mate it solved the problem.

happy coding.