getPeakAmplitude method

double getPeakAmplitude()

Gets the peak amplitude of the PCM data.

Implementation

double getPeakAmplitude() {
  final samples = getNormalizedSamples();
  if (samples.isEmpty) return 0.0;

  double maxAmplitude = 0.0;
  for (final sample in samples) {
    final absValue = sample.abs();
    if (absValue > maxAmplitude) {
      maxAmplitude = absValue;
    }
  }

  return maxAmplitude;
}