Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions crates/sgv2-core/src/mic/sens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,12 @@ impl Run {
let bins = self.p.bins();
for (m, blk) in blocks.iter_mut().enumerate().take(self.p.mics) {
let blk = &mut blk[..hop];
// A non-finite sample would stay in the smoothers and the
// overlap-add for good: take it as silence, as the engine does
// ahead of its stages (this keeps a direct caller safe too).
for x in blk.iter_mut().filter(|x| !x.is_finite()) {
*x = 0.0;
}
if self.p.bypass {
for (x, p) in blk.iter_mut().zip(self.prev[m].iter_mut()) {
let v = f64::from(*x);
Expand Down Expand Up @@ -415,6 +421,25 @@ pub(crate) mod tests {
(x.iter().map(|v| f64::from(*v).powi(2)).sum::<f64>() / x.len() as f64).sqrt()
}

#[test]
fn non_finite_input_is_silence_and_the_state_recovers() {
let p = params(2, 480);
let mut x = vec![noise(48_000, 0.05, 3), noise(48_000, 0.05, 4)];
for v in &mut x[0][4_800..4_900] {
*v = f32::NAN;
}
x[1][9_600] = f32::INFINITY;
x[1][9_601] = f32::NEG_INFINITY;
let y = run(&p, &x);
assert!(y.iter().all(|c| c.iter().all(|v| v.is_finite())));
// well after the bad samples the output tracks the clean input again
let clean = run(&p, &[noise(48_000, 0.05, 3), noise(48_000, 0.05, 4)]);
for (a, b) in y.iter().zip(&clean) {
let tail = 38_400..48_000;
assert!((rms(&a[tail.clone()]) / rms(&b[tail])).ln().abs() < 0.01);
}
}

#[test]
fn the_quadrant_window_is_power_complementary_and_near_vorbis() {
for n in 0..480 {
Expand Down
4 changes: 4 additions & 0 deletions packaging/pipewire/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,7 @@ compile refuses (no blob) when a stage is not characterised;
`--allow-partial` carries the stages documented as transparent or
attenuating as identity and flags the blob partial. Session wiring,
provisioning and WirePlumber priorities are not part of this example.
The artifact is versioned and the plugin refuses another version (a
version-1 blob from the first mic release gives silence and health 1 with
the current plugin), so whatever provisions the blob must recompile it
when the plugin changes instead of keeping a stale one.
Loading