refactor: move the v2 controller to the repository root

The ESP-IDF project, docs, tools, tests and web UI move from v2/ to the
root, and the Makefile, README, build scripts and test runner drop the
v2/ prefix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jimmyandClaude Opus 5.5 committed 2026-11-02 23:44:58 +13:00
1 parent 71bd320661
commit 1c222771a5
66 files changed
+30 -31

No files matched your search

+1
View File
@@ -0,0 +1 @@
<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Audio and beats</title><style>body{font-family:sans-serif;max-width:32em;margin:2em auto;padding:0 1em}td{padding:.2em 1em .2em 0}#bar{height:1.5em;background:#ddd;border-radius:4px;overflow:hidden}#fill{height:100%;width:0;background:#2a9d4b;transition:width .2s}.dot{display:inline-block;width:3em;height:3em;border-radius:50%;background:#ddd;vertical-align:middle}#onset{width:1.2em;height:1.2em;margin-left:1em}.bb{display:inline-block;width:1.6em;height:1.6em;line-height:1.6em;text-align:center;border-radius:4px;background:#eee;margin-right:.3em;font-size:.9em}.bb.on{background:#457b9d;color:#fff}.bb.one.on{background:#e63946}#barpos.guess .bb{opacity:.45}#tl{width:100%;height:90px;background:#f4f4f4;border-radius:4px}kbd{border:1px solid #bbb;border-radius:3px;padding:0 .3em}@keyframes down{from{background:#e63946;box-shadow:0 0 0 .5em #e6394655}to{background:#ddd}}#beat.down{animation:down .5s}@keyframes beat{from{background:#e63946}to{background:#ddd}}@keyframes onset{from{background:#457b9d}to{background:#ddd}}#beat.on{animation:beat .3s}#onset.on{animation:onset .15s}</style></head><body><p><a href="/">&larr; Controller</a></p><h1>Audio and beats</h1><table><tr><td>IP</td><td id="ip"></td></tr><tr><td>MAC</td><td id="mac"></td></tr><tr><td>Uptime</td><td id="up"></td></tr><tr><td>Free heap</td><td id="heap"></td></tr><tr><td>Mic RMS</td><td id="rms"></td></tr><tr><td>Mic peak</td><td id="peak"></td></tr><tr><td>Approx. SPL</td><td id="spl"></td></tr><tr><td>Tempo</td><td id="bpm">&ndash;</td></tr><tr><td>Confidence</td><td id="conf"></td></tr><tr><td>Time</td><td id="meter">&ndash;</td></tr></table><div id="bar"><div id="fill"></div></div><p><span class="dot" id="beat"></span><span class="dot" id="onset"></span></p><p id="barpos"></p><p><button id="tap" title="Press on the first beat of a bar to correct the bar position (or press T)">Tap beat 1</button></p><h2>You vs the computer</h2><p>Press <kbd>Space</kbd> on every beat.</p><canvas id="tl"></canvas><table><tr><td>Your tempo</td><td id="ytempo">&ndash;</td></tr><tr><td>Your timing</td><td id="yoff">&ndash;</td></tr><tr><td>Agreement</td><td id="ymatch">&ndash;</td></tr></table><p><button id="listen">Listen</button> <span id="lat"></span></p><p><a href="/status">/status</a> (JSON) &middot; <a href="/audio.wav">/audio.wav</a> (live) &middot; <a href="/beats">/beats</a> (event stream)</p><script>const $=id=>document.getElementById(id);async function tick(){try{const s=await(await fetch('/status')).json();$('ip').textContent=s.ip;$('mac').textContent=s.mac;$('up').textContent=s.uptime_s+' s';$('heap').textContent=s.free_heap+' bytes';$('rms').textContent=s.mic_rms_dbfs.toFixed(1)+' dBFS';$('peak').textContent=s.mic_peak_dbfs.toFixed(1)+' dBFS';$('spl').textContent=s.mic_spl_db.toFixed(0)+' dB';$('fill').style.width=Math.max(0,Math.min(100,(s.mic_rms_dbfs+90)/90*100))+'%';}catch(e){}setTimeout(tick,250)}tick();function flash(id,c){const d=$(id);d.classList.remove('on','down');void d.offsetWidth;d.classList.add(c||'on');}function bar(m,n){const b=$('barpos');if(b.children.length!=m){b.innerHTML='';for(let i=1;i<=m;i++){const s=document.createElement('span');s.className='bb'+(i==1?' one':'');s.textContent=i;b.appendChild(s);}}[...b.children].forEach((s,i)=>s.classList.toggle('on',i+1==n));}function tap(){fetch('/tap',{method:'POST'});}$('tap').addEventListener('pointerdown',e=>{e.preventDefault();tap();});document.addEventListener('keydown',e=>{if((e.key=='t'||e.key=='T')&&!e.repeat)tap();});let off=null,rtt=1e9,cbpm=0;const comp=[],taps=[];async function sync(){rtt*=1.5;for(let i=0;i<4;i++){try{const a=performance.now(),r=await(await fetch('/time',{cache:'no-store'})).json(),b=performance.now();if(b-a<=rtt){rtt=b-a;off=(a+b)/2-r.us/1000;}}catch(e){}}}sync();setInterval(sync,15000);document.addEventListener('keydown',e=>{if(e.code=='Space'){e.preventDefault();if(!e.repeat)taps.push(performance.now());}});document.addEventListener('keyup',e=>{if(e.code=='Space')e.preventDefault();});function median(a){if(!a.length)return null;const s=[...a].sort((x,y)=>x-y);return s[s.length>>1];}function stats(now){const lim=now-20000;while(comp.length&&comp[0].t<lim)comp.shift();while(taps.length&&taps[0]<lim)taps.shift();const iv=[];for(let i=1;i<taps.length;i++){const d=taps[i]-taps[i-1];if(d>=300&&d<=1000)iv.push(d);}const ti=median(iv.slice(-8));$('ytempo').textContent=ti?(60000/ti).toFixed(1)+' BPM (computer '+(cbpm?cbpm.toFixed(1):'-')+')':'-';const pairs=[];for(const t of taps){if(now-t<400)continue;let b=null;for(const c of comp)if(b===null||Math.abs(c.t-t)<Math.abs(b-t))b=c.t;if(b!==null)pairs.push([t,b]);}const rec=pairs.slice(-16),hit=rec.filter(p=>Math.abs(p[0]-p[1])<=70).map(p=>p[0]-p[1]);if(hit.length){const m=hit.reduce((a,b)=>a+b,0)/hit.length,sd=Math.sqrt(hit.reduce((a,b)=>a+(b-m)*(b-m),0)/hit.length);$('yoff').textContent=(m>=0?'+':Line truncated