{"_id":"@aperture-engine/audio","_rev":"3-a770542b306eda77c910fb829a5a8118","name":"@aperture-engine/audio","dist-tags":{"latest":"0.3.0"},"versions":{"0.1.0":{"name":"@aperture-engine/audio","version":"0.1.0","keywords":["aperture","ecs","game-engine","typescript","audio","web-audio","spatial-audio"],"author":{"name":"Felix Zhang"},"license":"MIT","_id":"@aperture-engine/audio@0.1.0","maintainers":[{"name":"felixtrz","email":"felixtrz96@gmail.com"}],"homepage":"https://github.com/felixtrz/aperture/tree/main/packages/audio#readme","bugs":{"url":"https://github.com/felixtrz/aperture/issues"},"dist":{"shasum":"454542d2b0df7baf87be048f4d392ffe8eb2b57d","tarball":"https://registry.npmjs.org/@aperture-engine/audio/-/audio-0.1.0.tgz","fileCount":35,"integrity":"sha512-58JtFNR6S9X3Ry/7G47bP7xCfhbIkuokn2oc8QupTyrg+1+N5CK5tWJEFOAj3bS6czysSYwxMamAbypoePA0aQ==","signatures":[{"sig":"MEQCIAhpXEdP7tDkAiCCjmTczM8MjkV/8H3KkYO708zgL2P6AiBILtqrVJSnZ0gW1FKKb1/BD8noOHL1ikRUYBWLIsc8Iw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":294599},"main":"./dist/index.js","type":"module","_from":"file:aperture-engine-audio-0.1.0.tgz","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./test-support":{"types":"./dist/test-support.d.ts","import":"./dist/test-support.js"}},"scripts":{"build":"tsc -p tsconfig.json","typecheck":"tsc --noEmit -p tsconfig.json"},"_npmUser":{"name":"felixtrz","email":"felixtrz96@gmail.com"},"_resolved":"/private/var/folders/xc/nttyc9pj3xngmbjsfbgdbddc0000gn/T/428b979fd95c6a47b4a32382adf47994/aperture-engine-audio-0.1.0.tgz","_integrity":"sha512-58JtFNR6S9X3Ry/7G47bP7xCfhbIkuokn2oc8QupTyrg+1+N5CK5tWJEFOAj3bS6czysSYwxMamAbypoePA0aQ==","repository":{"url":"git+https://github.com/felixtrz/aperture.git","type":"git","directory":"packages/audio"},"_npmVersion":"11.12.1","description":"Main-thread Web Audio realization layer for Aperture: a derived view of the authoritative ECS simulation.","directories":{},"sideEffects":false,"_nodeVersion":"26.0.0","dependencies":{"@aperture-engine/render":"^0.1.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/audio_0.1.0_1782151613577_0.1655504288501053","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@aperture-engine/audio","version":"0.2.0","keywords":["aperture","ecs","game-engine","typescript","audio","web-audio","spatial-audio"],"author":{"name":"Felix Zhang"},"license":"MIT","_id":"@aperture-engine/audio@0.2.0","maintainers":[{"name":"felixtrz","email":"felixtrz96@gmail.com"}],"homepage":"https://github.com/felixtrz/aperture/tree/main/packages/audio#readme","bugs":{"url":"https://github.com/felixtrz/aperture/issues"},"dist":{"shasum":"daf48d8ff9fd171ea3c1b25d3bd1e44175d09a96","tarball":"https://registry.npmjs.org/@aperture-engine/audio/-/audio-0.2.0.tgz","fileCount":35,"integrity":"sha512-B5txyog6+btlDG36zZ6FU6EotnCiuqGH40AAmIoXZg0yRJXCIWmi1FNtztkNvqXpVRy8krY88Ch6Na8CAQtVDw==","signatures":[{"sig":"MEYCIQDTQu2ZJkJeo4+YVzs7Rvcs2lgAWCTXxVpGc9J7QVdHqAIhAKYJnOqWhIcURLURGBDyXCtb7I7tytGb3mFl4hM1jLWE","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":294599},"main":"./dist/index.js","type":"module","_from":"file:aperture-engine-audio-0.2.0.tgz","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./test-support":{"types":"./dist/test-support.d.ts","import":"./dist/test-support.js"}},"scripts":{"build":"tsc -p tsconfig.json","typecheck":"tsc --noEmit -p tsconfig.json"},"_npmUser":{"name":"felixtrz","email":"felixtrz96@gmail.com"},"_resolved":"/private/var/folders/xc/nttyc9pj3xngmbjsfbgdbddc0000gn/T/df0e04dc4b320f58c73d5a80553970fc/aperture-engine-audio-0.2.0.tgz","_integrity":"sha512-B5txyog6+btlDG36zZ6FU6EotnCiuqGH40AAmIoXZg0yRJXCIWmi1FNtztkNvqXpVRy8krY88Ch6Na8CAQtVDw==","repository":{"url":"git+https://github.com/felixtrz/aperture.git","type":"git","directory":"packages/audio"},"_npmVersion":"11.12.1","description":"Main-thread Web Audio realization layer for Aperture: a derived view of the authoritative ECS simulation.","directories":{},"sideEffects":false,"_nodeVersion":"26.0.0","dependencies":{"@aperture-engine/render":"^0.2.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/audio_0.2.0_1782246369066_0.18482682803786954","host":"s3://npm-registry-packages-npm-production"}},"0.3.0":{"name":"@aperture-engine/audio","version":"0.3.0","description":"Main-thread Web Audio realization layer for Aperture: a derived view of the authoritative ECS simulation.","author":{"name":"Felix Zhang"},"repository":{"type":"git","url":"git+https://github.com/felixtrz/aperture.git","directory":"packages/audio"},"homepage":"https://github.com/felixtrz/aperture/tree/main/packages/audio#readme","bugs":{"url":"https://github.com/felixtrz/aperture/issues"},"keywords":["aperture","ecs","game-engine","typescript","audio","web-audio","spatial-audio"],"type":"module","license":"MIT","sideEffects":false,"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./test-support":{"types":"./dist/test-support.d.ts","import":"./dist/test-support.js"},"./package.json":"./package.json"},"main":"./dist/index.js","types":"./dist/index.d.ts","publishConfig":{"access":"public"},"dependencies":{"@aperture-engine/render":"^0.3.0"},"scripts":{"build":"tsc -p tsconfig.json","typecheck":"tsc --noEmit -p tsconfig.json"},"_id":"@aperture-engine/audio@0.3.0","_integrity":"sha512-BHu7XAjVDlFCMdmzXhpqjsS1cflvnEhFzxNsUdoxdkNE8rInRbSlD1YA69mKjTe5l2mMk7sba6F59vK5Q8Thgg==","_resolved":"/private/var/folders/xc/nttyc9pj3xngmbjsfbgdbddc0000gn/T/7992fbb3b9023a2d512c7cf6c51d486e/aperture-engine-audio-0.3.0.tgz","_from":"file:aperture-engine-audio-0.3.0.tgz","_nodeVersion":"26.0.0","_npmVersion":"11.12.1","dist":{"integrity":"sha512-BHu7XAjVDlFCMdmzXhpqjsS1cflvnEhFzxNsUdoxdkNE8rInRbSlD1YA69mKjTe5l2mMk7sba6F59vK5Q8Thgg==","shasum":"f8581c9803b1988580203bc2e9a639a0186c5dab","tarball":"https://registry.npmjs.org/@aperture-engine/audio/-/audio-0.3.0.tgz","fileCount":35,"unpackedSize":294639,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCZuNgR2tBSTaF0eN7MCemjyM9zT93p1a3XRHtQcekl9QIhAIs+FD4e+628TnYNFP+2AjjYXzF3MAjdEk7BpmOyYr6L"}]},"_npmUser":{"name":"felixtrz","email":"felixtrz96@gmail.com"},"directories":{},"maintainers":[{"name":"felixtrz","email":"felixtrz96@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/audio_0.3.0_1783122771164_0.3708044097833447"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-22T18:06:53.366Z","modified":"2026-07-03T23:52:51.407Z","0.1.0":"2026-06-22T18:06:53.710Z","0.2.0":"2026-06-23T20:26:09.215Z","0.3.0":"2026-07-03T23:52:51.298Z"},"bugs":{"url":"https://github.com/felixtrz/aperture/issues"},"author":{"name":"Felix Zhang"},"license":"MIT","homepage":"https://github.com/felixtrz/aperture/tree/main/packages/audio#readme","keywords":["aperture","ecs","game-engine","typescript","audio","web-audio","spatial-audio"],"repository":{"type":"git","url":"git+https://github.com/felixtrz/aperture.git","directory":"packages/audio"},"description":"Main-thread Web Audio realization layer for Aperture: a derived view of the authoritative ECS simulation.","maintainers":[{"name":"felixtrz","email":"felixtrz96@gmail.com"}],"readme":"# @aperture-engine/audio\n\nMain-thread Web Audio realization layer for Aperture: a derived view of the authoritative ECS simulation.\n\n## Install\n\n```sh\npnpm add @aperture-engine/audio\n```\n\nThis package is part of the [Aperture](https://github.com/felixtrz/aperture) WebGPU game engine and is normally used together with the other `@aperture-engine/*` packages (notably `@aperture-engine/render`, which produces the per-frame `RenderSnapshot` this layer consumes).\n\n## What it does\n\nAperture's authoritative simulation runs in a worker; this package is the main-thread audio engine that turns each frame's audio intent into sound. It owns a Web Audio backend, a five-bus submix mixer (`music`, `sfx`, `ui`, `ambient`, `voice`), a decode-once clip cache, and a pooled voice manager with spatial `PannerNode` voices and voice virtualization. Each frame, `applySnapshot` reconciles the live voice graph against the snapshot. It also handles scripted sidechain ducking, game pause vs. tab-hidden suspend, latency compensation, mono downmix, an optional AudioWorklet brickwall limiter, and clip start/end events for captions.\n\n## Usage\n\n```ts\nimport { createAudioEngine } from \"@aperture-engine/audio\";\n\n// Returns a discriminated result so a missing/blocked AudioContext is graceful.\nconst created = createAudioEngine({\n  // Resolve a clip id (e.g. \"audio-clip:boom\") to encoded bytes + metadata.\n  resolveClip: (clipId) => clipRegistry.get(clipId),\n});\nif (!created.ok) {\n  // No AudioContext (SSR / unsupported browser); run without audio.\n  return;\n}\nconst engine = created.engine;\n\n// Resume the AudioContext on the first user gesture (autoplay policy).\ncanvas.addEventListener(\"pointerdown\", () => engine.unlock(), { once: true });\n\n// Each frame: reconcile the voice graph against the render snapshot.\nfunction frame(snapshot, frameDeltaSeconds) {\n  engine.applySnapshot(snapshot, frameDeltaSeconds);\n}\n\nengine.setBusGain(\"music\", 0.6);\nengine.setPaused(true); // game pause: silences sfx/voice/ambient\n```\n\nVolume persistence (localStorage-backed, ramped, and mirrored as a deterministic worker command) is available via `createAudioSettings`. Lower-level pieces — `createWebAudioBackend`, `createAudioMixer`, `createClipCache`, `createVoiceManager` — are exported too, but most apps only need `createAudioEngine`.\n\n## Entry points\n\n- `@aperture-engine/audio` — the audio engine, mixer, clip cache, voice manager, backend, and settings.\n- `@aperture-engine/audio/test-support` — a deterministic, deviceless `FakeAudioBackend` (and fake node classes) for unit-testing control logic without Web Audio.\n\n## License\n\nPart of the [Aperture](https://github.com/felixtrz/aperture) monorepo. MIT licensed.\n","readmeFilename":"README.md"}