diff --git a/.github/workflows/dsp.yml b/.github/workflows/dsp.yml index a3a7da6..51b8744 100644 --- a/.github/workflows/dsp.yml +++ b/.github/workflows/dsp.yml @@ -4,6 +4,7 @@ on: paths: - "Source/DSP/**" - "WebUI/**" + - "ConsoleUI/**" - "tests/**" - "CMakeLists.txt" - ".github/workflows/dsp.yml" @@ -29,6 +30,24 @@ jobs: run: | node --check WebUI/app.js node WebUI/smoke.test.cjs + - name: Console EQ syntax and native ACK/readback contract + run: | + node --check ConsoleUI/app.js + node --check ConsoleUI/smoke.test.cjs + node ConsoleUI/smoke.test.cjs + - name: Capture console EQ design preview 900x540 and 720x460 + shell: bash + run: | + CHROME=$(command -v google-chrome || command -v chromium || true) + if [[ -z "$CHROME" ]]; then + echo "Chromium unavailable; no visual artifact" + exit 0 + fi + mkdir -p visual-qa + "$CHROME" --headless --no-sandbox --disable-gpu --hide-scrollbars --virtual-time-budget=1500 --window-size=900,540 --screenshot="$PWD/visual-qa/ArSonMix-ConsoleEQ-900x540.png" "file://$PWD/ConsoleUI/index.html?designPreview=1" + "$CHROME" --headless --no-sandbox --disable-gpu --hide-scrollbars --virtual-time-budget=1500 --window-size=720,460 --screenshot="$PWD/visual-qa/ArSonMix-ConsoleEQ-720x460.png" "file://$PWD/ConsoleUI/index.html?designPreview=1" + test -s visual-qa/ArSonMix-ConsoleEQ-900x540.png + test -s visual-qa/ArSonMix-ConsoleEQ-720x460.png - name: Capture 900x535 editor visual QA (no JUCE build) shell: bash run: | @@ -48,3 +67,11 @@ jobs: path: visual-qa/ArSonEQ-M3-1-900x535.png if-no-files-found: warn retention-days: 7 + + - name: Upload isolated Console EQ visuals + uses: actions/upload-artifact@v4 + with: + name: ArSonMix-Console-EQ-Design-Candidate + path: visual-qa/ArSonMix-ConsoleEQ-*.png + if-no-files-found: warn + retention-days: 7 diff --git a/.github/workflows/vst3-windows.yml b/.github/workflows/vst3-windows.yml index 7f1e0ad..f9bac84 100644 --- a/.github/workflows/vst3-windows.yml +++ b/.github/workflows/vst3-windows.yml @@ -35,8 +35,8 @@ jobs: shell: pwsh run: cmake -S . -B build-vst -DARSONEQ_BUILD_PLUGIN=ON -DARSONEQ_BUILD_TESTS=ON "-DJUCE_WEBVIEW2_PACKAGE_LOCATION=$env:RUNNER_TEMP/arsoneq-nuget" - name: Build BOTH Windows Release formats + native tests - run: cmake --build build-vst --config Release --target ArSonEQ_VST3 ArSonEQ_Standalone arson_eq_core_tests arson_eq_rt_tests arson_eq_analyzer_tests --parallel 2 - - name: Run 3 native DSP suites + run: cmake --build build-vst --config Release --target ArSonEQ_VST3 ArSonEQ_Standalone arson_eq_core_tests arson_eq_rt_tests arson_eq_console_tests arson_eq_analyzer_tests --parallel 2 + - name: Run 4 native DSP suites run: ctest --test-dir build-vst -C Release --output-on-failure - name: Package verified VST3 and Standalone EXE together shell: pwsh diff --git a/CMakeLists.txt b/CMakeLists.txt index d66ddc9..afff03e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,6 +24,9 @@ if(ARSONEQ_BUILD_TESTS) add_executable(arson_eq_rt_tests tests/eq_rt_tests.cpp) target_link_libraries(arson_eq_rt_tests PRIVATE arson_eq_dsp) add_test(NAME arson_eq_rt COMMAND arson_eq_rt_tests) + add_executable(arson_eq_console_tests tests/eq_console_tests.cpp) + target_link_libraries(arson_eq_console_tests PRIVATE arson_eq_dsp) + add_test(NAME arson_eq_console COMMAND arson_eq_console_tests) find_package(Threads REQUIRED) add_executable(arson_eq_analyzer_tests tests/eq_analyzer_tests.cpp) target_link_libraries(arson_eq_analyzer_tests PRIVATE arson_eq_dsp Threads::Threads) diff --git a/ConsoleUI/app.js b/ConsoleUI/app.js new file mode 100644 index 0000000..77de313 --- /dev/null +++ b/ConsoleUI/app.js @@ -0,0 +1,332 @@ +/* ArSonMix Console EQ GUI: display/control layer only. No audio, AudioContext, + * FFT, WebAudio, VST host, device access, or network. The browser may calculate + * a sample response only in explicit ?designPreview=1 fixture mode. A native + * host MUST deliver both accepted bands and native calculated curveDb[]. + */ +(() => { +'use strict'; +const $=id=>document.getElementById(id); +const KEY=[ + ['HPF','HIGH PASS',80,'#6ec7dc','LowCut'], + ['LS','LOW SHELF',160,'#87b7e5','LowShelf'], + ['1','BELL 1',250,'#78d2b1','Bell'], + ['2','BELL 2',500,'#d2bb84','Bell'], + ['3','BELL 3',1200,'#8caae9','Bell'], + ['4','BELL 4',3200,'#dfad82','Bell'], + ['5','BELL 5',7500,'#c9a5de','Bell'], + ['HS','HIGH SHELF',10000,'#8dc9c9','HighShelf'], + ['LPF','LOW PASS',18000,'#e1b58d','HighCut'] +]; +const N=9,pi=Math.PI,F0=20,F1=20000,GMAX=18,STEPS=257; +const canvas=$('eqPlot'),ctx=canvas.getContext('2d',{alpha:false}); +const rail=$('filterRail'); +const designPreview=new URLSearchParams(location.search).has('designPreview'); +const clamp=(x,a,b)=>Math.min(b,Math.max(a,x)); +const defaults=()=>KEY.map((k,i)=>({enabled:false,frequencyHz:k[2],gainDb:0,q:.7071067811865476,slopeDbPerOct:24})); +const isCut=i=>i===0||i===8; +const state={mode:designPreview?'design':'offline',sampleRate:48000,channelId:'1',deviceEpoch:'0',revision:'0',channelName:'CH 01 · VOCAL',bands:defaults(),curveDb:null,selected:3,pending:null,requestCounter:0,drag:null,previewDraft:null,readout:'Drag a point to adjust · wheel changes Q'}; +let viewWidth=400,viewHeight=300,dpr=1,needsFrame=false; +const hex=/^(0|[1-9][0-9]*)$/; +const validUint=v=>typeof v==='string'&&v.length<=20&&hex.test(v)&&BigInt(v)<=18446744073709551615n; +const validBand=(b,i,sr)=>b&&typeof b.enabled==='boolean'&&Number.isFinite(b.frequencyHz)&&b.frequencyHz>=20&&b.frequencyHz<=Math.min(20000,sr*.45)&&Number.isFinite(b.gainDb)&&b.gainDb>=-18&&b.gainDb<=18&&Number.isFinite(b.q)&&b.q>=.1&&b.q<=24&&[12,24,48].includes(b.slopeDbPerOct)&&(!isCut(i)||b.gainDb===0); +const sameBand=(a,b)=>a&&b&&a.enabled===b.enabled&&a.frequencyHz===b.frequencyHz&&a.gainDb===b.gainDb&&a.q===b.q&&a.slopeDbPerOct===b.slopeDbPerOct; +const round=(v,n=1)=>Number(v.toFixed(n)); +const copy=b=>({...b}); +const labelHz=f=>f>=1000?`${round(f/1000,1)}k`:`${Math.round(f)}`; +const xf=f=>39+Math.log(clamp(f,F0,F1)/F0)/Math.log(F1/F0)*(viewWidth-81); +const fx=x=>F0*Math.pow(F1/F0,clamp((x-39)/(viewWidth-81),0,1)); +const yg=db=>(viewHeight/2)-(clamp(db,-GMAX,GMAX)/GMAX)*(viewHeight*.39); +const gy=y=>clamp((viewHeight*.5-y)/(viewHeight*.39)*GMAX,-18,18); +const maxFrequency=()=>Math.min(20000,state.sampleRate*.45); +const draftBands=()=>state.previewDraft?state.bands.map((b,i)=>i===state.selected?state.previewDraft:b):state.bands; +const bandEnabledCount=()=>state.bands.reduce((v,b)=>v+(b.enabled?1:0),0); + +// Only used for the expressly labeled design fixture. Native mode NEVER +// computes a browser response; the real Engine provides curveDb from audio- +// owner-safe control-side snapshots. Biquad math here is display-only. +function previewResponse(bands, rate) { + const butter={1:[.7071067811865476],2:[.541196100146197,1.306562964876377],4:[.509795579104159,.601344886935045,.899976223136416,2.562915447741506]}; + const calc=(type,hz,gain,q)=>{ + const w=2*pi*hz/rate,s=Math.sin(w),c=Math.cos(w),A=Math.pow(10,gain/40),alpha=s/(2*q); + const S=clamp(q,.25,1),root=2*Math.sqrt(A)*(.5*s*Math.sqrt((A+1/A)*(1/S-1)+2)); + let b0=1,b1=0,b2=0,a0=1,a1=0,a2=0; + if(type==='Bell'){b0=1+alpha*A;b1=-2*c;b2=1-alpha*A;a0=1+alpha/A;a1=-2*c;a2=1-alpha/A;} + else if(type==='LowCut'){b0=(1+c)/2;b1=-(1+c);b2=(1+c)/2;a0=1+alpha;a1=-2*c;a2=1-alpha;} + else if(type==='HighCut'){b0=(1-c)/2;b1=1-c;b2=(1-c)/2;a0=1+alpha;a1=-2*c;a2=1-alpha;} + else if(type==='LowShelf'){b0=A*((A+1)-(A-1)*c+root);b1=2*A*((A-1)-(A+1)*c);b2=A*((A+1)-(A-1)*c-root);a0=(A+1)+(A-1)*c+root;a1=-2*((A-1)+(A+1)*c);a2=(A+1)+(A-1)*c-root;} + else if(type==='HighShelf'){b0=A*((A+1)+(A-1)*c+root);b1=-2*A*((A-1)+(A+1)*c);b2=A*((A+1)+(A-1)*c-root);a0=(A+1)-(A-1)*c+root;a1=2*((A-1)-(A+1)*c);a2=(A+1)-(A-1)*c-root;} + return [b0/a0,b1/a0,b2/a0,a1/a0,a2/a0]; + }; + const entries=[]; + bands.forEach((b,i)=>{ + if(!b.enabled)return; + const qs=isCut(i)?butter[b.slopeDbPerOct/12]:[b.q]; + for(const q of qs)entries.push(calc(KEY[i][4],b.frequencyHz,b.gainDb,q)); + }); + const out=[]; + for(let k=0;k1?KEY[index][0]:'PEQ';$('selectedTitle').append(suffix); + $('selectedMark').style.background=KEY[index][3]; + $('frequencyInput').value=round(b.frequencyHz,1); + $('gainInput').value=round(b.gainDb,2); + $('qInput').value=round(b.q,2); + $('slopeInput').value=String(b.slopeDbPerOct); + $('gainInput').disabled=!editable||isCut(index); + $('qInput').disabled=!editable||isCut(index); + $('slopeInput').disabled=!editable||!isCut(index); + $('frequencyInput').disabled=!editable; + $('bandToggle').disabled=!editable; + $('bandToggle').setAttribute('aria-pressed',String(b.enabled)); + $('bandToggle').setAttribute('aria-label',(b.enabled?'Disable':'Enable')+' '+KEY[index][1]); + $('powerText').textContent=b.enabled?'ON':'OFF'; + $('flatBtn').disabled=!editable; +} +function refresh(){renderRail();renderInspector();renderStatus();drawLater();} +function selectBand(i){if(i<0||i>=N)return;state.selected=i;state.previewDraft=null;refresh();} +function sendBand(i,band){ + if(state.mode==='offline'||state.pending||!validBand(band,i,state.sampleRate))return false; + if(state.mode==='design'){ + state.bands[i]=copy(band); + state.curveDb=previewResponse(state.bands,state.sampleRate); + refresh();return true; + } + const bridge=window.__ARSON_CONSOLE_EQ_BRIDGE__; + if(!bridge||typeof bridge.send!=='function')return false; + const requestId='ceq-'+(++state.requestCounter),expected=copy(band); + const payload={schemaVersion:1,kind:'eqSetBand',requestId,channelId:state.channelId, + deviceEpoch:state.deviceEpoch,baseRevision:state.revision,slot:i,parameters:expected}; + state.pending={requestId,slot:i,expected,ackRevision:null,epoch:state.deviceEpoch,channelId:state.channelId}; + armTimeout(requestId); + try{bridge.send(payload);}catch(e){state.pending=null;renderStatus('Native command rejected by transport');refresh();return false;} + refresh();renderStatus('PENDING · wait for native ACK and matching readback'); + return true; +} +function updateSelected(field,value){ + if(state.mode==='offline'||state.pending||!Number.isFinite(value))return false; + const i=state.selected,b=copy(state.bands[i]);b[field]=value; + if(!validBand(b,i,state.sampleRate))return false; + return sendBand(i,b); +} +function armTimeout(requestId) { + window.setTimeout(()=>{ + if(state.pending?.requestId!==requestId)return; + state.pending=null;refresh();renderStatus('TIMEOUT · EQ state not confirmed by native'); + },4000); +} +function resetFlat(){ + if(state.mode==='offline'||state.pending)return; + if(state.mode==='design') { + state.bands=state.bands.map(b=>({...b,enabled:false})); + state.curveDb=previewResponse(state.bands,state.sampleRate); + refresh();return; + } + // Native must implement atomic transaction; never emit nine unrelated edits. + const bridge=window.__ARSON_CONSOLE_EQ_BRIDGE__; + if(!bridge||typeof bridge.send!=='function')return; + const requestId='ceq-'+(++state.requestCounter); + state.pending={requestId,allFlat:true,ackRevision:null,epoch:state.deviceEpoch,channelId:state.channelId}; + armTimeout(requestId); + try{bridge.send({schemaVersion:1,kind:'eqResetFlat',requestId,channelId:state.channelId, + deviceEpoch:state.deviceEpoch,baseRevision:state.revision});} + catch(e){state.pending=null;refresh();renderStatus('Native FLAT unavailable');return;} + refresh();renderStatus('PENDING · waiting for atomic EQ reset confirmation'); +} + +// Strong validation: all nine fixed-type bands and current native response +// are accepted together, never preserve another ChannelId's curve on switch. +function setSnapshot(s){ + if(!s||s.schemaVersion!==1||!validUint(s.channelId)||!validUint(s.deviceEpoch)||!validUint(s.revision)|| + !Number.isFinite(s.sampleRate)||s.sampleRate<8000||s.sampleRate>192000|| + !Array.isArray(s.bands)||s.bands.length!==N|| + !s.bands.every((b,i)=>validBand(b,i,s.sampleRate))|| + (s.curveDb!==null&&s.curveDb!==undefined&&(!Array.isArray(s.curveDb)||s.curveDb.length<65||s.curveDb.length>1024||!s.curveDb.every(v=>Number.isFinite(v)&&v>=-100&&v<=100))))return false; + if(state.mode==='native'&&s.channelId===state.channelId&&s.deviceEpoch===state.deviceEpoch&&BigInt(s.revision)!sameBand(b,state.bands[i])))return false; + if(state.mode==='native'&&s.channelId===state.channelId&&BigInt(s.deviceEpoch)=BigInt(state.pending.ackRevision)&& + (state.pending.allFlat?s.bands.every(b=>!b.enabled):sameBand(s.bands[state.pending.slot],state.pending.expected)))state.pending=null; + refresh();return true; +} +function ack(a){ + const p=state.pending; + if(!p||!a||a.schemaVersion!==1||a.requestId!==p.requestId|| + a.channelId!==p.channelId||a.deviceEpoch!==p.epoch)return false; + if(a.status!=='accepted'){ + state.pending=null;refresh();renderStatus('REJECTED / STALE · native did not apply EQ change');return true; + } + if(!validUint(a.revision)||BigInt(a.revision)<=BigInt(state.revision))return false; + p.ackRevision=a.revision; + // Requires a fresh accepted native revision and exact requested parameters. + // An ACK alone can never repaint desired state as though audio were updated. + refresh();renderStatus('ACK received · awaiting matching native readback');return true; +} +function disconnect(){state.mode='offline';state.pending=null;state.curveDb=null;state.bands=defaults();state.deviceEpoch='0';state.revision='0';state.previewDraft=null;refresh();} + +function resize(){ + const r=canvas.getBoundingClientRect(); + if(!r.width||!r.height)return; + viewWidth=Math.max(120,r.width);viewHeight=Math.max(100,r.height);dpr=Math.min(2,window.devicePixelRatio||1); + canvas.width=Math.round(viewWidth*dpr);canvas.height=Math.round(viewHeight*dpr); + ctx.setTransform(dpr,0,0,dpr,0,0);drawLater(); +} +function drawLater(){if(needsFrame)return;needsFrame=true;requestAnimationFrame(()=>{needsFrame=false;draw();});} +function draw(){ + const w=viewWidth,h=viewHeight;ctx.clearRect(0,0,w,h); + ctx.fillStyle='#111d28';ctx.fillRect(0,0,w,h); + const stops=[20,50,100,200,500,1000,2000,5000,10000,20000]; + ctx.textBaseline='middle';ctx.font='10px Consolas, monospace'; + stops.forEach((f,i)=>{ + const x=xf(f);ctx.strokeStyle=i%2?'#293943':'#344651';ctx.globalAlpha=i%2?.55:.7; + ctx.beginPath();ctx.moveTo(x,26);ctx.lineTo(x,h-30);ctx.stroke();ctx.globalAlpha=1; + ctx.fillStyle='#7892a2';ctx.textAlign='center';ctx.fillText(f>=1000?(f/1000)+'k':String(f),x,h-17); + }); + [-18,-12,-6,0,6,12,18].forEach(db=>{ + const y=yg(db);ctx.setLineDash(db===0?[4,4]:[]);ctx.lineWidth=db===0?1.15:.65; + ctx.strokeStyle=db===0?'#65818d':'#29404e';ctx.beginPath();ctx.moveTo(39,y);ctx.lineTo(w-42,y);ctx.stroke();ctx.setLineDash([]); + ctx.textAlign='right';ctx.fillStyle=db===0?'#b5c9d3':'#6f8998';ctx.fillText((db>0?'+':'')+db,31,y); + + }); + ctx.textAlign='left';ctx.fillStyle='#708997';ctx.fillText('dB',w-33,32); + // Accepted host response is not assumed if missing. Flat is displayed only + // as the disabled baseline; the visible caption warns if native curve absent. + const curve=state.mode==='design'?(state.previewDraft?previewResponse(draftBands(),state.sampleRate):state.curveDb):state.curveDb; + if(curve&&curve.length>=65){ + ctx.beginPath();curve.forEach((db,i)=>{const x=39+i/(curve.length-1)*(w-81),y=yg(db);i?ctx.lineTo(x,y):ctx.moveTo(x,y);}); + ctx.lineTo(w-42,yg(0));ctx.lineTo(39,yg(0));ctx.closePath(); + const grd=ctx.createLinearGradient(0,yg(18),0,yg(-18));grd.addColorStop(0,'#b78d4750');grd.addColorStop(.5,'#b78d4712');grd.addColorStop(1,'#2fa7bb24');ctx.fillStyle=grd;ctx.fill(); + ctx.beginPath();curve.forEach((db,i)=>{const x=39+i/(curve.length-1)*(w-81),y=yg(db);i?ctx.lineTo(x,y):ctx.moveTo(x,y);}); + ctx.lineWidth=2.1;ctx.strokeStyle='#ebc47e';ctx.shadowColor='#f0c47735';ctx.shadowBlur=7;ctx.stroke();ctx.shadowBlur=0; + }else{ + ctx.strokeStyle='#9cb2be';ctx.lineWidth=1.2;ctx.beginPath();ctx.moveTo(39,yg(0));ctx.lineTo(w-42,yg(0));ctx.stroke(); + } + const bands=draftBands(); + bands.forEach((b,i)=>{ + const x=xf(b.frequencyHz),y=yg(isCut(i)?0:b.gainDb),picked=state.selected===i,r=picked?10:7; + ctx.beginPath();ctx.arc(x,y,r+3,0,2*pi);ctx.fillStyle='#0b151e';ctx.fill(); + ctx.beginPath();ctx.arc(x,y,r,0,2*pi);ctx.fillStyle=b.enabled?KEY[i][3]:'#25333b'; + ctx.strokeStyle=picked?'#d5f2ff':KEY[i][3];ctx.lineWidth=picked?1.8:1;ctx.fill();ctx.stroke(); + ctx.font=(picked?'600 ':'')+'9px Inter, Segoe UI, sans-serif';ctx.textAlign='center';ctx.textBaseline='middle';ctx.fillStyle=b.enabled?'#0c2734':picked?'#e8f4f8':'#acbcc4';ctx.fillText(KEY[i][0].length>1?KEY[i][0]:String(i-1),x,y+.2); + }); + ctx.textBaseline='alphabetic'; +} +function locate(e){const r=canvas.getBoundingClientRect();return {x:(e.clientX-r.left)*viewWidth/r.width,y:(e.clientY-r.top)*viewHeight/r.height};} +function pick(x,y){let index=-1,distance=20;for(let i=0;i3)drag.moved=true; + if(!drag.moved)return; + const candidate=copy(state.previewDraft||state.bands[idx]);candidate.frequencyHz=clamp(round(fx(p.x),1),20,maxFrequency()); + if(!isCut(idx))candidate.gainDb=round(gy(p.y),1); + if(!candidate.enabled)candidate.enabled=true; + state.previewDraft=candidate; + $('plotReadout').textContent=labelHz(candidate.frequencyHz)+' Hz · '+(candidate.gainDb>0?'+':'')+candidate.gainDb+' dB · EDIT NOT COMMITTED'; + renderInspector();drawLater();return; + } + const i=pick(p.x,p.y);const b=i>=0?state.bands[i]:null; + $('plotReadout').textContent=b?KEY[i][1]+' · '+labelHz(b.frequencyHz)+' Hz'+(isCut(i)?'':(' · '+b.gainDb.toFixed(1)+' dB')):'Drag a point to adjust · wheel changes Q'; +} +function mouseUp(e){if(!state.drag||e.pointerId!==state.drag.pointerId)return;const draft=state.previewDraft,idx=state.selected;state.drag=null;state.previewDraft=null;if(draft)sendBand(idx,draft);else refresh();} +function mouseWheel(e){if(state.mode==='offline'||state.pending)return;const p=locate(e),i=pick(p.x,p.y);if(i<0)return;selectBand(i);e.preventDefault();const b=copy(state.bands[i]);if(isCut(i)){const slopes=[12,24,48],next=clamp(slopes.indexOf(b.slopeDbPerOct)+(e.deltaY<0?1:-1),0,2);b.slopeDbPerOct=slopes[next];}else b.q=clamp(round(b.q*(e.deltaY<0?1.1:1/1.1),2),.1,24);sendBand(i,b);} +function doubleClick(e){if(state.mode==='offline'||state.pending)return;const p=locate(e),i=pick(p.x,p.y);if(i>=0){selectBand(i);sendBand(i,{...state.bands[i],enabled:!state.bands[i].enabled});}} + +KEY.forEach((k,i)=>{ + const btn=document.createElement('button');btn.className='filter-key';btn.type='button';btn.dataset.slot=String(i);btn.style.setProperty('--band-color',k[3]);btn.innerHTML=''+k[0]+'';btn.setAttribute('aria-label','Select '+k[1]); + btn.addEventListener('click',()=>selectBand(i));btn.addEventListener('dblclick',()=>{if(state.mode==='offline'||state.pending)return;sendBand(i,{...state.bands[i],enabled:!state.bands[i].enabled});});rail.append(btn); +}); +['frequencyInput','gainInput','qInput','slopeInput'].forEach(id=>$(id).addEventListener('change',e=>{ + const field={frequencyInput:'frequencyHz',gainInput:'gainDb',qInput:'q',slopeInput:'slopeDbPerOct'}[id]; + const ok=updateSelected(field,Number(e.target.value));if(!ok){renderInspector();renderStatus('Invalid or unacknowledged filter edit');} +})); +$('bandToggle').addEventListener('click',()=>{const b=state.bands[state.selected];sendBand(state.selected,{...b,enabled:!b.enabled});}); +$('flatBtn').addEventListener('click',resetFlat); +canvas.addEventListener('pointerdown',mouseDown);canvas.addEventListener('pointermove',mouseMove);canvas.addEventListener('pointerup',mouseUp);canvas.addEventListener('pointercancel',()=>{state.drag=null;state.previewDraft=null;refresh();});canvas.addEventListener('wheel',mouseWheel,{passive:false});canvas.addEventListener('dblclick',doubleClick); +window.addEventListener('resize',resize); +if(window.ResizeObserver)new ResizeObserver(resize).observe(canvas); +if(state.mode==='design'){ + state.bands[0].enabled=true; + state.bands[3].enabled=true;state.bands[3].gainDb=-3.5;state.bands[3].q=1.2; + state.bands[5].enabled=true;state.bands[5].gainDb=2.7;state.bands[5].q=1.1; + state.bands[7].enabled=true;state.bands[7].gainDb=1.7; + state.bands[8].enabled=true;state.bands[8].frequencyHz=18000; + state.curveDb=previewResponse(state.bands,state.sampleRate); +} +window.ArSonConsoleEQ=Object.freeze({setSnapshot,ack,disconnect,getDiagnostics:()=>({mode:state.mode,channelId:state.channelId,deviceEpoch:state.deviceEpoch,revision:state.revision,pending:state.pending?.requestId||null,selected:state.selected,activeBands:bandEnabledCount(),hasNativeCurve:state.mode==='native'&&!!state.curveDb}), + // Read-only contract introspection for native implementers / QA tests. + protocolVersion:1}); +resize();refresh(); + +// Browser QA exercised only via explicit ?smoke=1. The file is NOT loaded +// by the native mixer and never contacts a network or audio device. +if(new URLSearchParams(location.search).has('smoke')){ + try{ + const check=(v,why)=>{if(!v)throw new Error(why);}; + check(state.mode==='offline','default fail-closed'); + check($('frequencyInput').disabled,'offline disables edits'); + const good={schemaVersion:1,channelId:'10',deviceEpoch:'22',revision:'4',sampleRate:48000, + channelName:'Vocal ',bands:defaults(),curveDb:Array.from({length:257},()=>0)}; + check(setSnapshot(good),'good native accepted'); + check($('channelTitle').textContent.includes(' diff --git a/ConsoleUI/smoke.test.cjs b/ConsoleUI/smoke.test.cjs new file mode 100644 index 0000000..172fa33 --- /dev/null +++ b/ConsoleUI/smoke.test.cjs @@ -0,0 +1,12 @@ +// Offline browser smoke. No npm, network, WebAudio or new host. +const {spawnSync}=require('node:child_process'); +const {resolve}=require('node:path'); +const fs=require('node:fs'); +const browser=process.env.CHROME || ['/usr/bin/chromium','/usr/bin/google-chrome','/usr/bin/chromium-browser'].find(fs.existsSync); +if(!browser){console.log('Chromium absent: native-only smoke; screenshot gate skipped');process.exit(0)} +const page='file://'+resolve(__dirname,'index.html')+'?smoke=1'; +const r=spawnSync(browser,['--headless','--no-sandbox','--disable-gpu','--disable-dev-shm-usage','--virtual-time-budget=1500','--dump-dom',page],{encoding:'utf8',timeout:30000,maxBuffer:4*1024*1024}); +if(r.status!==0||!r.stdout.includes('data-smoke="PASS"')){ + console.error('ConsoleUI contract smoke failed',r.stdout.match(/data-smoke="[^"]+"/)?.[0],r.stderr.slice(-900));process.exit(1); +} +console.log('ConsoleUI native ACK+readback / stale-epoch / offline fail-closed browser smoke PASS'); diff --git a/ConsoleUI/style.css b/ConsoleUI/style.css new file mode 100644 index 0000000..d162803 --- /dev/null +++ b/ConsoleUI/style.css @@ -0,0 +1,27 @@ +/* ArSonMix /preview/ visual provenance: main@591444d (2026-11-06). + * Mirrors the approved component language (not its full mixer CSS): + * 29px industrial title bar; restrained silver toolbar; blue-black glass; + * #55afcb accent; compact equipment keys; no oversized cards or loud headings. + * Isolated module stylesheet -- never loaded by mixer /preview/ itself. + */ +:root{color-scheme:dark;--chassis:#292b2e;--panel:#222426;--edge:#111618;--rule:#41484b;--ink:#cbd4d8;--dim:#84939d;--blue:#55afcb;--cyan:#80d8ee;--gold:#f0c477;--glass:#111a24;--knob:#243642;--pressed:#78d1bd} +*{box-sizing:border-box} +html,body{margin:0;width:100%;height:100%;min-width:0;min-height:0;color:var(--ink);background:#1e2124;font:11px/1.3 Inter,'Segoe UI',Arial,sans-serif;overflow:hidden} +button,input,select{font:inherit}button{cursor:pointer}button:focus-visible,input:focus-visible,select:focus-visible{outline:2px solid #9bd9e8;outline-offset:1px}button:disabled,input:disabled,select:disabled{opacity:.43;cursor:default}[hidden]{display:none!important} +.eq-shell{height:100%;min-height:0;display:flex;flex-direction:column;border:1px solid #121618;background:linear-gradient(180deg,#2b2e31 0,#232629 58%,#1f2428 100%)} +.window-title{height:29px;flex:0 0 29px;display:flex;align-items:center;gap:10px;padding:0 13px;background:linear-gradient(#383b3e,#292b2e);border-bottom:1px solid #111518;box-shadow:inset 0 1px #5a6062} +.brand{color:#79c2d5;font-size:12px;font-weight:600;letter-spacing:.02em}.window-divider{width:1px;height:14px;background:#575e60}.window-name{font-size:10px;letter-spacing:1px;color:#bcc1c3}.window-right{margin-left:auto;font-size:9px;letter-spacing:.8px;color:#919fa3}.window-right.live{color:#81d6b3} +.eq-toolbar{height:47px;flex:0 0 47px;display:flex;align-items:center;justify-content:space-between;padding:0 14px;gap:12px;background:linear-gradient(#363b3e,#2b3033 48%,#262a2e);border-bottom:1px solid #101518;box-shadow:inset 0 1px #53595d} +.channel-identity,.toolbar-controls{display:flex;align-items:center;min-width:0;gap:9px}.channel-led{height:7px;width:7px;flex:none;background:#47b3d1;border-radius:50%;box-shadow:0 0 0 2px #1a2429}.channel-name{font-size:12px;font-weight:600;letter-spacing:.25px;color:#e4ecf0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.channel-kind{font-size:9px;color:#9ba9ae;letter-spacing:.7px;white-space:nowrap}.toolbar-controls{flex:none}.processing-tag,.latency-tag{font:10px Consolas,'SFMono-Regular',monospace;color:#97afb9;white-space:nowrap}.latency-tag{color:#9bcebd}.toolbar-rule{height:15px;width:1px;background:#171d20}.metal-button{height:25px;min-width:52px;border:1px solid #161e21;border-radius:3px;background:linear-gradient(#5a6265,#464d51 42%,#363b3e 43%,#484f53);box-shadow:inset 0 1px #929b9e,0 1px 1px #0b1117;color:#e2e8eb;font-size:10px;letter-spacing:.3px}.metal-button:active{transform:translateY(1px)} +.eq-main{flex:1;min-height:0;display:flex;flex-direction:column;padding:11px 12px 8px;gap:8px;background:radial-gradient(ellipse 75% 40% at 50% 0%,#30363a 0%,#24292c 63%,#202529 100%)} +.plot-area{flex:1;min-height:0;overflow:hidden;border:1px solid #080e13;border-radius:4px;box-shadow:0 2px 6px #0007,inset 0 1px #56626c}.plot-glass{position:relative;height:100%;overflow:hidden;background:linear-gradient(180deg,#192631,#0d1720 60%,#101e28)}.plot-glass::after{position:absolute;inset:0;content:"";pointer-events:none;background:linear-gradient(180deg,#fff1,transparent 9%,transparent 85%,#0004)}.plot-glass canvas{display:block;width:100%;height:100%;touch-action:none;cursor:crosshair} +.plot-caption{position:absolute;left:15px;right:16px;top:9px;display:flex;align-items:center;gap:6px;color:#819aa8;font-size:9px;font-weight:600;letter-spacing:.9px;pointer-events:none}.plot-dot{height:5px;width:5px;border-radius:50%;background:#5bc6db}.plot-caption-right{margin-left:auto;font-size:9px;letter-spacing:0;color:#6f909c;font-weight:400}.plot-footnote{display:none} +.filter-rail{height:37px;flex:0 0 37px;display:grid;grid-template-columns:repeat(9,minmax(0,1fr));gap:4px;padding:2px 0}.filter-key{position:relative;min-width:0;min-height:0;height:33px;border-radius:3px;border:1px solid #161e22;display:flex;align-items:center;justify-content:center;gap:7px;background:linear-gradient(180deg,#4a545c,#323d46 48%,#29343c 52%,#3b444b);box-shadow:inset 0 1px #74818b,0 1px 2px #0005;color:#b4c4cb;font-size:10px}.filter-key.selected{border-color:#6ea9b9;background:linear-gradient(#4a6471,#2a4d5b 55%,#2d4c5c);color:#f1f8fc}.filter-key[data-enabled="true"]::after{content:"";width:4px;height:4px;border-radius:50%;background:#91d9c1;box-shadow:0 0 4px #55c2a2}.filter-key .filter-swatch{width:5px;height:5px;border-radius:50%;background:var(--band-color)}.filter-key:active{transform:translateY(1px)} +.edit-deck{height:88px;flex:0 0 88px;display:flex;align-items:center;gap:14px;padding:10px 12px;border:1px solid #151d21;border-radius:4px;background:linear-gradient(180deg,#39454d,#2a343b 46%,#202a32);box-shadow:inset 0 1px #6e777b,inset 0 -1px #0d1318,0 2px 4px #0004}.edit-identity{display:flex;align-items:center;gap:9px;flex:0 0 132px;min-width:0}.selected-mark{width:4px;height:34px;flex:0 0 4px;background:#70c4de;border-radius:2px}.edit-label{font-size:8px;letter-spacing:1.1px;color:#8fa4ae}.selected-title{margin-top:3px;font-size:11px;font-weight:600;color:#e1e9ec;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.selected-title span{font-size:9px;font-weight:400;color:#9cb1ba} +.edit-controls{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:9px;align-items:center;flex:1;min-width:0}.control-box{min-width:0}.control-box>span{display:block;margin-bottom:4px;font-size:9px;letter-spacing:.7px;color:#a3b4bc}.number-shell,.select-shell{height:29px;display:flex;align-items:center;border-radius:3px;border:1px solid #101b22;background:linear-gradient(#101a22,#172632);box-shadow:inset 0 1px 3px #0009;color:#e4f1f4}.number-shell input{width:100%;min-width:0;height:100%;border:0;padding:2px 8px;outline:0;color:#ebf6f9;background:transparent;font:12px Consolas,monospace;font-variant-numeric:tabular-nums}.number-shell:focus-within,.select-shell:focus-within{border-color:#64bed5}.number-shell small{padding-right:7px;font:9px Consolas,monospace;color:#85a4b0}.number-shell input::-webkit-outer-spin-button,.number-shell input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.select-shell select{width:100%;height:100%;border:0;padding:0 5px;background:transparent;color:#dfeaf0;font:11px Consolas,monospace}.select-shell select option{background:#1b2a35} +.power-button{height:42px;width:43px;flex:0 0 43px;border:1px solid #152026;border-radius:3px;background:linear-gradient(#5d6c74,#344650 49%,#24343e 50%,#435058);box-shadow:inset 0 1px #a0b3bc,0 1px 3px #0007;color:#b9cbd2;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px}.power-button .power-icon{position:relative;display:block;width:14px;height:14px;border:2px solid currentColor;border-radius:50%;font-size:0;line-height:0}.power-button .power-icon::after{content:"";position:absolute;left:4px;top:-4px;width:2px;height:8px;border-radius:1px;background:currentColor;box-shadow:0 0 0 2px #315e55}.power-button span:last-child{font-size:8px;letter-spacing:.8px}.power-button[aria-pressed="true"]{color:#c6ffe5;border-color:#438a76;background:linear-gradient(#3b7365,#245e51 49%,#1e5047 50%,#37695a)}.power-button:active{transform:translateY(1px)} +.status-bar{height:26px;flex:0 0 26px;display:flex;align-items:center;gap:8px;padding:0 12px;background:linear-gradient(#343a3e,#262c2f);border-top:1px solid #58636a;color:#9caeb6;font-size:9px;white-space:nowrap;min-width:0}.status-dot{width:5px;height:5px;flex:none;background:#9ca0a5;border-radius:50%}.status-dot.live{background:#64d0ac}.status-dot.pending{background:#e2bd6d}.status-main{overflow:hidden;text-overflow:ellipsis}.status-spacer{flex:1}.status-sep{height:12px;width:1px;background:#59636a}.foot-brand{color:#87c1d0} +@media(max-width:740px){.eq-main{padding:8px;gap:6px}.eq-toolbar{padding:0 9px}.channel-kind{display:none}.processing-tag{display:none}.edit-deck{gap:8px;padding:6px}.edit-identity{flex-basis:84px}.selected-title{font-size:10px}.edit-controls{gap:5px}.filter-rail{gap:2px}.filter-key{gap:2px;font-size:9px}.filter-key .filter-swatch{width:3px;height:3px}.plot-caption-right{display:none}.foot-brand{display:none}} +@media(max-width:520px){.window-title{padding:0 8px}.eq-toolbar{height:42px;flex-basis:42px}.channel-name{font-size:11px}.latency-tag{font-size:9px}.edit-deck{height:115px;flex-basis:115px;align-items:flex-start}.edit-identity{flex:0 0 70px;padding-top:9px}.edit-controls{grid-template-columns:repeat(2,minmax(0,1fr));gap:4px 6px}.control-box>span{font-size:8px;margin-bottom:1px}.number-shell,.select-shell{height:26px}.power-button{width:34px;flex-basis:34px;height:36px;margin-top:13px}.filter-key{font-size:8px}.filter-key .filter-swatch{display:none}.status-bar{gap:5px;padding:0 7px}.status-sep{display:none}} +@media(max-height:450px){.eq-main{padding-top:5px;gap:4px}.edit-deck{height:75px;flex-basis:75px}.filter-rail{height:30px;flex-basis:30px}.filter-key{height:26px}.window-title{height:25px;flex-basis:25px}.eq-toolbar{height:37px;flex-basis:37px}} +@media(prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}} diff --git a/Source/DSP/ConsoleChannelEQ.h b/Source/DSP/ConsoleChannelEQ.h new file mode 100644 index 0000000..9b5db05 --- /dev/null +++ b/Source/DSP/ConsoleChannelEQ.h @@ -0,0 +1,182 @@ +// SPDX-License-Identifier: AGPL-3.0-only +// ArSonMix console profile over the existing ArSonEQ minimum-phase DSP. +// This has NO JUCE, WebView, VST3 host, allocations, or new audio callback. +#pragma once + +#include "ParametricEQ.h" +#include +#include +#include +#include +#include + +namespace arson::eq::console { + +enum class Slot : std::uint8_t { + HighPass = 0, LowShelf, Bell1, Bell2, Bell3, Bell4, Bell5, HighShelf, LowPass +}; + +constexpr std::size_t kSlots = 9; + +// Value-only control contract. Send on the owner's real-time control queue; +// never mutate a live ConsoleChannelEQ from a GUI/network thread. +struct Parameters { + bool enabled = false; + double frequencyHz = 1000.0; + double gainDb = 0.0; + double q = 0.7071067811865476; + int slopeDbPerOct = 24; +}; + +class ConsoleChannelEQ final { +public: + ConsoleChannelEQ() noexcept { + engine_.prepare(48000.0); + resetToFlat(); + // There is no fade or enabled filter in a newly created EQ. + everEnabled_ = false; + } + ConsoleChannelEQ(const ConsoleChannelEQ&) = delete; + ConsoleChannelEQ& operator=(const ConsoleChannelEQ&) = delete; + + static constexpr int addedLatencySamples() noexcept { return 0; } + static constexpr bool isValid(Slot slot) noexcept { + return static_cast(slot) < kSlots; + } + static constexpr bool isCut(Slot slot) noexcept { + return slot == Slot::HighPass || slot == Slot::LowPass; + } + static Type typeFor(Slot slot) noexcept { + switch (slot) { + case Slot::HighPass: return Type::LowCut; + case Slot::LowShelf: return Type::LowShelf; + case Slot::HighShelf: return Type::HighShelf; + case Slot::LowPass: return Type::HighCut; + default: return Type::Bell; + } + } + static Parameters defaultParameters(Slot slot) noexcept { + Parameters p; + switch (slot) { + case Slot::HighPass: p.frequencyHz=80.0; break; + case Slot::LowShelf: p.frequencyHz=160.0; break; + case Slot::Bell1: p.frequencyHz=250.0; break; + case Slot::Bell2: p.frequencyHz=500.0; break; + case Slot::Bell3: p.frequencyHz=1200.0; break; + case Slot::Bell4: p.frequencyHz=3200.0; break; + case Slot::Bell5: p.frequencyHz=7500.0; break; + case Slot::HighShelf: p.frequencyHz=10000.0; break; + case Slot::LowPass: p.frequencyHz=18000.0; break; + default: break; + } + return p; + } + + // Call before publishing this instance to the real-time owner. + // Retains settings, resets filter history, and adopts the new sample rate. + void prepare(double sampleRate) noexcept { + engine_.prepare(sampleRate); + const double maxHz = maximumFrequency(); + for (std::size_t i=0; i(i); + Band band=engine_.band(static_cast(i)); + if (band.frequency > maxHz) { + band.frequency=maxHz; + engine_.setBand(static_cast(i),band); + } + } + // Keep the process path enabled if there are outstanding fades. + // Re-preparing disabled channels is harmless; it never restarts a device. + } + + // Ownership: ONLY the audio thread at a block boundary, or the preparing + // control thread while the instance is not published. No simultaneous access. + bool setBand(Slot slot, const Parameters& p) noexcept { + if (!isValid(slot) || !std::isfinite(p.frequencyHz) || + !std::isfinite(p.gainDb) || !std::isfinite(p.q) || + p.frequencyHz < 20.0 || p.frequencyHz > maximumFrequency() || + p.q < 0.1 || p.q > 24.0 || + p.gainDb < -18.0 || p.gainDb > 18.0) return false; + if (isCut(slot) && p.slopeDbPerOct != 12 && + p.slopeDbPerOct != 24 && p.slopeDbPerOct != 48) return false; + const int index=static_cast(slot); + Band band=engine_.band(index); + band.enabled=p.enabled; + band.type=typeFor(slot); // immutable slot topology, never arbitrary VST band mapping + band.route=Route::Stereo; + band.frequency=p.frequencyHz; + band.gainDb=isCut(slot) ? 0.0 : p.gainDb; + band.q=p.q; + band.slope=isCut(slot) ? p.slopeDbPerOct : 12; + band.dynamicRangeDb=0.0; // Static, zero-lookahead console EQ only + band.thresholdDb=-24.0; + if (band.enabled) everEnabled_=true; + engine_.setBand(index,band); + return true; + } + + bool setEnabled(Slot slot, bool enabled) noexcept { + if (!isValid(slot)) return false; + const auto p=parameters(slot); + Parameters updated=p; + updated.enabled=enabled; + return setBand(slot,updated); + } + + Parameters parameters(Slot slot) const noexcept { + if (!isValid(slot)) return {}; + const Band b=engine_.band(static_cast(slot)); + return {b.enabled,b.frequency,b.gainDb,b.q,b.slope}; + } + + void resetToFlat() noexcept { + for (std::size_t i=0; i(i); + auto p=defaultParameters(slot); + p.frequencyHz=std::min(p.frequencyHz,maximumFrequency()); + setBand(slot,p); + } + // Do not clear everEnabled_ here: bypass transitions need to finish. + } + + // In-place, sample-synchronous minimum-phase IIR. No lookahead, no + // buffering, no extra callback and no allocation; process each ChannelId + // with its own distinct object. Never call concurrently on one instance. + void processStereo(float* left, float* right, std::size_t frames) noexcept { + if (!left || !right || frames == 0 || !everEnabled_) return; + if (left == right) { processMono(left,frames); return; } + for (std::size_t i=0; i(l); + right[i]=static_cast(r); + } + } + void processMono(float* mono, std::size_t frames) noexcept { + if (!mono || frames == 0 || !everEnabled_) return; + for (std::size_t i=0; i(v); + } + } + + // For a UI snapshot on the owning/control thread only; do NOT read + // engine_ concurrently with processing. Aggregate on the UI thread. + double bandResponseDb(Slot slot, double frequencyHz) const noexcept { + if (!isValid(slot) || !std::isfinite(frequencyHz) || + frequencyHz <= 0.0 || frequencyHz >= engine_.sampleRate()*0.5) + return 0.0; + return engine_.bandResponseDb(static_cast(slot),frequencyHz); + } + +private: + double maximumFrequency() const noexcept { + return std::min(20000.0,engine_.sampleRate()*0.45); + } + + Engine engine_; + bool everEnabled_=false; +}; + +} // namespace arson::eq::console diff --git a/docs/BUILTIN_CONSOLE_EQ_INTEGRATION.md b/docs/BUILTIN_CONSOLE_EQ_INTEGRATION.md new file mode 100644 index 0000000..1943093 --- /dev/null +++ b/docs/BUILTIN_CONSOLE_EQ_INTEGRATION.md @@ -0,0 +1,47 @@ +# ArSonMix built-in channel EQ — isolated DSP candidate + +**Branch scope (2026-11-06):** This is an additive, native-only console profile in the existing **ArSonEQ** source project. It does **not** change ArSonMix `main`, the approved `/preview/` GUI, mixer routing, monitoring, channel graph, VST3 factory packages, or audio callbacks. The existing 24-band ArSonEQ VST3/Standalone remain unchanged. + +## Why reuse the current engine + +The ArSonEQ PR #1 DSP already supplies RT-owned IIR biquads, Butterworth cut filters (12/24/36/48), gain/Q support, and fade/smoothing logic. The compact **ConsoleChannelEQ** wrapper uses that identical `Engine`, not a second EQ implementation, vendor library, WebView, FFT, or VST host. Source code lives in `Source/DSP/ConsoleChannelEQ.h` and is AGPL-3.0-only like the existing project. + +## Operator contract (9 stable slots) + +| ID | Type | Flat/default center | Controls | +| --- | --- | --- | --- | +| 0 | HPF / LowCut | 80 Hz | Enable, Hz, 12/24/48 dB/oct | +| 1 | Low shelf | 160 Hz | Enable, Hz, gain, Q | +| 2–6 | Bell 1–5 | 250 / 500 / 1200 / 3200 / 7500 Hz | Enable, Hz, gain, Q | +| 7 | High shelf | 10 kHz | Enable, Hz, gain, Q | +| 8 | LPF / HighCut | 18 kHz | Enable, Hz, 12/24/48 dB/oct | + +All bands **disabled** initially (flat, transparent). Frequency 20–min(20k, 0.45×sample rate); shelf/bell gain ±18 dB; Q 0.1–24. Cuts ignore gain and use Butterworth Q tables. Dynamics, oversampling and analyzer are OFF in this profile. No new host parameters, plugin identity or saved-show schema introduced at this stage. + +## Realtime and ownership + +- One instance per stable accepted `ChannelId` (mono or stereo). Each instance owns its filter history; do not share across channels or reconnect epochs. +- The same native audio callback and rendering graph must own `processMono` / `processStereo`. Processing is **in-place** with no new audio callback, block buffer, requeue, dynamic allocation, FFT, locks, or background sample transfer. A never-enabled EQ is a direct pass-through. +- Construct, prepare, and publish on the control side. Apply validated controls **only on the audio owner at a safe block boundary** (or prepare an immutable replacement off-thread). `setBand` is not thread-safe across UI/control/audio threads. Do not call `bandResponseDb` from the UI concurrently with processing. +- Slot enable/disable and topology changes reuse ArSonEQ's existing approximately 10ms crossfade. Numeric control changes reuse its smoothing. This is **zero additional sample buffering**, not a promise of zero analog/ASIO round-trip delay, zero IIR group delay, or click-free changes under all conditions. +- The audio graph must determine actual insert order (normally input trim → EQ → FX rack → fader → sends/MAIN) and keep gain staging safe; **this branch intentionally does not change that graph**. +- Controls must reflect accepted native state after `ACK + snapshot`, never browser simulation. Use existing epoch/revision checks and fail closed for unsupported ChannelIds. Do not make UI selector interactions start/arm a device or route new physical outputs. +- Rack master bypass remains independent from channel EQ. Do not override per-insert saved enable state. + +## Why this is not yet a product claim + +The wrapper and tests are a separately reviewable dependency candidate, **not an active ArSonMix EQ**. There is no new on-screen EQ button, live mixer PCM integration, installer change or platform roundtrip benchmark in this PR. Once the current mixer single-owner integration has stabilized, a separate planned native/GUI vertical slice can pin the audited ArSonEQ DSP source, expose a built-in channel EQ UI on **the existing approved** `/preview/` skin, wire accepted ChannelId parameters and readbacks, and run exact Windows builds + real ASIO hardware FAT. + +## Test contract + +The independent CMake test verifies the 9-slot schema, default transparency, fail-closed parameter validation, bell/cut frequency response, sample-0 impulse delivery, stereo independence, mono alias safety, bypass tail and no process-path heap allocations at 32/64/128/512 frames. Existing DSP/RT/analyzer tests must keep passing. Physical CPU load, plugin host VST3 footprint, dropouts and hardware timing remain **PENDING** and must not be inferred from CTest. + +## Isolated Console EQ editor design candidate (2026-11-06) + +- Assets: `ConsoleUI/index.html`, `style.css`, `app.js` and Chromium contract smoke. **These are NOT loaded or published by ArSonMix /preview/ or ArSonEQ's VST3/Standalone.** +- Visual reference: ArSonMix `main@591444d342492120b5e848d9a0dbea0d33f15efc`, `site/preview/` approved assembled console; `mixer-console-foundation.css` chassis/title; `mixer-chrome-material.css` buttons; `mixer-fx-rack.css` dark-glass FX; `design-references/brushed-metal-v1.0/reference.json` material guidance. No proprietary images or fonts copied. Panel density 900×540 / 720×460, 29px title, 47px toolbar, blue-black chart, slim rail, 88px editor deck, 26px status. The factory buttons/sprites on the approved mixer remain untouched. +- Static preview: open `ConsoleUI/index.html?designPreview=1` for **DESIGN PREVIEW · NO AUDIO**, where browser-only *illustrative* RBJ static-filter response helps exercise editor controls. This fixture MUST NOT be treated as live native audio or real host state. +- Native contract API: host calls `window.ArSonConsoleEQ.setSnapshot({schemaVersion:1,channelId,deviceEpoch,revision,sampleRate,channelName,bands:[9],curveDb:[257]})`, where identity/revisions are canonical decimal strings, bands are stable slot order, and `curveDb` is **from the native DSP** at log-spaced 20Hz–20kHz points on a safe non-audio UI snapshot path; no UI concurrent reads of DSP Engine. Native computes response via the existing `bandResponseDb()` for the accepted channel settings. +- Command adapter: host installs `window.__ARSON_CONSOLE_EQ_BRIDGE__.send(intent)`. UI emits `{schemaVersion:1,kind:'eqSetBand',requestId,channelId,deviceEpoch,baseRevision,slot,parameters}` or atomic `eqResetFlat`. Host validates ChannelId/epoch/revision and controls on a safe control queue; `setBand()` only on DSP owner. A matching `ArSonConsoleEQ.ack({schemaVersion:1,requestId,channelId,deviceEpoch,revision,status:'accepted'})` does **not** commit display state: a subsequent accepted matching native snapshot and parameter readback are also required. Stale/rejected ACK and epoch changes fail closed; 4s pending timeout releases controls but does not assert a native rollback. +- UI disabled on offline startup; no audio start, no WebAudio, no ASIO device operations, no CSS injection into approved /preview/ and no new engine/render callback. Use `ArSonConsoleEQ.disconnect()` on native bridge termination. The engineer integrating into the existing approved mixer renderer must create native readback and connect this subcomponent only after an independently reviewed mixer single-owner change. +- Visual QA is a candidate screenshot of the **isolated EQ editor**, not a screenshot of a live mixer or the Windows plugin. CI screenshots and responsive/interaction browser smoke must pass. Real Windows WebView2 integration, ARSONMIX host performance, hardware analog roundtrip and sound quality FAT remain **PENDING**. diff --git a/tests/eq_console_tests.cpp b/tests/eq_console_tests.cpp new file mode 100644 index 0000000..9a7b4cd --- /dev/null +++ b/tests/eq_console_tests.cpp @@ -0,0 +1,153 @@ +#include "../Source/DSP/ConsoleChannelEQ.h" +#include +#include +#include +#include +#include +#include + +// Allocation tripwire covers DSP process() only; setup remains control-side. +static std::atomic audioActive{false}; +static std::atomic audioAllocations{0}; +void* operator new(std::size_t n) { + if (audioActive.load(std::memory_order_relaxed)) + audioAllocations.fetch_add(1,std::memory_order_relaxed); + if (void* p=std::malloc(n ? n : 1)) return p; + throw std::bad_alloc(); +} +void* operator new[](std::size_t n) { + if (audioActive.load(std::memory_order_relaxed)) + audioAllocations.fetch_add(1,std::memory_order_relaxed); + if (void* p=std::malloc(n ? n : 1)) return p; + throw std::bad_alloc(); +} +void operator delete(void* p) noexcept { std::free(p); } +void operator delete[](void* p) noexcept { std::free(p); } +void operator delete(void* p,std::size_t) noexcept { std::free(p); } +void operator delete[](void* p,std::size_t) noexcept { std::free(p); } + +using arson::eq::console::ConsoleChannelEQ; +using arson::eq::console::Parameters; +using arson::eq::console::Slot; + +static void check(bool yes,const char* reason) { + if (!yes) { std::fprintf(stderr,"Console EQ FAILED: %s\n",reason); std::exit(1); } +} +static void enable(ConsoleChannelEQ& eq,Slot slot,double hz,double db=0,int slope=24) { + Parameters p=ConsoleChannelEQ::defaultParameters(slot); + p.enabled=true;p.frequencyHz=hz;p.gainDb=db;p.slopeDbPerOct=slope; + check(eq.setBand(slot,p),"valid frequency / gain / slope must be accepted"); +} + +int main() { + static_assert(ConsoleChannelEQ::addedLatencySamples() == 0, + "console EQ must not introduce block or lookahead latency"); + static_assert(arson::eq::console::kSlots == 9,"HPF, shelf, 5 PEQ, shelf, LPF"); + ConsoleChannelEQ eq; + eq.prepare(48000.0); + for(unsigned k=0;k<9;++k) { + const auto slot=static_cast(k); + check(!eq.parameters(slot).enabled,"every slot is bypassed by default"); + check(ConsoleChannelEQ::isValid(slot),"slot ID stable"); + } + check(!ConsoleChannelEQ::isValid(static_cast(9)),"reject out of range slot"); + check(!eq.setEnabled(static_cast(9),true),"reject invalid enable"); + check(eq.parameters(Slot::HighPass).frequencyHz==80.0,"HPF factory default"); + check(eq.parameters(Slot::LowPass).frequencyHz==18000.0,"LPF factory default"); + float left[4]{0.5f,-0.25f,0.0f,0.123f}; + float right[4]{-0.25f,0.5f,0.33f,0.001f}; + eq.processStereo(left,right,4); + check(left[0]==0.5f && left[3]==0.123f && + right[0]==-0.25f && right[2]==0.33f,"flat default bit transparent"); + auto invalid=ConsoleChannelEQ::defaultParameters(Slot::Bell1); + invalid.enabled=true;invalid.q=0.0; + check(!eq.setBand(Slot::Bell1,invalid),"invalid Q fail closed"); + invalid.q=1.;invalid.frequencyHz=30000.; + check(!eq.setBand(Slot::Bell1,invalid),"frequency above Nyquist guard fails"); + invalid.frequencyHz=1000.;invalid.gainDb=19.; + check(!eq.setBand(Slot::Bell1,invalid),"excess gain fails"); + invalid.gainDb=6.; + check(eq.setBand(Slot::Bell1,invalid),"valid bell accepted"); + check(std::abs(eq.bandResponseDb(Slot::Bell1,1000.)-6.)<0.05, + "PEQ bell has intended +6dB center response"); + check(eq.bandResponseDb(Slot::Bell1,100.)<0.3,"bell has localized response"); + enable(eq,Slot::HighPass,100.,0.,24); + check(eq.bandResponseDb(Slot::HighPass,20.)<-45.0, + "HPF 24dB/oct attenuates subbass"); + check(eq.bandResponseDb(Slot::HighPass,5000.)>-0.01, + "HPF preserves high frequencies"); + enable(eq,Slot::LowPass,1000.,0.,24); + check(eq.bandResponseDb(Slot::LowPass,5000.)<-50., + "LPF 24dB/oct rejects high frequencies"); + check(eq.bandResponseDb(Slot::LowPass,80.)>-0.01, + "LPF preserves low frequencies"); + Parameters hp=eq.parameters(Slot::HighPass);hp.slopeDbPerOct=36; + check(!eq.setBand(Slot::HighPass,hp),"only 12/24/48 slopes exposed by console"); + hp.slopeDbPerOct=48; + check(eq.setBand(Slot::HighPass,hp),"48dB/oct cutoff available"); + check(eq.bandResponseDb(Slot::HighPass,20.)<-90.0, + "48dB/oct HPF has steep attenuation"); + + // A minimum-phase IIR acts at the current sample, no buffering or + // lookahead. This does NOT imply zero ASIO device roundtrip/group delay. + ConsoleChannelEQ impulseEq;impulseEq.prepare(48000.); + enable(impulseEq,Slot::HighPass,80.); + float impulse[8]{1.,0,0,0,0,0,0,0}; + impulseEq.processMono(impulse,8); + check(std::isfinite(impulse[0]) && std::abs(impulse[0])>0.0001f, + "sample-0 impulse output, no block-delayed audio"); + + // Stereo L/R stay independent for stereo-routed static filters. + ConsoleChannelEQ stereo;stereo.prepare(48000.); + enable(stereo,Slot::Bell3,1000.,6.); + std::vector l(2048),r(2048); + for(std::size_t i=0;i memL(512,0.1f),memR(512,-0.1f); + for(std::size_t frames: {std::size_t(32),std::size_t(64), + std::size_t(128),std::size_t(512)}) { + audioActive.store(true,std::memory_order_relaxed); + stereo.processStereo(memL.data(),memR.data(),frames); + audioActive.store(false,std::memory_order_relaxed); + } + check(audioAllocations.load(std::memory_order_relaxed)==0, + "no audio-thread heap allocations"); + check(stereo.setEnabled(Slot::Bell3,false),"bypass command accepted"); + // Allow the existing 10ms dual-path bypass ramp to complete. + float silence[1024]{}; + stereo.processMono(silence,1024); + float clean[1]{0.25f}; + stereo.processMono(clean,1); + check(std::abs(clean[0]-0.25f)<0.001f,"bypassed band transparent after fade"); + + // Retain fixed slots and finite values over common live sample rates. + for(double rate: {44100.,48000.,96000.}) { + ConsoleChannelEQ instance; + instance.prepare(rate); + enable(instance,Slot::Bell4,3000.,-6.); + float pcm[128]{}; + pcm[0]=1.0f; + instance.processMono(pcm,128); + for(float v:pcm)check(std::isfinite(v),"common sample rates stable"); + } + std::puts("ArSonEQ isolated 9-slot console EQ tests passed"); +}