Skip to main content

binary_mask_from_ratio

Function binary_mask_from_ratio 

Source
pub fn binary_mask_from_ratio(
    target_ref: &[f32],
    other_ref: &[f32],
    out_mask: &mut [f32],
) -> Result<(), AudioError>
Expand description

Derive a binary mask from two reference magnitude spectra (the “ideal binary mask” when the references are the true stems): bin k is assigned to the target (1.0) when the target reference has at least as much magnitude there as the other reference, else 0.0.

Equivalent to thresholding the ratio target / (target + other) at 0.5, but computed by direct comparison to avoid a divide (and the 0/0 case). Zero-heap.

  • target_ref, other_ref: reference magnitudes, equal length N.
  • out_mask: at least N floats; each written as 0.0 or 1.0.

§Errors