コード例 #1
0
ファイル: DRCUi.py プロジェクト: TheBigW/DRC
 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()
コード例 #2
0
ファイル: DRCUi.py プロジェクト: TheBigW/DRC
 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
コード例 #3
0
ファイル: DRCUi.py プロジェクト: ShaquilleLiu/DRC
 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
コード例 #4
0
ファイル: DRCUi.py プロジェクト: TheBigW/DRC
 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)
コード例 #5
0
ファイル: DRCUi.py プロジェクト: TheBigW/DRC
 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)
コード例 #6
0
ファイル: DRCUi.py プロジェクト: ShaquilleLiu/DRC
 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)
コード例 #7
0
ファイル: PORCCfgDlg.py プロジェクト: TheBigW/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("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")
コード例 #8
0
ファイル: PORCCfgDlg.py プロジェクト: ShaquilleLiu/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("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")
コード例 #9
0
ファイル: DRCUi.py プロジェクト: ShaquilleLiu/DRC
 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)
コード例 #10
0
ファイル: ChannelSelDlg.py プロジェクト: ShaquilleLiu/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("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)
コード例 #11
0
ファイル: ChannelSelDlg.py プロジェクト: TheBigW/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("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)
コード例 #12
0
ファイル: TargetCurveDlg.py プロジェクト: TheBigW/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("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 = []
コード例 #13
0
 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 = []
コード例 #14
0
ファイル: DRCUi.py プロジェクト: ShaquilleLiu/DRC
    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()
コード例 #15
0
 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
コード例 #16
0
ファイル: DRCUi.py プロジェクト: TheBigW/DRC
    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()
コード例 #17
0
ファイル: ImpRespDlg.py プロジェクト: ShaquilleLiu/DRC
 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 = []
コード例 #18
0
ファイル: ImpRespDlg.py プロジェクト: TheBigW/DRC
 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 = []
コード例 #19
0
ファイル: MeasureQADlg.py プロジェクト: TheBigW/DRC
 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
コード例 #20
0
ファイル: DRCTargetCurveUI.py プロジェクト: TheBigW/DRC
 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)
コード例 #21
0
 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")
コード例 #22
0
ファイル: DRCCfgDlg.py プロジェクト: TheBigW/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")
コード例 #23
0
ファイル: DRCUi.py プロジェクト: ShaquilleLiu/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)
コード例 #24
0
ファイル: DRCUi.py プロジェクト: TheBigW/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)
コード例 #25
0
ファイル: DRCUi.py プロジェクト: ShaquilleLiu/DRC
 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()