Music for your game.
Your game stays in control.

Give your browser game a soundtrack from LoftwahFM’s public stations. Try the small night-sea game in the demo, then hand your coding agent a working starter configured the same way.

No account or key. No sound until you press Play. This is a streaming proof of concept, not a grant to bundle or redistribute the audio.

Hear it before you build.

The demo is a small playable scene: Signal run. Steer a skiff down a night sea with arrow keys, WASD or the on-screen controls, and clear five signal gates by aiming for their lit gaps. Each clean gate scores; clipping one costs the points, thuds, and ducks the music. Clear all five to finish a run, then sail again slightly faster.

The scene, movement, gates and oscillator sound effects all run locally and keep working when the music cannot load. Music stays separate: choose one of the real public stations, then Play, pause or mute it independently.

The demo’s Copy setup and Download starter actions produce the starter below with your chosen station, music volume and duck depth written into it, so the exported file is ready to serve as your own page.

The Woodhouse copy runs on a separate origin and may trail this page’s demo. It is a demonstration of the integration, not an independently adopted game. Source: LoftwahFM’s public demo, pinned to SDK 1.2.0.

Low Tide in motion. An animated station illustration, not filmed coastline. Its sound is separate from the station’s music. The original artwork is credited to Woodhouse · GPT Image 2.6 via Fal; it was animated with MiniMax H3 Max Turbo in Media Studio. Listen to Low Tide.

These links open the listener without starting sound. Read the station catalogue or browse the public audio catalogue. The demo’s station chooser reads that same catalogue when it answers and falls back to this documented list when it does not, so it never invents a station. Change the station ID and URL in the starter to use another one.

Start with one HTML file.

Save this as an HTML file and serve it from your game’s local web server. It loads the pinned browser SDK directly, streams one station through a host-owned Web Audio music bus, and exposes an optionalgameMusic.duck() helper for game effects. The marked setup values at the top are the whole configuration.

What is optional is exactly what should be: if the SDK, the station manifest or the media fail, the page reports it quietly and your game keeps running. Nothing here starts sound before an explicit Play, and ducking only touches gain, so music the listener paused stays paused. The playable demo adds the scene, movement, gates, sound effects, a station chooser and the configured export on top of this file.

