[perf](trx-server): set opus complexity to 5 and raise default bitrate to 256k

Set opus encoder complexity from default (9-10) to 5 for both cpal and
SDR audio paths, significantly reducing encoding CPU usage with minimal
quality impact at these bitrates. Raise default bitrate from 192 kbps to
256 kbps for higher fidelity stereo audio.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
2026-03-01 10:42:00 +01:00
parent e3c7231650
commit 00a453f18c
3 changed files with 5 additions and 1 deletions
+1
View File
@@ -295,6 +295,7 @@ fn run_capture(
let mut encoder = opus::Encoder::new(sample_rate, opus_channels, opus::Application::Audio)?; let mut encoder = opus::Encoder::new(sample_rate, opus_channels, opus::Application::Audio)?;
encoder.set_bitrate(opus::Bitrate::Bits(bitrate_bps as i32))?; encoder.set_bitrate(opus::Bitrate::Bits(bitrate_bps as i32))?;
encoder.set_complexity(5)?;
// Start paused — only capture when clients are connected // Start paused — only capture when clients are connected
info!( info!(
+1 -1
View File
@@ -267,7 +267,7 @@ impl Default for AudioConfig {
sample_rate: 48000, sample_rate: 48000,
channels: 2, channels: 2,
frame_duration_ms: 20, frame_duration_ms: 20,
bitrate_bps: 192000, bitrate_bps: 256000,
} }
} }
} }
+3
View File
@@ -519,6 +519,9 @@ fn spawn_rig_audio_stack(
if let Err(e) = encoder.set_bitrate(opus::Bitrate::Bits(sdr_bitrate_bps as i32)) { if let Err(e) = encoder.set_bitrate(opus::Bitrate::Bits(sdr_bitrate_bps as i32)) {
tracing::warn!("SDR audio: set_bitrate failed: {}", e); tracing::warn!("SDR audio: set_bitrate failed: {}", e);
} }
if let Err(e) = encoder.set_complexity(5) {
tracing::warn!("SDR audio: set_complexity failed: {}", e);
}
let mut opus_buf = vec![0u8; 4096]; let mut opus_buf = vec![0u8; 4096];
loop { loop {
match sdr_rx.recv().await { match sdr_rx.recv().await {