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.

64 lines
1.2KB

  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 VERSION
  12. std::string logFilename = assetLocal("log.txt");
  13. gLogFile = fopen(logFilename.c_str(), "w");
  14. #endif
  15. if (!gApplicationVersion.empty()) {
  16. info("Rack v%s", gApplicationVersion.c_str());
  17. }
  18. {
  19. char *cwd = getcwd(NULL, 0);
  20. info("Current working directory: %s", cwd);
  21. free(cwd);
  22. std::string globalDir = assetGlobal("");
  23. std::string localDir = assetLocal("");
  24. info("Global directory: %s", globalDir.c_str());
  25. info("Local directory: %s", localDir.c_str());
  26. }
  27. pluginInit();
  28. engineInit();
  29. guiInit();
  30. sceneInit();
  31. if (argc >= 2) {
  32. // TODO Set gRackWidget->lastPath
  33. gRackWidget->loadPatch(argv[1]);
  34. }
  35. else {
  36. gRackWidget->loadPatch(assetLocal("autosave.vcv"));
  37. }
  38. settingsLoad(assetLocal("settings.json"));
  39. engineStart();
  40. guiRun();
  41. engineStop();
  42. settingsSave(assetLocal("settings.json"));
  43. gRackWidget->savePatch(assetLocal("autosave.vcv"));
  44. sceneDestroy();
  45. guiDestroy();
  46. engineDestroy();
  47. pluginDestroy();
  48. #ifdef VERSION
  49. fclose(gLogFile);
  50. #endif
  51. return 0;
  52. }