hydra

Terminal replacement for Loopback — virtual audio devices and routing on macOS, from a ratatui TUI.
Log | Files | Refs | README | LICENSE

hydra_mic_probe.js (1436B)


      1 // Paste into Vesktop DevTools console (Cmd+Opt+I) with Hydra selected as input.
      2 // Reports what Chromium's WebRTC capture actually sees from the device — the layer
      3 // shell tools can't reach. Run with Hydra selected, then again with Loopback, compare.
      4 (async () => {
      5   const md = navigator.mediaDevices;
      6   const s = await md.getUserMedia({ audio: { channelCount: 2, echoCancellation:false, noiseSuppression:false, autoGainControl:false } });
      7   const t = s.getAudioTracks()[0];
      8   console.log("[probe] track:", t.label);
      9   console.log("[probe] settings:", JSON.stringify(t.getSettings()));   // channelCount HERE is the truth
     10   // Tap the actual samples per channel
     11   const ac = new AudioContext();
     12   const src = ac.createMediaStreamSource(s);
     13   const sp = ac.createScriptProcessor(4096, 2, 2);
     14   let n=0, peakL=0, peakR=0;
     15   sp.onaudioprocess = e => {
     16     const L=e.inputBuffer.getChannelData(0), R=e.inputBuffer.getChannelData(1);
     17     for (let i=0;i<L.length;i++){ peakL=Math.max(peakL,Math.abs(L[i])); peakR=Math.max(peakR,Math.abs(R[i])); }
     18     if (++n>=20){ sp.disconnect(); src.disconnect(); s.getTracks().forEach(x=>x.stop()); ac.close();
     19       console.log(`[probe] captured peaks  L=${peakL.toFixed(4)}  R=${peakR.toFixed(4)}  ${peakL>0.001&&peakR>0.001?"BOTH ✓":"ONE EAR ✗"}`); }
     20   };
     21   src.connect(sp); sp.connect(ac.destination);
     22   console.log("[probe] listening 2s — make sure audio is routing into Hydra...");
     23 })();