Native audio engine for sonic-core.
C# NativeAOT binary that handles real audio — playback, device routing, and Kokoro TTS synthesis. Communicates with sonic-core over ndjson-stdio. Single native executable, no JIT, no runtime dependency.
Build
dotnet build
Publish
dotnet publish src/SonicRuntime \
-c Release -r win-x64
Protocol
→ {"id":1,"method":"version"}
← {"name":"sonic-runtime",
"version":"0.5.0",
"protocol":"ndjson-stdio-v1"}
Features
Everything the native audio layer provides.
OpenAL Soft
Low-latency audio via Silk.NET OpenAL bindings. Source/buffer model with per-source volume, pan, and looping.
NativeAOT
Single native executable via .NET 8 NativeAOT. No JIT warmup, no runtime dependency, sub-millisecond startup.
Per-Playback Device Routing
Route individual playbacks to specific audio output devices. Multiple device/context pairs managed lazily.
Kokoro TTS
Text-to-speech via ONNX inference with eSpeak G2P. 510 voices, ~5x realtime on CPU.
ndjson-stdio Protocol
Strict JSON-over-stdio wire format with versioned handshake. Request/response + unsolicited events. No network sockets.
95 Tests
Comprehensive xUnit suite covering playback, device management, synthesis, protocol, and event emission.
Quick Start
Build
# Clone and build
git clone https://github.com/mcp-tool-shop-org/sonic-runtime
cd sonic-runtime
dotnet build
dotnet test Publish
# Build NativeAOT single-file binary
dotnet publish src/SonicRuntime \
-c Release -r win-x64
# Output:
# src/SonicRuntime/bin/Release/
# net8.0/win-x64/publish/SonicRuntime.exe Wire Protocol
# Version handshake
→ {"id":1,"method":"version"}
← {"id":1,"result":{...}}
# Load + play
→ {"id":2,"method":"load_asset",
"params":{"asset_ref":"file:///rain.wav"}}
← {"id":2,"result":{"handle":"h_000001"}}
→ {"id":3,"method":"play",
"params":{"handle":"h_000001",
"volume":0.8,"loop":true}}
← {"id":3,"result":null}