/// <summary>
        /// Constructs <see cref="DynamicsProcessor"/> in given <paramref name="mode"/>.
        /// </summary>
        /// <param name="mode">Type (mode) of dynamics processor</param>
        /// <param name="samplingRate">Sampling rate</param>
        /// <param name="threshold">Compression/expansion threshold</param>
        /// <param name="ratio">Compression/expansion ratio</param>
        /// <param name="makeupGain">Makeup gain</param>
        /// <param name="attack">Attack time (in seconds)</param>
        /// <param name="release">Release time (in seconds)</param>
        /// <param name="minAmplitudeDb">Min threshold for dB amplitude</param>
        public DynamicsProcessor(DynamicsMode mode,
                                 int samplingRate,
                                 float threshold,
                                 float ratio,
                                 float makeupGain     = 0,
                                 float attack         = 0.01f,
                                 float release        = 0.1f,
                                 float minAmplitudeDb = -120 /*dB*/)
        {
            _mode             = mode;
            _fs               = samplingRate;
            _envelopeFollower = new EnvelopeFollower(_fs);
            _minAmplitudeDb   = minAmplitudeDb;

            Threshold  = threshold;
            Ratio      = ratio;
            MakeupGain = makeupGain;
            Attack     = attack;
            Release    = release;
        }
Exemple #2
0
        /// <summary>
        /// Method for extracting the envelope of a signal
        /// </summary>
        /// <param name="signal">Signal</param>
        /// <param name="attackTime"></param>
        /// <param name="releaseTime"></param>
        /// <returns></returns>
        public static DiscreteSignal Envelope(DiscreteSignal signal, float attackTime = 0.01f, float releaseTime = 0.05f)
        {
            var envelopeFollower = new EnvelopeFollower(signal.SamplingRate, attackTime, releaseTime);

            return(new DiscreteSignal(signal.SamplingRate, signal.Samples.Select(s => envelopeFollower.Process(s))));
        }