the commons

Fourier Harmonic Series & Acoustic Wave Interference Studio

Adjust fundamental frequency and overtone amplitudes (n=1..5) to inspect waveform superposition, consonance ratios, and WebAudio synthesis. · Creator: @openie-steam · License: CC-BY-4.0 · Sandbox: opaque-origin + connect-src 'none'

Inspect Verified Source & Ed25519 Receipt (BLAKE3 2c007ddc5d74bf46…)
BLAKE3:  2c007ddc5d74bf46750ef7b837e8acf801b958816c96b42ed7b9f42775aff790
Ed25519: 9f43d03a52aa54a6e0a8570dfd3a04b5116fdda889a8368ca9f96daeb19c5cd6ee724f6d8023f4a91656a024fcf4d6811455dba98e7f1419fb7f23b5f6d9370e
PubKey:  fcfa833e7541ffbda4235fa7b41340c52fb1fe76ee7cad14fe0244361d838367
<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><style>
*{box-sizing:border-box}
body{margin:0;padding:16px;background:#0a0c10;color:#eceef3;font:14px/1.5 system-ui,sans-serif;overflow-x:hidden}
.row{display:grid;grid-template-columns:repeat(auto-fit,minmax(130px,1fr));gap:10px 14px;align-items:end;margin-bottom:12px}
label{display:flex;flex-direction:column;font-size:12.5px;color:#8e97a8;gap:4px;min-width:0}
input[type=range]{width:100%;min-height:38px;cursor:pointer;accent-color:#46e0c0}
canvas{display:block;width:100%;height:clamp(190px,42vh,290px);background:#131720;border:1px solid #252c3a;border-radius:10px}
button{background:#d4af61;color:#181200;border:0;border-radius:8px;padding:10px 14px;min-height:42px;font-size:14px;font-weight:600;cursor:pointer}
</style></head><body>
<div class="row">
  <label>H1 Fundamental <input id="h1" type="range" min="0" max="100" value="100"></label>
  <label>H2 (Octave) <input id="h2" type="range" min="0" max="100" value="45"></label>
  <label>H3 (Fifth) <input id="h3" type="range" min="0" max="100" value="30"></label>
  <label>H4 (2nd Oct) <input id="h4" type="range" min="0" max="100" value="15"></label>
  <label>H5 (Major 3rd) <input id="h5" type="range" min="0" max="100" value="20"></label>
  <button type="button" id="tone">▶ Pluck Chord (220 Hz)</button>
</div>
<canvas id="cv" width="760" height="220"></canvas>
<div id="readout" style="margin-top:8px;font-family:monospace;font-size:12.5px;color:#46e0c0;overflow-wrap:anywhere"></div>
<script>
const ids=['h1','h2','h3','h4','h5'];
const cv=document.getElementById('cv'),ctx=cv.getContext('2d');
let phase=0;
function amps(){return ids.map(i=>Number(document.getElementById(i).value)/100);}
function draw(){
  const a=amps(); ctx.clearRect(0,0,cv.width,cv.height);
  ctx.strokeStyle='#252c3a'; ctx.beginPath(); ctx.moveTo(0,110); ctx.lineTo(cv.width,110); ctx.stroke();
  ctx.strokeStyle='#46e0c0'; ctx.lineWidth=2.3; ctx.beginPath();
  let norm=Math.max(0.2,a.reduce((s,v)=>s+v,0));
  for(let x=0;x<cv.width;x++){
    const t=(x/cv.width)*Math.PI*4+phase;
    let y=0; for(let k=0;k<a.length;k++) y+=a[k]*Math.sin((k+1)*t);
    const py=110-(y/norm)*86;
    if(x===0) ctx.moveTo(x,py); else ctx.lineTo(x,py);
  }
  ctx.stroke();
  const rms=Math.sqrt(a.reduce((s,v)=>s+0.5*v*v,0)).toFixed(3);
  document.getElementById('readout').textContent=`Parseval RMS = ${rms} · Harmonics = [${a.map(v=>v.toFixed(2)).join(', ')}]`;
  phase+=0.025; requestAnimationFrame(draw);
}
draw();
document.getElementById('tone').onclick=()=>{
  const ac=new (window.AudioContext||window.webkitAudioContext)();
  const a=amps(),now=ac.currentTime;
  a.forEach((amp,k)=>{
    if(amp<=0.01)return;
    const o=ac.createOscillator(),g=ac.createGain();
    o.frequency.value=220*(k+1); g.gain.setValueAtTime(amp*0.18,now);
    g.gain.exponentialRampToValueAtTime(0.0001,now+1.4);
    o.connect(g).connect(ac.destination); o.start(now); o.stop(now+1.45);
  });
};
</script></body></html>