def test_merge_2x4hd_output_with_split(): dsp_type = DspType.MINIDSP_TWO_BY_FOUR_HD parser = HDXmlParser(dsp_type, False, in_out_split=['4', '6']) filt = xml_to_filt(os.path.join(os.path.dirname(__file__), 'input.xml')) with open(os.path.join(os.path.dirname(__file__), 'MiniDSP-2x4HD-setting.xml'), 'r') as f1: with open(os.path.join(os.path.dirname(__file__), 'expected_output_2x4HD_split.xml'), 'r') as f2: convert_and_compare(f1, f2, filt, parser)
def test_merge_2x4hd_output_with_output(): dsp_type = DspType.MINIDSP_TWO_BY_FOUR_HD parser = HDXmlParser(dsp_type, False, selected_channels=[str(i) for i in range(1, 7)]) filt = xml_to_filt(os.path.join(os.path.dirname(__file__), 'input.xml')) with open(os.path.join(os.path.dirname(__file__), 'MiniDSP-2x4HD-setting.xml'), 'r') as f1: with open(os.path.join(os.path.dirname(__file__), 'expected_output_2x4HD_output.xml'), 'r') as f2: convert_and_compare(f1, f2, filt, parser)
def __process_file(self, base_parts_idx, xml): ''' Processes an individual file. :param base_parts_idx: the path index to start from. :param xml: the source xml. ''' dir_parts = [] try: dir_parts = xml.parts[base_parts_idx:-1] file_output_dir = os.path.join(self.__output_dir, *dir_parts) os.makedirs(file_output_dir, exist_ok=True) dst = Path(file_output_dir).joinpath(xml.name).with_suffix(self.__parser.file_extension()) logger.info(f"Copying {self.__config_file} to {dst}") dst = shutil.copy2(self.__config_file, dst.resolve()) filt = xml_to_filt(str(xml), fs=self.__dsp_type.target_fs) output_config, was_optimised = self.__parser.convert(str(dst), filt) with dst.open('w') as dst_file: dst_file.write(output_config) if was_optimised is False: self.__signals.on_success.emit() else: self.__signals.on_optimised.emit(' - '.join(dir_parts), xml.name) except Exception as e: logger.exception(f"Unexpected failure during processing of {xml}") self.__signals.on_failure.emit(' - '.join(dir_parts), xml.name, str(e))
def test_codec_minidsp_xml(): filts = xml_to_filt(os.path.join(os.path.dirname(__file__), 'minidsp.xml')) assert filts assert len(filts) == 2 assert type(filts[0]) is PeakingEQ assert filts[0].freq == 45.0 assert filts[0].gain == 0.4 assert filts[0].q == 1.0 assert type(filts[1]) is LowShelf assert filts[1].freq == 19.0 assert filts[1].gain == 3.8 assert filts[1].q == 0.9 assert filts[1].count == 3
def test_merge_2x4hd(): from model.minidsp import xml_to_filt, HDXmlParser from model.merge import DspType dsp_type = DspType.MINIDSP_TWO_BY_FOUR_HD parser = HDXmlParser(dsp_type, False) filt = xml_to_filt(os.path.join(os.path.dirname(__file__), 'input.xml')) with open( os.path.join(os.path.dirname(__file__), 'MiniDSP-2x4HD-setting.xml'), 'r') as f1: with open( os.path.join(os.path.dirname(__file__), 'expected_output_2x4HD.xml'), 'r') as f2: convert_and_compare(f1, f2, filt, parser)