Skip to main content
Glama
SphereAudio MCP Server

SphereAudio MCP Server

by devenu85

SphereAudio (v2.0.0)

Open-source full-sphere (-90° under feet to +90° overhead) 3D spatial audio engine scaling from 2-channel binaural headphones (with optional AES69 SOFA HRTFs) up to 255-channel Ultra-Dome rigs, featuring a .sph Opus container, Web Studio with real-time REST/WebSocket/OSC head-tracking bridge, Physical Speaker Calibration Wizard, and MCP server for AI agents.

Licensed under Apache 2.0.

Key Capabilities

  • Full-Sphere Binaural Headphone Renderer (sphereaudio/dsp.py): Woodworth ITD, head-shadow ILD, pinna elevation notch shifts (-90° to +90°), overhead Blauert boost, below-ear torso bounce/shadowing, and early floor reflections.

  • Real AES69 SOFA HRTF Convolution (sphereaudio/hrtf_sofa.py): Optional .sofa loader for standard KEMAR, SADIE II, and HUTUBS datasets via sofar or h5py (with graceful fallback to the built-in parametric full-sphere HRTF engine when neither is installed). Includes spherical Delaunay barycentric + ITD-aligned and nearest-neighbor HRIR interpolation across -90° to +90°, exposed via --sofa in CLI and sofa_path in MCP render_scene.

  • Physical Speaker Mapper (sphereaudio/rigs.py): Scales seamlessly up to 255 discrete channels (matching the Opus multistream ceiling):

    • headphones_binaural (2ch full-sphere binaural headphones)

    • bedroom_underbed_hybrid (9ch: 4 ear + 2 overhead + 2 edge-firing under-bed + tactile bass)

    • home_5_1_4_2_underseat (12ch: 5 ear + 4 overhead + 2 under-sofa with fabric occlusion EQ + tactile LFE)

    • theater_full_sphere_24ch (24ch cinema dome with perforated riser & under-seat vents)

    • theater_flagship_128ch (128ch symmetrical full-sphere cinema dome)

    • theater_ultradome_255ch (255ch maximum-density full-sphere dome: 51 ear-level, 96 overhead, 96 mirrored perforated-riser/under-seat/floor-grid, 12 LFE/tactile)

  • Interactive 3D Web Studio & Python Bridge (studio/index.html, sphereaudio/studio_server.py): Launch with sphereaudio studio --api for a live REST + RFC 6455 WebSocket + UDP OSC bridge enabling Render High-Quality WAV, Test Physical Under-Seat Rig, and real-time Webcam / WebXR / OSC head-tracking (yaw/pitch/roll).

  • Physical Speaker Calibration Wizard (sphereaudio/calibrate.py): sphereaudio calibrate CLI and calibrate_speaker MCP tool generate logarithmic sine sweeps and 1/f pink noise WAVs for under_seat, perforated_riser, and under_bed speakers, and compute custom OcclusionProfile EQ curves (cutoff_hz, high_shelf_comp_db, max_usable_hz) from recorded room microphone WAVs.

  • .sph Opus Container (sphereaudio/container.py): Packs .sphere.json trajectory metadata + Opus-compressed mono sound objects (via ffmpeg/libopus, with FLAC and WAV fallbacks) into a tiny, self-contained .sph delivery file that renders live to any rig (2ch to 255ch).

  • Per-Channel Mono Stem Exporter (--stems): Writes balanced mono WAV stems + manifest.json for 24ch, 128ch, and 255ch rigs without hitting the 4 GB standard WAV limit.

  • MCP Server & Agent Demo (sphereaudio/mcp_server.py, examples/mcp_agent_demo.py): 12 JSON-RPC 2.0 stdio tools and 3 resources so AI agents can create scenes, pack/unpack .sph Opus containers, calibrate speakers, inspect rigs, and render SOFA or multi-channel audio.

Related MCP server: cochlea

Quickstart

pip install -e .
# Optional: enable AES69 .sofa HRTF dataset loading (KEMAR / SADIE II / HUTUBS)
pip install -e ".[sofa]"

# 1. Pack a scene into a compressed .sph Opus container
sphereaudio pack examples/full_sphere_demo.sphere.json -o demo.sph --codec opus --bitrate 48

# 2. Inspect the compressed .sph container
sphereaudio inspect demo.sph

# 3. Render with built-in parametric HRTF, an external .sofa HRTF, or 255ch Ultra-Dome stems
sphereaudio render demo.sph -o demo_headphones.wav --rig headphones_binaural
sphereaudio render demo.sph -o demo_kemar.wav --rig headphones_binaural --sofa path/to/KEMAR.sofa --hrtf-interp barycentric
sphereaudio render demo.sph -o stems_255 --rig theater_ultradome_255ch --stems

# 4. Launch the Interactive 3D Web Studio with Python DSP, Under-Seat Rig Test, WebSocket & OSC Head-Tracking
sphereaudio studio --api --osc-port 9001

