package detect // Decimate downsamples by averaging fixed-size blocks rather than dropping samples. // // Only a cheap pre-filter ahead of a coarse alignment search: averaging keeps the signal's // overall shape, which is all a coarse search needs, where keeping every Nth sample would // alias. Correctness of the real match still comes from re-checking at full resolution. func Decimate(samples []float64, factor int) []float64 { if factor <= 1 { return samples } out := make([]float64, len(samples)/factor) for i := range out { sum := 0.0 base := i * factor for j := 0; j < factor; j++ { sum += samples[base+j] } out[i] = sum / float64(factor) } return out }