def on_Ok(self, param): self.dlg.response(Gtk.ResponseType.OK) aCfg = DRCConfig() aCfg.MicCalibrationFile = self.filechooserbuttonMicCalFile.\ get_filename() aCfg.save() self.dlg.set_visible(False)
def do_activate(self): try: self.duration = 0 self.entry = None self.selfAllowTriggered = False self.filterSet = False self.shell = self.object self.shell_player = self.shell.props.shell_player self.player = self.shell_player.props.player self.fir_filter = Gst.ElementFactory.make('audiofirfilter', 'MyFIRFilter') # open filter files self.hasMultiKernel = self.updateFilter() # print( str(dir( self.shell.props)) ) except Exception as inst: print(('filter not set', sys.exc_info()[0], type(inst), inst)) pass aCfg = DRCConfig() if aCfg.FIRFilterMode == 1: #only for gst-FIR filter the skip-workaround is needed self.psc_id = self.shell_player.connect('playing-song-changed', self.playing_song_changed) # no possible workaround as somehow never reaches end of song :( self.shell_player.connect('elapsed-changed', self.elapsed_changed) # finally add UI self.add_ui(self, self.shell)
def applyConfig(self): aCfg = DRCConfig() if os.path.exists(aCfg.MicCalibrationFile): self.filechooserbuttonMicCalFile.set_filename( aCfg.MicCalibrationFile) else: self.filechooserbuttonMicCalFile.set_current_folder( "/usr/share/drc/mic")
def updateFilter(self, filterFileName=None): aCfg = DRCConfig() if filterFileName is None: filterFileName = aCfg.filterFile if aCfg.FIRFilterMode == 1: #gstFIR self.set_filter() hasMultiKernel = False try: source = self.shell_player.get_playing_source() self.shell_player.pause() #in case of a multichannel kernel with > 2 channels only #the first 2 channels shall be used for gstreamer filtering #as gstreamer FIR only supports at maximum 2 channels audioParams = DRCFileTool.LoadAudioFileStereoChannels( filterFileName, aCfg.numFilterChanels, 2) filter_array = audioParams.data # pass the filter data to the fir filter num_filter_coeff = len(filter_array) if num_filter_coeff > 0: hasMultiKernel = self.set_kernel(filter_array) self.set_filter() if self.entry is not None: self.shell_player.play_entry(self.entry, source) except Exception as inst: print(('error updating filter', sys.exc_info()[0], type(inst), inst)) pass return hasMultiKernel elif aCfg.FIRFilterMode == 2: #bruteFIF #nothing ToDO self.remove_Filter() else: #None : disable all filtering self.remove_Filter() return True
def saveSettings(self): aCfg = DRCConfig() aCfg.filterFile = self.filechooserbtn.get_filename() aCfg.recordGain = self.sweep_level aCfg.sweepDuration = int(self.entrySweepDuration.get_text()) aCfg.FIRFilterMode = self.comboboxFIRFilterMode.get_active() aCfg.playHardwareIndex = self.alsaPlayHardwareCombo.get_active() aCfg.recHardwareIndex = self.alsaRecHardwareCombo.get_active() aCfg.recHardwareChannelIndex = self.comboInputChanel.get_active() fileExt = os.path.splitext(aCfg.filterFile)[-1] print(("ext = " + fileExt)) if fileExt != ".wav": if self.channelSelDlg.run() == Gtk.ResponseType.OK: aCfg.numFilterChanels = self.channelSelDlg.getNumChannels() aCfg.save()
def initUI(self): aCfg = DRCConfig() self.uibuilder = Gtk.Builder() self.uibuilder.add_from_file( DependsWrapperImpl.find_plugin_file(self.parent, "DRCUI.glade")) self.dlg = self.uibuilder.get_object("DRCDlg") self.dlg.connect("close", self.on_close) audioFileFilter = Gtk.FileFilter() audioFileFilter.add_pattern("*.wav") audioFileFilter.add_pattern("*.pcm") audioFileFilter.add_pattern("*.raw") self.filechooserbtn = self.uibuilder.get_object( "drcfilterchooserbutton") self.filechooserbtn.set_filter(audioFileFilter) if os.path.isfile(aCfg.filterFile): self.filechooserbtn.set_filename(aCfg.filterFile) else: self.filechooserbtn.set_current_folder(self.getFilterResultsDir()) self.filechooserbtn.connect("file-set", self.on_file_selected) self.entrySweepDuration = self.uibuilder.get_object( "entrySweepDuration") self.entrySweepDuration.set_text(str(aCfg.sweepDuration)) self.progressbarInputVolume = self.uibuilder.get_object( "progressbarInputVolume") self.alsaPlayHardwareCombo = self.uibuilder.get_object("comboOutput") self.alsaRecHardwareCombo = self.uibuilder.get_object("comboRecord") self.comboSampleRate = self.uibuilder.get_object("comboSampleRate") self.execMeasureBtn = self.uibuilder.get_object("buttonMeassure") self.execMeasureBtn.connect("clicked", self.on_execMeasure) self.alsaDevices = AlsaDevices() alsaTools.fillComboFromDeviceList(self.alsaPlayHardwareCombo, self.alsaDevices.alsaPlayDevs, aCfg.playHardwareIndex) alsaTools.fillComboFromDeviceList(self.alsaRecHardwareCombo, self.alsaDevices.alsaRecDevs, aCfg.recHardwareIndex) self.alsaRecHardwareCombo.connect("changed", self.on_recDeviceChanged) self.comboInputChanel = self.uibuilder.get_object("comboInputChanel") self.comboInputChanel.set_active(aCfg.recHardwareChannelIndex) # fill the number of input channels self.updateRecDeviceInfo() self.comboInputChanel.connect("changed", self.on_InputChanelChanged) calcDRCBtn = self.uibuilder.get_object("buttonCalculateFilter") calcDRCBtn.connect("clicked", self.on_calculateDRC) slider = self.uibuilder.get_object("scaleSweepAmplitude") slider.set_range(0.1, 1) slider.set_value_pos(Gtk.PositionType.TOP) self.sweep_level = aCfg.recordGain slider.set_value(self.sweep_level) slider.connect("value_changed", self.slider_changed) apply_closeBtn = self.uibuilder.get_object("apply_closeBtn") apply_closeBtn.connect("clicked", self.on_apply_settings) cancel_closeBtn = self.uibuilder.get_object("cancelButton") cancel_closeBtn.connect("clicked", self.on_Cancel) self.buttonSetImpRespFile = self.uibuilder.get_object( "buttonSetImpRespFile") self.buttonSetImpRespFile.connect("clicked", self.on_setImpRespFiles) self.comboDRC = self.uibuilder.get_object("combo_drc_type") self.cfgDRCButton = self.uibuilder.get_object("cfgDRCButton") self.cfgDRCButton.connect("clicked", self.on_cfgDRC) self.comboDRC.append_text("DRC") self.comboDRC.append_text("PORC") self.comboDRC.set_active(0) self.comboDRC.connect("changed", self.on_DRCTypeChanged) self.on_DRCTypeChanged(self.comboDRC) self.drcCfgDlg = DRCCfgDlg(self.parent) self.porcCfgDlg = PORCCfgDlg(self.parent) self.channelSelDlg = ChanelSelDlg(self.parent) self.impRespDlg = ImpRespDlg(self, self.getMeasureResultsDir()) self.targetCurveDlg = TargetCurveDlg(self.parent) self.exec_2ChannelMeasure = self.uibuilder.get_object( "checkbutton_2ChannelMeasure") self.exec_2ChannelMeasure.set_sensitive(True) self.spinbutton_NumChannels = self.uibuilder.get_object( "spinbutton_NumChannels") self.notebook = self.uibuilder.get_object("notebook1") self.volumeUpdateBlocked = False self.mode = None self.inputVolumeUpdate = InputVolumeProcess( self.progressbarInputVolume) self.comboboxFIRFilterMode = self.uibuilder.get_object( "comboboxFIRFilterMode") self.comboboxFIRFilterMode.set_active(aCfg.FIRFilterMode) self.comboboxFIRFilterMode.connect("changed", self.on_FIRFilterModeChanged) self.uibuilder.get_object("buttonTargetCurve").connect( "clicked", self.on_EditTargetCurve)