Skip to content

Commit 7f5806f

Browse files
author
Nick Knight
committed
mono recording onlyone leg - sum
1 parent 109b57e commit 7f5806f

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

rust/src/channel/mixer.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,17 @@ async fn feed_recorders(
857857
}
858858
inter
859859
} else {
860-
samples.to_vec()
860+
// Mono: saturated sum of self leg + peer leg, matching C++
861+
// `soundfilewriter::write` where mono advances buf by 1 in
862+
// both loops so the second leg is `*buf += outval`.
863+
match peer_samples {
864+
Some(peer) => samples.iter().enumerate().map(|(idx, &s)| {
865+
let a = s as i32;
866+
let b = peer.get(idx).copied().unwrap_or(0) as i32;
867+
(a + b).clamp(i16::MIN as i32, i16::MAX as i32) as i16
868+
}).collect(),
869+
None => samples.to_vec(),
870+
}
861871
};
862872
// Power calc on the narrowband `samples` (self's inbound), not
863873
// the interleaved stereo `frame` — matches C++ `codecx::power()`.

0 commit comments

Comments
 (0)