def on_calculateDRC(self, param): drcMethod = self.comboDRC.get_active_text() drcScript = [DependsWrapperImpl.find_plugin_file(self.parent, "calcFilterDRC")] pluginPath = os.path.dirname(os.path.abspath(drcScript[0])) filterResultFile = self.getFilterResultsDir() + "/Filter" + str( drcMethod) + datetime.datetime.now().strftime( "%Y%m%d%H%M%S") + ".wav" impRespFiles = self.impRespDlg.getImpRespFiles() #get number of channels from impRespFiles and loop over numChannels = DRCFileTool.getNumChannels(impRespFiles[0].fileName) #go through all impRespFiles, average them and pass the #result to the impRespFile avgImpRespFile = self.calculateAvgImpResponse(impRespFiles) soxMergeCall = ["sox", "-M"] channelFilterFile = "" for currChannel in range(0, numChannels): channelFilterFile = "/tmp/filter" + str(currChannel) + ".wav" soxMergeCall.append(channelFilterFile) #get target curve filename per channel targetCurveFileName = self.targetCurveDlg.getTargetCurveFileName( currChannel) if avgImpRespFile is None: self.showMsgBox("no file loaded") return if drcMethod == "DRC": drcScript = self.prepareDRC(avgImpRespFile, channelFilterFile, targetCurveFileName) drcScript.append(avgImpRespFile) drcScript.append(channelFilterFile) drcScript.append(str(currChannel)) elif drcMethod == "PORC": drcScript = [DependsWrapperImpl.find_plugin_file(self.parent, "calcFilterPORC")] porcCommand = pluginPath + "/porc/porc.py" if not os.path.isfile(porcCommand): self.showMsgBox( "porc.py not found. Please download from github and " "install in the DRC plugin subfolder 'porc'") return drcScript.append(porcCommand) drcScript.append(avgImpRespFile) drcScript.append(channelFilterFile) drcScript.append(str(currChannel)) drcScript.append(targetCurveFileName) if self.porcCfgDlg.getMixedPhaseEnabled(): drcScript.append("--mixed") print(("drc command line: " + str(drcScript))) p = subprocess.Popen(drcScript, 0, None, None, subprocess.PIPE, subprocess.PIPE) (out, err) = p.communicate() print(("output from filter calculate script : " + str(out))) #use sox to merge all results to one filter file soxMergeCall.append(filterResultFile) p = subprocess.Popen(soxMergeCall, 0, None, None, subprocess.PIPE, subprocess.PIPE) print(("output from sox filter merge : " + str(out))) self.filechooserbtn.set_filename(filterResultFile) self.set_filter() self.notebook.next_page()
def prepareDRC(self, impRespFile, filterResultFile, targetCurveFile): drcScript = [DependsWrapperImpl.find_plugin_file(self.parent, "calcFilterDRC")] drcCfgFileName = os.path.basename(self.drcCfgDlg.getBaseCfg()) print(("drcCfgBaseName : " + drcCfgFileName)) drcCfgSrcFile = self.drcCfgDlg.getBaseCfg() drcCfgDestFile = self.getTmpCfgDir() + "/" + drcCfgFileName drcScript.append(drcCfgDestFile) print(("drcCfgDestFile : " + drcCfgDestFile)) # update filter file srcDrcCfgFile = open(drcCfgSrcFile, "r") srcData = srcDrcCfgFile.read() micCalFile = self.drcCfgDlg.getMicCalibrationFile() normMethod = self.drcCfgDlg.getNormMethod() changeCfgFileArray = [["BCInFile", impRespFile], ["PSPointsFile", targetCurveFile], ["PSNormType", normMethod] ] if micCalFile is not None: changeCfgFileArray.append(["MCFilterType", "M"]) changeCfgFileArray.append(["MCPointsFile", micCalFile]) else: changeCfgFileArray.append(["MCFilterType", "N"]) destData = self.changeCfgParamDRC(srcData, changeCfgFileArray) destDrcCfgFile = open(drcCfgDestFile, "w") destDrcCfgFile.write(destData) destDrcCfgFile.close() return drcScript
def prepareDRC(self, impRespFile, filterResultFile, targetCurveFile): drcScript = [ DependsWrapperImpl.find_plugin_file(self.parent, "calcFilterDRC") ] drcCfgFileName = os.path.basename(self.drcCfgDlg.getBaseCfg()) print(("drcCfgBaseName : " + drcCfgFileName)) drcCfgSrcFile = self.drcCfgDlg.getBaseCfg() drcCfgDestFile = self.getTmpCfgDir() + "/" + drcCfgFileName drcScript.append(drcCfgDestFile) print(("drcCfgDestFile : " + drcCfgDestFile)) # update filter file srcDrcCfgFile = open(drcCfgSrcFile, "r") srcData = srcDrcCfgFile.read() micCalFile = self.drcCfgDlg.getMicCalibrationFile() normMethod = self.drcCfgDlg.getNormMethod() changeCfgFileArray = [["BCInFile", impRespFile], ["PSPointsFile", targetCurveFile], ["PSNormType", normMethod]] if micCalFile is not None: changeCfgFileArray.append(["MCFilterType", "M"]) changeCfgFileArray.append(["MCPointsFile", micCalFile]) else: changeCfgFileArray.append(["MCFilterType", "N"]) destData = self.changeCfgParamDRC(srcData, changeCfgFileArray) destDrcCfgFile = open(drcCfgDestFile, "w") destDrcCfgFile.write(destData) destDrcCfgFile.close() return drcScript
def on_DRCTypeChanged(self, combo): drcMethod = combo.get_active_text() if drcMethod == "DRC": self.cfgDRCButton.set_label("configure DRC") else: self.cfgDRCButton.set_label("configure PORC") drcScript = [DependsWrapperImpl.find_plugin_file(self.parent, "calcFilterDRC")] pluginPath = os.path.dirname(os.path.abspath(drcScript[0])) porcTargetCurve = pluginPath + "/porc/data/tact30f.txt" if not os.path.exists(porcTargetCurve): print("installing PORC") installScript = DependsWrapperImpl.find_plugin_file(self.parent, "installPORC.sh") pluginPath = os.path.dirname(installScript) porcInstCommand = "xterm -e " + installScript + " " + \ pluginPath subprocess.call(porcInstCommand, shell=True)
def updateBruteFIRCfg(self, enable): updateBruteFIRScript = [DependsWrapperImpl.find_plugin_file(self.parent, "updateBruteFIRCfg")] if enable is True: self.comboboxFIRFilterMode.set_active(2) updateBruteFIRScript.append(self.getAlsaPlayHardwareString()) updateBruteFIRScript.append(self.filechooserbtn.get_filename()) print('create bruteFIRConfig and start/install bruteFIR') updateBruteFIRCommand = "xterm -e " + " ".join(updateBruteFIRScript) subprocess.call(updateBruteFIRCommand, shell=True)
def on_DRCTypeChanged(self, combo): drcMethod = combo.get_active_text() if drcMethod == "DRC": self.cfgDRCButton.set_label("configure DRC") else: self.cfgDRCButton.set_label("configure PORC") drcScript = [ DependsWrapperImpl.find_plugin_file(self.parent, "calcFilterDRC") ] pluginPath = os.path.dirname(os.path.abspath(drcScript[0])) porcTargetCurve = pluginPath + "/porc/data/tact30f.txt" if not os.path.exists(porcTargetCurve): print("installing PORC") installScript = DependsWrapperImpl.find_plugin_file( self.parent, "installPORC.sh") pluginPath = os.path.dirname(installScript) porcInstCommand = "xterm -e " + installScript + " " + \ pluginPath subprocess.call(porcInstCommand, shell=True)
def __init__(self, parent): self.uibuilder = Gtk.Builder() self.uibuilder.add_from_file( DependsWrapperImpl.find_plugin_file(parent, "DRCUI.glade")) self.dlg = self.uibuilder.get_object("porcCfgDlg") okBtn = self.uibuilder.get_object("button_OKPORCDlg") okBtn.connect("clicked", self.on_Ok) cancelBtn = self.uibuilder.get_object("button_CancelPORCDlg") cancelBtn.connect("clicked", self.on_Cancel) self.checkbuttonMixedPhase = self.uibuilder.get_object( "checkbuttonMixedPhase")
def updateBruteFIRCfg(self, enable): updateBruteFIRScript = [ DependsWrapperImpl.find_plugin_file(self.parent, "updateBruteFIRCfg") ] if enable is True: self.comboboxFIRFilterMode.set_active(2) updateBruteFIRScript.append(self.getAlsaPlayHardwareString()) updateBruteFIRScript.append(self.filechooserbtn.get_filename()) print('create bruteFIRConfig and start/install bruteFIR') updateBruteFIRCommand = "xterm -e " + " ".join(updateBruteFIRScript) subprocess.call(updateBruteFIRCommand, shell=True)
def __init__(self, parent): self.uibuilder = Gtk.Builder() self.uibuilder.add_from_file( DependsWrapperImpl.find_plugin_file(parent, "DRCUI.glade")) self.dlg = self.uibuilder.get_object("channel_no_dlg") self.check2ChanCombo = self.uibuilder.get_object( "comboboxtextChannels") self.check2ChanCombo.connect("changed", self.onChannelSelChanged) self.numChannels = 1 okBtn = self.uibuilder.get_object("button_OK") okBtn.connect("clicked", self.on_Ok) cancelBtn = self.uibuilder.get_object("button_Cancel") cancelBtn.connect("clicked", self.on_Cancel)
def __init__(self, parent): self.uibuilder = Gtk.Builder() self.uibuilder.add_from_file( DependsWrapperImpl.find_plugin_file(parent, "DRCUI.glade")) self.dlg = self.uibuilder.get_object("TargetCurveSelDlg") self.uibuilder.get_object("button_OKTargetCurve").connect( "clicked", self.on_Ok) self.elementGrid = self.uibuilder.get_object("elementGridTargetCurve") self.parent = parent self.uibuilder.get_object("buttonEditTargetCurve").connect("clicked", self.on_editTargetCurve) self.impRespFile = None self.defaultTargetCurveFile = "/usr/share/drc/target/44.1 kHz/flat-44.1.txt" self.channelControls = []
def __init__(self, parent): self.uibuilder = Gtk.Builder() self.uibuilder.add_from_file( DependsWrapperImpl.find_plugin_file(parent, "DRCUI.glade")) self.dlg = self.uibuilder.get_object("TargetCurveSelDlg") self.uibuilder.get_object("button_OKTargetCurve").connect( "clicked", self.on_Ok) self.elementGrid = self.uibuilder.get_object("elementGridTargetCurve") self.parent = parent self.uibuilder.get_object("buttonEditTargetCurve").connect( "clicked", self.on_editTargetCurve) self.impRespFile = None self.defaultTargetCurveFile = "/usr/share/drc/target/44.1 kHz/flat-44.1.txt" self.channelControls = []
def on_execMeasure(self, param): self.inputVolumeUpdate.stop() # TODO: make the measure script output the volume and parse from # there during measurement scriptName = DependsWrapperImpl.find_plugin_file( self.parent, "measure1Channel") #create new folder for this complete measurement strResultsDir = self.getMeasureResultsDir() + "/" +\ datetime.datetime.now().strftime("%Y%m%d%H%M%S_") + \ str(self.entrySweepDuration.get_text()) os.makedirs(strResultsDir) raw_sweep_file_base_name = "/tmp/msrawsweep.pcm" raw_sweep_recorded_base_name = "/tmp/msrecsweep0.pcm" evalDlg = MeasureQADlg(self.parent, raw_sweep_file_base_name, raw_sweep_recorded_base_name, self.sweep_level) iterLoopMeasure = 0 acquiredImpResFiles = [] while (True): impOutputFile = strResultsDir + "/" + str(iterLoopMeasure) + ".wav" # execute measure script to generate filters commandLine = [ scriptName, str(self.sweep_level), self.getAlsaRecordHardwareString(), self.getAlsaPlayHardwareString(), "10", "22050", str(self.entrySweepDuration.get_text()), impOutputFile, self.comboInputChanel.get_active_text(), str(self.exec_2ChannelMeasure.get_active()), str(int(self.spinbutton_NumChannels.get_value())), str(self.comboSampleRate.get_active_text()) ] p = subprocess.Popen(commandLine, 0, None, None, subprocess.PIPE, subprocess.PIPE) (out, err) = p.communicate() print(("output from measure script : " + str(out) + " error : " + str(None))) # quality check:sweep file and measured result evalDlg.setImpRespFileName(impOutputFile) evalDlg.run() iterLoopMeasure += 1 if evalDlg.Result == MeasureQARetVal.Reject: continue acquiredImpResFiles.append(evalDlg.impRespFile) if evalDlg.Result == MeasureQARetVal.Done: break self.impRespDlg.removeAll() self.impRespDlg.setFiles(acquiredImpResFiles) self.notebook.next_page()
def __init__(self, parent, genSweepFile, measSweepFile, sweep_level): self.uibuilder = Gtk.Builder() self.uibuilder.add_from_file( DependsWrapperImpl.find_plugin_file(parent, "DRCUI.glade")) self.dlg = self.uibuilder.get_object("measureQualityDlg") self.uibuilder.get_object("button_doneMeasQA").connect( "clicked", self.on_button_doneMeasQA) self.uibuilder.get_object("button_rejectMeasQA").connect( "clicked", self.on_button_rejectMeasQA) self.uibuilder.get_object("button_ProceedMeasQA").connect( "clicked", self.on_button_ProceedMeasQA) btnViewAudacity = self.uibuilder.get_object("buttonViewRecSweep") btnViewAudacity.connect("clicked", self.on_viewRecSweep) self.genSweepFile = genSweepFile self.measSweepFile = measSweepFile
def on_execMeasure(self, param): self.inputVolumeUpdate.stop() # TODO: make the measure script output the volume and parse from # there during measurement scriptName = DependsWrapperImpl.find_plugin_file(self.parent, "measure1Channel") #create new folder for this complete measurement strResultsDir = self.getMeasureResultsDir() + "/" +\ datetime.datetime.now().strftime("%Y%m%d%H%M%S_") + \ str(self.entrySweepDuration.get_text()) os.makedirs(strResultsDir) raw_sweep_file_base_name = "/tmp/msrawsweep.pcm" raw_sweep_recorded_base_name = "/tmp/msrecsweep0.pcm" evalDlg = MeasureQADlg(self.parent, raw_sweep_file_base_name, raw_sweep_recorded_base_name, self.sweep_level) iterLoopMeasure = 0 acquiredImpResFiles = [] while(True): impOutputFile = strResultsDir + "/" + str(iterLoopMeasure) + ".wav" # execute measure script to generate filters commandLine = [scriptName, str(self.sweep_level), self.getAlsaRecordHardwareString(), self.getAlsaPlayHardwareString(), "10", "22050", str(self.entrySweepDuration.get_text()), impOutputFile, self.comboInputChanel.get_active_text(), str(self.exec_2ChannelMeasure.get_active()), str(int(self.spinbutton_NumChannels.get_value())), str(self.comboSampleRate.get_active_text())] p = subprocess.Popen(commandLine, 0, None, None, subprocess.PIPE, subprocess.PIPE) (out, err) = p.communicate() print(("output from measure script : " + str(out) + " error : " + str(None))) # quality check:sweep file and measured result evalDlg.setImpRespFileName(impOutputFile) evalDlg.run() iterLoopMeasure += 1 if evalDlg.Result == MeasureQARetVal.Reject: continue acquiredImpResFiles.append(evalDlg.impRespFile) if evalDlg.Result == MeasureQARetVal.Done: break self.impRespDlg.removeAll() self.impRespDlg.setFiles(acquiredImpResFiles) self.notebook.next_page()
def __init__(self, drcDlg, resultsDir): self.uibuilder = Gtk.Builder() self.resultsDir = resultsDir self.uibuilder.add_from_file( DependsWrapperImpl.find_plugin_file(drcDlg.parent, "DRCUI.glade")) self.dlg = self.uibuilder.get_object("impRespSelDlg") self.uibuilder.get_object("button_OKImpRespSelDlg").connect( "clicked", self.on_Ok) self.uibuilder.get_object("openFiles").connect("clicked", self.on_AddFiles) self.uibuilder.get_object("buttonRemoveFile").connect( "clicked", self.on_RemoveFile) self.elementGrid = self.uibuilder.get_object("elementGrid") self.drcDlg = drcDlg self.mesureResultsDir = self.drcDlg.getMeasureResultsDir() self.fileControlList = []
def __init__(self, drcDlg, resultsDir): self.uibuilder = Gtk.Builder() self.resultsDir = resultsDir self.uibuilder.add_from_file( DependsWrapperImpl.find_plugin_file(drcDlg.parent, "DRCUI.glade")) self.dlg = self.uibuilder.get_object("impRespSelDlg") self.uibuilder.get_object("button_OKImpRespSelDlg").connect( "clicked", self.on_Ok) self.uibuilder.get_object("openFiles").connect( "clicked", self.on_AddFiles) self.uibuilder.get_object("buttonRemoveFile").connect( "clicked", self.on_RemoveFile) self.elementGrid = self.uibuilder.get_object("elementGrid") self.drcDlg = drcDlg self.mesureResultsDir = self.drcDlg.getMeasureResultsDir() self.fileControlList = []
def __init__(self, targetCurveFile, parent): # self.set_title( "N Bands parametric EQ" ) self.targetCurveFilename = targetCurveFile addBtn = self.uibuilder = Gtk.Builder() self.uibuilder.add_from_file( DependsWrapperImpl.find_plugin_file(parent, "DRCUI.glade")) self.dlg = self.uibuilder.get_object("EQDlg") addBtn = self.uibuilder.get_object("buttonAddEQBand") addBtn.connect("clicked", self.add_new_eq_band) closeBtn = self.uibuilder.get_object("button_CloseEQ") closeBtn.connect("clicked", self.on_Ok) saveTargetCurveButton = self.uibuilder.get_object( "saveTargetCurveButton") saveTargetCurveButton.connect("file-set", self.on_file_selected) data = loadTargetCurveFile(targetCurveFile) self.eqBox = self.uibuilder.get_object("EQBox") self.rebuild_eq_controls(data)
def __init__(self, parent): self.uibuilder = Gtk.Builder() self.uibuilder.add_from_file( DependsWrapperImpl.find_plugin_file(parent, "DRCUI.glade")) self.dlg = self.uibuilder.get_object("drcCfgDlg") okBtn = self.uibuilder.get_object("button_OKDRCDlg") okBtn.connect("clicked", self.on_Ok) cancelBtn = self.uibuilder.get_object("button_CancelDRCDlg") cancelBtn.connect("clicked", self.on_Cancel) self.filechooserbuttonMicCalFile = self.uibuilder.get_object( "filechooserbuttonMicCalFile") self.uibuilder.get_object("resetBtn").connect("clicked", self.on_ResetToDefaults) self.applyConfig() self.comboboxtext_norm_method = self.uibuilder.get_object( "comboboxtext_norm_method") self.filechooserbuttonBaseCfg = self.uibuilder.get_object( "filechooserbuttonBaseCfg") self.filechooserbuttonBaseCfg.set_current_folder( "/usr/share/drc/config/44.1 kHz") self.filechooserbuttonBaseCfg.set_filename( "/usr/share/drc/config/44.1 kHz/erb-44.1.drc")
def __init__(self, parent): self.uibuilder = Gtk.Builder() self.uibuilder.add_from_file( DependsWrapperImpl.find_plugin_file(parent, "DRCUI.glade")) self.dlg = self.uibuilder.get_object("drcCfgDlg") okBtn = self.uibuilder.get_object("button_OKDRCDlg") okBtn.connect("clicked", self.on_Ok) cancelBtn = self.uibuilder.get_object("button_CancelDRCDlg") cancelBtn.connect("clicked", self.on_Cancel) self.filechooserbuttonMicCalFile = self.uibuilder.get_object( "filechooserbuttonMicCalFile") self.uibuilder.get_object( "resetBtn").connect("clicked", self.on_ResetToDefaults) self.applyConfig() self.comboboxtext_norm_method = self.uibuilder.get_object( "comboboxtext_norm_method") self.filechooserbuttonBaseCfg = self.uibuilder.get_object( "filechooserbuttonBaseCfg") self.filechooserbuttonBaseCfg.set_current_folder( "/usr/share/drc/config/44.1 kHz") self.filechooserbuttonBaseCfg.set_filename( "/usr/share/drc/config/44.1 kHz/erb-44.1.drc")
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)
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)
def on_calculateDRC(self, param): drcMethod = self.comboDRC.get_active_text() drcScript = [ DependsWrapperImpl.find_plugin_file(self.parent, "calcFilterDRC") ] pluginPath = os.path.dirname(os.path.abspath(drcScript[0])) filterResultFile = self.getFilterResultsDir() + "/Filter" + str( drcMethod) + datetime.datetime.now().strftime( "%Y%m%d%H%M%S") + ".wav" impRespFiles = self.impRespDlg.getImpRespFiles() #get number of channels from impRespFiles and loop over numChannels = DRCFileTool.getNumChannels(impRespFiles[0].fileName) #go through all impRespFiles, average them and pass the #result to the impRespFile avgImpRespFile = self.calculateAvgImpResponse(impRespFiles) soxMergeCall = ["sox", "-M"] channelFilterFile = "" for currChannel in range(0, numChannels): channelFilterFile = "/tmp/filter" + str(currChannel) + ".wav" soxMergeCall.append(channelFilterFile) #get target curve filename per channel targetCurveFileName = self.targetCurveDlg.getTargetCurveFileName( currChannel) if avgImpRespFile is None: self.showMsgBox("no file loaded") return if drcMethod == "DRC": drcScript = self.prepareDRC(avgImpRespFile, channelFilterFile, targetCurveFileName) drcScript.append(avgImpRespFile) drcScript.append(channelFilterFile) drcScript.append(str(currChannel)) elif drcMethod == "PORC": drcScript = [ DependsWrapperImpl.find_plugin_file( self.parent, "calcFilterPORC") ] porcCommand = pluginPath + "/porc/porc.py" if not os.path.isfile(porcCommand): self.showMsgBox( "porc.py not found. Please download from github and " "install in the DRC plugin subfolder 'porc'") return drcScript.append(porcCommand) drcScript.append(avgImpRespFile) drcScript.append(channelFilterFile) drcScript.append(str(currChannel)) drcScript.append(targetCurveFileName) if self.porcCfgDlg.getMixedPhaseEnabled(): drcScript.append("--mixed") print(("drc command line: " + str(drcScript))) p = subprocess.Popen(drcScript, 0, None, None, subprocess.PIPE, subprocess.PIPE) (out, err) = p.communicate() print(("output from filter calculate script : " + str(out))) #use sox to merge all results to one filter file soxMergeCall.append(filterResultFile) p = subprocess.Popen(soxMergeCall, 0, None, None, subprocess.PIPE, subprocess.PIPE) print(("output from sox filter merge : " + str(out))) self.filechooserbtn.set_filename(filterResultFile) self.set_filter() self.notebook.next_page()