OpenStudio Protocol (OSP) - A high-performance, low-latency audio networking layer inspired by AOO (Audio over OSC) but extended with rich control messages for DAW collaboration.
OSP is NOT a fork of SonoBus. It is a custom protocol that:
- Is inspired by AOO (Audio over OSC) - the protocol SonoBus uses
- Extends with DAW collaboration features (effects sync, multi-track, beat sync)
- Adds Cloudflare MoQ relay for scalability beyond P2P mesh limits
- Multi-track support (up to 8 tracks per user)
- Full effects parameter synchronization
- Master clock with sub-ms beat sync
- Automatic P2P <-> relay switching
- Cloudflare MoQ integration for scalability
| Component | Status | Notes |
|---|---|---|
| Audio Engine Core | ✅ Done | ASIO/CoreAudio device access, ringbuffers |
| AudioBridgeHandle | ✅ Done | Thread-safe handle for network ops |
| Opus Codec | ✅ Done | Full encode/decode with FEC |
| Jitter Buffer | ✅ Done | Adaptive for live jamming |
| Clock Sync | ✅ Done | NTP-style sub-ms sync |
| QUIC/MoQ Relay Client | ✅ Done | Connects to relay servers |
| P2P Network | ✅ Done | UDP receive/heartbeat loops implemented |
| Effects Chain | ✅ Done | 35 effects fully implemented (Phase 1 + 2) |
| Audio-Network Bridge | ✅ Done | Started from server on room join |
| Transport Forwarding | ✅ Done | Clock sync, tempo, transport events forwarded |
| Network Reconnection | ✅ Done | Automatic reconnection with exponential backoff |
| Connection Health Monitor | ✅ Done | Monitors relay/P2P health, auto-recovers |
All 29 effects implemented with custom DSP primitives:
- ✅ Wah (manual/auto/envelope modes)
- ✅ Overdrive (asymmetric soft clipping)
- ✅ Distortion (5 types: classic, hard, fuzz, asymmetric, rectifier)
- ✅ Amp simulation (6 types: clean, crunch, highgain, british, american, modern)
- ✅ Cabinet simulation (EQ-based speaker/mic modeling)
- ✅ Noise gate (state machine with attack/hold/release)
- ✅ EQ (multi-band parametric)
- ✅ Compressor (soft-knee dynamics)
- ✅ Chorus (3-voice modulated delay)
- ✅ Flanger (short modulated delay with feedback)
- ✅ Phaser (up to 12-stage allpass cascade)
- ✅ Delay (digital/analog/tape/pingpong types)
- ✅ Tremolo (LFO amplitude modulation)
- ✅ Reverb (Freeverb algorithm: 8 combs + 4 allpasses)
- ✅ Limiter (brickwall with lookahead)
- ✅ Vocal Doubler (multi-voice ADT)
- ✅ De-esser (sidechain dynamics)
- ✅ Bitcrusher (sample rate/bit depth reduction)
- ✅ Ring Modulator (carrier frequency modulation)
- ✅ Auto Pan (LFO stereo panning)
- ✅ Multi-Filter (LP/HP/BP/Notch with modulation)
- ✅ Vibrato (pitch modulation via variable delay)
- ✅ Transient Shaper (attack/sustain control)
- ✅ Stereo Imager (M/S width control)
- ✅ Exciter (harmonic enhancement)
- ✅ Multiband Compressor (3-band with LR4 crossovers)
- ✅ Stereo Delay (independent L/R delays)
- ✅ Room Simulator (early reflections + reverb)
- ✅ Shimmer Reverb (pitch-shifted feedback)
- ✅ Pitch Correction (autocorrelation + granular shifting)
- ✅ Harmonizer (3-voice musical interval shifting)
- ✅ Formant Shifter (16-band vocoder-style filterbank)
- ✅ Frequency Shifter (Bode-style Hilbert transform)
- ✅ Granular Delay (8-grain texture/cloud generator)
- ✅ Rotary Speaker (Leslie horn/drum simulation)
-
1. Fix
unimplemented!()Panic- Added
new_shared()method for Arc-wrapped creation - Added
init_self_ref()for post-Arc initialization - File:
src/network/manager.rs
- Added
-
2. Spawn P2P Receive/Send Loops
- Implemented
spawn_receive_loop()for UDP packet processing - Implemented
spawn_heartbeat_loop()for peer keepalive/timeout - File:
src/network/p2p.rs
- Implemented
-
3. Start AudioNetworkBridge from Protocol Server
- Bridge starts when user joins room via JoinRoom message
- Bridge stops and cleans up on LeaveRoom
- Files:
src/protocol/server.rs,src/main.rs
-
4. Wire Up Transport/Metronome Forwarding
- Added
TransportEventenum for clock sync, tempo, transport state - Bridge emits transport events via broadcast channel
- File:
src/network/bridge.rs
- Added
-
5. Expose
send_packetfor P2P Control Broadcast- Added public
broadcast_control()method to P2P network - Manager now uses
broadcast_control()for control/clock sync messages - Files:
src/network/p2p.rs,src/network/manager.rs
- Added public
-
6. Implement Audio Effects
- All 29 effects fully implemented with custom DSP primitives
- Core DSP: Biquad filters, delay lines, LFOs, envelope followers
- Files:
src/effects/*.rs(15+ files)
-
7. Hook Mixer to Effects Chain
- EffectsChain processes audio in correct order
- All effects properly wired with settings and metering
- File:
src/effects/chain.rs
-
8. Add Reconnection Logic for Relay
- Exponential backoff reconnection implemented
- Connection health monitoring loop
- File:
src/network/manager.rs
-
9. Implement Error Recovery for Network Failures
- Automatic reconnection with configurable max attempts
- P2P quality monitoring (packet loss, RTT warnings)
- Graceful degradation notifications
- File:
src/network/manager.rs
- Monitor packet loss and RTT
- Adjust Opus bitrate dynamically
- Use Opus FEC for packet loss recovery
- Implement interpolation for missing frames
- Implement
MasterElectionmessage type (OSP 0x0303) - Elect lowest-latency peer as clock master
- Detect stale connections
- Clean up resources for disconnected clients
- Track RTT, jitter, packet loss per peer
- Expose via API for UI display
- When local user changes effect, broadcast to room
- Implement OSP message type 0x0207
- Allow/deny remote control of tracks
- Sync AI-generated content state
- Sync loop start/end/enabled state
- Windows: ASIO exclusive mode
- macOS: CoreAudio low-latency settings
- Linux: JACK integration
- Two clients on same machine
- Verify audio round-trip
- Connect through actual MoQ relay
- Verify audio quality
- Maximum performer count
- Monitor CPU, memory, latency
- Target: <15ms RTT on LAN
- Measure encode + network + decode + buffer
- Packet loss, high latency, disconnects
- Verify graceful handling
- Windows with ASIO
- macOS with CoreAudio
- Linux with ALSA/JACK
- Biquad - Direct Form II Transposed filter
- All standard types: LP, HP, BP, Notch, Peak, LowShelf, HighShelf, Allpass
- DelayLine - Circular buffer with linear interpolation
- LFO - Waveforms: sine, triangle, square, sawtooth
- EnvelopeFollower - Attack/release dynamics
- DcBlocker - High-pass at ~10Hz
Wah → Overdrive → Distortion → Amp → Cabinet →
NoiseGate → DeEsser → TransientShaper →
EQ → Exciter → MultiFilter →
Compressor → MultibandCompressor →
Bitcrusher → RingMod → Chorus → Flanger → Phaser → Vibrato → Tremolo → AutoPan → VocalDoubler →
Delay → StereoDelay →
RoomSimulator → Reverb → ShimmerReverb →
StereoImager → Limiter
| Category | Tasks | Status |
|---|---|---|
| Critical blockers | 5 | ✅ Complete |
| High priority | 4 | ✅ Complete |
| Effects (Phase 1) | 29 effects | ✅ Complete |
| Effects (Phase 2) | 6 pitch effects | ✅ Complete |
| Room context integration | 3 tasks | ✅ Complete |
| Medium priority | 5 | In progress |
| Testing & polish | 6 | Not started |
Phase 1 + 2 Complete: All 35 effects fully functional, including pitch-based effects.
Next Steps:
- Production testing
- Platform-specific optimizations
- Effect parameter sync to remote users
Room state is synchronized using Supabase Realtime (PostgreSQL NOTIFY/LISTEN), NOT the native OSP protocol. OSP handles P2P/relay audio streaming only.
| State | Table/Channel | Notes |
|---|---|---|
| Room members | rooms |
Presence, join/leave |
| Musical key/scale | syncedAnalysis |
Master broadcasts detected key |
| BPM | syncedAnalysis |
Master broadcasts tempo |
| User tracks | user_tracks |
Track settings, stems |
| Effect presets | saved_tracks |
Saved presets (not live state) |
| Chat messages | room_chat |
Text chat |
| World positions | room_store |
3D positioning |
- Frontend detects key/BPM changes (via audio analysis or user input)
- Master user broadcasts via
broadcastAnalysis()→ Supabase Realtime - All clients receive update in
room-store.ts→setSyncedAnalysis() - Frontend sends
SetRoomContextmessage to native bridge WebSocket - Native bridge updates
EffectsChain.set_room_context():- Pitch Correction uses key/scale for note snapping
- Harmonizer uses key/scale for harmony intervals
- Delay/AutoPan/StereoDelay use BPM for tempo sync
- Latency tolerance: Room state can handle 100-500ms latency
- Reliability: Supabase provides persistence and retries
- Scalability: Works for 100+ observers (not just 8 performers)
- OSP focus: OSP stays lean for <15ms audio latency
| Message | Purpose |
|---|---|
| AudioFrame | Opus-encoded audio data |
| ClockSync | Sub-ms beat synchronization |
| Ping/Pong | RTT measurement |
| Handshake | P2P peer discovery |