Beispiel #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="samplingRate"></param>
        /// <param name="lfo"></param>
        /// <param name="q"></param>
        public PhaserEffect(int samplingRate, SignalBuilder lfo, float q = 0.5f)
        {
            _fs = samplingRate;
            Q   = q;
            Lfo = lfo;

            _filter = new NotchFilter(Lfo.NextSample() / _fs, Q);
        }
Beispiel #2
0
        public override float NextSample()
        {
            var sample = _builder.NextSample();

            if (_last > 0)
            {
                sample *= _last-- / (float)FadeSamples;
            }
            else if (_first < FadeSamples)
            {
                sample *= _first++ / (float)FadeSamples;
            }

            return(sample);
        }
Beispiel #3
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="samplingRate"></param>
        /// <param name="q"></param>
        /// <param name="lfoFrequency"></param>
        /// <param name="minFrequency"></param>
        /// <param name="maxFrequency"></param>
        public PhaserEffect(int samplingRate,
                            float lfoFrequency = 1.0f,
                            float minFrequency = 300,
                            float maxFrequency = 3000,
                            float q            = 0.5f)
        {
            _fs = samplingRate;

            Lfo = new TriangleWaveBuilder().SampledAt(samplingRate);

            LfoFrequency = lfoFrequency;
            MinFrequency = minFrequency;
            MaxFrequency = maxFrequency;
            Q            = q;

            _filter = new NotchFilter(Lfo.NextSample() / _fs, Q);
        }
Beispiel #4
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override float NextSample()
        {
            var sample = _builder.NextSample();

            if (FadeStarted || _index++ > Length - _fadeOutSampleCount)
            {
                sample *= (float)_fadeOutIndex-- / _fadeOutSampleCount;

                FadeStarted = !FadeFinished;
            }

            if (_fadeInIndex < _fadeInSampleCount)
            {
                sample *= (float)_fadeInIndex++ / _fadeInSampleCount;
            }

            return(sample);
        }