コード例 #1
0
		public EnvelopeFollower(double fs, double releaseMs)
		{
			Fs = fs;
            double ts = 1.0 / fs;
			
			inputFilter = new Butterworth(fs);
			inputFilter.Parameters[Butterworth.P_ORDER] = 2;
			inputFilter.Parameters[Butterworth.P_CUTOFF_HZ] = InputFilterCutoff;
			inputFilter.Update();

			var emaAlpha = Utils.ComputeLpAlpha(EmaFc, ts);

			double slowDbDecayPerSample = -60 / (3000 / 1000.0 * fs);
			slowDecay = Utils.Db2Gain(slowDbDecayPerSample);

			SetRelease(releaseMs);

			sma = new Sma((int)(fs * SmaPeriodSeconds));
			ema = new Ema(emaAlpha);
			movementLatch = new EmaLatch(0.005, 0.2); // frequency dependent, but not really that critical...

	        triggerCounterTimeoutSamples = (int)(fs * TimeoutPeriodSeconds);

			holdAlpha = Utils.ComputeLpAlpha(HoldSmootherFc, ts);
		}
コード例 #2
0
        public EnvelopeFollower(double fs, double releaseMs)
        {
            Fs = fs;
            double ts = 1.0 / fs;

            inputFilter = new Butterworth(fs);
            inputFilter.Parameters[Butterworth.P_ORDER]     = 2;
            inputFilter.Parameters[Butterworth.P_CUTOFF_HZ] = InputFilterCutoff;
            inputFilter.Update();

            var emaAlpha = Utils.ComputeLpAlpha(EmaFc, ts);

            double slowDbDecayPerSample = -60 / (3000 / 1000.0 * fs);

            slowDecay = Utils.Db2Gain(slowDbDecayPerSample);

            SetRelease(releaseMs);

            sma           = new Sma((int)(fs * SmaPeriodSeconds));
            ema           = new Ema(emaAlpha);
            movementLatch = new EmaLatch(0.005, 0.2);             // frequency dependent, but not really that critical...

            triggerCounterTimeoutSamples = (int)(fs * TimeoutPeriodSeconds);

            holdAlpha = Utils.ComputeLpAlpha(HoldSmootherFc, ts);
        }