Example #1
0
        /// <summary>
        /// Initializes a new instance for the Generator
        /// </summary>
        public BasicSignal(double initGain = 1, double initFrequency = 440.0)
        {
            WaveFormat = Constants.Wave.DefaultMonoWaveFormat;

            // Default
            Type = BasicSignalType.Sin;
            ZeroCrossingPosition = 0.5;

            rampGain = new RampGain(initGain);

            CurrentPhaseStep = initFrequency;
            TargetPhaseStep  = initFrequency;
            PhaseStepDelta   = 0;
            SeekFrequency    = false;

            AMSignals = new List <BasicSignal>();
            FMSignals = new List <BasicSignal>();
            PMSignals = new List <BasicSignal>();

            //init noise
            for (int i = 0; i < noiseValue.Length; i++)
            {
                noiseValue[i] = SampleWhite();
            }
        }
 /// <summary>
 /// Initializes a new instance of MonoToStereoSampleProviderEx
 /// </summary>
 /// <param name="source">Source sample provider</param>
 public MonoToStereoSampleProviderEx(ISampleProvider source,
                                     double initLeftGain = 1.0, double initRightGain = 1.0)
 {
     leftRampGain  = new RampGain(initLeftGain);
     rightRampGain = new RampGain(initRightGain);
     if (source.WaveFormat.Channels != 1)
     {
         throw new ArgumentException("Source must be mono");
     }
     this.source = source;
     WaveFormat  = WaveFormat.CreateIeeeFloatWaveFormat(source.WaveFormat.SampleRate, 2);
 }
Example #3
0
        /// <summary>
        /// Initializes a new instance for the Generator
        /// </summary>
        public BasicSignal(double initGain = 1, double initFrequency = 440.0)
        {
            WaveFormat = Constants.Wave.DefaultMonoWaveFormat;

            // Default
            Type = BasicSignalType.Sin;
            ZeroCrossingPosition = 0.5;

            rampGain = new RampGain(initGain);

            CurrentPhaseStep = initFrequency;
            TargetPhaseStep  = initFrequency;
            PhaseStepDelta   = 0;
            SeekFrequency    = false;

            /*
             * AM Signal with gain bump
             * https://www.desmos.com/calculator/ya9ayr9ylc
             * f_{1}=1
             * g_{0}=0.25
             * y_{0}=g_{0}\sin\left(f_{1}\cdot2\pi x\right)
             * y_{1}=y_{0}+1-g_{0}
             * y_{2}=\frac{\left(y_{1}+1\right)}{2}
             * y=\sin\left(20\cdot2\pi x\right)\cdot y_{2}\left\{-1<y<1\right\}
             */
            AMSignals = new AggregableSignals(1, (current, next, signal) => current * (next + 2 - (float)signal.Gain) / 2);
            FMSignals = new AggregableSignals(0, (current, next, _) => current + next);
            PMSignals = new AggregableSignals(0, (current, next, _) => current + next);
            ZMSignals = new AggregableSignals(0, (current, next, _) => current + next);

            //init noise
            for (int i = 0; i < noiseValue.Length; i++)
            {
                noiseValue[i] = SampleWhite();
            }
        }
 /// <summary>
 /// Initializes a new instance of VolumeSampleProviderEx
 /// </summary>
 /// <param name="source">Source Sample Provider</param>
 public VolumeSampleProviderEx(ISampleProvider source)
 {
     this.source = source;
     rampGain    = new RampGain();
 }