Esempio n. 1
0
    def __init__(self, logger):
        QMainWindow.__init__(self)

        # exception hook that logs to console, file, and display a message box
        self.errorDialogOpened = False
        sys.excepthook = self.excepthook

        # logger
        self.logger = logger

        # Setup the user interface
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        # Initialize the audio data ring buffer
        self.audiobuffer = AudioBuffer(self.logger)

        # Initialize the audio backend
        self.audiobackend = AudioBackend(self.logger)

        # signal containing new data from the audio callback thread, processed as numpy array
        self.audiobackend.new_data_available.connect(self.audiobuffer.handle_new_data)

        # this timer is used to update widgets that just need to display as fast as they can
        self.display_timer = QtCore.QTimer()
        self.display_timer.setInterval(SMOOTH_DISPLAY_TIMER_PERIOD_MS)  # constant timing

        # slow timer
        self.slow_timer = QtCore.QTimer()
        self.slow_timer.setInterval(SLOW_TIMER_PERIOD_MS)  # constant timing

        self.about_dialog = About_Dialog(self, self.logger, self.audiobackend, self.slow_timer)
        self.settings_dialog = Settings_Dialog(self, self.logger, self.audiobackend)

        self.centralwidget = CentralWidget(self.ui.centralwidget, self.logger, "central_widget", 0)
        self.centralLayout = QVBoxLayout(self.ui.centralwidget)
        self.centralLayout.setContentsMargins(0, 0, 0, 0)
        self.centralLayout.addWidget(self.centralwidget)

        self.dockmanager = DockManager(self, self.logger)

        # timer ticks
        self.display_timer.timeout.connect(self.centralwidget.canvasUpdate)
        self.display_timer.timeout.connect(self.dockmanager.canvasUpdate)

        # toolbar clicks
        self.ui.actionStart.triggered.connect(self.timer_toggle)
        self.ui.actionSettings.triggered.connect(self.settings_called)
        self.ui.actionAbout.triggered.connect(self.about_called)
        self.ui.actionNew_dock.triggered.connect(self.dockmanager.new_dock)

        # restore the settings and widgets geometries
        self.restoreAppState()

        # start timers
        self.timer_toggle()
        self.slow_timer.start()

        self.logger.push("Init finished, entering the main loop")
Esempio n. 2
0
    def __init__(self):
        QMainWindow.__init__(self)

        self.logger = logging.getLogger(__name__)

        # exception hook that logs to console, file, and display a message box
        self.errorDialogOpened = False
        sys.excepthook = self.excepthook

        # Setup the user interface
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        # Initialize the audio data ring buffer
        self.audiobuffer = AudioBuffer()

        # Initialize the audio backend
        # signal containing new data from the audio callback thread, processed as numpy array
        AudioBackend().new_data_available.connect(
            self.audiobuffer.handle_new_data)

        # this timer is used to update widgets that just need to display as fast as they can
        self.display_timer = QtCore.QTimer()
        self.display_timer.setInterval(
            SMOOTH_DISPLAY_TIMER_PERIOD_MS)  # constant timing

        # slow timer
        self.slow_timer = QtCore.QTimer()
        self.slow_timer.setInterval(SLOW_TIMER_PERIOD_MS)  # constant timing

        self.about_dialog = About_Dialog(self, self.slow_timer)
        self.settings_dialog = Settings_Dialog(self)

        self.level_widget = Levels_Widget(self)
        self.level_widget.set_buffer(self.audiobuffer)
        self.audiobuffer.new_data_available.connect(
            self.level_widget.handle_new_data)

        self.hboxLayout = QHBoxLayout(self.ui.centralwidget)
        self.hboxLayout.setContentsMargins(0, 0, 0, 0)
        self.hboxLayout.addWidget(self.level_widget)

        self.centralLayout = TileLayout()
        self.centralLayout.setContentsMargins(0, 0, 0, 0)
        self.hboxLayout.addLayout(self.centralLayout)

        self.dockmanager = DockManager(self)

        # timer ticks
        self.display_timer.timeout.connect(self.dockmanager.canvasUpdate)
        self.display_timer.timeout.connect(self.level_widget.canvasUpdate)
        self.display_timer.timeout.connect(AudioBackend().fetchAudioData)

        # toolbar clicks
        self.ui.actionStart.triggered.connect(self.timer_toggle)
        self.ui.actionSettings.triggered.connect(self.settings_called)
        self.ui.actionAbout.triggered.connect(self.about_called)
        self.ui.actionNew_dock.triggered.connect(self.dockmanager.new_dock)

        # restore the settings and widgets geometries
        self.restoreAppState()

        # make sure the toolbar is shown
        # in case it was closed by mistake (before it was made impossible)
        self.ui.toolBar.setVisible(True)

        # prevent from hiding or moving the toolbar
        self.ui.toolBar.toggleViewAction().setVisible(True)
        self.ui.toolBar.setMovable(False)
        self.ui.toolBar.setFloatable(False)

        # start timers
        self.timer_toggle()
        self.slow_timer.start()

        self.logger.info("Init finished, entering the main loop")
Esempio n. 3
0
    def __init__(self, logger):
        QMainWindow.__init__(self)

        # logger
        self.logger = logger

        # Setup the user interface
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        # Initialize the audio data ring buffer
        self.audiobuffer = AudioBuffer(self.logger)

        # Initialize the audio backend
        self.audiobackend = AudioBackend(self.logger)

        # this timer is used to update widgets that just need to display as fast as they can
        self.display_timer = QtCore.QTimer()
        self.display_timer.setInterval(
            SMOOTH_DISPLAY_TIMER_PERIOD_MS)  # constant timing

        # slow timer
        self.slow_timer = QtCore.QTimer()
        self.slow_timer.setInterval(SLOW_TIMER_PERIOD_MS)  # constant timing

        self.about_dialog = About_Dialog(self, self.logger, self.audiobackend,
                                         self.slow_timer)
        self.settings_dialog = Settings_Dialog(self, self.logger,
                                               self.audiobackend)

        self.centralwidget = CentralWidget(self.ui.centralwidget, self.logger,
                                           "central_widget", 0)
        self.centralLayout = QVBoxLayout(self.ui.centralwidget)
        self.centralLayout.setContentsMargins(0, 0, 0, 0)
        self.centralLayout.addWidget(self.centralwidget)

        self.dockmanager = DockManager(self, self.logger)

        # timer ticks
        self.connect(self.display_timer, QtCore.SIGNAL('timeout()'),
                     self.update_buffer)
        self.connect(self.display_timer, QtCore.SIGNAL('timeout()'),
                     self.centralwidget.update)
        self.connect(self.display_timer, QtCore.SIGNAL('timeout()'),
                     self.dockmanager.update)

        # toolbar clicks
        self.connect(self.ui.actionStart, QtCore.SIGNAL('triggered()'),
                     self.timer_toggle)
        self.connect(self.ui.actionSettings, QtCore.SIGNAL('triggered()'),
                     self.settings_called)
        self.connect(self.ui.actionAbout, QtCore.SIGNAL('triggered()'),
                     self.about_called)
        self.connect(self.ui.actionNew_dock, QtCore.SIGNAL('triggered()'),
                     self.dockmanager.new_dock)

        # restore the settings and widgets geometries
        self.restoreAppState()

        # start timers
        self.timer_toggle()
        self.slow_timer.start()

        self.logger.push("Init finished, entering the main loop")