src/app.js

  1. /**
  2. * App initialization is done here.
  3. * @module app
  4. */
  5. const blessed = require("blessed");
  6. const Layout = require("./layout");
  7. const Keyboard = require("./keyboard");
  8. const Jack = require("./jack_client");
  9. const { settings } = require("../settings");
  10. const LV2 = require("./lv2");
  11. const store = require("./store");
  12. const program = blessed.program();
  13. const screen = blessed.screen({
  14. smartCSR: true,
  15. });
  16. try {
  17. LV2.init();
  18. Jack.init();
  19. // Create a screen object.
  20. Layout.setUpLayout(screen);
  21. Keyboard.registerKeyboardShortcuts(screen);
  22. } catch (error) {
  23. console.trace("ERROR: " + error);
  24. console.log("Aborting...");
  25. process.exit(0);
  26. }
  27. screen.render();
  28. program.enableMouse();
  29. store.app.INITIALIZED = true;
  30. Jack.poll();
  31. // Set up polling
  32. let jackPoll = setInterval(() => {
  33. Jack.poll();
  34. }, settings.JACK_POLLING_RATE);
  35. let uiPoll = setInterval(() => {
  36. store.notifySubscribers();
  37. screen.render();
  38. }, settings.UI_UPDATE_RATE);
  39. function exit() {
  40. store.clearRack();
  41. program.clear();
  42. screen.detach();
  43. return process.exit(0);
  44. }
  45. exports.exit = exit;