def open(self, filename): if not filename: raise Exception("Invalid filename") if not os.path.exists(filename): raise Exception("Invalid path in file system.") try: signal = openSignal(filename) self.__signalFilePath = filename # update signal self.signal = signal self.graph() except Exception as ex: raise ex
def on_actionPlay_triggered(self): """ Play the currently selected file in the tab widget. If there are more that one file plays all in order of selection if no selection nothing is do it. :return: """ files_selected = [x[0] for x in self.files_selected()] if len(files_selected) == 0: return # play the first file try: self.player = AudioSignalPlayer(openSignal(files_selected[0])) self.player.play() except Exception as ex: pass
from PyQt4.QtGui import * import sys from duetto.audio_signals import openSignal from duetto.widgets.SpectrogramWidget import SpectrogramWidget app = QApplication([]) signal = openSignal("example.wav") spec_widget = SpectrogramWidget() # is possible to select the histogram position and visibility spec_widget = SpectrogramWidget(visible_histogram=True) # # spec_widget = SpectrogramWidget(visible_histogram=True,horizontal_histogram=False) # set the signal to the widget spec_widget.signal = signal # graph the signal spec_widget.graph() # could be visualized just a section of the signal spec_widget.graph(indexFrom=0,indexTo=signal.length/2) sys.exit(app.exec_())
def __init__(self, parent=None, measurement_template=None, signal=None, workspace=None): """ :type specgram_data: dict with the options of spectrogram creation on main window options are NFFT and overlap """ QtGui.QDialog.__init__(self, parent) self.setupUi(self) # the list of templates names self.templates_paths = [] self.load_templates() # if accepted or cancel anyway raise the changes self.buttonBox.clicked.connect( lambda bttn: self.parameterChangeFinished.emit( self.measurement_template)) self.remove_measurement_template_bttn.clicked.connect( self.delete_template) self.save_measurement_template_as_bttn.clicked.connect( self.save_template_as) self.measurement_template_cbox.currentIndexChanged.connect( self.select_template) # configuration of parameters and location trees user interface self.parameter_tree_widget = DuettoParameterTree() self.parameter_tree_widget.setAutoScroll(True) self.parameter_tree_widget.setHeaderHidden(True) self.location_tree_widget = DuettoParameterTree() self.location_tree_widget.setAutoScroll(True) self.location_tree_widget.setHeaderHidden(True) # create and set the layout for the parameter and location settings widget self.create_layout_for_settings_widget() self.param_measurement_tree = None self.location_measurement_tree = None # create the parameter trees for parameter settings and location settings self.param_measurement_tree = Parameter.create(name=unicode( self.tr(u'Parameter')), type=u'group') self.parameter_tree_widget.setParameters(self.param_measurement_tree) self.location_measurement_tree = Parameter.create(name=unicode( self.tr(u'Location')), type=u'group') self.location_tree_widget.setParameters(self.location_measurement_tree) # tables are just for selection (of parameter-location) not for edit elements. self.parameter_locations_table.setEditTriggers( QAbstractItemView.NoEditTriggers) self.wave_parameter_table.setEditTriggers( QAbstractItemView.NoEditTriggers) self.time_parameter_table.setEditTriggers( QAbstractItemView.NoEditTriggers) self.workspace = workspace self.signal = signal self._measurement_template = None self.measurement_template = measurement_template if measurement_template is not None else MeasurementTemplate( ) # pre visualization signal try: signal = openSignal(self.PARAMETER_VISUALIZATION_SIGNAL_PATH) except Exception as e: signal = small_signal(signal) self.configure_advanced_mode_items(signal) self.segmentManager = SegmentManager() self.segmentManager.signal = self.widget.signal self.segmentManager.segmentVisualItemAdded.connect( self.widget.add_parameter_visual_items) self.segmentManager.measurementsFinished.connect( self.widget.draw_elements) self.try_load_signal_segment()