D2: LimiterFx brickwall — lookahead 1-5ms + oversample 4x + hard clip, UI toggle SOFT/BRICKWALL + LOOKAHEAD ms
This commit is contained in:
@@ -481,3 +481,50 @@ def test_57_master_chain_imager_maximizer_vst3(monkeypatch, tmp_path, fx_bridge,
|
||||
assert base > 0.001, "pan tạo side content"
|
||||
assert s0 < 0.05 * base, f"imager w=0 không giết side: {s0:.5f} vs {base:.5f}"
|
||||
assert s2 > 1.5 * base, f"imager w=200 không tăng side: {s2:.5f} vs {base:.5f}"
|
||||
|
||||
def test_59_limiter_brickwall_oversample(fx_bridge):
|
||||
"""D2: LimiterFx mode brickwall — lookahead + oversample 4x + hard clip.
|
||||
Impulse 0dB qua ceiling -1dB: peak <= ceiling + 0.005, length giu nguyen;
|
||||
soft mode giu tanh (peak ~1.0); low-level qua brickwall ~ unity."""
|
||||
n = 4096
|
||||
imp = np.zeros(n, dtype=np.float32)
|
||||
imp[512] = 1.0
|
||||
audio = np.stack([imp, imp * 0.8]).astype(np.float32)
|
||||
ceil_lin = 10.0 ** (-1.0 / 20.0)
|
||||
|
||||
brick = [{"type": "builtin", "id": "limiter",
|
||||
"params": {"ceiling": -1.0, "mode": 1, "lookahead_ms": 2.0}}]
|
||||
brick_str = [{"type": "builtin", "id": "limiter",
|
||||
"params": {"ceiling": -1.0, "mode": "brickwall", "lookahead_ms": 3.0}}]
|
||||
soft = [{"type": "builtin", "id": "limiter",
|
||||
"params": {"ceiling": -1.0}}]
|
||||
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
wav_in = os.path.join(td, "in.wav")
|
||||
_write_wav(wav_in, audio, SR)
|
||||
out_brick = _render_bridge(fx_bridge, wav_in, SR, brick, block=512)
|
||||
out_brick_str = _render_bridge(fx_bridge, wav_in, SR, brick_str, block=512)
|
||||
out_soft = _render_bridge(fx_bridge, wav_in, SR, soft, block=512)
|
||||
|
||||
assert out_brick.shape == audio.shape, "brickwall length giu nguyen"
|
||||
pk = float(np.max(np.abs(out_brick)))
|
||||
assert pk <= ceil_lin + 0.005, f"brickwall peak {pk:.4f} > ceiling {ceil_lin:.4f}"
|
||||
assert pk >= 0.70, f"brickwall khong giam dinh? peak {pk:.4f}"
|
||||
|
||||
pk_str = float(np.max(np.abs(out_brick_str)))
|
||||
assert pk_str <= ceil_lin + 0.005, f"mode string peak {pk_str:.4f}"
|
||||
|
||||
pk_soft = float(np.max(np.abs(out_soft)))
|
||||
assert pk_soft > 0.95, f"soft peak {pk_soft:.4f} (tanh normalized ~1.0)"
|
||||
assert pk_soft <= 1.0005, f"soft peak {pk_soft:.4f} vuot 1.0"
|
||||
|
||||
imp2 = np.zeros(n, dtype=np.float32)
|
||||
imp2[2048] = 0.1
|
||||
audio2 = np.stack([imp2, imp2]).astype(np.float32)
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
wav_in2 = os.path.join(td, "in2.wav")
|
||||
_write_wav(wav_in2, audio2, SR)
|
||||
out_low = _render_bridge(fx_bridge, wav_in2, SR, brick, block=512)
|
||||
pk_low = float(np.max(np.abs(out_low)))
|
||||
assert 0.05 <= pk_low <= 0.15, f"low-level peak {pk_low:.4f} lech unity"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user