You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.5KB

  1. #include "engine.hpp"
  2. #include "gui.hpp"
  3. #include "app.hpp"
  4. #include "plugin.hpp"
  5. #include "settings.hpp"
  6. #include "asset.hpp"
  7. #include <unistd.h>
  8. using namespace rack;
  9. int main(int argc, char* argv[]) {
  10. randomSeedTime();
  11. #ifdef RELEASE
  12. std::string logFilename = assetLocal("log.txt");
  13. gLogFile = fopen(logFilename.c_str(), "w");
  14. #endif
  15. info("Rack v%s", gApplicationVersion.c_str());
  16. {
  17. char *cwd = getcwd(NULL, 0);
  18. info("Current working directory: %s", cwd);
  19. free(cwd);
  20. std::string globalDir = assetGlobal("");
  21. std::string localDir = assetLocal("");
  22. info("Global directory: %s", globalDir.c_str());
  23. info("Local directory: %s", localDir.c_str());
  24. }
  25. pluginInit();
  26. engineInit();
  27. guiInit();
  28. sceneInit();
  29. settingsLoad(assetLocal("settings.json"));
  30. // To prevent launch crashes, if Rack crashes between now and 15 seconds from now, the "skipAutosaveOnLaunch" property will remain in settings.json, so that in the next launch, the broken autosave will not be loaded.
  31. bool oldSkipAutosaveOnLaunch = skipAutosaveOnLaunch;
  32. skipAutosaveOnLaunch = true;
  33. settingsSave(assetLocal("settings.json"));
  34. skipAutosaveOnLaunch = false;
  35. if (!oldSkipAutosaveOnLaunch)
  36. gRackWidget->loadPatch(assetLocal("autosave.vcv"));
  37. engineStart();
  38. guiRun();
  39. engineStop();
  40. gRackWidget->savePatch(assetLocal("autosave.vcv"));
  41. settingsSave(assetLocal("settings.json"));
  42. sceneDestroy();
  43. guiDestroy();
  44. engineDestroy();
  45. pluginDestroy();
  46. #ifdef RELEASE
  47. fclose(gLogFile);
  48. #endif
  49. return 0;
  50. }