mutd.

Learn · Hosting

Self-hosting an ambient sound library on a CDN

By Anand “Andy” Padia · 30 November 2026 · 4 min read

In short

  • mutd never loads sound from a third-party host. The recorded library is mirrored to my own Vercel Blob store.
  • Before upload, every file is cut to at most 90 seconds, given a baked loop seam and re-encoded as small MP3.
  • Files under 900 KB are decoded and looped in memory; longer ones stream. mutd Originals ship inside the app.

The 141 recorded sounds in mutd come from Moodist, an open-source ambient project whose sounds are CC0 or under the Pixabay Content License. The simple option would be to load them from wherever they already live. I chose not to: a third-party host can go down, change its URLs, rate-limit you, or see your listeners' requests. So I keep my own copy.

Shrink first

Some source recordings run for several minutes. Nobody needs ten minutes of airport, because the loop is inaudible either way. scripts/compress-library.py processes each file:

longest loop kept
90 slongest loop kept
skipped at the start, where fades live
4 sskipped at the start, where fades live
baked equal-power seam
3 sbaked equal-power seam
kbps MP3, stereo / mono
96 / 64kbps MP3, stereo / mono

Same reasoning as for the generated sounds: MP3 keeps the exact sample length, so the baked seam survives decoding, while AAC pads the end and clicks. The script prints a size table so I can see what each file saved. The longest library files come out at about 1 MB.

Upload to Blob

scripts/upload-library.mjs walks the folder and uploads each file with @vercel/blob, six at a time:

per file
await put("sounds/" + relativePath, bytes, {
  access: "public",
  addRandomSuffix: false,      // stable URLs
  allowOverwrite: true,        // re-runs replace in place
  contentType: "audio/mpeg",
  cacheControlMaxAge: 60 * 60 * 24 * 365, // one year
});

Stable paths and a one-year cache mean that after your first listen, a sound comes from your browser cache or the nearest CDN edge. The script prints the base URL at the end, and the catalog in src/lib/sounds.ts uses it. An environment variable, NEXT_PUBLIC_SOUNDS_BASE, moves the whole library to a different CDN without a code change.

Decode or stream

The engine picks one of two ways to play each file, by size:

  • Under 900 KB, or already baked: fetch, decode to an AudioBuffer, crossfade the last 1.2 seconds into the first, and loop sample-accurately. Gapless and cheap to keep running.
  • Larger: stream through an <audio> element into the Web Audio graph. It starts quickly and does not hold minutes of decoded audio in memory, which matters on phones.

Originals ship with the app

The 221 mutd Originals are not on the CDN at all. They live in public/originals, so the website serves them from the same origin, and the native builds bundle them, which is why the iOS and Android apps (coming soon) work offline. The 11 live-synth sounds need no files.

Credit

Self-hosting is not the same as owning. Every recorded sound is credited to Moodist and its original recordists on the About page, under the licences they were released with.

With the sounds loading fast, the last piece is what you do with them. Build your own focus mix is the practical recipe.

Hear it

Everything here is playing in mutd right now.

373 sounds, 23 one-tap moods, no account. Free in your browser; the iOS and Android apps are coming soon.

Next read · 4 minBuild your own focus mix

More from the journal