package audio // WaveformData holds pre-computed waveform samples type WaveformData struct { Samples []float64 MaxValue float64 } // NewWaveformData creates waveform data from raw samples func NewWaveformData(samples []float64) *WaveformData { wd := &WaveformData{ Samples: samples, } // Find max value for normalization for _, s := range samples { if s > wd.MaxValue { wd.MaxValue = s } } if wd.MaxValue == 0 { wd.MaxValue = 1 // Avoid division by zero } return wd } // Normalized returns samples normalized to 0-1 range func (w *WaveformData) Normalized() []float64 { normalized := make([]float64, len(w.Samples)) for i, s := range w.Samples { normalized[i] = s / w.MaxValue } return normalized }