pub fn quantize_to(quantizer: f32) -> impl Fn(f32) -> f32 {
  move |input| {
    let remainder = input % quantizer;
    match (quantizer / 2. < remainder.abs(), input > 0.) {
      (true, true) => input + (quantizer - remainder.abs()),
      (true, false) => input - (quantizer - remainder.abs()),
      (false, true) => input - remainder.abs(),
      (false, false) => input + remainder.abs(),
    }
  }
}
// TODO: there's gotta be a better implementation...
there's gotta be a better implementation
there ' s gotta be a better implementation
pub fn quantize_to(quantizer: f32) -> impl Fn(f32) -> f32 {
  move |input| {
    let remainder = input % quantizer;
    match (quantizer / 2. < remainder.abs(), input > 0.) {
      (true, true) => input + (quantizer - remainder.abs()),
      (true, false) => input - (quantizer - remainder.abs()),
      (false, true) => input - remainder.abs(),
      (false, false) => input + remainder.abs(),
    }
  }
}
pub fn quantize_to ( quantizer : f32 ) -> impl Fn ( f32 ) -> f32 { move | input | { let remainder = input % quantizer ; match ( quantizer / 2. < remainder . abs ( ) , input > 0. ) { ( true , true ) => input + ( quantizer - remainder . abs ( ) ) , ( true , false ) => input - ( quantizer - remainder . abs ( ) ) , ( false , true ) => input - remainder . abs ( ) , ( false , false ) => input + remainder . abs ( ) , } } }
TODO: there's gotta be a better implementation...
TODO : there ' s gotta be a better implementation ...
quantizer
f32