self.sessionPrefix=""#set in nsm_openOrNewCallback. If we want to save and load resources they need to be in the session dir. We never load from outside, the scheme is always "import first, load local file"
self.absoluteJsonFilePath=""#set in nsm_openOrNewCallback. Makes it possible to save a file manually. Even in script mode or debug mode.
self.guiWasSavedAsNSMVisible=True#set by nsm_openOrNewCallback, but without a save file we start with an initially visible GUI
self.nsmClient=None#We get it from api.startEngine which gets it from the GUI. nsmClient.reactToMessage is added to the global event loop there.
self.history=History()#Undo and Redo. Works through the api but is saved in the session. Not saved in the save file.
self.guiSharedDataToSave={}#the gui can write its values here directly to get them saved and restored on startup. We opt not to use the Qt config save to keep everything in one file.
self.recordingEnabled=False#MidiInput callbacks can use this to prevent/allow data creation. Handled via api callback. Not saved.
self.eventLoop=None# added in api.startEngine
self.data=None#nsm_openOrNewCallback
defaddSessionPrefix(self,jsonDataAsString:str):
"""During load the current session prefix gets added. Turning pseudo-relative paths into
#A workaround to have the program adopt to JACK transport position. It already tries but there is no song yet, so it is song-duration=0 and setting transport is not possible beyond song duration.
#We fake a song length which will shortly be set to the real size.
atexit.register(self.stopSession)#this will handle all python exceptions, but not segfaults of C modules.
cbox.do_cmd("/master/set_ppqn_factor",None,[D4])#quarter note has how many ticks? needs to be in a list.
self.sessionPrefix=ourPath#if we want to save and load resources they need to be in the session dir. We never load from outside, the scheme is always "import first, load local file"
self.data=None#This makes debugging output nicer. If we init Data() here all errors will be presented as follow-up error "while handling exception FileNotFoundError".
except(NotADirectoryError,PermissionError)ase:
self.data=None
logging.error("Will not load or save because: "+e.__repr__())