Beispiel #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;
        }
Beispiel #2
0
 private void InitControls(SteppedSineEqualizer lastEqualizer, uint steps, double amplitude)
 {
     if (null == lastEqualizer || lastEqualizer.GetPointsOfEQ() != steps ||
         amplitude < lastEqualizer.TargetAmplitude || lastEqualizer.TargetAmplitude < amplitude / 10)
     {
         return;
     }
     for (ushort i = 0; i < steps; i++)
     {
         if (Math.Abs(lastEqualizer.GetEQ(i)) > 0.00001)
         {
             // TODO equalizer value is the 1/value, to Confirm
             _equalizers[i].Value = 1 / lastEqualizer.GetEQ(i);
         }
     }
 }