Download this starter

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="robots" content="noindex,nofollow" />
    <title>My game music</title>
    <style>
      body {
        font: 16px/1.5 system-ui;
        background: #0b0e14;
        color: #eef2fa;
        margin: 0;
        padding: 24px;
      }
      button {
        padding: 12px 16px;
        margin: 4px 6px 4px 0;
        min-height: 44px;
        border: 1px solid #33456b;
        border-radius: 8px;
        background: #131c2e;
        color: inherit;
        font: inherit;
      }
      button:disabled {
        opacity: 0.45;
      }
      #status {
        min-height: 1.5em;
      }
      .note {
        color: #95a3bd;
        font-size: 0.9rem;
        max-width: 60ch;
      }
    </style>
  </head>
  <body>
    <button id="play" disabled>Play music</button>
    <button id="pause" disabled>Pause music</button>
    <button id="mute" disabled>Mute music</button>
    <p id="status" role="status">Loading music…</p>
    <p class="note">
      Music is optional. This file keeps its own buttons and stream; your game
      keeps its own gameplay, effects and offline audio. Game sound is never
      routed through this file, and no sound starts until Play is pressed.
    </p>

    <script type="module">
      // LoftwahFM setup — change the marked values to suit your game.
      const STATION_ID = "night-signal"; /*fm:station-id*/
      const STATION_URL =
        "https://fm.loftwah.com/api/radio/v1/stations/night-signal/current"; /*fm:station-url*/
      const MUSIC_VOLUME = 0.65; /*fm:volume*/
      const DUCK_LEVEL = 0.35; /*fm:duck-level*/ // 0 disables ducking; try 0.55 light, 0.35 standard, 0.2 deep
      const DUCK_DOWN_MS = 40; // ramp down to DUCK_LEVEL
      const DUCK_UP_MS = 250; // ramp back to full music gain
      // Optional: for a station mix, use
      // https://fm.loftwah.com/api/radio/v1/stations/all-stations/current?include=night-signal,low-tide
      // and keep STATION_ID as "all-stations". The published station list is at
      // https://fm.loftwah.com/api/radio/v1/stations.

      const play = document.querySelector("#play");
      const pause = document.querySelector("#pause");
      const mute = document.querySelector("#mute");
      const status = document.querySelector("#status");

      // ── Host audio owned by this page ───────────────────────────────────────────
      // One AudioContext, one music bus. The music bus is where ducking happens, so
      // an impact can lower the music without touching the element's own play state.
      let context = null;
      let musicBus = null;
      const duck = {
        from: 1,
        to: 1,
        downStart: -1e9,
        downEnd: -1e9,
        upEnd: -1e9,
      };

      function duckLevelNow() {
        const time = performance.now();
        if (time >= duck.upEnd) return 1;
        if (time < duck.downEnd) {
          const down = duck.downEnd - duck.downStart;
          return down <= 0
            ? duck.to
            : duck.from +
                (duck.to - duck.from) * ((time - duck.downStart) / down);
        }
        const up = duck.upEnd - duck.downEnd;
        return up <= 0
          ? 1
          : duck.to + (1 - duck.to) * ((time - duck.downEnd) / up);
      }

      /**
       * Optional helper for your game's effects. Gain only: it never calls play(),
       * pause() or resume(), so music the listener paused stays paused through any
       * number of impacts.
       */
      function duckMusic(
        level = DUCK_LEVEL,
        downMs = DUCK_DOWN_MS,
        upMs = DUCK_UP_MS,
      ) {
        const time = performance.now();
        duck.from = duckLevelNow();
        duck.to = Math.max(0, Math.min(1, level));
        duck.downStart = time;
        duck.downEnd = time + Math.max(1, downMs);
        duck.upEnd = duck.downEnd + Math.max(1, upMs);
        if (musicBus && context) {
          const at = context.currentTime;
          musicBus.gain.cancelScheduledValues(at);
          musicBus.gain.setValueAtTime(duck.from, at);
          musicBus.gain.linearRampToValueAtTime(
            duck.to,
            at + Math.max(1, downMs) / 1000,
          );
          musicBus.gain.linearRampToValueAtTime(
            1,
            at + (Math.max(1, downMs) + Math.max(1, upMs)) / 1000,
          );
        }
        return duckLevelNow();
      }

      // Host-gain transport, copied from LoftwahFM's examples/radio/host-gain-transport.mjs
      // (pinned SDK 1.2.0). The host owns the context, the music bus and teardown;
      // this adapter only disconnects its own two nodes.
      function createHostGainTransport(
        audio,
        audioContext,
        output,
        nativeFactory,
      ) {
        audio.crossOrigin = "anonymous";
        audio.loop = false;
        const native = nativeFactory(audio);
        const source = audioContext.createMediaElementSource(audio);
        const gain = audioContext.createGain();
        source.connect(gain);
        gain.connect(output);
        let revision = 0;
        let disposed = false;
        return {
          load(item, token) {
            if (disposed) return;
            revision++;
            native.load(item, token);
          },
          async play(signal) {
            if (disposed || signal.aborted) return;
            const attempt = ++revision;
            const cancel = () => {
              if (attempt === revision && !disposed) native.pause();
            };
            signal.addEventListener("abort", cancel, { once: true });
            try {
              // Both admission calls happen synchronously in the same click stack.
              // Do not await resume before calling HTMLMediaElement.play().
              const resumed =
                audioContext.state === "running"
                  ? Promise.resolve()
                  : audioContext.resume();
              const playing = native.play(signal);
              await Promise.all([resumed, playing]);
              if (signal.aborted) cancel();
              if (audioContext.state !== "running" && !signal.aborted)
                throw new Error("host_context_not_running");
            } catch (error) {
              if (attempt === revision && !disposed) native.pause();
              throw error;
            } finally {
              signal.removeEventListener("abort", cancel);
            }
          },
          pause() {
            revision++;
            native.pause();
          },
          gain(volume, muted) {
            if (disposed) return;
            const level = Number.isFinite(volume)
              ? Math.max(0, Math.min(1, volume))
              : 0;
            gain.gain.setValueAtTime(
              muted ? 0 : level,
              audioContext.currentTime,
            );
            native.gain(1, muted); // Never rely on iOS element.volume for attenuation.
          },
          subscribe(listener) {
            return native.subscribe(listener);
          },
          dispose() {
            if (disposed) return;
            disposed = true;
            revision++;
            native.dispose();
            source.disconnect();
            gain.disconnect();
          },
        };
      }

      try {
        const { createRadioClient, createMediaElementTransport } = await import(
          "https://fm.loftwah.com/radio/v1/client/1.2.0/index.js"
        );
        context = new AudioContext();
        musicBus = context.createGain();
        musicBus.gain.value = 1;
        musicBus.connect(context.destination);
        const audio = new Audio(); // one streaming element, owned by this page
        const radio = createRadioClient({
          transport: createHostGainTransport(
            audio,
            context,
            musicBus,
            createMediaElementTransport,
          ),
        });
        radio.preferences({
          enabled: false,
          muted: false,
          speech: false,
          explicit: false,
          volume: MUSIC_VOLUME,
        });
        radio.subscribe((snapshot) => {
          status.textContent = snapshot.item
            ? snapshot.phase + " — " + snapshot.item.title
            : snapshot.phase === "unavailable"
              ? "Music unavailable. Your game can keep going."
              : "Loading music…";
          play.disabled = !snapshot.item || snapshot.phase === "playing";
          pause.disabled = snapshot.phase !== "playing";
          mute.disabled = !snapshot.item;
          mute.textContent = snapshot.preferences.muted
            ? "Unmute music"
            : "Mute music";
        });
        // Fetch before Play. Call play() directly from the player's gesture.
        play.onclick = () => {
          void radio.play();
        };
        pause.onclick = () => radio.pause();
        mute.onclick = () =>
          radio.preferences({ muted: !radio.snapshot().preferences.muted });
        document.addEventListener("visibilitychange", () => {
          if (document.hidden) radio.suspend();
        });
        window.addEventListener("pagehide", () => radio.suspend());
        // Expose only what your effects need; rename to suit your game.
        window.gameMusic = {
          duck: duckMusic,
          duckLevel: duckLevelNow,
          play: () => radio.play(),
          pause: () => radio.pause(),
          dispose: () => radio.dispose(),
        };
        await radio.selectStation(STATION_URL, STATION_ID);
      } catch {
        status.textContent = "Music unavailable. Your game can keep going.";
      }
    </script>
  </body>
