From d44be212dfb1c025fa31eef497d4e13ae1d1f14f Mon Sep 17 00:00:00 2001 From: Dogfather Date: Thu, 5 Nov 2026 15:03:17 +0100 Subject: [PATCH] =?UTF-8?q?Runde=205:=20Lautheit=20je=20Quelle=20(Mikro,?= =?UTF-8?q?=20Spiel)=20mit=20Vorschlag=20am=20eigenen=20Regler=20und=20R?= =?UTF-8?q?=C3=BCckg=C3=A4ngig;=20Mein=20Mix=20am=20Handy=20gepr=C3=BCft?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- server/pruef-ton-quellen-blick.mjs | 259 +++++++++++++++++++++++++++++ workspace/anleitung.html | 28 ++-- workspace/anruf-probe.html | 10 +- workspace/app.webmanifest | 8 +- workspace/assets/css/lautheit.css | 9 + workspace/assets/js/lautheit.js | 109 +++++++++++- workspace/assets/js/reaktion.js | 2 + workspace/aufgaben.html | 38 ++--- workspace/automation.html | 32 ++-- workspace/befinden.html | 34 ++-- workspace/bereich.html | 48 +++--- workspace/bewerben.html | 38 ++--- workspace/bewerbungen.html | 36 ++-- workspace/buehne.html | 12 +- workspace/calls.html | 34 ++-- workspace/chat.html | 48 +++--- workspace/content.html | 34 ++-- workspace/crew-index.html | 12 +- workspace/crew.webmanifest | 8 +- workspace/dateien.html | 34 ++-- workspace/dogtags.html | 38 ++--- workspace/entwicklung.html | 36 ++-- workspace/fernbedienung.html | 20 +-- workspace/hilfe.html | 30 ++-- workspace/index.html | 10 +- workspace/kalender.html | 34 ++-- workspace/koppeln.html | 14 +- workspace/leistung.html | 32 ++-- workspace/manager-ziele.html | 30 ++-- workspace/material.html | 32 ++-- workspace/nachbericht.html | 22 +-- workspace/notizen.html | 28 ++-- workspace/personen.html | 32 ++-- workspace/probesaal.html | 14 +- workspace/profil.html | 36 ++-- workspace/reaktion-foyer.html | 36 ++-- workspace/reaktion.html | 166 +++++++++--------- workspace/rechte.html | 34 ++-- workspace/report.html | 36 ++-- workspace/scouting.html | 32 ++-- workspace/start.html | 40 ++--- workspace/startcheck.html | 34 ++-- workspace/steckbrief.html | 36 ++-- workspace/support.html | 32 ++-- workspace/tafel.html | 10 +- workspace/talente.html | 36 ++-- workspace/team.html | 32 ++-- workspace/teamlage.html | 34 ++-- workspace/teilen.html | 30 ++-- workspace/treff-moderation.html | 32 ++-- workspace/treff-regeln.html | 32 ++-- workspace/uebersicht.html | 32 ++-- workspace/unsere-seiten.html | 30 ++-- workspace/unterstuetzen.html | 32 ++-- workspace/werdegang.html | 32 ++-- workspace/willkommen.html | 2 +- workspace/wissen.html | 34 ++-- 57 files changed, 1215 insertions(+), 840 deletions(-) create mode 100644 server/pruef-ton-quellen-blick.mjs diff --git a/server/pruef-ton-quellen-blick.mjs b/server/pruef-ton-quellen-blick.mjs new file mode 100644 index 00000000..ea36f99b --- /dev/null +++ b/server/pruef-ton-quellen-blick.mjs @@ -0,0 +1,259 @@ +/* ===================================================================== + LAUTHEIT JE QUELLE + VORSCHLAG (05.11.2026, Perfektionsplan Runde 5) + Zockabend mit Mikro (−23 dBFS) und Spielton (−35 dBFS): je Quelle auf + ±1 LU gemessen, Vorschlag für die weiter entfernte Quelle (höchstens +6 dB, + Rest ans Pult), „übernehmen“ und „Rückgängig“ am echten Regler. + DREI AUSGÄNGE: 0 in Ordnung · 1 Befund · 3 konnte nicht nachsehen. + Bilder: TQ_BILDER= node server/pruef-ton-quellen-blick.mjs + ===================================================================== */ +import { mkdtempSync, rmSync, readFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join, dirname } from "node:path"; +import { fileURLToPath } from "node:url"; +import { request } from "node:http"; +import { createServer as httpsServer } from "node:https"; +import { zertifikatBauen } from "./helfer-openssl.mjs"; +import { notbremse } from "./helfer-notbremse.mjs"; +import { eigenerPort } from "./helfer-port.mjs"; + +const HIER = dirname(fileURLToPath(import.meta.url)); +const ordner = mkdtempSync(join(tmpdir(), "pruef-ton-quellen-")); +process.env.WORKSPACE_DB = join(ordner, "workspace.db"); + +const PORT = await eigenerPort(import.meta); +const HTTPS_PORT = await eigenerPort(import.meta, "pruef-ton-quellen-blick (HTTPS)", 1); +process.env.PORT = `${PORT}`; +process.env.SITE_ACCESS_SECRET = "lokaler-test"; +process.env.SITE_PUBLIC_LAUNCH_AT = "2020-01-01T00:00:00+01:00"; + +const express = (await import("express")).default; +/* Der Sitzungskeks ist `secure`. Der Vorbau unten spricht https, der + Server dahinter nicht -- ohne diesen Griff setzt er den Keks und + der Browser verwirft ihn. */ +const ec = express.response.cookie; +express.response.cookie = function (n, w, o) { return ec.call(this, n, w, { ...(o || {}), secure: false }); }; +await import("./index.js"); +notbremse(300_000, "pruef-ton-quellen-blick"); +await new Promise((r) => setTimeout(r, 1000)); + +const CREW = "crew.dogfather-universe.com"; + +/* ---------- Leute ------------------------------------------------------- */ +const { DatabaseSync } = await import("node:sqlite"); +const { scryptSync, randomBytes, createHmac } = await import("node:crypto"); +const d = new DatabaseSync(process.env.WORKSPACE_DB); +const kenn = randomBytes(32).toString("hex"); +d.prepare("INSERT INTO einstellungen (schluessel, wert, geaendert, von)" + + " VALUES (?,?,?,NULL) ON CONFLICT(schluessel) DO NOTHING") + .run("code_kennung_schluessel", kenn, new Date().toISOString()); +const ALT = new Date(Date.now() - 200 * 86400000).toISOString(); +function anlegen(name, rolle, code) { + const salt = randomBytes(16).toString("hex"); + const hash = scryptSync(code, salt, 64, + { N: 32768, r: 8, p: 1, maxmem: 96 * 1024 * 1024 }).toString("hex"); + d.prepare("INSERT INTO personen (name, rolle, code_hash, code_salt, code_n," + + " code_kennung, aktiv, erstellt) VALUES (?,?,?,?,?,?,1,?)") + .run(name, rolle, hash, salt, 32768, + createHmac("sha256", kenn).update(code).digest("hex"), ALT); +} +const CODES = { + admin: "CODE-M00-000001", hand: "CODE-M01-000001", + gast: "CODE-M02-000001", gast2: "CODE-M03-000001", +}; +/* VANVAN IST DIE RECHTE HAND und wird mitgemessen, nicht nur + DogFather: Filipe hat "nur ich und vanvan" gesagt, und ob die + zweite Haelfte davon stimmt, sieht man nur, wenn sie dabei ist. */ +anlegen("DogFather", "admin", CODES.admin); +anlegen("VanVan", "hand", CODES.hand); +anlegen("Nachtfalter", "gast", CODES.gast); +anlegen("Lenny", "gast", CODES.gast2); +d.close(); + +function roh(pfad, { method = "GET", keks = "", rumpf = null } = {}) { + return new Promise((fertig, schief) => { + const daten = rumpf === null ? null : Buffer.from(JSON.stringify(rumpf)); + const a = request({ + host: "127.0.0.1", port: PORT, path: pfad, method, + headers: { + Host: CREW, Origin: `https://${CREW}`, + ...(keks ? { Cookie: keks } : {}), + ...(daten ? { "Content-Type": "application/json", "Content-Length": daten.length } : {}), + }, + }, (antwort) => { + const teile = []; + antwort.on("data", (s) => teile.push(s)); + antwort.on("end", () => { + const text = Buffer.concat(teile).toString("utf8"); + let j = null; try { j = JSON.parse(text); } catch { /* kein JSON */ } + fertig({ code: antwort.statusCode, text, j, kopf: antwort.headers }); + }); + }); + a.on("error", schief); + if (daten) a.write(daten); + a.end(); + }); +} +async function anmelden(wer) { + const a = await roh("/workspace/api/anmelden", { + method: "POST", + rumpf: { rolle: wer === "gast2" ? "gast" : wer, code: CODES[wer], alter_ok: true }, + }); + return [].concat(a.kopf["set-cookie"] || []).map((z) => z.split(";")[0]).join("; "); +} +const k = { + admin: await anmelden("admin"), + hand: await anmelden("hand"), + gast: await anmelden("gast"), + gast2: await anmelden("gast2"), +}; + +/* ---------- Zaehlwerk --------------------------------------------------- */ +let fehler = 0; +let geprueft = 0; +const ok = (b, t) => { + geprueft++; + console.log((b ? " ok " : " FEHL ") + t); + if (!b) fehler++; +}; +function nichtNachsehbar(grund) { + console.log("\n -- NICHT NACHSEHBAR"); + console.log(` ${grund}`); + console.log(" Das ist KEIN Befund am Code -- es heisst nur, dass"); + console.log(" gerade niemand nachsehen konnte.\n"); + try { rmSync(ordner, { recursive: true, force: true }); } catch { /* egal */ } + process.exit(3); +} + +/* ---------- Die Buehne fuellen ------------------------------------------ */ +/* ZWEI STUECKE IN DER WARTESCHLANGE, EINES MIT TERMIN UND EINES OHNE. + Genau das ist die Aussage der linken Reihe ("was keinen hat, steht + unten"), und mit nur einem Eintrag liesse sie sich nicht messen. */ +for (const adresse of ["https://youtu.be/9bZkp7q19f0", + "https://www.youtube.com/watch?v=kJQP7kiw5Fk"]) { + const a = await roh("/workspace/api/reaktion/liste", { + method: "POST", keks: k.admin, rumpf: { video: adresse }, + }); + if (a.code >= 400) nichtNachsehbar(`Die Warteschlange nimmt nichts an (HTTP ${a.code}).`); +} +const liste0 = (await roh("/workspace/api/reaktion", { keks: k.admin })).j?.liste || []; +if (liste0.length !== 2) { + nichtNachsehbar(`In der Warteschlange stehen ${liste0.length} Stuecke statt 2.`); +} + +/* Der Termin liegt in der ZUKUNFT und wird relativ gerechnet. Ein + festes Datum waere eine Zeitbombe: Es ist richtig, bis der Kalender + es einholt -- und dann schlaegt "ueberfaellig" an, ohne dass etwas + kaputt ist. */ +{ + const a = await roh(`/workspace/api/reaktion/liste/${liste0[0].id}/wann`, { + method: "PUT", keks: k.admin, + rumpf: { wann: new Date(Date.now() + 3 * 86400000).toISOString() }, + }); + if (a.code >= 400) nichtNachsehbar(`Der Termin laesst sich nicht setzen (HTTP ${a.code}).`); +} +await roh("/workspace/api/reaktion", { + method: "PUT", keks: k.admin, + rumpf: { + titel: "Wir schauen den neuen Trailer", + video: "https://www.youtube.com/watch?v=dQw4w9WgXcQ", + beginnt_am: new Date(Date.now() + 7 * 60_000).toISOString(), + }, +}); + +/* ---------- Der Vorbau -------------------------------------------------- */ +const schluesselDatei = join(ordner, "p.key"); +const zertDatei = join(ordner, "p.crt"); +try { + zertifikatBauen(schluesselDatei, zertDatei, CREW); +} catch (f) { + nichtNachsehbar(`Kein Zertifikat zu bauen: ${f?.message}\n` + + " openssl liegt bei Git in mingw64/bin -- im System-PATH\n" + + " steht oft nur Git/cmd."); +} +const vorbau = httpsServer({ + key: readFileSync(schluesselDatei), cert: readFileSync(zertDatei), +}, (von, nach) => { + const weiter = request({ + host: "127.0.0.1", port: PORT, path: von.url, method: von.method, + headers: { ...von.headers, host: `${CREW}:${HTTPS_PORT}` }, + }, (antwort) => { + nach.writeHead(antwort.statusCode || 502, antwort.headers); + antwort.pipe(nach); + }); + weiter.on("error", () => { try { nach.writeHead(502); nach.end(); } catch { /* egal */ } }); + von.pipe(weiter); +}); +await new Promise((r) => vorbau.listen(HTTPS_PORT, "127.0.0.1", r)); +const BASIS = `https://${CREW}:${HTTPS_PORT}`; +/* Der Zockabend beginnt im Test selbst über „Zocken starten“. */ +for (const [w, t] of [["gast", "Erster im Saal"], ["gast2", "Zweite Nachricht"]]) await roh("/workspace/api/reaktion/chat", { method: "POST", keks: k[w], rumpf: { text: t } }); + +let pw = null; +try { pw = await import("file:///C:/Users/qciga/Documents/Obelix/Analyse/node_modules/playwright/index.mjs"); } catch (f) { nichtNachsehbar(`Playwright fehlt: ${f?.message}`); } +const browser = await pw.chromium.launch({ args: [`--host-resolver-rules=MAP ${CREW} 127.0.0.1`, "--ignore-certificate-errors", "--use-fake-ui-for-media-stream", "--use-fake-device-for-media-stream", "--autoplay-policy=no-user-gesture-required"] }); +const BILDER = process.env.TQ_BILDER || ""; +const warte = (ms) => new Promise((r) => setTimeout(r, ms)); +const konsole = []; +const kx = await browser.newContext({ viewport: { width: 1440, height: 900 }, ignoreHTTPSErrors: true, permissions: ["camera", "microphone"] }); +await kx.addCookies(k.admin.split("; ").filter(Boolean).map((z) => { const [n, ...r] = z.split("="); return { name: n, value: r.join("="), domain: CREW, path: "/" }; })); +const s = await kx.newPage(); +s.on("pageerror", (f) => konsole.push(String(f?.message || f))); +await s.addInitScript(() => { + /* Mikro 440 Hz bei −23 dBFS, Spielton 1000 Hz bei −35 dBFS – zwei bekannte Pegel. */ + const ton = (f, db) => { const ac = new AudioContext({ sampleRate: 48000 }); const o = ac.createOscillator(); o.frequency.value = f; const g = ac.createGain(); g.gain.value = Math.pow(10, db / 20); const z = ac.createMediaStreamDestination(); z.channelCount = 1; o.connect(g); g.connect(z); o.start(); return z.stream.getAudioTracks()[0]; }; + const orig = navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices); + navigator.mediaDevices.getUserMedia = async (w) => { const st = await orig(w); if (w && w.audio) { for (const t of st.getAudioTracks()) { st.removeTrack(t); t.stop(); } st.addTrack(ton(440, -23)); } return st; }; + navigator.mediaDevices.getDisplayMedia = async () => { const c = Object.assign(document.createElement("canvas"), { width: 1280, height: 720 }); const x = c.getContext("2d"); let n = 0; setInterval(() => { x.fillStyle = `hsl(${(n += 5) % 360} 40% 30%)`; x.fillRect(0, 0, 1280, 720); }, 33); const st = c.captureStream(30); st.addTrack(ton(1000, -35)); return st; }; +}); +await s.goto(`${BASIS}/workspace/reaktion.html`, { waitUntil: "domcontentloaded" }); +await s.waitForSelector("#zock-start", { state: "attached", timeout: 20000 }); +await s.waitForFunction(() => window.RegieLaden?.fertig?.(), null, { timeout: 20000 }).catch(() => {}); +await s.fill("#zock-titel", "Ton-Probe"); +await s.click("#zock-start"); +let teile = false; +for (let i = 0; i < 60 && !teile; i++) { teile = await s.evaluate(() => !!window.SaalKamera?.teile?.()?.spiel); if (!teile) await warte(500); } +ok(teile, "beim Zocken gibt es Mikro und Spiel als Einzelausgänge"); +await s.evaluate(() => document.getElementById("reiter-ton")?.click()); +let q = null; +for (let i = 0; i < 40; i++) { q = await s.evaluate(() => window.Lautheit?.quellen?.()); if (q?.mikro?.bloecke > 30 && q?.spiel?.bloecke > 30) break; await warte(300); } +console.log(" je Quelle:", JSON.stringify({ mikro: q?.mikro?.kurz, spiel: q?.spiel?.kurz })); +const nah = (x, soll) => Number.isFinite(x) && Math.abs(x - soll) <= 1; +ok(nah(q?.mikro?.kurz, -23) && nah(q?.spiel?.kurz, -35), `je Quelle gemessen: Mikro ${q?.mikro?.kurz?.toFixed?.(1)} (Soll −23), Spiel ${q?.spiel?.kurz?.toFixed?.(1)} (Soll −35)`); +const zeilen = await s.evaluate(() => [...document.querySelectorAll("#lt-quellen .lt-quelle")].map((z) => z.textContent)); +ok(zeilen.length === 2 && /Mikro/.test(zeilen.join()) && /Spiel/.test(zeilen.join()), `beide Quellen stehen in der Anzeige (${zeilen.join(" | ")})`); +await warte(600); +const v = await s.evaluate(() => { const k = document.getElementById("lt-uebernehmen"); return k ? { text: k.textContent, was: k.dataset.was, neu: k.dataset.neu, rest: document.getElementById("lt-vorschlag").textContent } : null; }); +ok(v && v.was === "spiel" && /Spiel \+3,5 dB übernehmen \(150 %\)/.test(v.text) && v.neu === "150" && /Rest am Pult lauter/.test(v.rest), `der Vorschlag nimmt die Quelle, die am weitesten weg ist, der Knopf sagt, was der Regler wirklich schafft (+3,5 dB bis 150 %), Rest ans Pult (${JSON.stringify(v)})`); +if (BILDER) { await s.evaluate(() => document.getElementById("lt")?.scrollIntoView({ block: "start" })); await warte(400); await s.locator("#lt").screenshot({ path: `${BILDER}/lautheit-quellen.png` }); } +const vorher = await s.evaluate(() => document.querySelector('.mischregler[data-was="spiel"] input[type="range"]').value); +await s.click("#lt-uebernehmen"); +await warte(500); +const nachher = await s.evaluate(() => document.querySelector('.mischregler[data-was="spiel"] input[type="range"]').value); +ok(vorher === "100" && nachher === "150", `„übernehmen“ setzt den eigenen Spiel-Regler (${vorher} → ${nachher})`); +await s.click("#lt-rueck"); +await warte(500); +ok(await s.evaluate(() => document.querySelector('.mischregler[data-was="spiel"] input[type="range"]').value) === "100", "„Rückgängig“ stellt ihn zurück"); +/* Mein Mix am Handy: derselbe Knopf im Chat-Kopf, mit Finger erreichbar. Die + Medienweiche ist hier nicht da – ihre zwei Spuren kommen aus einer Attrappe + (gegen die echte Weiche geprüft in _plan-werkzeug/gesamt/meinmix-test.mjs). */ +const hk = await browser.newContext({ viewport: { width: 390, height: 844 }, ignoreHTTPSErrors: true, hasTouch: true, isMobile: true }); +await hk.addCookies(k.gast.split("; ").filter(Boolean).map((z) => { const [n2, ...r] = z.split("="); return { name: n2, value: r.join("="), domain: CREW, path: "/" }; })); +const h = await hk.newPage(); +h.on("pageerror", (f) => konsole.push(String(f?.message || f))); +await h.goto(`${BASIS}/workspace/reaktion.html`, { waitUntil: "domcontentloaded" }); +await h.waitForSelector("body[data-stand]", { timeout: 20000 }); +await h.waitForTimeout(1500); +await h.evaluate(() => { const ac = new AudioContext(); const z = () => ac.createMediaStreamDestination().stream.getAudioTracks()[0]; const sp = z(), st = z(); window.SaalWeiche.quellen = () => ({ spiel: sp, stimme: st }); }); +await h.waitForTimeout(1200); +const mm = await h.evaluate(() => { const k2 = document.getElementById("mm-knopf"); const r = k2?.getBoundingClientRect(); return k2 ? { da: !k2.hidden && r.height > 0, h: Math.round(r.height), drin: r.right <= innerWidth + 1 && r.left >= 0 } : null; }); +ok(mm?.da && mm.h >= 44 && mm.drin, `Mein Mix am Handy: Knopf im Chat-Kopf, ${mm?.h} px, im Fenster (${JSON.stringify(mm)})`); +await h.evaluate(() => document.getElementById("mm-knopf")?.click()); +await h.waitForTimeout(500); +const tf = await h.evaluate(() => { const t = document.getElementById("mm-tafel"); const r = t?.getBoundingClientRect(); const reg = document.getElementById("mm-spiel")?.getBoundingClientRect(); return { offen: !!t && !t.hidden, breit: document.documentElement.scrollWidth <= innerWidth + 1, regler: Math.round(reg?.height || 0), drin: !!r && r.right <= innerWidth + 1 }; }); +ok(tf.offen && tf.breit && tf.regler >= 44 && tf.drin, `… die Tafel geht am Handy auf, Regler 44 px, nichts ragt hinaus (${JSON.stringify(tf)})`); +ok(!konsole.length, `keine Fehler (${konsole.slice(0, 3).join(" | ")})`); +await browser.close(); +vorbau.close(); +console.log(`\n${geprueft} Pruefungen, ${fehler} Fehler`); +try { rmSync(ordner, { recursive: true, force: true }); } catch { /* egal */ } +process.exit(fehler ? 1 : 0); diff --git a/workspace/anleitung.html b/workspace/anleitung.html index ac0b4309..ca3fb906 100644 --- a/workspace/anleitung.html +++ b/workspace/anleitung.html @@ -7,17 +7,17 @@ - - - - - + + + + + - - + + @@ -289,16 +289,16 @@ Und anleitung.js braucht es doppelt: Symbol, Farbe, Name und Adresse jeder Karte kommen von dort, nicht vom Server. --> - + - - - - - - + + + + + + diff --git a/workspace/anruf-probe.html b/workspace/anruf-probe.html index cf6bc4d3..e9ba0105 100644 --- a/workspace/anruf-probe.html +++ b/workspace/anruf-probe.html @@ -16,8 +16,8 @@ verdeckt. Gefunden hat es pruef-struktur. Richtig sind `gate.css` (die Farbwerte des Hauses) und `haus.css`. --> - - + + - +