Dough Git

commit

Why was that so hard... RAHHH

commit
1b1948db5e0e731a66fb5c99aaf4f984e02c92ed
author
Clove Twilight <[email protected]>
date
2026-08-24 19:23

diff --git a/apps/web/src/app.ts b/apps/web/src/app.ts
index 2d793bf..d740a3b 100644
--- a/apps/web/src/app.ts
+++ b/apps/web/src/app.ts
@@ -268,7 +268,6 @@ async function boot(): Promise<void> {
   restoreNowPlaying();
   handleLastfmRedirect();
   render();
-  startVisualizer();
 }
 
 // Back/forward: the URL is already correct, so just re-derive the view from
@@ -1840,7 +1839,6 @@ function mountPlayerBar(el: HTMLElement, song: Song): void {
             ? `<img class="cover" src="${song.coverUrl}" alt="" />`
             : `<div class="cover cover-empty"><i class="bi bi-music-note-beamed"></i></div>`
         }
-        <canvas class="pb-viz" id="pb-viz"></canvas>
       </div>
       <div class="song-meta">
         <span class="song-title">${escapeHtml(song.title)}</span>
@@ -1955,40 +1953,6 @@ function updatePlayerBar(): void {
   updateVolumeIcon();
 }
 
-// Frequency-bar visualizer painted behind the player bar while a track plays.
-function startVisualizer(): void {
-  const draw = () => {
-    const canvas = document.getElementById("pb-viz") as HTMLCanvasElement | null;
-    const analyser = player.getAnalyser();
-    if (canvas && analyser) {
-      const ctx = canvas.getContext("2d");
-      if (ctx) {
-        const w = (canvas.width = canvas.clientWidth);
-        const h = (canvas.height = canvas.clientHeight);
-        ctx.clearRect(0, 0, w, h);
-        if (player.playing) {
-          const bins = analyser.frequencyBinCount;
-          const data = new Uint8Array(bins);
-          analyser.getByteFrequencyData(data);
-          // Dim the art a touch so the bars read on top of it.
-          ctx.fillStyle = "rgba(0, 0, 0, 0.32)";
-          ctx.fillRect(0, 0, w, h);
-          const n = 14;
-          const bw = w / n;
-          ctx.fillStyle = "rgba(120, 200, 140, 0.95)"; // green equalizer
-          for (let i = 0; i < n; i++) {
-            const idx = Math.floor((i / n) * bins);
-            const bh = Math.max(2, (data[idx]! / 255) * h);
-            ctx.fillRect(i * bw + bw * 0.18, h - bh, bw * 0.64, bh);
-          }
-        }
-      }
-    }
-    requestAnimationFrame(draw);
-  };
-  requestAnimationFrame(draw);
-}
-
 function updateVolumeIcon(): void {
   const icon = document.querySelector("#mute i");
   if (!icon) return;
diff --git a/apps/web/src/styles.css b/apps/web/src/styles.css
index d086935..1e03795 100644
--- a/apps/web/src/styles.css
+++ b/apps/web/src/styles.css
@@ -461,7 +461,7 @@ button {
   margin: auto;
 }
 
-/* Visualizer overlaid on the now-playing album cover */
+/* Now-playing album cover in the player bar */
 .pb-cover {
   position: relative;
   width: 44px;
@@ -469,15 +469,6 @@ button {
   flex-shrink: 0;
 }
 
-.pb-viz {
-  position: absolute;
-  inset: 0;
-  width: 100%;
-  height: 100%;
-  border-radius: 6px;
-  pointer-events: none;
-}
-
 .pb-song {
   display: flex;
   align-items: center;
diff --git a/package.json b/package.json
index 92fa937..8464c64 100644
--- a/package.json
+++ b/package.json
@@ -14,11 +14,11 @@
     "migrate": "bun run --filter @musicapp/server migrate",
     "typecheck": "bun run --filter '*' typecheck",
     "tauri": "tauri",
-    "desktop:dev": "cd apps/desktop/src-tauri && cargo tauri dev",
-    "desktop:build": "cd apps/desktop/src-tauri && cargo tauri build",
-    "android:init": "cd apps/desktop/src-tauri && cargo tauri android init",
-    "android:dev": "cd apps/desktop/src-tauri && cargo tauri android dev",
-    "android:build": "cd apps/desktop/src-tauri && cargo tauri android build --apk"
+    "desktop:dev": "cd apps/desktop/src-tauri && bunx tauri dev",
+    "desktop:build": "cd apps/desktop/src-tauri && bunx tauri build",
+    "android:init": "cd apps/desktop/src-tauri && bunx tauri android init",
+    "android:dev": "cd apps/desktop/src-tauri && bunx tauri android dev",
+    "android:build": "cd apps/desktop/src-tauri && bunx tauri android build --apk"
   },
   "dependencies": {
     "@dotenvx/dotenvx": "^2.19.1"
diff --git a/packages/player/src/player.ts b/packages/player/src/player.ts
index 888c0ab..eee5ec4 100644
--- a/packages/player/src/player.ts
+++ b/packages/player/src/player.ts
@@ -1,12 +1,12 @@
 // Controller around a single <audio> element, with shuffle, repeat, volume.
 // Works unchanged in a browser tab or a Tauri desktop webview — both give
-// us a real HTMLAudioElement/AudioContext/localStorage, so there's no
+// us a real HTMLAudioElement/localStorage, so there's no
 // platform abstraction here beyond the injectable prefs storage.
 
 import type { Song } from "@musicapp/shared";
 
 import { Emitter } from "./events.ts";
-import { createAudioElement, hasNativeHost, type MediaEl } from "./native-audio.ts";
+import { createAudioElement, type MediaEl } from "./native-audio.ts";
 import { localStoragePrefs, type Prefs, type PrefsStorage } from "./storage.ts";
 
 export type RepeatMode = Prefs["repeat"];
@@ -36,8 +36,6 @@ export class Player {
   private readonly maxRecoverAttempts = 4;
   private stallTimer: ReturnType<typeof setTimeout> | null = null;
   private prefs: Prefs;
-  private ctx: AudioContext | null = null;
-  private analyser: AnalyserNode | null = null;
   // iOS ignores HTMLMediaElement.volume (hardware-controlled). Detect so the
   // UI can hide the volume slider there.
   readonly volumeSupported = !isIOS();
@@ -316,11 +314,6 @@ export class Player {
     }
   }
 
-  // Web Audio analyser for the visualizer. Exposed for the canvas draw loop.
-  getAnalyser(): AnalyserNode | null {
-    return this.analyser;
-  }
-
   // Snapshot of the current session, for resume-after-reload.
   snapshot(): { ids: string[]; index: number; position: number } | null {
     if (!this.current) return null;
@@ -355,46 +348,12 @@ export class Player {
     this.events.emit("change");
   }
 
-  // Build the Web Audio graph once (source -> analyser -> speakers). Wrapped so
-  // any failure leaves plain <audio> playback untouched.
-  private setupGraph(): void {
-    if (this.ctx) return;
-    // Native (Android) audio can't be tapped by Web Audio; skip entirely so we
-    // don't construct a throwaway AudioContext on every track (which would leak
-    // contexts and eventually hit the browser's hard limit).
-    if (hasNativeHost()) return;
-    try {
-      const Ctx =
-        window.AudioContext ||
-        (window as unknown as { webkitAudioContext: typeof AudioContext })
-          .webkitAudioContext;
-      const ctx = new Ctx();
-      // Only a real HTMLMediaElement can feed Web Audio. With the native
-      // backend this throws and we fall through to the catch — the visualizer
-      // is simply disabled on Android (native owns the audio pipeline).
-      const src = ctx.createMediaElementSource(this.audio as unknown as HTMLMediaElement);
-      const analyser = ctx.createAnalyser();
-      analyser.fftSize = 128;
-      analyser.smoothingTimeConstant = 0.8;
-      src.connect(analyser);
-      analyser.connect(ctx.destination);
-      this.ctx = ctx;
-      this.analyser = analyser;
-    } catch {
-      this.ctx = null;
-      this.analyser = null;
-    }
-  }
-
   // Play the current element and surface only *real* failures. `token` ties
   // this attempt to the load() that started it: if a newer track has since
   // loaded, the play() promise rejects with AbortError and we ignore it (it
   // was superseded on purpose). A genuine "element wasn't ready yet" abort is
   // retried once on `canplay`; autoplay-policy blocks get a friendlier note.
   private tryPlay(token = this.playToken, retried = false): void {
-    this.setupGraph();
-    void this.ctx?.resume();
-
     const p = this.audio.play();
     if (!p || typeof p.catch !== "function") return;