# 5. Calibrate physical under-seat / perforated-riser / under-bed speakers
sphereaudio calibrate generate -o cal_underseat.wav --target under_seat --signal sweep
sphereaudio calibrate measure recorded_mic.wav --reference cal_underseat.wav --target under_seat -o custom_profile.json

# 6. Run the AI Agent MCP stdio demo (renders headphones + 24ch theater output)
python3 examples/mcp_agent_demo.py -o mcp_demo_out

MCP Server Configuration

{
  "mcpServers": {
    "sphereaudio": {
      "command": "sphereaudio-mcp",
      "args": [],
      "cwd": "/path/to/SphereAudio"
    }
  }
}

Or invoke directly via Python (python3 -m sphereaudio.mcp_server).

Running Tests

python3 -m unittest discover -s tests -v

Available Tools

12 tools
add_sound_objectB

Add a 3D sound object to an existing .sphere.json scene at any spherical coordinate (azimuth_deg in [-180, 180], elevation_deg in [-90, +90] where -90 is under feet, distance_m > 0.05), optionally with animated keyframes.

Inputs: id (required), source (required), scene_path (required), gain, +10 more.

analyze_speaker_gainsC

Compute exact 3D panning gains across every speaker channel in a rig for a given spherical coordinate.

Inputs: rig_preset (required), azimuth_deg (required), elevation_deg (required), lfe_send, +1 more.

calibrate_speakerB

Physical speaker calibration wizard: generate pink-noise/log-sweep calibration WAVs for under_seat, perforated_riser, or under_bed speakers (mode='generate'), or measure a recorded room-mic WAV to compute a custom OcclusionProfile EQ curve (mode='measure').

Inputs: mode (required), target, duration_s, rig_preset, +6 more.

create_sceneC

Create a new open .sphere.json full-sphere 3D audio scene file (supports elevations from -90° directly under feet to +90° overhead).

Inputs: scene_path (required), title, duration_s, rig_preset, +2 more.

inspect_sphA

Inspect manifest metadata, codec, bitrate, and streams inside a .sph container without unpacking.

Inputs: sph_path (required).

list_speaker_rigsA

List all built-in full-sphere speaker and headphone rigs from 2ch up to 255ch Ultra-Dome.

Inputs: no named parameters.

list_synth_presetsA

List built-in procedural audio presets available for rapid full-sphere sound design.

Inputs: no named parameters.

move_sound_objectB

Update a sound object's static 3D position or append an animation keyframe.

Inputs: id (required), scene_path (required), azimuth_deg (required), elevation_deg (required), +2 more.

pack_sphC

Pack a .sphere.json scene and its sound objects into a compressed .sph Opus/FLAC container.

Inputs: output_sph (required), scene_path (required), codec, bitrate_kbps.

render_sceneA

Render a .sphere.json scene OR a compressed .sph Opus container to an interleaved WAV or per-channel mono stems + manifest.json (supports up to 255ch theater_ultradome_255ch).

Inputs: output_wav (required), scene_path (required), sofa_path, rig_preset, +3 more.

unpack_sphC

Unpack a compressed .sph container into decoded 48 kHz mono WAV objects and scene.sphere.json.

Inputs: sph_path (required), output_dir (required).

validate_sceneC

Validate a .sphere.json scene file and return a summary of its objects and vertical elevation range.

Inputs: scene_path (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 12 tools

    Disambiguation4/5

    Most tools target clearly distinct operations (create/add/move/render/pack/validate), and descriptions explicitly state inputs and outputs. The only real confusion risk is between inspect_sph (metadata only) and unpack_sph (full decode), and to a lesser degree render_scene accepting a .sph input, but the descriptions do disambiguate them.

    Naming Consistency5/5

    Every tool follows a strict snake_case verb_noun pattern (validate_scene, create_scene, add_sound_object, pack_sph, list_speaker_rigs, analyze_speaker_gains). No mixed conventions or vague standalone verbs.

    Tool Count5/5

    12 tools sits squarely in the well-scoped range, and each maps to a distinct stage of the scene lifecycle (author, validate, render, pack/unpack, inspect, rig analysis, calibration). No obvious filler tools.

    Completeness3/5

    The surface covers create/add/move/validate/render/pack/unpack/inspect plus rig analysis, but there is no delete_sound_object or remove-keyframe operation, so an agent cannot undo additions, and no scene-level delete or metadata edit. These are notable lifecycle gaps rather than fatal ones, since scenes remain editable externally.

    Maintenance

    ActivityNo data
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Provides audio inspection, conversion, processing, and generation capabilities via SoX, enabling AI agents to 'hear' and manipulate audio files through structured JSON interfaces.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables agents to conjure individual sounds by semantic text search over a CLAP-embedded audio database and render them into stereo, 5.1, or 7.1.4 spatial mixes, with tools for summing mixes, analyzing a mix's sounds and spatial balance, and mimicking existing mixes. Documentation resources are exposed so the client can read usage guides on demand.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to check whether generated audio matches a prompt in any language, rank takes, run technical QC, judge fit against images or video, and search or dedupe a local sound library. Each tool returns the same JSON records as the matching CLI command, with the model loaded once and everything running locally.
      18
      MIT