</html>

For a bundled game, install the versioned URL package with your usual package manager and keep the lockfile:

npm install https://fm.loftwah.com/radio/v1/client/1.2.0/loftwahfm-radio-client-1.2.0.tgz

SHA-256 integrity manifest · SDK type reference. This is a URL-installed package; it is not published to the npm registry.

Keep your own audio controls.

Public streams support anonymous CORS. Fetch without credentials; set crossOrigin="anonymous" before a media source. If your game has a Content Security Policy, admithttps://fm.loftwah.com for connections and media, plus scripts for the direct-import example and images only if showing artwork. Bundling the SDK needs no added script origin.

Physical iPhone interruption and audible-output checks still belong to your game’s release testing. This starter does not promise offline music, synchronised broadcasting, seamless loops or an audio licence.

Give this to your coding agent.

It names the useful defaults and the checks your game still owns.

Add LoftwahFM streaming music to this browser game using the existing audio owner.
Start with https://fm.loftwah.com/game-music/ and the downloadable demo there.
Pin @loftwahfm/radio-client 1.2.0 from the published URL package and verify integrity.json.
Keep gameplay, sound effects, saved settings and local/offline music independent of FM.
Default to music off, speech:false and explicit:false. Honour existing off/mute before unlocking audio.
Prepare the station before Play; call play() synchronously from a user gesture.
Use one music transport. Preserve the host's music/master gain; use its Web Audio graph for iOS ducking.
The guide's starter routes the element through a host-owned music bus and exposes a gain-only duck helper
(ramp down, ramp back) that must never resume music the listener paused. Copy that shape into the game.
Suspend on hidden/pagehide. Returning to the page must stay quiet until another gesture.
Show the current track, truthful state, a LoftwahFM listener link and a quiet unavailable/retry choice.
For React, own one client in the app audio lifecycle and dispose/unsubscribe on teardown.
For Phaser, use its existing AudioManager and context, not a client per scene.
Test SDK, manifest and media failure separately; movement/SFX must survive all three.
Verify real cross-origin playback, mute/off, pause, hidden return, cleanup and the game's device matrix.
This is public-catalogue streaming; don't bundle audio or claim a music licence or independent adoption.

For a website or showcase with its own visible player, use an embeddable widget. An actual game should own the SDK transport so its mute, effects and lifecycle stay together.