From 9a138b7b5eab594eb830c7b96a922cf6e13075df Mon Sep 17 00:00:00 2001 From: Henrik Date: Thu, 7 Mar 2024 20:52:25 +0100 Subject: [PATCH 1/3] Fix import of partial configs --- backend/legacy_config_import.py | 15 +++++++++------ tests/test_legacy_config.py | 7 +++++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/backend/legacy_config_import.py b/backend/legacy_config_import.py index ac0a581..ac3972d 100644 --- a/backend/legacy_config_import.py +++ b/backend/legacy_config_import.py @@ -80,13 +80,16 @@ def _modify_devices(config): Update the options in the devices section """ # New logic for setting sample format - dev = config["devices"]["capture"] - _modify_coreaudio_device(dev) - dev = config["devices"]["playback"] - _modify_coreaudio_device(dev) + if "devices" in config: + if "capture" in config["devices"]: + dev = config["devices"]["capture"] + _modify_coreaudio_device(dev) + if "playback" in config["devices"]: + dev = config["devices"]["playback"] + _modify_coreaudio_device(dev) - # Resampler - _modify_resampler(config) + # Resampler + _modify_resampler(config) def _modify_coreaudio_device(dev): diff --git a/tests/test_legacy_config.py b/tests/test_legacy_config.py index 9a09fb3..c94bf9b 100644 --- a/tests/test_legacy_config.py +++ b/tests/test_legacy_config.py @@ -145,3 +145,10 @@ def test_schema_validation(basic_config): validator.validate_config(basic_config) errors = validator.get_errors() assert len(errors) == 0 + +def test_filters_only(basic_config): + # make a config containing only filters, + # to check that partial configs can be translated + filters_only = {"filters": basic_config["filters"]} + migrate_legacy_config(filters_only) + assert len(filters_only["filters"]) == 3 From 5b90924a3d3754183aac73d47950f440a9aed8c1 Mon Sep 17 00:00:00 2001 From: Henrik Date: Fri, 8 Mar 2024 23:53:06 +0100 Subject: [PATCH 2/3] Fix import of REW files --- backend/legacy_config_import.py | 12 ++++++++++++ tests/test_legacy_config.py | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/backend/legacy_config_import.py b/backend/legacy_config_import.py index ac3972d..3b808e7 100644 --- a/backend/legacy_config_import.py +++ b/backend/legacy_config_import.py @@ -117,11 +117,23 @@ def _modify_dither(config): params["parameters"]["type"] = "Highpass" +def _fix_rew_pipeline(config): + if "pipeline" in config: + pipeline = config["pipeline"] + if isinstance(pipeline, dict) and "names" in pipeline and "type" in pipeline: + # This config was exported from REW. + # Convert `pipeline` to a list of steps instead of a single step, + # and add the missing `channel` attribute. + if "channel" not in pipeline: + pipeline["channel"] = 0 + config["pipeline"] = [pipeline] + def migrate_legacy_config(config): """ Modifies an older config file to the latest format. The modifications are done in-place. """ + _fix_rew_pipeline(config) _remove_volume_filters(config) _modify_loundness_filters(config) _modify_dither(config) diff --git a/tests/test_legacy_config.py b/tests/test_legacy_config.py index c94bf9b..5eb4834 100644 --- a/tests/test_legacy_config.py +++ b/tests/test_legacy_config.py @@ -152,3 +152,10 @@ def test_filters_only(basic_config): filters_only = {"filters": basic_config["filters"]} migrate_legacy_config(filters_only) assert len(filters_only["filters"]) == 3 + +def test_rew_export(basic_config): + # REW exports a single pipeline step rather than a list. + # Check that this is handled ok. + basic_config["pipeline"] = basic_config["pipeline"][0] + migrate_legacy_config(basic_config) + assert len(basic_config["pipeline"]) == 1 From 34e0c203de859101cb048900e9148e6369921ec4 Mon Sep 17 00:00:00 2001 From: Henrik Date: Fri, 8 Mar 2024 23:54:17 +0100 Subject: [PATCH 3/3] Bump version 2.1.1 --- backend/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/version.py b/backend/version.py index 96177d1..cd88aba 100644 --- a/backend/version.py +++ b/backend/version.py @@ -1 +1 @@ -VERSION = (2, 1, 0) +VERSION = (2, 1, 1)