Ejemplo n.º 1
0
        /// <summary>
        /// 构造SteppedSineWaveform
        /// </summary>
        /// <param name="sourceWaveform">源波形</param>
        /// <param name="equalizer">均衡器</param>
        public SteppedSineWaveform(SteppedSineWaveform sourceWaveform, SteppedSineEqualizer equalizer)
        {
            this.SampleRate = sourceWaveform.SampleRate;

            double maxEqalizer = 0;

            for (ushort i = 0; i < equalizer.GetPointsOfEQ(); i++)
            {
                // TODO 凌华的均衡器实际数值是倒数,待确认
                maxEqalizer = Math.Abs(equalizer.GetEQ(i)) < maxEqalizer
                    ? Math.Abs(equalizer.GetEQ(i))
                    : maxEqalizer;
            }
            this.Amplitude    = sourceWaveform.Amplitude / (maxEqalizer > 0 ? maxEqalizer : 1);
            this.FrequencyMax = sourceWaveform.FrequencyMax;
            this.FrequencyMin = sourceWaveform.FrequencyMin;
            this.Steps        = sourceWaveform.Steps;
            this.MinCycle     = sourceWaveform.MinCycle;
            this.MinDuration  = sourceWaveform.MinDuration;
            this.IsLog        = sourceWaveform.IsLog;
            this.IsInverse    = sourceWaveform.IsInverse;

            var waveform     = new ManagedAudioLibrary.SteppedSineWaveform();
            var rawWaveform  = sourceWaveform.GetRawWaveform() as ManagedAudioLibrary.SteppedSineWaveform;
            var rawEqualizer = equalizer.GetRawEqualizer() as ManagedAudioLibrary.SteppedSineEqualizer;

            waveform.CreateData(rawWaveform, rawEqualizer);
            RawWaveform = waveform;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 构造SteppedSineWaveform
        /// </summary>
        /// <param name="sampleRate">采样率</param>
        /// <param name="amplitude">波形幅度</param>
        /// <param name="frequencyMin">最小频率</param>
        /// <param name="frequencyMax">最大频率</param>
        /// <param name="steps">频率阶数</param>
        /// <param name="minCycle">最小周期数</param>
        /// <param name="minDuration">单阶最小时间</param>
        /// <param name="isLog">是否对数波形</param>
        /// <param name="isInverse">是否反转</param>
        public SteppedSineWaveform(double sampleRate, double amplitude,
                                   double frequencyMin, double frequencyMax, ushort steps, ushort minCycle,
                                   double minDuration, bool isLog = false, bool isInverse = false)
        {
            this.SampleRate   = sampleRate;
            this.Amplitude    = amplitude;
            this.FrequencyMax = frequencyMax;
            this.FrequencyMin = frequencyMin;
            this.Steps        = steps;
            this.MinCycle     = minCycle;
            this.MinDuration  = minDuration;
            this.IsLog        = isLog;
            this.IsInverse    = isInverse;

            var waveform = new ManagedAudioLibrary.SteppedSineWaveform();

            waveform.CreateData(amplitude, frequencyMin, frequencyMax, steps, isLog, isInverse, minCycle,
                                minDuration, sampleRate);
            RawWaveform = waveform;
        }