Example #1
0
            /* create a new histogram processor */
            public static HistogramRec NewHistogram(
                HistogramSpecRec Template,
                SynthParamRec SynthParams)
            {
                double Cutoff;

                HistogramRec Histogram = new HistogramRec();

                Histogram.HistogramString = GetHistogramSpecLabel(Template);

                Histogram.NumBins  = GetHistogramSpecNumBins(Template);
                Histogram.BinArray = new int[Histogram.NumBins];

                Histogram.LeftLowpass  = new FirstOrderLowpassRec();
                Histogram.RightLowpass = new FirstOrderLowpassRec();

                Cutoff = GetHistogramSpecPowerEstimatorCutoff(Template);
                FirstOrderLowpassRec.SetFirstOrderLowpassCoefficients(
                    Histogram.LeftLowpass,
                    Cutoff,
                    SynthParams.dSamplingRate);
                FirstOrderLowpassRec.SetFirstOrderLowpassCoefficients(
                    Histogram.RightLowpass,
                    Cutoff,
                    SynthParams.dSamplingRate);

                Histogram.Min    = GetHistogramSpecBottom(Template);
                Histogram.Max    = GetHistogramSpecTop(Template);
                Histogram.Unders = 0;
                Histogram.Overs  = 0;

                Histogram.IgnoreUnders  = GetHistogramSpecDiscardUnders(Template);
                Histogram.Logarithmic   = GetHistogramSpecBinDistribution(Template);
                Histogram.ChannelSelect = GetHistogramSpecChannelSelector(Template);
                Histogram.FilterMethod  = GetHistogramSpecPowerEstimatorMethod(Template);
                Histogram.ChartWidth    = GetHistogramSpecBarChartWidth(Template);

                Histogram.IgnoreUnders = Histogram.IgnoreUnders || (Histogram.Min == 0);
                if (Histogram.Logarithmic)
                {
                    Histogram.LnMin = Math.Log(Histogram.Min);
                    Histogram.LnMax = Math.Log(Histogram.Max);
                }

                return(Histogram);
            }
Example #2
0
            /* create a new analyzer processor */
            public static AnalyzerRec NewAnalyzer(
                AnalyzerSpecRec Template,
                SynthParamRec SynthParams)
            {
                AnalyzerRec Analyzer = new AnalyzerRec();

                Analyzer.AnalyzerString = GetAnalyzerSpecString(Template);

                Analyzer.LeftMinimum       = Int32.MaxValue;
                Analyzer.LeftMaximum       = Int32.MinValue;
                Analyzer.RightMinimum      = Int32.MaxValue;
                Analyzer.RightMaximum      = Int32.MinValue;
                Analyzer.FrameCount        = 0;
                Analyzer.LeftPowerMaximum  = Int32.MinValue;
                Analyzer.RightPowerMaximum = Int32.MinValue;

                Analyzer.PowerEnabled = IsAnalyzerSpecPowerEstimatorEnabled(Template);
                if (Analyzer.PowerEnabled)
                {
                    Analyzer.LeftLowpass = new FirstOrderLowpassRec();
                    FirstOrderLowpassRec.SetFirstOrderLowpassCoefficients(
                        Analyzer.LeftLowpass,
                        GetAnalyzerSpecPowerEstimatorCutoff(Template),
                        SynthParams.dSamplingRate);

                    Analyzer.RightLowpass = new FirstOrderLowpassRec();
                    FirstOrderLowpassRec.SetFirstOrderLowpassCoefficients(
                        Analyzer.RightLowpass,
                        GetAnalyzerSpecPowerEstimatorCutoff(Template),
                        SynthParams.dSamplingRate);

                    Analyzer.PowerMethod = GetAnalyzerSpecPowerEstimatorMethod(Template);
#if DEBUG
                    if ((Analyzer.PowerMethod != AnalyzerPowerEstType.eAnalyzerPowerAbsVal) &&
                        (Analyzer.PowerMethod != AnalyzerPowerEstType.eAnalyzerPowerRMS))
                    {
                        Debug.Assert(false);
                        throw new ArgumentException();
                    }
#endif
                }

                return(Analyzer);
            }