EQ 预设 10 个(平直/流行/摇滚/爵士/古典/人声/低音/高音/深夜/柔化): 用控制点在对数频率轴插值成 32 段; CDP 点击实测低音[7,7,7,7,6.5,6]+后段-1、柔化前段-2后段-4.5 均写入 DSP

This commit is contained in:
lou
2026-09-19 19:56:58 +08:00
parent bd9238e8b0
commit 6a43111d5a
2 changed files with 114 additions and 0 deletions
+53
View File
@@ -0,0 +1,53 @@
"""点 EQ 预设, 验证前端与 DSP 都真的变了。"""
from __future__ import annotations
import json
import subprocess
import time
import urllib.request
import websocket
API = "http://127.0.0.1:8789"
page = subprocess.Popen([
"google-chrome", "--headless=new", "--disable-gpu", "--remote-debugging-port=9333",
"--remote-allow-origins=*", "--user-data-dir=/tmp/cxchrome4", API],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
time.sleep(4)
tabs = json.load(urllib.request.urlopen("http://127.0.0.1:9333/json/list", timeout=15))
ws = websocket.create_connection([t for t in tabs if t.get("type") == "page"][0]["webSocketDebuggerUrl"], timeout=25)
_mid = [0]
def js(expr: str) -> object:
_mid[0] += 1
ws.send(json.dumps({"id": _mid[0], "method": "Runtime.evaluate",
"params": {"expression": expr, "returnByValue": True}}))
while True:
msg = json.loads(ws.recv())
if msg.get("id") == _mid[0]:
return ((msg.get("result") or {}).get("result") or {}).get("value")
print("预设按钮:", js("Array.from(document.querySelectorAll('#presets button')).map(b => b.textContent).join(' / ')"))
for name in ("低音", "柔化"):
js("Array.from(document.querySelectorAll('#presets button')).find(b => b.textContent === '%s').click()" % name)
time.sleep(0.7)
vals = js("Array.from(document.querySelectorAll('#eq input')).map(i => +i.value)")
srv = json.load(urllib.request.urlopen(API + "/api/state", timeout=15))
print()
print("点[%s] 前端前6段 = %s" % (name, [round(v, 1) for v in vals[:6]]))
print(" 前端后6段 = %s" % [round(v, 1) for v in vals[-6:]])
print(" 服务端前6 = %s 后6 = %s" % (
[round(g, 1) for g in srv["gains"][:6]], [round(g, 1) for g in srv["gains"][-6:]]))
print(" 状态栏 =", js("document.getElementById('status').textContent"))
# 收尾: 回到平直
js("Array.from(document.querySelectorAll('#presets button')).find(b => b.textContent === '平直').click()")
time.sleep(0.5)
print()
print("已复位到平直:", js("Array.from(document.querySelectorAll('#eq input')).every(i => +i.value === 0)"))
ws.close()
page.terminate()