Exemple #1
0
 /* add an ideal lowpass filter to the spec list */
 public static void AddIdealLPToEffectSpecList(
     EffectSpecListRec EffectSpecList,
     IdealLPSpecRec IdealLPSpec,
     bool EnabledFlag)
 {
     AddGenericToEffectSpecList(EffectSpecList, EffectTypes.eIdealLowpassEffect, IdealLPSpec, EnabledFlag);
 }
        /* create anew ideal lowpass filter specification */
        public static IdealLPSpecRec NewIdealLowpassSpec(
            double Cutoff,
            int Order)
        {
            IdealLPSpecRec IdealLPSpec = new IdealLPSpecRec();

            IdealLPSpec.Order  = Order;
            IdealLPSpec.Cutoff = Cutoff;

            return(IdealLPSpec);
        }
            /* create a new ideal lowpass processor */
            public static IdealLPRec NewIdealLP(
                IdealLPSpecRec Template,
                SynthParamRec SynthParams)
            {
                IdealLPRec IdealLP = new IdealLPRec();

                IdealLP.Cutoff = IdealLowpassSpecGetCutoff(Template);
                IdealLP.Order  = IdealLowpassSpecGetOrder(Template);
#if DEBUG
                if ((IdealLP.Order < 1) || ((IdealLP.Order % 2) == 0))
                {
                    // order must be positive odd integer
                    Debug.Assert(false);
                    throw new ArgumentException();
                }
#endif
                IdealLP.Order &= 0x1fffffff; /* some sanity -- will result in out of mem instead of gpf */

                IdealLP.OneChannelLength = 1;
                while (IdealLP.OneChannelLength < IdealLP.Order)
                {
                    IdealLP.OneChannelLength = IdealLP.OneChannelLength << 1;
                }

                IdealLP.Coefficients = new AlignedWorkspace(IdealLP.Order);

                int vectorPadding = 0;
#if VECTOR
                if (EnableVector)
                {
                    vectorPadding = Vector <float> .Count - 1;
                }
#endif
                IdealLP.LeftState  = new AlignedWorkspace(IdealLP.OneChannelLength + vectorPadding);
                IdealLP.RightState = new AlignedWorkspace(IdealLP.OneChannelLength + vectorPadding);

                IdealLP.FilterEnabled = GenerateIdealLowPassImpulse(
                    IdealLP.Coefficients.Base,
                    IdealLP.Coefficients.Offset,
                    IdealLP.Order,
                    IdealLP.Cutoff,
                    SynthParams.dSamplingRate);
                if (SynthParams.iSamplingRate < GetIdealLowpassMinSamplingRate(Template))
                {
                    IdealLP.FilterEnabled = false;
                }

                return(IdealLP);
            }
 public static int GetIdealLowpassMinSamplingRate(IdealLPSpecRec IdealLPSpec)
 {
     return(IdealLPSpec.MinSamplingRate);
 }
 public static void SetIdealLowpassMinSamplingRate(IdealLPSpecRec IdealLPSpec, int minSamplingRate)
 {
     IdealLPSpec.MinSamplingRate = minSamplingRate;
 }
 /* get the order for the ideal lowpass filter */
 public static int IdealLowpassSpecGetOrder(IdealLPSpecRec IdealLPSpec)
 {
     return(IdealLPSpec.Order);
 }
 /* get the cutoff frequency for the ideal lowpass filter */
 public static double IdealLowpassSpecGetCutoff(IdealLPSpecRec IdealLPSpec)
 {
     return(IdealLPSpec.Cutoff);
 }
 /* check ideal lowpass filter effect */
 public static SynthErrorCodes CheckIdealLowpassEffectForUnreferencedSamples(
     IdealLPSpecRec IdealLPEffect,
     CheckUnrefParamRec Param)
 {
     return(SynthErrorCodes.eSynthDone);
 }