Overview
Adaptive Buffering is an intelligent system that monitors network quality in real-time and automatically adjusts the ring buffer size to balance stability (preventing dropouts) and latency (minimizing delay). This feature is essential for wireless networks and environments with variable network conditions.Introduced in v1.5.0: Adaptive buffering was added to address the challenge of finding the optimal buffer size across diverse network environments, from stable wired Ethernet to congested WiFi.
How It Works
The Core Problem
Fixed ring buffers have inherent trade-offs:- Too small: Dropouts occur when network jitter exceeds buffer capacity
- Too large: Unnecessary latency even on stable networks
Monitoring Interval
The adaptive buffer system checks network conditions every 10 seconds:Jitter Measurement
Jitter is the deviation from the ideal packet timing schedule. TCP Streamer uses the Strict Clock Strategy to measure jitter with microsecond precision.Calculation Method
Determine Ideal Schedule
Each chunk should be sent exactly Example: 1024 samples @ 48 kHz = 21,333 microseconds (21.3ms)
tick_duration apart:Jitter Interpretation
| Jitter (ms) | Network Quality | Typical Cause |
|---|---|---|
| < 5 ms | Excellent | Wired Ethernet, low load |
| 5 - 15 ms | Good | WiFi with good signal, moderate load |
| 15 - 30 ms | Fair | WiFi with interference, CPU throttling |
| > 30 ms | Poor | Congested network, high CPU load, distant WiFi |
Buffer Sizing Algorithm
Every 10 seconds, the adaptive buffer evaluates jitter and determines the target buffer size:Scaling Formula
For jitter between 5-15ms, the buffer size is interpolated:Resize Threshold
To avoid constant micro-adjustments, the buffer only resizes when the change is >10%:- Current buffer: 5000ms
- Target buffer: 5400ms
- Difference: 8% → No resize
- Current buffer: 5000ms
- Target buffer: 5600ms
- Difference: 12% → Resize
Device-Specific Ranges
The adaptive buffer uses different min/max ranges depending on the input device type:WASAPI Loopback (Windows)
| Setting | Default | Reason |
|---|---|---|
| Base buffer | 8000ms | Accounts for WASAPI timing variability |
| Min adaptive | 4000ms | Best-case wired network + low jitter |
| Max adaptive | 12000ms | WiFi laptop with CPU throttling + high jitter |
Standard Input / VB Audio Cable
| Setting | Default | Reason |
|---|---|---|
| Base buffer | 5000ms | WiFi tolerance |
| Min adaptive | 2000ms | Wired network, low jitter |
| Max adaptive | 6000ms | WiFi with moderate interference |
Network Quality Score
The adaptive buffer system contributes to the Network Quality Score displayed in the UI.Score Calculation
Penalty Breakdown
- Jitter Penalty (50 points max)
- Buffer Penalty (30 points max)
- Error Penalty (20 points max)
- Target: < 5ms jitter = 0 penalty
- Threshold: > 20ms jitter = max penalty
- Formula:
(jitter / 20.0) × 50points
- 2ms jitter → 5 penalty → contributes to 95+ score
- 10ms jitter → 25 penalty → contributes to 75 score
- 25ms jitter → 50 penalty → major score hit
Quality Levels
| Score | Rating | Color | Typical Conditions |
|---|---|---|---|
| 90-100 | Excellent | Green | Wired Ethernet, <5ms jitter |
| 70-89 | Good | Yellow | WiFi with good signal, 5-15ms jitter |
| 50-69 | Fair | Orange | WiFi with interference, 15-30ms jitter |
| 0-49 | Poor | Red | Congested network, >30ms jitter, errors |
Configuration
Enabling Adaptive Buffering
In the Advanced tab of the UI:Network Presets
Three presets automatically configure adaptive buffer ranges:- Ethernet (Stable)
- WiFi (Standard)
- WiFi (Poor Signal)
- Wired network connections
- Low-latency scenarios
- Home servers with direct connection
Custom Configuration
Advanced users can manually configure adaptive buffer bounds:- Select Custom from the Network Preset dropdown
- Set Min Buffer (e.g., 2000ms)
- Set Max Buffer (e.g., 8000ms)
- Enable Adaptive Buffer checkbox
- Click Save to apply
Rule of Thumb: The max buffer should be at least 2-3× the min buffer to give the adaptive algorithm enough room to adjust. For example:
- Min: 2000ms → Max: 6000-8000ms
- Min: 4000ms → Max: 10000-12000ms
Events and Logging
When the adaptive buffer resizes, it emits events for both logging and UI updates.Buffer Resize Event
Frontend Handler
Example Log Messages
Performance Impact
CPU Overhead
Adaptive buffering adds minimal CPU overhead:- Jitter calculation: 2-3 floating-point operations per chunk (~0.01% CPU)
- Buffer check: Once every 10 seconds (~0.001% CPU)
- Total: Negligible (<0.02% CPU)
Memory Impact
The ring buffer size affects memory usage:Memory is Cheap: Even at maximum buffer size (15 seconds), memory usage is only ~6 MB, which is negligible on modern systems. The stability benefits far outweigh the minimal memory cost.
Latency Trade-off
| Buffer Size | Latency | Stability |
|---|---|---|
| 2000ms | Low (2s) | Poor on WiFi |
| 5000ms | Medium (5s) | Good |
| 10000ms | High (10s) | Excellent |
| 15000ms | Very High (15s) | Rock solid |
Troubleshooting
Buffer keeps growing to maximum
Buffer keeps growing to maximum
Symptoms:
- Buffer size constantly at max (e.g., 15000ms)
- Quality score stays in “Fair” or “Poor” range
- Frequent “Increased due to high jitter” log messages
- Poor WiFi signal strength
- Network congestion
- CPU throttling (laptops)
- Underpowered hardware
- Move closer to WiFi router or switch to Ethernet
- Reduce network traffic (pause downloads, streams)
- Disable laptop power saving modes
- Increase max buffer beyond 15000ms if dropouts still occur
Buffer oscillates between min and max
Buffer oscillates between min and max
Symptoms:
- Buffer size changes every 10-20 seconds
- Alternating “Increased” and “Decreased” log messages
- Quality score fluctuates rapidly
- Intermittent network interference (e.g., microwave, neighboring WiFi)
- Variable CPU load (background tasks)
- Insufficient hysteresis in jitter smoothing
- Increase EWMA smoothing (lower alpha, e.g., 0.05 instead of 0.1)
- Widen the jitter threshold gap (e.g., <3ms = min, >20ms = max)
- Switch to 5GHz WiFi band to avoid 2.4GHz congestion
- Increase the resize threshold from 10% to 20%
Adaptive buffering doesn't seem to work
Adaptive buffering doesn't seem to work
Symptoms:
- Buffer size never changes from initial value
- No “Buffer resized” log messages
- Quality score doesn’t reflect network conditions
- Adaptive buffering not enabled
- Min and max buffers set to same value
- Jitter always falls within the 10% resize threshold
- Verify “Adaptive Buffer” checkbox is enabled in Advanced tab
- Ensure min and max buffers are different (e.g., 3000ms and 10000ms)
- Manually test with poor network conditions (download large file while streaming)
- Check logs for jitter values to confirm they’re being calculated
Future Implementation Note
Related Features
Audio Streaming
Learn about the ring buffer and precision timing
Silence Detection
RMS-based silence detection for bandwidth savings
Profiles
Save adaptive buffer settings per network environment