public double Normalize(double dBfs, bool doIt)
{
// Make sure the whole buffer is scaled
double gain = 0;
double max = 0;
for (int j = 0; j < _samples.Count; j++)
{
ISample s = _samples[j];
for (int c = 0; c < s.NumChannels; c++)
{
max = Math.Max(max, Math.Abs(s[c]));
}
}
if (max == 0)
{
return 0;
}
gain = MathUtil.gain(dBfs) / max;
if (doIt)
{
ApplyGain(gain);
}
return gain;
}