Spaces:
Paused
Paused
Live mixer: aligned waveforms, audible solo/mute/FX/tempo, MIX dock under tracks
Browse files- app/mixer.py +18 -8
- app/static/index.html +16 -5
- app/static/studio-v1.css +27 -2
- app/static/studio.js +268 -57
- tests/test_arrangement.py +12 -0
- tests/test_photoreal_studio.py +18 -0
app/mixer.py
CHANGED
|
@@ -145,16 +145,26 @@ def render_mix(sources:dict[str,Path], settings:dict, destination:Path,
|
|
| 145 |
|
| 146 |
|
| 147 |
def sampled_peaks(path:Path, size:int=360)->dict:
|
| 148 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
info=sf.info(str(path))
|
| 150 |
if info.channels not in (1,2):raise ValueError("Only mono/stereo available")
|
| 151 |
-
size=max(64,min(size,
|
|
|
|
| 152 |
points=[]
|
| 153 |
with sf.SoundFile(str(path)) as f:
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
return {"samples":points,"duration":round(info.duration,3),
|
| 159 |
-
"samplerate":info.samplerate,"sample_method":"
|
| 160 |
-
"peak_reliability":"visualization only; not exhaustive"}
|
|
|
|
| 145 |
|
| 146 |
|
| 147 |
def sampled_peaks(path:Path, size:int=360)->dict:
|
| 148 |
+
"""Uniform time-bin envelope for playhead-aligned waveforms.
|
| 149 |
+
|
| 150 |
+
Each point is the max-abs of one contiguous slice covering the file from
|
| 151 |
+
start to end. Visualization only — not an exhaustive sample audit.
|
| 152 |
+
"""
|
| 153 |
info=sf.info(str(path))
|
| 154 |
if info.channels not in (1,2):raise ValueError("Only mono/stereo available")
|
| 155 |
+
size=max(64,min(int(size),2000))
|
| 156 |
+
frames=int(info.frames)
|
| 157 |
points=[]
|
| 158 |
with sf.SoundFile(str(path)) as f:
|
| 159 |
+
if frames<=0:
|
| 160 |
+
points=[0.0]*size
|
| 161 |
+
else:
|
| 162 |
+
for i in range(size):
|
| 163 |
+
start=i*frames//size
|
| 164 |
+
end=max(start+1,(i+1)*frames//size)
|
| 165 |
+
f.seek(min(start,frames-1))
|
| 166 |
+
block=f.read(max(1,min(end,frames)-start),dtype="float32",always_2d=True)
|
| 167 |
+
points.append(round(float(np.max(np.abs(block))) if block.size else 0,5))
|
| 168 |
return {"samples":points,"duration":round(info.duration,3),
|
| 169 |
+
"samplerate":info.samplerate,"sample_method":"uniform_bins_maxabs",
|
| 170 |
+
"peak_reliability":"visualization only; bin-max envelope, not exhaustive"}
|
app/static/index.html
CHANGED
|
@@ -69,17 +69,28 @@
|
|
| 69 |
<div class="transport-params"><label>TEMPO <span><input id="tempo" class="compact-input" type="number" min="50" max="200" step="1" value="100" aria-label="Tempo in Prozent"> %</span></label>
|
| 70 |
<label>PITCH <span><input id="pitch" class="compact-input" type="number" min="-12" max="12" step="1" value="0" aria-label="Transponierung in Halbtönen"> ST</span></label></div>
|
| 71 |
</div>
|
| 72 |
-
<div class="monitor-foot"><span id="nowPlaying">
|
| 73 |
<audio id="player" preload="metadata"></audio>
|
| 74 |
</section>
|
| 75 |
<section class="tracks panel" id="tracksSection">
|
| 76 |
<div class="section-heading track-heading">
|
| 77 |
-
<div><span class="eyebrow">SPUR-MIXER / Ω02</span><h2>Alle Spuren <span class="count-bubble" id="trackBubble">0</span></h2><p>
|
| 78 |
-
<div class="track-actions"><span class="
|
| 79 |
</div>
|
| 80 |
<div class="track-key"><span>SPUR / PEGEL</span><span>STEREOFELD · WAVEFORM</span><span>WERKZEUGE</span></div>
|
| 81 |
<div class="track-list" id="trackList"><div class="empty-tracks"><div class="empty-symbol">∿</div><b>Hier entstehen deine Spuren.</b><p>Eine Audiodatei importieren und Ω FUSION starten: Die vorhandenen Klanganteile erscheinen hier automatisch.</p><button class="btn btn-soft" id="emptyDemo" data-action="demo">Demo laden</button></div></div>
|
| 82 |
-
<div class="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
</section>
|
| 84 |
</main>
|
| 85 |
<aside class="inspector panel" id="inspector" aria-label="Bearbeitungswerkzeuge">
|
|
@@ -167,7 +178,7 @@
|
|
| 167 |
<details class="tool-group" id="group-export">
|
| 168 |
<summary><span class="tool-n">03</span><span><b>Export & Qualitätsbericht</b><small>Original, Spuren, Mix und Differenz.</small></span><span class="chev">⌄</span></summary>
|
| 169 |
<div class="tool-body">
|
| 170 |
-
<p class="field-help">
|
| 171 |
<div class="embedded-module" id="tab-export">
|
| 172 |
<div class="tool-intro"><h3>Export & Diagnose</h3><p>Original, echte Stems und gerenderter Mix desselben Projekts.</p></div>
|
| 173 |
<div class="export-grid"><a class="btn btn-soft full link-disabled" id="exportOriginal">↓ Quelldatei</a><a class="btn btn-soft full link-disabled" id="exportStems">↓ Alle Stems · ZIP</a><a class="btn btn-primary full link-disabled" id="exportMix">↓ Letzter Mix · WAV</a><a class="btn btn-soft full link-disabled" id="exportBass">↓ Bass-Projekt · ZIP</a><a class="btn btn-soft full link-disabled" id="exportNoise">↓ NOISE-Projekt · ZIP</a></div>
|
|
|
|
| 69 |
<div class="transport-params"><label>TEMPO <span><input id="tempo" class="compact-input" type="number" min="50" max="200" step="1" value="100" aria-label="Tempo in Prozent"> %</span></label>
|
| 70 |
<label>PITCH <span><input id="pitch" class="compact-input" type="number" min="-12" max="12" step="1" value="0" aria-label="Transponierung in Halbtönen"> ST</span></label></div>
|
| 71 |
</div>
|
| 72 |
+
<div class="monitor-foot"><span id="nowPlaying">Live-Mixer bereit</span><span id="rubberbandInfo">Solo, Mute, FX und Tempo sind live hörbar</span></div>
|
| 73 |
<audio id="player" preload="metadata"></audio>
|
| 74 |
</section>
|
| 75 |
<section class="tracks panel" id="tracksSection">
|
| 76 |
<div class="section-heading track-heading">
|
| 77 |
+
<div><span class="eyebrow">SPUR-MIXER / Ω02</span><h2>Alle Spuren <span class="count-bubble" id="trackBubble">0</span></h2><p>Solo, Mute, Pegel, Panorama, FX und Tempo greifen sofort — sichtbar und hörbar.</p></div>
|
| 78 |
+
<div class="track-actions"><span class="live-pill" id="livePill"><span class="led"></span> LIVE</span></div>
|
| 79 |
</div>
|
| 80 |
<div class="track-key"><span>SPUR / PEGEL</span><span>STEREOFELD · WAVEFORM</span><span>WERKZEUGE</span></div>
|
| 81 |
<div class="track-list" id="trackList"><div class="empty-tracks"><div class="empty-symbol">∿</div><b>Hier entstehen deine Spuren.</b><p>Eine Audiodatei importieren und Ω FUSION starten: Die vorhandenen Klanganteile erscheinen hier automatisch.</p><button class="btn btn-soft" id="emptyDemo" data-action="demo">Demo laden</button></div></div>
|
| 82 |
+
<div class="mix-dock" id="mixDock">
|
| 83 |
+
<div class="mix-dock-copy">
|
| 84 |
+
<span class="soft-status" id="mixStatus">Mix-Export noch nicht berechnet</span>
|
| 85 |
+
<small>Regler wirken live im Player. MIX schreibt den hochwertigen WAV-Export (inkl. Rubber Band, falls vorhanden).</small>
|
| 86 |
+
</div>
|
| 87 |
+
<div class="mix-dock-actions">
|
| 88 |
+
<button class="btn btn-primary" id="renderMix" disabled>◉ MIX</button>
|
| 89 |
+
<button class="btn btn-glass" id="previewRender" disabled>▶ Export hören</button>
|
| 90 |
+
<a class="btn btn-glass link-disabled" id="downloadRender" aria-disabled="true">↓ WAV</a>
|
| 91 |
+
</div>
|
| 92 |
+
</div>
|
| 93 |
+
<div class="tracks-footer"><div class="preservation"><span class="shield">◇</span><span><b id="consistency">Original unverändert</b><small id="consistencyDetail">Alle Änderungen sind nichtdestruktiv.</small></span></div></div>
|
| 94 |
</section>
|
| 95 |
</main>
|
| 96 |
<aside class="inspector panel" id="inspector" aria-label="Bearbeitungswerkzeuge">
|
|
|
|
| 178 |
<details class="tool-group" id="group-export">
|
| 179 |
<summary><span class="tool-n">03</span><span><b>Export & Qualitätsbericht</b><small>Original, Spuren, Mix und Differenz.</small></span><span class="chev">⌄</span></summary>
|
| 180 |
<div class="tool-body">
|
| 181 |
+
<p class="field-help">Im Player hörst du Solo, Mute, FX und Tempo sofort. MIX speichert denselben Stand als WAV-Export. Ein älterer Export wird bei Änderungen als veraltet markiert.</p>
|
| 182 |
<div class="embedded-module" id="tab-export">
|
| 183 |
<div class="tool-intro"><h3>Export & Diagnose</h3><p>Original, echte Stems und gerenderter Mix desselben Projekts.</p></div>
|
| 184 |
<div class="export-grid"><a class="btn btn-soft full link-disabled" id="exportOriginal">↓ Quelldatei</a><a class="btn btn-soft full link-disabled" id="exportStems">↓ Alle Stems · ZIP</a><a class="btn btn-primary full link-disabled" id="exportMix">↓ Letzter Mix · WAV</a><a class="btn btn-soft full link-disabled" id="exportBass">↓ Bass-Projekt · ZIP</a><a class="btn btn-soft full link-disabled" id="exportNoise">↓ NOISE-Projekt · ZIP</a></div>
|
app/static/studio-v1.css
CHANGED
|
@@ -100,10 +100,11 @@ body::after{
|
|
| 100 |
.overview-header span:last-child{color:#8199af;font-size:9px;letter-spacing:.01em;font-weight:500}
|
| 101 |
.overview-canvas-wrap{
|
| 102 |
height:168px;position:relative;overflow:hidden;background:linear-gradient(180deg,#081520,#0b101b);
|
| 103 |
-
border:1px solid #58768e87;border-radius:11px;box-shadow:inset 0 0 35px #05121f,0 0 18px #268ba414
|
|
|
|
| 104 |
}
|
| 105 |
.overview-canvas-wrap canvas{width:100%;height:100%;display:block}
|
| 106 |
-
.play-line{position:absolute;top:0;bottom:0;width:
|
| 107 |
.wave-corner{pointer-events:none;position:absolute;width:17px;height:17px;border:1px solid #8edddf8a}
|
| 108 |
.wave-corner.tl{left:0;top:0;border-right:none;border-bottom:none}
|
| 109 |
.wave-corner.br{right:0;bottom:0;border-left:none;border-top:none}
|
|
@@ -367,3 +368,27 @@ body::before,body::after{display:none}
|
|
| 367 |
border:1px solid #ffffff1b;font-weight:650;line-height:1.35}
|
| 368 |
.fusion-status-grid .is-ready{background:#3ea89521;color:#a8f1dd;border-color:#5edcb050}
|
| 369 |
.fusion-status-grid .is-pending{background:#c59c5120;color:#ffe1b1;border-color:#d8a44f3d}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
.overview-header span:last-child{color:#8199af;font-size:9px;letter-spacing:.01em;font-weight:500}
|
| 101 |
.overview-canvas-wrap{
|
| 102 |
height:168px;position:relative;overflow:hidden;background:linear-gradient(180deg,#081520,#0b101b);
|
| 103 |
+
border:1px solid #58768e87;border-radius:11px;box-shadow:inset 0 0 35px #05121f,0 0 18px #268ba414;
|
| 104 |
+
contain:strict
|
| 105 |
}
|
| 106 |
.overview-canvas-wrap canvas{width:100%;height:100%;display:block}
|
| 107 |
+
.play-line{position:absolute;top:0;bottom:0;left:0;width:2px;margin:0;background:#e8f6ff;box-shadow:0 0 12px #9be7ff,0 0 2px #fff;pointer-events:none;will-change:left;transform:translateX(-50%);z-index:3}
|
| 108 |
.wave-corner{pointer-events:none;position:absolute;width:17px;height:17px;border:1px solid #8edddf8a}
|
| 109 |
.wave-corner.tl{left:0;top:0;border-right:none;border-bottom:none}
|
| 110 |
.wave-corner.br{right:0;bottom:0;border-left:none;border-top:none}
|
|
|
|
| 368 |
border:1px solid #ffffff1b;font-weight:650;line-height:1.35}
|
| 369 |
.fusion-status-grid .is-ready{background:#3ea89521;color:#a8f1dd;border-color:#5edcb050}
|
| 370 |
.fusion-status-grid .is-pending{background:#c59c5120;color:#ffe1b1;border-color:#d8a44f3d}
|
| 371 |
+
|
| 372 |
+
.live-pill{display:inline-flex;align-items:center;gap:7px;border:1px solid #5edcb06a;background:#12352fcc;color:#b6ffe8;border-radius:999px;padding:6px 11px;font-size:10px;font-weight:850;letter-spacing:.14em}
|
| 373 |
+
.live-pill .led{width:7px;height:7px;border-radius:50%;background:#7dffcf;box-shadow:0 0 10px #6dffc8;display:inline-block}
|
| 374 |
+
.live-pill.is-playing{border-color:#d7f7a8;color:#f3ffe8;background:#2a4a1ccc}
|
| 375 |
+
.live-pill.is-playing .led{background:#d6ff7a;box-shadow:0 0 12px #e7ff8a;animation:livePulse 1.1s ease-in-out infinite}
|
| 376 |
+
@keyframes livePulse{50%{opacity:.45}}
|
| 377 |
+
.mix-dock{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:14px 18px 16px;border-top:1px solid #3d627380;background:linear-gradient(180deg,#152433,#101924)}
|
| 378 |
+
.mix-dock-copy{display:grid;gap:4px;min-width:0}
|
| 379 |
+
.mix-dock-copy small{color:#93adbf;font-size:10px;line-height:1.45}
|
| 380 |
+
.mix-dock-actions{display:flex;gap:8px;flex-wrap:wrap;justify-content:flex-end}
|
| 381 |
+
.mix-dock-actions .btn-primary{min-width:108px;font-size:13px;letter-spacing:.08em}
|
| 382 |
+
.track-wave{position:relative;min-width:0;flex:1}
|
| 383 |
+
.track-wave .track-play{z-index:2}
|
| 384 |
+
.track.is-muted{opacity:.48;filter:saturate(.55)}
|
| 385 |
+
.track.is-soloed{box-shadow:inset 0 0 0 1px #f0c56a88}
|
| 386 |
+
.track-middle{position:relative}
|
| 387 |
+
.toggle[aria-pressed="true"].muted,.toggle.muted{background:#8b4a4a;color:#fff;border-color:#ff988f}
|
| 388 |
+
.toggle[aria-pressed="true"].soloed,.toggle.soloed{background:#b48a36;color:#0c1016;border-color:#ffde8a}
|
| 389 |
+
.track-canvas{contain:strict}
|
| 390 |
+
@media(max-width:710px){
|
| 391 |
+
.mix-dock{flex-direction:column;align-items:stretch}
|
| 392 |
+
.mix-dock-actions{width:100%}
|
| 393 |
+
.mix-dock-actions .btn{flex:1}
|
| 394 |
+
}
|
app/static/studio.js
CHANGED
|
@@ -9,6 +9,8 @@
|
|
| 9 |
const esc=(s)=>String(s??"").replace(/[&<>"']/g,x=>({"&":"&","<":"<",">":">",'"':""","'":"'"}[x]));
|
| 10 |
const S={id:null,project:null,projects:[],tracks:{},settings:{},peaks:{},plan:[],modelReady:false,rubberband:false,virtualReady:false,busy:false,job:null,mixDirty:true,audioTarget:"original",tab:"workflow",generation:0};
|
| 11 |
const audio=$("player");
|
|
|
|
|
|
|
| 12 |
const fmt=(n)=>{n=Math.max(0,Math.floor(Number(n)||0));return `${Math.floor(n/3600)?String(Math.floor(n/3600))+":":""}${String(Math.floor(n%3600/60)).padStart(2,"0")}:${String(n%60).padStart(2,"0")}`};
|
| 13 |
const stemTitle=(id)=>({harmonic:"Harmonik",percussive:"Percussion",residual:"Residual",vocals:"Gesang",drums:"Drums",bass:"Bass",other:"Instrumente",kick_core:"KICK · Bass-Core",bassline_core:"BASSLINE · Bass-Core",noise_difference:"NOISE · Stördifferenz"}[id]||id.replace(/_/g," ").replace(/[-]/g," "));
|
| 14 |
const role=(id,m)=>id==="noise_difference"?"FREIGEGEBENE DIFFERENZ":id.includes("kick")||id.includes("bassline")?"BASS · DSP-SCHÄTZUNG":m?.role==="base_compensated"?"BASIS · KOMPENSIERT":m?.role==="estimated_percussive"?"DSP-SCHÄTZUNG":m?.role||"AUDIO-STEM";
|
|
@@ -29,9 +31,10 @@
|
|
| 29 |
function setLink(id,url){const a=$(id);if(!a)return;if(url){a.href=url;a.removeAttribute("aria-disabled");a.classList.remove("link-disabled");}else{a.removeAttribute("href");a.setAttribute("aria-disabled","true");a.classList.add("link-disabled")}}
|
| 30 |
function requireSource(){if(!S.project?.asset)throw Error("Bitte zuerst eine Quelle importieren.")}
|
| 31 |
function markDirty(){
|
| 32 |
-
S.mixDirty=true;$("mixStatus").textContent="
|
| 33 |
$("renderMix").disabled=!Object.keys(S.tracks).length||S.busy;
|
| 34 |
$("previewRender").disabled=true;setLink("downloadRender",null);setLink("exportMix",null);
|
|
|
|
| 35 |
}
|
| 36 |
async function loadLibrary(){
|
| 37 |
const data=await req("/projects");
|
|
@@ -56,7 +59,7 @@
|
|
| 56 |
if(serial!==S.generation)return;
|
| 57 |
const different=S.id!==id;
|
| 58 |
S.id=id;S.project=manifest;S.plan=(manifest.plan||[]).map(x=>({...x}));
|
| 59 |
-
if(different){S.peaks={};S.settings={};audio.pause();audio.removeAttribute("src");S.audioTarget="original";}
|
| 60 |
hideMobile();
|
| 61 |
const tracks=manifest.unified?.mix_consistent?manifest.unified.stems:(manifest.stems||{});
|
| 62 |
const names=Object.keys(tracks);
|
|
@@ -114,10 +117,10 @@
|
|
| 114 |
document.querySelectorAll(".needs-tracks").forEach(b=>b.disabled=!names.length||S.busy);
|
| 115 |
$("renderMix").disabled=!names.length||S.busy;
|
| 116 |
$("previewRender").disabled=S.mixDirty||!m?.mixer;
|
| 117 |
-
$("mixStatus").textContent=S.mixDirty?"
|
| 118 |
-
const
|
| 119 |
-
|
| 120 |
-
|
| 121 |
$("virtualRun").disabled=!asset||!S.virtualReady||a.channels!==2||S.busy;
|
| 122 |
$("playClean").disabled=!m?.noise?.repair;
|
| 123 |
$("playDifference").disabled=!m?.noise?.repair;
|
|
@@ -159,20 +162,21 @@
|
|
| 159 |
<p>${S.project?.asset?"Starte Ω FUSION rechts: es erstellt Grundstems, Bass/Kick und scannt Störstellen in einem Durchlauf.":"Importiere eine Datei und bearbeite alle vorhandenen Stems in dieser gemeinsamen Ansicht."}</p><button class="btn btn-primary" data-action="${S.project?.asset?"fusion":"demo"}">${S.project?.asset?"Ω FUSION starten":"Demo laden"}</button></div>`;redraw();return}
|
| 160 |
$("trackList").innerHTML=entries.map(([name,meta],i)=>{
|
| 161 |
const s=S.settings[name]||defaultSettings(),col=COLORS[i%COLORS.length];
|
| 162 |
-
return `<article class="track" style="--track-color:${col}" data-stem="${esc(name)}">
|
| 163 |
<div class="track-head"><div class="track-title"><span class="track-dot"></span><b title="${esc(stemTitle(name))}">${esc(meta?.label||stemTitle(name))}</b><button data-track-action="play" title="Stem einzeln hören">▶</button></div>
|
| 164 |
<div class="track-type">${esc(role(name,meta))} · STEM ${String(i+1).padStart(2,"0")}</div>
|
| 165 |
<div class="track-controls"><button class="toggle ${s.mute?"muted":""}" data-track-action="mute" aria-pressed="${!!s.mute}">M</button>
|
| 166 |
<button class="toggle ${s.solo?"soloed":""}" data-track-action="solo" aria-pressed="${!!s.solo}">S</button>
|
| 167 |
<input data-param="gain_db" type="range" min="-48" max="12" step=".5" value="${s.gain_db}" aria-label="Lautstärke ${esc(name)}"><output data-out="gain_db">${s.gain_db} dB</output></div>
|
| 168 |
</div>
|
| 169 |
-
<div class="track-middle"><div class="pan-head"><b>L</b><input data-param="pan" type="range" min="-1" max="1" step=".01" value="${s.pan}" aria-label="Stereo-Panorama ${esc(name)}"><b>R</b><output data-out="pan">${s.pan===0?"C":s.pan<0?"L"+Math.round(-s.pan*100):"R"+Math.round(s.pan*100)}</output></div>
|
|
|
|
| 170 |
<div class="fx-panel"><details><summary>⚙ FX ▾</summary><div class="fx-controls">
|
| 171 |
<label>LOW CUT <output data-out="highpass_hz">${s.highpass_hz||"Aus"}</output><input data-param="highpass_hz" type="range" min="0" max="400" step="5" value="${s.highpass_hz}"></label>
|
| 172 |
<label>HIGH CUT <output data-out="lowpass_hz">${s.lowpass_hz||"Aus"}</output><input data-param="lowpass_hz" type="range" min="0" max="18000" step="100" value="${s.lowpass_hz}"></label>
|
| 173 |
<label>SÄTTIGUNG <output data-out="drive">${Math.round(s.drive*100)} %</output><input data-param="drive" type="range" min="0" max="1" step=".01" value="${s.drive}"></label>
|
| 174 |
<label>STEREO-BREITE <output data-out="width">${Math.round(s.width*100)} %</output><input data-param="width" type="range" min="0" max="2" step=".02" value="${s.width}"></label>
|
| 175 |
-
<small>
|
| 176 |
</div></details></div></article>`;
|
| 177 |
}).join("");
|
| 178 |
redraw();
|
|
@@ -181,27 +185,39 @@
|
|
| 181 |
if(!canvas)return;
|
| 182 |
const width=canvas.clientWidth,height=canvas.clientHeight;
|
| 183 |
if(!width||!height)return;
|
| 184 |
-
const dpr=Math.min(2,window.devicePixelRatio||1);
|
| 185 |
-
|
|
|
|
|
|
|
|
|
|
| 186 |
if(baseline){ctx.strokeStyle="#294454";ctx.lineWidth=1;ctx.beginPath();ctx.moveTo(0,height/2);ctx.lineTo(width,height/2);ctx.stroke();
|
| 187 |
ctx.strokeStyle="#213647";for(let i=1;i<8;i++){const x=width*i/8;ctx.beginPath();ctx.moveTo(x,0);ctx.lineTo(x,height);ctx.stroke()}}
|
| 188 |
-
if(!data?.length)return;
|
|
|
|
| 189 |
ctx.globalAlpha=opacity;ctx.fillStyle=color;
|
| 190 |
-
for(let i=0;i<
|
| 191 |
const a=Math.max(.01,Math.min(1,Number(data[i])||0)),h=a*height*.46;
|
| 192 |
-
ctx.fillRect(Math.floor(
|
| 193 |
}ctx.globalAlpha=1;
|
| 194 |
}
|
| 195 |
function redraw(){
|
| 196 |
const master=$("masterCanvas"),original=S.peaks.original;
|
| 197 |
drawWave(master,original,"#5d889c",.45,true);
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
const
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
}
|
| 206 |
document.querySelectorAll("canvas[data-wave]").forEach(canvas=>{
|
| 207 |
const name=canvas.dataset.wave;const i=Object.keys(S.tracks).indexOf(name);
|
|
@@ -209,12 +225,224 @@
|
|
| 209 |
});
|
| 210 |
paintPlayhead();
|
| 211 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 212 |
function paintPlayhead(){
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
$("overviewPlay")
|
| 216 |
-
|
| 217 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 218 |
}
|
| 219 |
function renderPlan(){
|
| 220 |
const inv=new Map((S.project?.inventory?.detections||[]).map(x=>[x.id,x]));
|
|
@@ -262,17 +490,6 @@
|
|
| 262 |
["Render",m?.mixer?.result?.peak_dbfs!==undefined?m.mixer.result.peak_dbfs+" dBFS":"Nicht gerendert"]];
|
| 263 |
$("diagnostics").innerHTML=values.map(([k,v])=>`<div class="diag-row"><span>${esc(k)}</span><b>${esc(v)}</b></div>`).join("");
|
| 264 |
}
|
| 265 |
-
function player(name="original",kind="stem"){
|
| 266 |
-
requireSource();
|
| 267 |
-
let url,label;
|
| 268 |
-
if(kind==="mix"){url=`${ROOT}/projects/${q(S.id)}/mixer/audio`;label="Gerenderter Mix";}
|
| 269 |
-
else if(kind==="noise"){url=`${ROOT}/projects/${q(S.id)}/noise/audio/${q(name)}?preview=true`;label=`NOISE ${name}`;}
|
| 270 |
-
else{url=URLFor(name,true);label=name==="original"?"Original":stemTitle(name);}
|
| 271 |
-
if(S.audioTarget!==url){audio.src=url;S.audioTarget=url;}
|
| 272 |
-
$("nowPlaying").textContent=`Player: ${label} · Projekt ${S.project.name}`;
|
| 273 |
-
audio.play().catch(()=>note("Audio-Wiedergabe fehlgeschlagen. Bitte Dateien/Backend prüfen.",true));
|
| 274 |
-
$("playPause").textContent="Ⅱ";
|
| 275 |
-
}
|
| 276 |
async function jobWait(job,label){
|
| 277 |
S.busy=true;S.job=job;$("jobLamp").style.background="#ffd88b";lockButtons(true);
|
| 278 |
const currentId=S.id;
|
|
@@ -409,7 +626,7 @@
|
|
| 409 |
});
|
| 410 |
for(const id of ["newProject","importTop","importInPanel"])$(id).addEventListener("click",()=>$("fileInput").click());
|
| 411 |
$("fileInput").addEventListener("change",e=>importFile(e.target.files[0]));
|
| 412 |
-
$("emptyDemo").addEventListener("click",importDemo);
|
| 413 |
$("demoInPanel").addEventListener("click",importDemo);
|
| 414 |
$("renameProject").addEventListener("click",async ()=>{
|
| 415 |
if(!S.id)return;const name=prompt("Projekt umbenennen:",S.project.name);if(name===null)return;
|
|
@@ -434,19 +651,18 @@
|
|
| 434 |
document.querySelectorAll("[data-focus]").forEach(el=>el.addEventListener("click",()=>focusTool(el.dataset.focus)));
|
| 435 |
document.querySelectorAll("[data-tab]").forEach(b=>b.addEventListener("click",()=>showTab(b.dataset.tab)));
|
| 436 |
document.body.addEventListener("click",e=>{const btn=e.target.closest("[data-action]");if(btn)action(btn.dataset.action)});
|
| 437 |
-
$("listenOriginal").addEventListener("click",()=>{try{player()}catch(e){note(e.message,true)}});
|
| 438 |
$("playPause").addEventListener("click",()=>{
|
| 439 |
-
if(!
|
| 440 |
-
|
| 441 |
-
else audio.pause();
|
| 442 |
});
|
| 443 |
-
$("stop").addEventListener("click",()=>
|
| 444 |
-
audio.addEventListener("play",()=>$("playPause").textContent="Ⅱ");
|
| 445 |
-
audio.addEventListener("pause",()=>$("playPause").textContent="▶");
|
| 446 |
-
audio.addEventListener("timeupdate",paintPlayhead);
|
| 447 |
-
audio.addEventListener("loadedmetadata",paintPlayhead);
|
| 448 |
-
$("seek").addEventListener("input",e=>
|
| 449 |
-
$("masterCanvas").addEventListener("click",e=>{
|
| 450 |
$("trackList").addEventListener("click",e=>{
|
| 451 |
const row=e.target.closest("[data-stem]");if(!row)return;
|
| 452 |
const name=row.dataset.stem,btn=e.target.closest("[data-track-action]");
|
|
@@ -459,7 +675,7 @@
|
|
| 459 |
btn.setAttribute("aria-pressed",String(S.settings[name][action]));markDirty();return;
|
| 460 |
}
|
| 461 |
}
|
| 462 |
-
if(e.target.matches("canvas")){
|
| 463 |
});
|
| 464 |
$("trackList").addEventListener("input",e=>{
|
| 465 |
const input=e.target.closest("[data-param]");if(!input)return;
|
|
@@ -513,13 +729,8 @@
|
|
| 513 |
return !["range","checkbox","radio","button","submit","reset","color","file","image"].includes((el.type||"text").toLowerCase());};
|
| 514 |
const isSpace=e=>(e.code==="Space"||e.key===" ")&&!e.ctrlKey&&!e.metaKey&&!e.altKey;
|
| 515 |
const toggleSpace=()=>{
|
| 516 |
-
if(
|
| 517 |
-
|
| 518 |
-
if(!S.project?.asset){note("Zuerst Audiodatei importieren.",true);return}
|
| 519 |
-
try{player(S.project?.mixer&&!S.mixDirty?"mix":"original",S.project?.mixer&&!S.mixDirty?"mix":"stem")}catch(err){note(err.message,true)}
|
| 520 |
-
return;
|
| 521 |
-
}
|
| 522 |
-
audio.play().catch(()=>note("Wiedergabe fehlgeschlagen.",true));
|
| 523 |
};
|
| 524 |
window.addEventListener("keydown",e=>{
|
| 525 |
if(!isSpace(e)||typing(e.target)||typing(document.activeElement))return;
|
|
|
|
| 9 |
const esc=(s)=>String(s??"").replace(/[&<>"']/g,x=>({"&":"&","<":"<",">":">",'"':""","'":"'"}[x]));
|
| 10 |
const S={id:null,project:null,projects:[],tracks:{},settings:{},peaks:{},plan:[],modelReady:false,rubberband:false,virtualReady:false,busy:false,job:null,mixDirty:true,audioTarget:"original",tab:"workflow",generation:0};
|
| 11 |
const audio=$("player");
|
| 12 |
+
const Live={ctx:null,master:null,nodes:{},buffers:{},pending:{},sources:{},
|
| 13 |
+
playing:false,startedAt:0,offset:0,rate:1,duration:0,isolate:null,fileMode:false,raf:0};
|
| 14 |
const fmt=(n)=>{n=Math.max(0,Math.floor(Number(n)||0));return `${Math.floor(n/3600)?String(Math.floor(n/3600))+":":""}${String(Math.floor(n%3600/60)).padStart(2,"0")}:${String(n%60).padStart(2,"0")}`};
|
| 15 |
const stemTitle=(id)=>({harmonic:"Harmonik",percussive:"Percussion",residual:"Residual",vocals:"Gesang",drums:"Drums",bass:"Bass",other:"Instrumente",kick_core:"KICK · Bass-Core",bassline_core:"BASSLINE · Bass-Core",noise_difference:"NOISE · Stördifferenz"}[id]||id.replace(/_/g," ").replace(/[-]/g," "));
|
| 16 |
const role=(id,m)=>id==="noise_difference"?"FREIGEGEBENE DIFFERENZ":id.includes("kick")||id.includes("bassline")?"BASS · DSP-SCHÄTZUNG":m?.role==="base_compensated"?"BASIS · KOMPENSIERT":m?.role==="estimated_percussive"?"DSP-SCHÄTZUNG":m?.role||"AUDIO-STEM";
|
|
|
|
| 31 |
function setLink(id,url){const a=$(id);if(!a)return;if(url){a.href=url;a.removeAttribute("aria-disabled");a.classList.remove("link-disabled");}else{a.removeAttribute("href");a.setAttribute("aria-disabled","true");a.classList.add("link-disabled")}}
|
| 32 |
function requireSource(){if(!S.project?.asset)throw Error("Bitte zuerst eine Quelle importieren.")}
|
| 33 |
function markDirty(){
|
| 34 |
+
S.mixDirty=true;$("mixStatus").textContent="Live aktiv · Export nicht aktuell";
|
| 35 |
$("renderMix").disabled=!Object.keys(S.tracks).length||S.busy;
|
| 36 |
$("previewRender").disabled=true;setLink("downloadRender",null);setLink("exportMix",null);
|
| 37 |
+
applyLiveParams();
|
| 38 |
}
|
| 39 |
async function loadLibrary(){
|
| 40 |
const data=await req("/projects");
|
|
|
|
| 59 |
if(serial!==S.generation)return;
|
| 60 |
const different=S.id!==id;
|
| 61 |
S.id=id;S.project=manifest;S.plan=(manifest.plan||[]).map(x=>({...x}));
|
| 62 |
+
if(different){resetLive();S.peaks={};S.settings={};audio.pause();audio.removeAttribute("src");S.audioTarget="original";}
|
| 63 |
hideMobile();
|
| 64 |
const tracks=manifest.unified?.mix_consistent?manifest.unified.stems:(manifest.stems||{});
|
| 65 |
const names=Object.keys(tracks);
|
|
|
|
| 117 |
document.querySelectorAll(".needs-tracks").forEach(b=>b.disabled=!names.length||S.busy);
|
| 118 |
$("renderMix").disabled=!names.length||S.busy;
|
| 119 |
$("previewRender").disabled=S.mixDirty||!m?.mixer;
|
| 120 |
+
$("mixStatus").textContent=S.mixDirty?"Live aktiv · Export nicht aktuell":"Live aktiv · Export verfügbar";
|
| 121 |
+
for(const id of ["tempo","pitch"])$(id).disabled=false;
|
| 122 |
+
$("rubberbandInfo").textContent=S.rubberband
|
| 123 |
+
?"Live hörbar · MIX-Export mit Rubber Band":"Live-Tempo/Pitch im Player · Export-Pitch braucht Rubber Band";
|
| 124 |
$("virtualRun").disabled=!asset||!S.virtualReady||a.channels!==2||S.busy;
|
| 125 |
$("playClean").disabled=!m?.noise?.repair;
|
| 126 |
$("playDifference").disabled=!m?.noise?.repair;
|
|
|
|
| 162 |
<p>${S.project?.asset?"Starte Ω FUSION rechts: es erstellt Grundstems, Bass/Kick und scannt Störstellen in einem Durchlauf.":"Importiere eine Datei und bearbeite alle vorhandenen Stems in dieser gemeinsamen Ansicht."}</p><button class="btn btn-primary" data-action="${S.project?.asset?"fusion":"demo"}">${S.project?.asset?"Ω FUSION starten":"Demo laden"}</button></div>`;redraw();return}
|
| 163 |
$("trackList").innerHTML=entries.map(([name,meta],i)=>{
|
| 164 |
const s=S.settings[name]||defaultSettings(),col=COLORS[i%COLORS.length];
|
| 165 |
+
return `<article class="track ${s.mute?"is-muted":""} ${s.solo?"is-soloed":""}" style="--track-color:${col}" data-stem="${esc(name)}">
|
| 166 |
<div class="track-head"><div class="track-title"><span class="track-dot"></span><b title="${esc(stemTitle(name))}">${esc(meta?.label||stemTitle(name))}</b><button data-track-action="play" title="Stem einzeln hören">▶</button></div>
|
| 167 |
<div class="track-type">${esc(role(name,meta))} · STEM ${String(i+1).padStart(2,"0")}</div>
|
| 168 |
<div class="track-controls"><button class="toggle ${s.mute?"muted":""}" data-track-action="mute" aria-pressed="${!!s.mute}">M</button>
|
| 169 |
<button class="toggle ${s.solo?"soloed":""}" data-track-action="solo" aria-pressed="${!!s.solo}">S</button>
|
| 170 |
<input data-param="gain_db" type="range" min="-48" max="12" step=".5" value="${s.gain_db}" aria-label="Lautstärke ${esc(name)}"><output data-out="gain_db">${s.gain_db} dB</output></div>
|
| 171 |
</div>
|
| 172 |
+
<div class="track-middle"><div class="pan-head"><b>L</b><input data-param="pan" type="range" min="-1" max="1" step=".01" value="${s.pan}" aria-label="Stereo-Panorama ${esc(name)}"><b>R</b><output data-out="pan">${s.pan===0?"C":s.pan<0?"L"+Math.round(-s.pan*100):"R"+Math.round(s.pan*100)}</output></div>
|
| 173 |
+
<div class="track-wave"><canvas class="track-canvas" data-wave="${esc(name)}" height="80" aria-label="Wellenform ${esc(name)}"></canvas><div class="play-line track-play"></div></div></div>
|
| 174 |
<div class="fx-panel"><details><summary>⚙ FX ▾</summary><div class="fx-controls">
|
| 175 |
<label>LOW CUT <output data-out="highpass_hz">${s.highpass_hz||"Aus"}</output><input data-param="highpass_hz" type="range" min="0" max="400" step="5" value="${s.highpass_hz}"></label>
|
| 176 |
<label>HIGH CUT <output data-out="lowpass_hz">${s.lowpass_hz||"Aus"}</output><input data-param="lowpass_hz" type="range" min="0" max="18000" step="100" value="${s.lowpass_hz}"></label>
|
| 177 |
<label>SÄTTIGUNG <output data-out="drive">${Math.round(s.drive*100)} %</output><input data-param="drive" type="range" min="0" max="1" step=".01" value="${s.drive}"></label>
|
| 178 |
<label>STEREO-BREITE <output data-out="width">${Math.round(s.width*100)} %</output><input data-param="width" type="range" min="0" max="2" step=".02" value="${s.width}"></label>
|
| 179 |
+
<small>Low/High Cut, Sättigung, Solo, Mute, Pegel und Pan sind live. Stereo-Breite sitzt im MIX-Export.</small>
|
| 180 |
</div></details></div></article>`;
|
| 181 |
}).join("");
|
| 182 |
redraw();
|
|
|
|
| 185 |
if(!canvas)return;
|
| 186 |
const width=canvas.clientWidth,height=canvas.clientHeight;
|
| 187 |
if(!width||!height)return;
|
| 188 |
+
const dpr=Math.min(2,window.devicePixelRatio||1);
|
| 189 |
+
canvas.width=Math.round(width*dpr);canvas.height=Math.round(height*dpr);
|
| 190 |
+
const ctx=canvas.getContext("2d");
|
| 191 |
+
ctx.setTransform(dpr,0,0,dpr,0,0);
|
| 192 |
+
ctx.clearRect(0,0,width,height);
|
| 193 |
if(baseline){ctx.strokeStyle="#294454";ctx.lineWidth=1;ctx.beginPath();ctx.moveTo(0,height/2);ctx.lineTo(width,height/2);ctx.stroke();
|
| 194 |
ctx.strokeStyle="#213647";for(let i=1;i<8;i++){const x=width*i/8;ctx.beginPath();ctx.moveTo(x,0);ctx.lineTo(x,height);ctx.stroke()}}
|
| 195 |
+
if(!data?.length)return;
|
| 196 |
+
const n=data.length,bar=width/n;
|
| 197 |
ctx.globalAlpha=opacity;ctx.fillStyle=color;
|
| 198 |
+
for(let i=0;i<n;i++){
|
| 199 |
const a=Math.max(.01,Math.min(1,Number(data[i])||0)),h=a*height*.46;
|
| 200 |
+
ctx.fillRect(Math.floor(i*bar),height/2-h,Math.max(1,Math.ceil(bar*.72)),2*h);
|
| 201 |
}ctx.globalAlpha=1;
|
| 202 |
}
|
| 203 |
function redraw(){
|
| 204 |
const master=$("masterCanvas"),original=S.peaks.original;
|
| 205 |
drawWave(master,original,"#5d889c",.45,true);
|
| 206 |
+
if(master){
|
| 207 |
+
const ctx=master.getContext("2d"),w=master.clientWidth,h=master.clientHeight;
|
| 208 |
+
const dpr=Math.min(2,window.devicePixelRatio||1);
|
| 209 |
+
ctx.setTransform(dpr,0,0,dpr,0,0);
|
| 210 |
+
let index=0;for(const name of Object.keys(S.tracks)){
|
| 211 |
+
const samples=S.peaks[name];if(!samples?.length)continue;
|
| 212 |
+
const n=samples.length,bar=w/n;
|
| 213 |
+
ctx.globalAlpha=.55;ctx.fillStyle=COLORS[index%COLORS.length];
|
| 214 |
+
for(let i=0;i<n;i++){
|
| 215 |
+
const amplitude=Math.min(1,samples[i])*h*.40;
|
| 216 |
+
ctx.fillRect(Math.floor(i*bar),h/2-amplitude,Math.max(1,Math.ceil(bar*.58)),amplitude*2);
|
| 217 |
+
}
|
| 218 |
+
index++;
|
| 219 |
+
}
|
| 220 |
+
ctx.globalAlpha=1;
|
| 221 |
}
|
| 222 |
document.querySelectorAll("canvas[data-wave]").forEach(canvas=>{
|
| 223 |
const name=canvas.dataset.wave;const i=Object.keys(S.tracks).indexOf(name);
|
|
|
|
| 225 |
});
|
| 226 |
paintPlayhead();
|
| 227 |
}
|
| 228 |
+
function liveRate(){
|
| 229 |
+
const tempo=Math.max(50,Math.min(200,Number($("tempo")?.value)||100))/100;
|
| 230 |
+
const pitch=Math.max(-12,Math.min(12,Number($("pitch")?.value)||0));
|
| 231 |
+
return Math.max(0.25,Math.min(4,tempo*Math.pow(2,pitch/12)));
|
| 232 |
+
}
|
| 233 |
+
function durationSec(){
|
| 234 |
+
if(Live.duration>0)return Live.duration;
|
| 235 |
+
const a=Number(S.project?.analysis?.duration_seconds);
|
| 236 |
+
if(a>0)return a;
|
| 237 |
+
if(Number.isFinite(audio.duration)&&audio.duration>0)return audio.duration;
|
| 238 |
+
return 1;
|
| 239 |
+
}
|
| 240 |
+
function nowTime(){
|
| 241 |
+
if(Live.playing&&Live.ctx&&!Live.fileMode)
|
| 242 |
+
return Math.min(durationSec(),Math.max(0,Live.offset+(Live.ctx.currentTime-Live.startedAt)*Live.rate));
|
| 243 |
+
if(Live.fileMode&&audio.src&&Number.isFinite(audio.currentTime))return audio.currentTime;
|
| 244 |
+
return Live.offset||0;
|
| 245 |
+
}
|
| 246 |
function paintPlayhead(){
|
| 247 |
+
const d=durationSec(),t=nowTime(),fraction=Math.min(1,Math.max(0,t/d));
|
| 248 |
+
const pct=(fraction*100).toFixed(4)+"%";
|
| 249 |
+
const line=$("overviewPlay");
|
| 250 |
+
if(line){line.style.left=pct;line.style.transform="translateX(-50%)"}
|
| 251 |
+
document.querySelectorAll(".track-play").forEach(el=>{el.style.left=pct;el.style.transform="translateX(-50%)"});
|
| 252 |
+
const seek=$("seek");if(seek)seek.value=Math.round(fraction*1000);
|
| 253 |
+
const clock=$("clock");if(clock)clock.textContent=`${fmt(t)} / ${fmt(d)}`;
|
| 254 |
+
if(Live.playing&&!Live.fileMode){
|
| 255 |
+
if(t>=d-0.03){stopLive(true);return}
|
| 256 |
+
Live.raf=requestAnimationFrame(paintPlayhead);
|
| 257 |
+
}
|
| 258 |
+
}
|
| 259 |
+
function resetLive(){
|
| 260 |
+
stopLive(true);
|
| 261 |
+
Live.nodes={};Live.buffers={};Live.pending={};Live.sources={};Live.duration=0;Live.isolate=null;
|
| 262 |
+
}
|
| 263 |
+
function ensureCtx(){
|
| 264 |
+
if(!Live.ctx){
|
| 265 |
+
const AC=window.AudioContext||window.webkitAudioContext;
|
| 266 |
+
if(!AC)throw Error("Web Audio nicht verfügbar");
|
| 267 |
+
Live.ctx=new AC();
|
| 268 |
+
Live.master=Live.ctx.createGain();
|
| 269 |
+
Live.master.connect(Live.ctx.destination);
|
| 270 |
+
}
|
| 271 |
+
return Live.ctx.resume();
|
| 272 |
+
}
|
| 273 |
+
function driveCurve(amount){
|
| 274 |
+
const n=2048,curve=new Float32Array(n),k=1+Math.max(0,amount)*6;
|
| 275 |
+
for(let i=0;i<n;i++){const x=i*2/n-1;curve[i]=Math.tanh(x*k)/Math.tanh(k)}
|
| 276 |
+
return curve;
|
| 277 |
+
}
|
| 278 |
+
function chainFor(name){
|
| 279 |
+
if(Live.nodes[name])return Live.nodes[name];
|
| 280 |
+
const ctx=Live.ctx;
|
| 281 |
+
const hp=ctx.createBiquadFilter();hp.type="highpass";hp.frequency.value=20;
|
| 282 |
+
const lp=ctx.createBiquadFilter();lp.type="lowpass";lp.frequency.value=Math.max(1000,ctx.sampleRate/2-80);
|
| 283 |
+
const shaper=ctx.createWaveShaper();shaper.oversample="2x";
|
| 284 |
+
const pan=ctx.createStereoPanner();
|
| 285 |
+
const gain=ctx.createGain();
|
| 286 |
+
hp.connect(lp);lp.connect(shaper);shaper.connect(pan);pan.connect(gain);gain.connect(Live.master);
|
| 287 |
+
Live.nodes[name]={hp,lp,shaper,pan,gain};
|
| 288 |
+
return Live.nodes[name];
|
| 289 |
+
}
|
| 290 |
+
function audibleGain(name){
|
| 291 |
+
const s=S.settings[name]||defaultSettings();
|
| 292 |
+
const names=Object.keys(S.tracks);
|
| 293 |
+
if(Live.isolate)return name===Live.isolate&&!s.mute?Math.pow(10,Number(s.gain_db||0)/20):0;
|
| 294 |
+
const anySolo=names.some(n=>(S.settings[n]||{}).solo);
|
| 295 |
+
if(s.mute||(anySolo&&!s.solo))return 0;
|
| 296 |
+
return Math.pow(10,Number(s.gain_db||0)/20);
|
| 297 |
+
}
|
| 298 |
+
function applyLiveParams(){
|
| 299 |
+
if(!Live.ctx){
|
| 300 |
+
document.querySelectorAll(".track[data-stem]").forEach(row=>{
|
| 301 |
+
const name=row.dataset.stem,s=S.settings[name]||defaultSettings();
|
| 302 |
+
const names=Object.keys(S.tracks),anySolo=names.some(n=>(S.settings[n]||{}).solo);
|
| 303 |
+
row.classList.toggle("is-muted",!!s.mute||(anySolo&&!s.solo));
|
| 304 |
+
row.classList.toggle("is-soloed",!!s.solo);
|
| 305 |
+
});
|
| 306 |
+
const pill=$("livePill");if(pill)pill.classList.toggle("is-playing",false);
|
| 307 |
+
return;
|
| 308 |
+
}
|
| 309 |
+
const nyquist=Math.max(1000,Live.ctx.sampleRate/2-80);
|
| 310 |
+
for(const name of Object.keys(S.tracks)){
|
| 311 |
+
const s=S.settings[name]||defaultSettings();
|
| 312 |
+
const n=Live.nodes[name];if(!n)continue;
|
| 313 |
+
const now=Live.ctx.currentTime;
|
| 314 |
+
n.gain.gain.setTargetAtTime(audibleGain(name),now,0.02);
|
| 315 |
+
n.pan.pan.setTargetAtTime(Math.max(-1,Math.min(1,Number(s.pan)||0)),now,0.02);
|
| 316 |
+
n.hp.frequency.value=s.highpass_hz>0?Number(s.highpass_hz):20;
|
| 317 |
+
n.lp.frequency.value=s.lowpass_hz>0?Number(s.lowpass_hz):nyquist;
|
| 318 |
+
n.shaper.curve=s.drive>0.01?driveCurve(Number(s.drive)):null;
|
| 319 |
+
}
|
| 320 |
+
if(Live.playing&&!Live.fileMode){
|
| 321 |
+
const next=liveRate();
|
| 322 |
+
if(Math.abs(next-Live.rate)>1e-4){
|
| 323 |
+
Live.offset=nowTime();Live.startedAt=Live.ctx.currentTime;Live.rate=next;
|
| 324 |
+
}
|
| 325 |
+
Object.values(Live.sources).forEach(src=>{try{src.playbackRate.value=Live.rate}catch(_){}});
|
| 326 |
+
}
|
| 327 |
+
document.querySelectorAll(".track[data-stem]").forEach(row=>{
|
| 328 |
+
const name=row.dataset.stem,s=S.settings[name]||defaultSettings();
|
| 329 |
+
const names=Object.keys(S.tracks),anySolo=names.some(n=>(S.settings[n]||{}).solo);
|
| 330 |
+
row.classList.toggle("is-muted",!!s.mute||(anySolo&&!s.solo));
|
| 331 |
+
row.classList.toggle("is-soloed",!!s.solo);
|
| 332 |
+
});
|
| 333 |
+
const pill=$("livePill");if(pill)pill.classList.toggle("is-playing",!!Live.playing&&!Live.fileMode);
|
| 334 |
+
if($("monitorState")&&S.project?.asset)$("monitorState").textContent=Live.playing?"LIVE PLAY":"SOURCE READY";
|
| 335 |
+
}
|
| 336 |
+
async function decodeStem(name){
|
| 337 |
+
const url=URLFor(name==="__original__"?"original":name,true);
|
| 338 |
+
if(Live.buffers[url])return Live.buffers[url];
|
| 339 |
+
if(Live.pending[url])return Live.pending[url];
|
| 340 |
+
Live.pending[url]=(async()=>{
|
| 341 |
+
const r=await fetch(url);if(!r.ok)throw Error("Spur nicht ladbar: "+name);
|
| 342 |
+
const raw=await r.arrayBuffer();
|
| 343 |
+
const buf=await Live.ctx.decodeAudioData(raw.slice(0));
|
| 344 |
+
Live.buffers[url]=buf;return buf;
|
| 345 |
+
})();
|
| 346 |
+
try{return await Live.pending[url]}finally{delete Live.pending[url]}
|
| 347 |
+
}
|
| 348 |
+
function stopSources(){
|
| 349 |
+
for(const src of Object.values(Live.sources)){try{src.onended=null;src.stop()}catch(_){}}
|
| 350 |
+
Live.sources={};
|
| 351 |
+
}
|
| 352 |
+
function stopLive(reset){
|
| 353 |
+
if(Live.raf){cancelAnimationFrame(Live.raf);Live.raf=0}
|
| 354 |
+
const t=nowTime();
|
| 355 |
+
Live.playing=false;
|
| 356 |
+
stopSources();
|
| 357 |
+
if(reset)Live.offset=0;else Live.offset=t;
|
| 358 |
+
audio.pause();
|
| 359 |
+
Live.fileMode=false;
|
| 360 |
+
const btn=$("playPause");if(btn)btn.textContent="▶";
|
| 361 |
+
applyLiveParams();
|
| 362 |
+
paintPlayhead();
|
| 363 |
+
}
|
| 364 |
+
function startSources(offset){
|
| 365 |
+
stopSources();
|
| 366 |
+
const names=Live.isolate?[Live.isolate]:(Object.keys(S.tracks).length?Object.keys(S.tracks):["__original__"]);
|
| 367 |
+
const ctx=Live.ctx;
|
| 368 |
+
Live.rate=liveRate();
|
| 369 |
+
Live.startedAt=ctx.currentTime;
|
| 370 |
+
Live.offset=Math.max(0,offset||0);
|
| 371 |
+
let maxDur=0;
|
| 372 |
+
for(const name of names){
|
| 373 |
+
const buf=Live.buffers[URLFor(name==="__original__"?"original":name,true)];
|
| 374 |
+
if(!buf)continue;
|
| 375 |
+
maxDur=Math.max(maxDur,buf.duration);
|
| 376 |
+
const src=ctx.createBufferSource();
|
| 377 |
+
src.buffer=buf;
|
| 378 |
+
src.playbackRate.value=Live.rate;
|
| 379 |
+
if(name==="__original__"){
|
| 380 |
+
if(!Live.nodes.__original__){
|
| 381 |
+
const g=ctx.createGain();g.connect(Live.master);Live.nodes.__original__={gain:g};
|
| 382 |
+
}
|
| 383 |
+
src.connect(Live.nodes.__original__.gain);
|
| 384 |
+
}else{
|
| 385 |
+
src.connect(chainFor(name).hp);
|
| 386 |
+
}
|
| 387 |
+
const off=Math.min(Math.max(0,Live.offset),Math.max(0,buf.duration-0.01));
|
| 388 |
+
if(off>=buf.duration)continue;
|
| 389 |
+
src.start(ctx.currentTime,off);
|
| 390 |
+
Live.sources[name]=src;
|
| 391 |
+
}
|
| 392 |
+
Live.duration=maxDur||durationSec();
|
| 393 |
+
applyLiveParams();
|
| 394 |
+
}
|
| 395 |
+
async function startTransport(offset){
|
| 396 |
+
requireSource();
|
| 397 |
+
await ensureCtx();
|
| 398 |
+
Live.fileMode=false;
|
| 399 |
+
audio.pause();
|
| 400 |
+
const want=Live.isolate?[Live.isolate]:(Object.keys(S.tracks).length?Object.keys(S.tracks):["__original__"]);
|
| 401 |
+
$("nowPlaying").textContent=Live.isolate?`Live · ${stemTitle(Live.isolate)}`:`Live-Mixer · ${S.project.name}`;
|
| 402 |
+
const loaded=await Promise.all(want.map(async n=>{
|
| 403 |
+
try{await decodeStem(n==="__original__"?"__original__":n);return n}
|
| 404 |
+
catch(_){return null}
|
| 405 |
+
}));
|
| 406 |
+
if(!loaded.some(Boolean))throw Error("Keine hörbare Spur geladen.");
|
| 407 |
+
startSources(offset??Live.offset);
|
| 408 |
+
Live.playing=true;
|
| 409 |
+
$("playPause").textContent="Ⅱ";
|
| 410 |
+
applyLiveParams();
|
| 411 |
+
paintPlayhead();
|
| 412 |
+
}
|
| 413 |
+
function seekTransport(t){
|
| 414 |
+
const pos=Math.min(durationSec(),Math.max(0,t));
|
| 415 |
+
if(Live.fileMode){if(audio.src)audio.currentTime=pos;paintPlayhead();return}
|
| 416 |
+
Live.offset=pos;
|
| 417 |
+
if(Live.playing)startSources(pos);
|
| 418 |
+
else paintPlayhead();
|
| 419 |
+
}
|
| 420 |
+
function toggleTransport(){
|
| 421 |
+
if(Live.fileMode){
|
| 422 |
+
if(!audio.src){startTransport(0).catch(e=>note(e.message,true));return}
|
| 423 |
+
if(audio.paused)audio.play().catch(()=>note("Wiedergabe fehlgeschlagen.",true));
|
| 424 |
+
else audio.pause();
|
| 425 |
+
return;
|
| 426 |
+
}
|
| 427 |
+
if(Live.playing){stopLive(false);return}
|
| 428 |
+
startTransport(Live.offset).catch(e=>note(e.message,true));
|
| 429 |
+
}
|
| 430 |
+
function player(name="original",kind="stem"){
|
| 431 |
+
requireSource();
|
| 432 |
+
if(kind==="mix"||kind==="noise"){
|
| 433 |
+
stopLive(false);
|
| 434 |
+
Live.fileMode=true;Live.playing=false;
|
| 435 |
+
let url,label;
|
| 436 |
+
if(kind==="mix"){url=`${ROOT}/projects/${q(S.id)}/mixer/audio`;label="Mix-Export";}
|
| 437 |
+
else{url=`${ROOT}/projects/${q(S.id)}/noise/audio/${q(name)}?preview=true`;label=`NOISE ${name}`;}
|
| 438 |
+
if(S.audioTarget!==url){audio.src=url;S.audioTarget=url;}
|
| 439 |
+
$("nowPlaying").textContent=`Player: ${label} · Projekt ${S.project.name}`;
|
| 440 |
+
audio.play().catch(()=>note("Audio-Wiedergabe fehlgeschlagen. Bitte Dateien/Backend prüfen.",true));
|
| 441 |
+
$("playPause").textContent="Ⅱ";
|
| 442 |
+
return;
|
| 443 |
+
}
|
| 444 |
+
Live.isolate=(name&&name!=="original")?name:null;
|
| 445 |
+
startTransport(Live.offset).catch(e=>note(e.message,true));
|
| 446 |
}
|
| 447 |
function renderPlan(){
|
| 448 |
const inv=new Map((S.project?.inventory?.detections||[]).map(x=>[x.id,x]));
|
|
|
|
| 490 |
["Render",m?.mixer?.result?.peak_dbfs!==undefined?m.mixer.result.peak_dbfs+" dBFS":"Nicht gerendert"]];
|
| 491 |
$("diagnostics").innerHTML=values.map(([k,v])=>`<div class="diag-row"><span>${esc(k)}</span><b>${esc(v)}</b></div>`).join("");
|
| 492 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 493 |
async function jobWait(job,label){
|
| 494 |
S.busy=true;S.job=job;$("jobLamp").style.background="#ffd88b";lockButtons(true);
|
| 495 |
const currentId=S.id;
|
|
|
|
| 626 |
});
|
| 627 |
for(const id of ["newProject","importTop","importInPanel"])$(id).addEventListener("click",()=>$("fileInput").click());
|
| 628 |
$("fileInput").addEventListener("change",e=>importFile(e.target.files[0]));
|
| 629 |
+
const emptyDemo=$("emptyDemo");if(emptyDemo)emptyDemo.addEventListener("click",importDemo);
|
| 630 |
$("demoInPanel").addEventListener("click",importDemo);
|
| 631 |
$("renameProject").addEventListener("click",async ()=>{
|
| 632 |
if(!S.id)return;const name=prompt("Projekt umbenennen:",S.project.name);if(name===null)return;
|
|
|
|
| 651 |
document.querySelectorAll("[data-focus]").forEach(el=>el.addEventListener("click",()=>focusTool(el.dataset.focus)));
|
| 652 |
document.querySelectorAll("[data-tab]").forEach(b=>b.addEventListener("click",()=>showTab(b.dataset.tab)));
|
| 653 |
document.body.addEventListener("click",e=>{const btn=e.target.closest("[data-action]");if(btn)action(btn.dataset.action)});
|
| 654 |
+
$("listenOriginal").addEventListener("click",()=>{try{Live.isolate=null;player()}catch(e){note(e.message,true)}});
|
| 655 |
$("playPause").addEventListener("click",()=>{
|
| 656 |
+
if(!S.project?.asset){note("Zuerst Audiodatei importieren.",true);return}
|
| 657 |
+
toggleTransport();
|
|
|
|
| 658 |
});
|
| 659 |
+
$("stop").addEventListener("click",()=>stopLive(true));
|
| 660 |
+
audio.addEventListener("play",()=>{if(Live.fileMode)$("playPause").textContent="Ⅱ"});
|
| 661 |
+
audio.addEventListener("pause",()=>{if(Live.fileMode)$("playPause").textContent="▶"});
|
| 662 |
+
audio.addEventListener("timeupdate",()=>{if(Live.fileMode)paintPlayhead()});
|
| 663 |
+
audio.addEventListener("loadedmetadata",()=>{if(Live.fileMode)paintPlayhead()});
|
| 664 |
+
$("seek").addEventListener("input",e=>seekTransport(e.target.value/1000*durationSec()));
|
| 665 |
+
$("masterCanvas").addEventListener("click",e=>{const r=e.currentTarget.getBoundingClientRect();seekTransport(Math.min(1,Math.max(0,(e.clientX-r.left)/r.width))*durationSec())});
|
| 666 |
$("trackList").addEventListener("click",e=>{
|
| 667 |
const row=e.target.closest("[data-stem]");if(!row)return;
|
| 668 |
const name=row.dataset.stem,btn=e.target.closest("[data-track-action]");
|
|
|
|
| 675 |
btn.setAttribute("aria-pressed",String(S.settings[name][action]));markDirty();return;
|
| 676 |
}
|
| 677 |
}
|
| 678 |
+
if(e.target.matches("canvas")){const r=e.target.getBoundingClientRect();seekTransport(Math.min(1,Math.max(0,(e.clientX-r.left)/r.width))*durationSec())}
|
| 679 |
});
|
| 680 |
$("trackList").addEventListener("input",e=>{
|
| 681 |
const input=e.target.closest("[data-param]");if(!input)return;
|
|
|
|
| 729 |
return !["range","checkbox","radio","button","submit","reset","color","file","image"].includes((el.type||"text").toLowerCase());};
|
| 730 |
const isSpace=e=>(e.code==="Space"||e.key===" ")&&!e.ctrlKey&&!e.metaKey&&!e.altKey;
|
| 731 |
const toggleSpace=()=>{
|
| 732 |
+
if(!S.project?.asset){note("Zuerst Audiodatei importieren.",true);return}
|
| 733 |
+
toggleTransport();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 734 |
};
|
| 735 |
window.addEventListener("keydown",e=>{
|
| 736 |
if(!isSpace(e)||typing(e.target)||typing(document.activeElement))return;
|
tests/test_arrangement.py
CHANGED
|
@@ -65,6 +65,18 @@ def test_sparse_waveform_is_file_derived(tmp_path):
|
|
| 65 |
assert w["peak_reliability"].startswith("visualization")
|
| 66 |
|
| 67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
def test_synthetic_mini_model_is_bundled(tmp_path):
|
| 69 |
assert MODEL_FILE.is_file()
|
| 70 |
paths,a,b=make_stems(tmp_path)
|
|
|
|
| 65 |
assert w["peak_reliability"].startswith("visualization")
|
| 66 |
|
| 67 |
|
| 68 |
+
def test_waveform_bins_follow_time(tmp_path):
|
| 69 |
+
sr=8000
|
| 70 |
+
x=np.zeros((sr*2,2),np.float32)
|
| 71 |
+
x[sr:sr+400]=0.5
|
| 72 |
+
path=tmp_path/"delay.wav"
|
| 73 |
+
sf.write(path,x,sr,subtype="FLOAT")
|
| 74 |
+
w=sampled_peaks(path,8)
|
| 75 |
+
assert max(w["samples"][:3])<0.05
|
| 76 |
+
assert max(w["samples"][4:])>0.2
|
| 77 |
+
assert w["sample_method"]=="uniform_bins_maxabs"
|
| 78 |
+
|
| 79 |
+
|
| 80 |
def test_synthetic_mini_model_is_bundled(tmp_path):
|
| 81 |
assert MODEL_FILE.is_file()
|
| 82 |
paths,a,b=make_stems(tmp_path)
|
tests/test_photoreal_studio.py
CHANGED
|
@@ -34,3 +34,21 @@ def test_ui_script_has_real_handlers_and_no_remote_calls(tmp_path):
|
|
| 34 |
assert '"libraryClose"' in script
|
| 35 |
assert "data-action" in script
|
| 36 |
assert "https://" not in script and "http://" not in script
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
assert '"libraryClose"' in script
|
| 35 |
assert "data-action" in script
|
| 36 |
assert "https://" not in script and "http://" not in script
|
| 37 |
+
for live in ("applyLiveParams", "toggleTransport", "nowTime", "startTransport", "seekTransport"):
|
| 38 |
+
assert f"function {live}(" in script or f"async function {live}(" in script
|
| 39 |
+
assert "AudioContext" in script
|
| 40 |
+
assert "setTransform" in script
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def test_mix_dock_sits_under_tracks_and_waveform_is_aligned(tmp_path):
|
| 44 |
+
with TestClient(create_app(tmp_path / "data")) as client:
|
| 45 |
+
home = client.get("/").text
|
| 46 |
+
assert 'id="mixDock"' in home
|
| 47 |
+
assert 'id="livePill"' in home
|
| 48 |
+
assert home.index('id="trackList"') < home.index('id="mixDock"')
|
| 49 |
+
assert home.index('id="mixDock"') < home.index('id="renderMix"')
|
| 50 |
+
heading = home.split('id="tracksSection"')[1].split('id="trackList"')[0]
|
| 51 |
+
assert "renderMix" not in heading
|
| 52 |
+
css = client.get("/static/studio-v1.css").text
|
| 53 |
+
assert ".mix-dock" in css
|
| 54 |
+
assert "translateX(-50%)" in css
|