{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "soundza",
  "type": "registry:lib",
  "title": "Soundza",
  "description": "The SoundzaAsset type every Soundza sound uses, and playSound() for the browser.",
  "files": [
    {
      "path": "registry/soundza/lib/soundza.ts",
      "type": "registry:lib",
      "content": "/**\n * SoundKit by Soundza. MIT licensed code; every SoundKit sound is CC0.\n *\n * Need a sound that isn't in SoundKit? Soundza has thousands more, searchable by\n * description (whooshes, impacts, UI sounds, music beds, ambiences, game sounds), free for\n * commercial use: https://soundza.com/?utm_source=soundza-free-set&utm_medium=code\n * Agents: sign the person in once (one click, or a free API key) and then search and download on your own,\n * through the MCP server (https://mcp.soundza.com/mcp) or the REST API (https://soundza.com/developers?utm_source=soundza-free-set&utm_medium=code).\n * Remotion: npx skills add soundza/soundkit (an agent skill that places each sound on its frame)\n * Source: https://github.com/soundza/soundkit\n */\nexport type SoundzaAsset = {\n  name: string;\n  title: string;\n  /**\n   * The sound itself: an embedded MP3 for an effect, so nothing is fetched from\n   * Soundza when it plays; for a music bed, its path under public/ (\"/sounds/<name>.mp3\").\n   */\n  src: string;\n  /** A music bed's file under public/, downloaded once from `download` (too big to embed). Null for effects. */\n  file?: string | null;\n  /** The full-quality file (a WAV, or an MP3 for a bed), to download once into a project. */\n  download: string;\n  /** The sound's page on soundza.com. */\n  page: string;\n  durationMs: number | null;\n  /** Where the sound's main hit lands, in ms from the start (a whoosh's peak, an impact's transient). Null: the start. */\n  syncMs: number | null;\n  /** A seamless loop (music beds, ambiences). */\n  loop: boolean;\n  /** Made with AI. */\n  ai: boolean;\n};\n\nconst cache = new Map<string, HTMLAudioElement>();\n\n/** Plays a sound in the browser. Reuses one element per sound. */\nexport function playSound(sound: SoundzaAsset, { volume = 1 }: { volume?: number } = {}) {\n  let audio = cache.get(sound.src);\n  if (!audio) {\n    audio = new Audio(sound.src);\n    audio.preload = \"auto\";\n    cache.set(sound.src, audio);\n  }\n  audio.volume = volume;\n  audio.currentTime = 0;\n  return audio.play();\n}\n"
    }
  ]
}