skills/ar-vr/spatial-audio/SKILL.md
Implements 3D audio positioning and rendering for immersive AR/VR experiences.
npx skillsauth add alphaonedev/openclaw-graph spatial-audioInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill implements 3D audio positioning and rendering for AR/VR applications, using techniques like Head-Related Transfer Function (HRTF) to simulate spatial sound sources in real-time.
Use this skill when building immersive AR/VR experiences that require realistic audio, such as virtual tours, gaming environments, or simulations where sound direction and distance enhance user presence. Avoid it for 2D audio needs, as it adds overhead for non-spatial applications.
Always initialize the audio context first, then set up sound sources with positions. Use a loop for updates in real-time applications. For CLI, pipe audio files through the tool; for API, call endpoints in sequence. Pattern: Import library > Create audio context > Add sources > Render and update. Handle cleanup on exit to free resources.
Use the OpenClaw CLI for quick prototyping or the REST API for programmatic control. Authentication requires setting $SPATIAL_AUDIO_API_KEY as an environment variable.
CLI Command: Render audio with positioning
spatial-audio render --input audio.wav --position 1.5 2.0 3.0 --hrtf default --output rendered.wav
This processes an audio file at the specified 3D coordinates.
API Endpoint: Create a sound source
POST to https://api.openclaw.ai/spatial-audio/sources with JSON body:
{ "sourceId": "src1", "position": [0, 0, 5], "audioUrl": "s3://bucket/audio.mp3" }
Response includes a source handle for updates.
Code Snippet (Python): Initialize and position audio
import openclaw.spatial_audio as sa
context = sa.init(hrtf='default')
source = sa.add_source(context, position=[1, 2, 3])
sa.update_position(source, [4, 5, 6])
Config Format: JSON for API configs, e.g.,
{ "hrtfProfile": "custom", "attenuation": "inverse", "maxSources": 16 }
Load via CLI: spatial-audio config load --file config.json.
Integrate by adding the OpenClaw SDK as a dependency (e.g., pip install openclaw-sdk or via npm for JS). Set $SPATIAL_AUDIO_API_KEY before runtime. For AR/VR frameworks, wrap in Unity's AudioListener or WebXR's AudioContext—e.g., in Unity, attach the SpatialAudio component to the main camera. Ensure audio devices are compatible; check for Web Audio API support in browsers. For multi-platform, use abstraction layers like Three.js for web-based AR.
Always check return codes or exceptions for errors. Common issues: Invalid positions (e.g., NaN values) return error code 400; audio device unavailability raises "DEVICE_NOT_FOUND". Handle with try-except blocks:
try:
sa.render(context)
except sa.AudioError as e:
if e.code == 400:
print("Invalid position; correct coordinates.")
For CLI, parse stderr output (e.g., "Error: HRTF not loaded—use --hrtf flag"). Retry transient errors like network failures with exponential backoff.
To set up 3D audio for an AR object:
sa.init(hrtf='builtin')source = sa.add_source(context, position=[0, 1, 2], audioUrl='object_sound.mp3')sa.update_position(source, user_coords)sa.render(context)For a VR game with moving sound sources:
spatial-audio render --input explosion.wav --position 10 0 0 --hrtf customconst context = await sa.init();
const source = await sa.addSource(context, { position: [5, 0, 0] });
setInterval(() => sa.updateSource(source, [Math.random()*10, 0, 0]), 1000);
tools
Root web development: project structure, tooling selection, deployment decisions
development
WebAssembly: Rust/Go/C to WASM, wasm-bindgen, Emscripten, WASM Component Model
development
Vue 3: Composition API script setup, Pinia, Vue Router 4, SFCs, Vite, Nuxt 3
tools
Tailwind CSS 4: utility classes, config, JIT, arbitrary values, darkMode, plugins, shadcn/ui