- schedule como única fuente de verdad: f_inst = interpolación de sus puntos - fase continua por trapecio acumulado, encadenable entre bloques - pink/rain periódicos por síntesis espectral (loop sin costura sin crossfade) - pico limitado a −3 dBFS por escala determinista, nunca recorte - 5 presets YAML, validación pydantic con errores en español - tests: criterios 1-4, 6, 8 + escalado, envolvente, bloques (26 en verde) - 30 min de audio generados en 1.6 s (< 5 s requerido)
41 lines
1.5 KiB
Python
41 lines
1.5 KiB
Python
"""Schedule: forma de los puntos, escalado proporcional y consistencia (criterio 6)."""
|
|
|
|
import numpy as np
|
|
import pytest
|
|
|
|
from binaural.session import f_inst, schedule_de_preset
|
|
|
|
|
|
def test_schedule_estudio_igual_al_brief(presets):
|
|
sch = schedule_de_preset(presets["estudio"])
|
|
assert [(p.t, p.beat_hz) for p in sch.points] == [(0, 10), (300, 10), (900, 14), (1800, 14)]
|
|
assert sch.duration_s == 1800
|
|
assert sch.carrier_hz == 220
|
|
assert sch.noise == "rain"
|
|
assert sch.noise_db == -20
|
|
assert sch.fade_s == 4
|
|
assert sch.preroll_s == 1.5
|
|
|
|
|
|
def test_escalado_proporcional(presets):
|
|
sch = schedule_de_preset(presets["estudio"], duracion_min=15)
|
|
assert [p.t for p in sch.points] == [0, 150, 450, 900]
|
|
assert [p.beat_hz for p in sch.points] == [10, 10, 14, 14]
|
|
assert sch.duration_s == 900
|
|
|
|
|
|
def test_duracion_fuera_de_rango(presets):
|
|
with pytest.raises(ValueError, match="fuera de rango"):
|
|
schedule_de_preset(presets["foco"], duracion_min=61)
|
|
|
|
|
|
def test_consistencia_motores(presets):
|
|
"""Criterio 6: interpolación lineal del schedule == f_inst, error < 1e-6 Hz."""
|
|
for preset in presets.values():
|
|
sch = schedule_de_preset(preset)
|
|
ts = np.array([p.t for p in sch.points])
|
|
bs = np.array([p.beat_hz for p in sch.points])
|
|
t = np.linspace(0.0, sch.duration_s, 20001)
|
|
referencia = np.interp(t, ts, bs) # lo que hace Web Audio con rampas lineales
|
|
assert np.max(np.abs(f_inst(sch, t) - referencia)) < 1e-6
|