Implemented track loudness analysis

This commit is contained in:
patben8 committed 2026-10-19 14:07:54 +02:00
1 parent 5c9387f136
commit d70a7c5de2
28 files changed
+1732 -144

No files matched your search

+24
View File
@@ -241,6 +241,28 @@ with tempfile.TemporaryDirectory() as d:
check("…with no second download", downloads == [target], downloads)
c.post("/api/save")
print("== loudness: measured here, kept on the server ==")
import httpx
puts = []
real_put = adapter.client.loudness_put
adapter.client.loudness_put = lambda entries: (puts.append(entries), real_put(entries))[1]
r = c.post("/api/tracks/loudness", json={"track_id": target})
check("the deck's loudness runs here, on the cached copy", r.status_code == 200 and downloads == [target],
r.text[:200])
server_path = str(mapped / file_name)
check("…and is sent to the server, keyed by the SERVER's path",
puts and puts[-1][0]["path"] == server_path, str(puts)[:300])
vals = c.post("/api/loudness", json={"track_ids": [target]}).json()["values"]
check("the table reads it back through the server", target in vals and not vals[target]["stale"], str(vals))
direct = httpx.post(f"http://127.0.0.1:{port}/v1/loudness/get", json={"paths": [server_path]},
auth=("dj", "secret")).json()
check("…the server holds it", [e["path"] for e in direct["entries"]] == [server_path], str(direct))
r = httpx.put(f"http://127.0.0.1:{port}/v1/loudness", json={"entries": direct["entries"]},
auth=("dj", "secret"))
check("storing without the session is refused (423)", r.status_code == 423, r.text[:200])
check("…and a measurement leaves nothing unsaved", not c.get("/api/state").json()["dirty"])
print("== export, from the server's library ==")
dest = root / "stick"
r = c.post("/api/exports", json={"name": "Gig", "targets": ["traktor"], "destination": str(dest)})
@@ -399,6 +421,8 @@ with tempfile.TemporaryDirectory() as d:
and st["remote"]["machine"] == "Studio iMac")
caps = c.get("/api/capabilities").json()
check("…through its capabilities", not caps["writable"] and caps["readonly_cause"] == "taken_over")
r = c.post("/api/tracks/loudness", json={"track_id": target})
check("…and a measurement can no longer be stored", r.status_code == 503, r.text[:200])
check("the server still has the genre this computer saved", server_adapter.track(target).genre == "Remote Edit")
r = c.post("/api/library/open-remote", json={"remote_id": remote_id})
check("reopening says who holds it", r.status_code == 409