Soundcn
blockback-003source: ok · refreshed
Back 003
A brief, crisp sound indicating a backward navigation or an action reversal within an application.
npx shadcn add "https://soundcn.xyz/r/back-003.json"free
No selection tags yet — empty means no evidence, not lack of support.
Files3 · source cached 10/2/2026, 1:23:16 AM
registry/soundcn/sounds/back-003/back-003.ts
import type { SoundAsset } from "@/lib/sound-types";
export const back003Sound: SoundAsset = {
name: "back-003",
dataUri: "data:audio/mpeg;base64,SUQzBAAAAAAAIlRTU0UAAAAOAAADTGF2ZjYyLjMuMTAwAAAAAAAAAAAAAAD/+1DAAAAAAAAAAAAAAAAAAAAAAABJbmZvAAAADwAAAAUAAATkAFVVVVVVVVVVVVVVVVVVVVVVVVV/f39/f39/f39/f39/f39/f39/f6qqqqqqqqqqqqqqqqqqqqqqqqqq1dXV1dXV1dXV1dXV1dXV1dXV1dX//////////////////////////wAAAABMYXZjNjIuMTEAAAAAAAAAAAAAAAAkBMAAAAAAAAAE5Hd3BbcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//tQxAAABXwXSPQxgAIULG2XHrAAAiYU2pIhbu7u4AIDFYOAgCDsQHOJw/4PwQDHnP8uD5rwx/wfP/u//4P//9+AE66CSENoyQ0S7FMzkIKVDznNI6HBWkJJsozQkCYdQggTiYOs+0uLjMuPexh52jdqovhhufIAejxoUaqNp2991ko6szyld7f3vuu3Nk2NTVsNa5rYYz//qZ/lrWt/4hzGV//xb2rnr+Yhjnff8e/3///8wkeGVCIAiy2NoQ53/8At/+gwAkfPP/CoMBYVhf/7UsQFAAvQe3C4lIABYo4tAxiQAEoDwMhVGPhZABoMkBslZJhLiEyae0Ta0i1r+6/8v6tPEowpaaU1l4pwWGPKg7LEcAiEFmhI6FQZBFLWRcyesIh3WKgAxw6ddkiJ7nWt7bWM5tjGeaBsKRFEIdiaCAekM7MhKEocyIgl04NBkNFUkZzGkGNIHbnknnvM91bKyT4rLzdQOGQmZg0SgFkDCQJBYiARVhoFhM2gVRrFeKgVj+aO8WP9REb0HVC31o/N1QCPxz+x9GRGLERmLBaT//tSxAcAC+yHYrjEgAGEIGlnHqAAzthcMh8KjZZLY6PEqJdQSGTRhz8dufNz0vnrGmXtMxqMZZOpRaajv7jLkjsFgCHCocMnBZAOAtgyFD9Bo9wMEgriwDCDewzxcVFm6hIsUbxVQAAAElCEiiCAADsXwoU009EmKhzF+Xttdq38GsCwhLYNwhAvxWIi/JSMwQBCpKReMiEVxiLSHKpvxNMJSZC6Icv+p48Ih4P25yV/lzFZVU4t//+hKTJcoV/+kVGsoe///QoAJQJFxysAPFz/+1LEBIAKmGreOfMAAZUwI5c2oABedAEcXuA3BwCpY1B1+BItnLK2EOTgvg5woNJkErIkECWf9AyU6Zn//5dICFZF+XFggsXL+PAjHwy71oyld5/5p6tF4jSQ6f7/gR2gAANAAApB+FIPo08sHiD/5YQXVz/79f7XN4IQFntBvC9EP98GwGoGgRf28WRbHg2Fj/8fjUfkBMPP/88lJzCYkP///JScwuSKWJ0///8uYpY9C5ilj/////5cxB8CIPgT////0B8ACADFkCSPDCxAvP/7UsQFgAmlERA5MoAAAAA0g4AABH8dvgKFeBg8F/gURGB7/EhodERn/iwkoqVP/xYxxUpDf/5jlKQxjl///ESB4SOHREgeEn/+VDQNAUNA0BQ1//waAtVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",
duration: 0.090,
format: "mp3",
license: "CC0",
author: "Kenney",
};
registry/soundcn/lib/sound-types.ts
export interface SoundAsset {
/** Unique identifier for the sound */
name: string;
/** Base64-encoded data URI (data:audio/mpeg;base64,...) */
dataUri: string;
/** Duration in seconds */
duration: number;
/** Audio format */
format: "mp3" | "wav" | "ogg";
/** License identifier */
license: "CC0" | "OGA-BY" | "MIT";
/** Original author/creator */
author: string;
}
export interface UseSoundOptions {
/** Volume level from 0 to 1. Default: 1 */
volume?: number;
/** Playback speed multiplier. Default: 1 */
playbackRate?: number;
/** If true, calling play() stops current playback first. Default: false */
interrupt?: boolean;
/** If false, play() does nothing. Useful for user preferences. Default: true */
soundEnabled?: boolean;
/** Called when playback starts */
onPlay?: () => void;
/** Called when playback ends naturally */
onEnd?: () => void;
/** Called when pause() is called */
onPause?: () => void;
/** Called when stop() is called */
onStop?: () => void;
}
export type PlayFunction = (overrides?: {
volume?: number;
playbackRate?: number;
}) => void;
export interface SoundControls {
stop: () => void;
pause: () => void;
isPlaying: boolean;
duration: number | null;
sound: SoundAsset;
}
export type UseSoundReturn = readonly [PlayFunction, SoundControls];
registry/soundcn/lib/sound-engine.ts
let audioContext: AudioContext | null = null;
const bufferCache = new Map<string, AudioBuffer>();
export function getAudioContext(): AudioContext {
if (!audioContext) {
audioContext = new AudioContext();
}
return audioContext;
}
export async function decodeAudioData(dataUri: string): Promise<AudioBuffer> {
const cached = bufferCache.get(dataUri);
if (cached) return cached;
const ctx = getAudioContext();
const base64 = dataUri.split(",")[1];
const binaryString = atob(base64);
const bytes = new Uint8Array(binaryString.length);
for (let i = 0; i < binaryString.length; i++) {
bytes[i] = binaryString.charCodeAt(i);
}
const audioBuffer = await ctx.decodeAudioData(bytes.buffer.slice(0));
bufferCache.set(dataUri, audioBuffer);
return audioBuffer;
}
export interface PlaySoundOptions {
volume?: number;
playbackRate?: number;
onEnd?: () => void;
}
export interface SoundPlayback {
stop: () => void;
}
export async function playSound(
dataUri: string,
options: PlaySoundOptions = {}
): Promise<SoundPlayback> {
const { volume = 1, playbackRate = 1, onEnd } = options;
const ctx = getAudioContext();
if (ctx.state === "suspended") {
await ctx.resume();
}
const buffer = await decodeAudioData(dataUri);
const source = ctx.createBufferSource();
const gain = ctx.createGain();
source.buffer = buffer;
source.playbackRate.value = playbackRate;
gain.gain.value = volume;
source.connect(gain);
gain.connect(ctx.destination);
source.onended = () => {
onEnd?.();
};
source.start(0);
return {
stop: () => {
try {
source.stop();
} catch {
// No-op if already stopped.
}
},
};
}