diff options
Diffstat (limited to 'lib/tests/test_pipeline.py')
| -rw-r--r-- | lib/tests/test_pipeline.py | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/lib/tests/test_pipeline.py b/lib/tests/test_pipeline.py new file mode 100644 index 0000000..da2e9da --- /dev/null +++ b/lib/tests/test_pipeline.py @@ -0,0 +1,70 @@ +import numpy as np +from conftest import band_db, sine, speechish + +from producer import meters, pipeline +from producer.config import Options + + +def test_stage_order_and_names(): + opts = Options() + opts.denoise = "off" + opts.enhance = "off" + res = pipeline.run_pipeline(np.zeros(44100, dtype=np.float32), 44100, opts) + names = [s.name for s in res.stages] + assert names == ["denoise", "enhance", "dsp", "levelling"] + by_name = {s.name: s for s in res.stages} + assert by_name["denoise"].enabled is False + assert by_name["enhance"].enabled is False + assert by_name["dsp"].enabled is True + assert by_name["levelling"].enabled is True + + +def test_full_chain_profile_bounds(sr): + opts = Options() + opts.denoise = "off" + opts.enhance = "off" + x = speechish(8.0, sr, level_dbfs=-35.0) + res = pipeline.run_pipeline(x, sr, opts) + assert abs(meters.rms_db(res.audio) + 20.0) < 0.6 + assert meters.true_peak_db(res.audio, sr) <= -2.9 + assert res.timings.get("levelling", 0) >= 0 + + +def test_passthrough_when_disabled(sr): + opts = Options() + opts.denoise = "off" + opts.enhance = "off" + opts.dsp = False + opts.levelling = False + x = speechish(4.0, sr, level_dbfs=-20.0) + res = pipeline.run_pipeline(x, sr, opts) + assert np.allclose(res.audio, x) + + +def test_knob_zero_disables_eq(sr): + base = Options() + base.denoise = "off" + base.enhance = "off" + base.levelling = False + base.strengths["warmth"] = 0.0 + warm = Options() + warm.denoise = "off" + warm.enhance = "off" + warm.levelling = False + x = sine(60, 4.0, sr, -20.0) + sine(3000, 4.0, sr, -20.0) + y_flat = pipeline.run_pipeline(x, sr, base).audio + y_warm = pipeline.run_pipeline(x, sr, warm).audio + d_flat = band_db(y_flat, sr, 50, 70) - band_db(x, sr, 50, 70) + d_warm = band_db(y_warm, sr, 50, 70) - band_db(x, sr, 50, 70) + assert d_warm - d_flat > 0.8 + + +def test_podcast_profile_bounds(sr): + opts = Options() + opts.profile = "podcast" + opts.denoise = "off" + opts.enhance = "off" + x = speechish(8.0, sr, level_dbfs=-35.0) + res = pipeline.run_pipeline(x, sr, opts) + assert abs(meters.lufs(res.audio, sr) + 16.0) < 0.8 + assert meters.true_peak_db(res.audio, sr) <= -1.4 |
