Пример #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")
Пример #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")
Пример #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)

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

        self.chunk_number = 0

        self.buffer_timer_time = 0.

        self.cpu_percent = 0.

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

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

        devices = self.audiobackend.get_readable_devices_list()
        for device in devices:
            self.settings_dialog.comboBox_inputDevice.addItem(device)

        channels = self.audiobackend.get_readable_current_channels()
        for channel in channels:
            self.settings_dialog.comboBox_firstChannel.addItem(channel)
            self.settings_dialog.comboBox_secondChannel.addItem(channel)

        current_device = self.audiobackend.get_readable_current_device()
        self.settings_dialog.comboBox_inputDevice.setCurrentIndex(
            current_device)

        first_channel = self.audiobackend.get_current_first_channel()
        self.settings_dialog.comboBox_firstChannel.setCurrentIndex(
            first_channel)
        second_channel = self.audiobackend.get_current_second_channel()
        self.settings_dialog.comboBox_secondChannel.setCurrentIndex(
            second_channel)

        # 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(1000)  # constant timing

        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)

        # timer ticks
        self.connect(self.display_timer, QtCore.SIGNAL('timeout()'),
                     self.update_buffer)
        self.connect(self.display_timer, QtCore.SIGNAL('timeout()'),
                     self.statistics)

        # timer ticks
        self.connect(self.slow_timer, QtCore.SIGNAL('timeout()'),
                     self.get_cpu_percent)

        # 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.new_dock_called)

        # settings signals
        self.connect(self.settings_dialog.comboBox_inputDevice,
                     QtCore.SIGNAL('currentIndexChanged(int)'),
                     self.input_device_changed)
        self.connect(self.settings_dialog.comboBox_firstChannel,
                     QtCore.SIGNAL('currentIndexChanged(int)'),
                     self.first_channel_changed)
        self.connect(self.settings_dialog.comboBox_secondChannel,
                     QtCore.SIGNAL('currentIndexChanged(int)'),
                     self.second_channel_changed)
        self.connect(self.settings_dialog.radioButton_single,
                     QtCore.SIGNAL('toggled(bool)'),
                     self.single_input_type_selected)
        self.connect(self.settings_dialog.radioButton_duo,
                     QtCore.SIGNAL('toggled(bool)'),
                     self.duo_input_type_selected)
        self.connect(self.settings_dialog.doubleSpinBox_delay,
                     QtCore.SIGNAL('valueChanged(double)'), self.delay_changed)

        # log change
        self.connect(self.logger, QtCore.SIGNAL('logChanged'),
                     self.log_changed)
        self.connect(self.about_dialog.log_scrollarea.verticalScrollBar(),
                     QtCore.SIGNAL('rangeChanged(int,int)'),
                     self.log_scroll_range_changed)

        # 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")
Пример #4
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")