DSPUtil.SoundBuffer.Normalize C# (CSharp) Method

Normalize() public method

public Normalize ( double dBfs, bool doIt ) : double
dBfs double
doIt bool
return double
        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;
        }

Same methods

SoundBuffer::Normalize ( double dBfs ) : double

Usage Example

Exemplo n.º 1
0
        private ISoundObj _buff()
        {
            if (double.IsNaN(_normalization))
            {
                return(_input);
            }
            // We've been asked to normalize
            SoundBuffer b = new SoundBuffer(_input);

            b.ReadAll();
            _gain = b.Normalize(_normalization, false);
            return(b);
        }
All Usage Examples Of DSPUtil.SoundBuffer::Normalize