Audio plugin host https://kx.studio/carla
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.

219 lines
7.2KB

  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Carla plugin host
  4. # Copyright (C) 2011-2014 Filipe Coelho <falktx@falktx.com>
  5. #
  6. # This program is free software; you can redistribute it and/or
  7. # modify it under the terms of the GNU General Public License as
  8. # published by the Free Software Foundation; either version 2 of
  9. # the License, or any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # For a full copy of the GNU General Public License see the GPL.txt file
  17. # ------------------------------------------------------------------------------------------------------------
  18. # Imports (Config)
  19. from carla_config import *
  20. # ------------------------------------------------------------------------------------------------------------
  21. # Imports (Global)
  22. if config_UseQt5:
  23. from PyQt5.QtCore import QEvent
  24. from PyQt5.QtWidgets import QLabel, QTabWidget
  25. else:
  26. from PyQt4.QtCore import QEvent
  27. from PyQt4.QtGui import QLabel, QTabWidget
  28. # ------------------------------------------------------------------------------------------------------------
  29. # Imports (Custom Stuff)
  30. from carla_host import *
  31. # ------------------------------------------------------------------------------------------------------------
  32. # Main Window
  33. #class CarlaHostW(HostWindow):
  34. #def __init__(self, host):
  35. #HostWindow.__init__(self, host)
  36. # -------------------------------------------------------------
  37. # Set-up GUI stuff
  38. #self.fInfoText = ""
  39. #self.fInfoLabel = QLabel(self)
  40. #self.fInfoLabel.setAlignment(Qt.AlignRight|Qt.AlignVCenter)
  41. #self.fInfoLabel.setText("Engine stopped")
  42. #self.fDockLocation = Qt.LeftDockWidgetArea
  43. #self.fDockFloating = 0
  44. #if MACOS and False: # TODO: check if NOT using pro theme
  45. #self.fInfoLabel.hide()
  46. #self.setUnifiedTitleAndToolBarOnMac(True)
  47. # -------------------------------------------------------------
  48. #self.ui.act_settings_show_toolbar.triggered.connect(self.slot_toolbarShown)
  49. #self.ui.dockWidget.dockLocationChanged.connect(self.slot_dockLocationChanged)
  50. #self.ui.dockWidget.topLevelChanged.connect(self.slot_dockTopLevelChanged)
  51. #self.ui.dockWidget.installEventFilter(self)
  52. #QTimer.singleShot(0, self.slot_initWidgets)
  53. # -----------------------------------------------------------------
  54. #def engineChanged(self):
  55. #self.fInfoText = "Engine running | SampleRate: %g | BufferSize: %i" % (self.host.get_sample_rate(), self.host.get_buffer_size())
  56. #self.fInfoLabel.setText("%s | %s" % (self.fInfoText, self.fTransportText))
  57. #def engineStarted(self):
  58. #self.engineChanged()
  59. #def engineStopped(self):
  60. #self.fInfoText = ""
  61. #self.fInfoLabel.setText("Engine stopped")
  62. # -----------------------------------------------------------------
  63. #def updateInfoLabelXandSize(self):
  64. #tabBar = self.fContainer.tabBar()
  65. #x = tabBar.width() + 20
  66. #width = self.fContainer.width() - tabBar.width() - 20
  67. #if self.fDockLocation == Qt.LeftDockWidgetArea and self.fDockFloating <= 1:
  68. #x += self.ui.dockWidget.width()
  69. #self.fInfoLabel.move(x, self.fInfoLabel.y())
  70. #self.fInfoLabel.resize(width, self.fInfoLabel.height())
  71. #if self.fDockFloating == 1:
  72. #self.fDockFloating = 2
  73. #def updateInfoLabelY(self):
  74. #tabBar = self.fContainer.tabBar()
  75. #y = tabBar.mapFromParent(self.ui.centralwidget.pos()).y()
  76. #if not self.ui.toolBar.isVisible():
  77. #y -= self.ui.toolBar.height()
  78. #self.fInfoLabel.move(self.fInfoLabel.x(), y)
  79. # -----------------------------------------------------------------
  80. #@pyqtSlot()
  81. #def slot_initWidgets(self):
  82. #tabBar = self.fContainer.tabBar()
  83. #x = tabBar.width() + 20
  84. #y = tabBar.mapFromParent(self.ui.centralwidget.pos()).y()
  85. #if self.fDockLocation == Qt.LeftDockWidgetArea and self.fDockFloating <= 1:
  86. #x += self.ui.tabUtils.width()
  87. #self.fInfoLabel.move(x, y)
  88. #self.fInfoLabel.resize(self.fContainer.width()-tabBar.width()-20, tabBar.height())
  89. #@pyqtSlot(bool)
  90. #def slot_dockTopLevelChanged(self, top):
  91. #self.fDockFloating = 1 if top else 0
  92. #self.updateInfoLabelXandSize()
  93. #@pyqtSlot(Qt.DockWidgetArea)
  94. #def slot_dockLocationChanged(self, area):
  95. #self.fDockLocation = area
  96. #self.updateInfoLabelXandSize()
  97. #@pyqtSlot()
  98. #def slot_toolbarShown(self):
  99. #self.updateInfoLabelY()
  100. # -----------------------------------------------------------------
  101. #def eventFilter(self, obj, event):
  102. #if obj == self.ui.dockWidget and event.type() == QEvent.Resize:
  103. #self.updateInfoLabelXandSize()
  104. #return HostWindow.eventFilter(self, obj, event)
  105. #def closeEvent(self, event):
  106. #HostWindow.closeEvent(self, event)
  107. ## needed if using separate patchbay window
  108. #QApplication.instance().quit()
  109. #def resizeEvent(self, event):
  110. #HostWindow.resizeEvent(self, event)
  111. #self.updateInfoLabelXandSize()
  112. #def timerEvent(self, event):
  113. #HostWindow.timerEvent(self, event)
  114. #if event.timerId() == self.fIdleTimerFast:
  115. #self.fInfoLabel.setText("%s | %s" % (self.fInfoText, self.fTransportText))
  116. # ------------------------------------------------------------------------------------------------------------
  117. # Main
  118. if __name__ == '__main__':
  119. # -------------------------------------------------------------
  120. # Read CLI args
  121. initName = os.path.basename(__file__) if ("__file__" in dir() and os.path.dirname(__file__) in PATH) else sys.argv[0]
  122. libPrefix = None
  123. for arg in sys.argv:
  124. if arg.startswith("--with-appname="):
  125. initName = os.path.basename(arg.replace("--with-initname=", ""))
  126. elif arg.startswith("--with-libprefix="):
  127. libPrefix = arg.replace("--with-libprefix=", "")
  128. # -------------------------------------------------------------
  129. # App initialization
  130. app = CarlaApplication("Carla2", libPrefix)
  131. # -------------------------------------------------------------
  132. # Set-up custom signal handling
  133. setUpSignals()
  134. # -------------------------------------------------------------
  135. # Init host backend
  136. host = initHost(initName, libPrefix, False, False, True)
  137. loadHostSettings(host)
  138. # -------------------------------------------------------------
  139. # Create GUI
  140. gui = HostWindow(host, True)
  141. # -------------------------------------------------------------
  142. # Load project file if set
  143. args = app.arguments()
  144. if len(args) > 1:
  145. arg = args[-1]
  146. if arg.startswith("--with-appname=") or arg.startswith("--with-libprefix="):
  147. pass
  148. elif os.path.exists(arg):
  149. gui.loadProjectLater(arg)
  150. # -------------------------------------------------------------
  151. # Show GUI
  152. gui.show()
  153. # -------------------------------------------------------------
  154. # App-Loop
  155. app.exit_exec()