use crate::types::Rate;
use super::LONG_SIGNAL_FRAME_COUNT;
pub(crate) fn time_weights(frame_stop: usize, n_max: usize, rate: Rate) -> Vec<f32> {
let mut weights = vec![1.0f32; frame_stop + 1];
if frame_stop < LONG_SIGNAL_FRAME_COUNT {
return weights;
}
let n = ((n_max - 2 * rate.margin_samples()) / rate.frame_hop()) - 1;
let f = ((n as f64 - 1000.0) / 5500.0).min(0.5);
let n = n as f64;
for (frame, weight) in weights.iter_mut().enumerate() {
*weight = ((1.0 - f) + f * frame as f64 / n) as f32;
}
weights
}