コード例 #1
0
ファイル: Histogram.cs プロジェクト: programmatom/OutOfPhase
            /* helper function to generate filter */
            private static void HistogramFilter(
                HistogramRec Histogram,
                float[] Workspace,
                int WorkspaceOffset,
                int Length,
                FirstOrderLowpassRec Lowpass)
            {
                switch (Histogram.FilterMethod)
                {
                default:
                    Debug.Assert(false);
                    throw new ArgumentException();

                case HistogramPowerEstType.eHistogramAbsVal:
                case HistogramPowerEstType.eHistogramSmoothedAbsVal:
                    FloatVectorAbsVal(
                        Workspace,
                        WorkspaceOffset,
                        Workspace,
                        WorkspaceOffset,
                        Length);
                    break;

                case HistogramPowerEstType.eHistogramSmoothedRMS:
                    FloatVectorSquare(
                        Workspace,
                        WorkspaceOffset,
                        Workspace,
                        WorkspaceOffset,
                        Length);
                    break;
                }

                switch (Histogram.FilterMethod)
                {
                default:
                    Debug.Assert(false);
                    throw new ArgumentException();

                case HistogramPowerEstType.eHistogramAbsVal:
                    break;

                case HistogramPowerEstType.eHistogramSmoothedAbsVal:
                case HistogramPowerEstType.eHistogramSmoothedRMS:
                    FirstOrderLowpassRec.ApplyFirstOrderLowpassVectorModify(
                        Lowpass,
                        Workspace,
                        WorkspaceOffset,
                        Length);
                    break;
                }

                switch (Histogram.FilterMethod)
                {
                default:
                    Debug.Assert(false);
                    throw new ArgumentException();

                case HistogramPowerEstType.eHistogramAbsVal:
                case HistogramPowerEstType.eHistogramSmoothedAbsVal:
                    break;

                case HistogramPowerEstType.eHistogramSmoothedRMS:
                    FloatVectorSquareRoot(
                        Workspace,
                        WorkspaceOffset,
                        Length);
                    break;
                }
            }
コード例 #2
0
ファイル: Analyzer.cs プロジェクト: programmatom/OutOfPhase
            /* apply analyzer to some stuff */
            public SynthErrorCodes Apply(
                float[] workspace,
                int lOffset,
                int rOffset,
                int nActualFrames,
                SynthParamRec synthParams)
            {
                this.FrameCount += nActualFrames;

#if DEBUG
                Debug.Assert(!synthParams.ScratchWorkspace1InUse);
                synthParams.ScratchWorkspace1InUse = true;
#endif
                int LeftBufferOffset  = synthParams.ScratchWorkspace1LOffset;
                int RightBufferOffset = synthParams.ScratchWorkspace1ROffset;

                /* build buffers */
                FloatVectorCopy(
                    workspace,
                    lOffset,
                    workspace,
                    LeftBufferOffset,
                    nActualFrames);
                FloatVectorCopy(
                    workspace,
                    rOffset,
                    workspace,
                    RightBufferOffset,
                    nActualFrames);

                FloatVectorReductionMinMax(
                    ref this.LeftMinimum,
                    ref this.LeftMaximum,
                    workspace,
                    LeftBufferOffset,
                    nActualFrames);
                FloatVectorReductionMinMax(
                    ref this.RightMinimum,
                    ref this.RightMaximum,
                    workspace,
                    RightBufferOffset,
                    nActualFrames);

                /* compute power analysis */
                if (this.PowerEnabled)
                {
                    switch (this.PowerMethod)
                    {
                    default:
                        Debug.Assert(false);
                        throw new ArgumentException();

                    case AnalyzerPowerEstType.eAnalyzerPowerAbsVal:
                    {
                        float Min = 0;

                        /* absval the vector */
                        FloatVectorAbsVal(
                            workspace,
                            LeftBufferOffset,
                            workspace,
                            LeftBufferOffset,
                            nActualFrames);
                        FloatVectorAbsVal(
                            workspace,
                            RightBufferOffset,
                            workspace,
                            RightBufferOffset,
                            nActualFrames);

                        /* apply filter */
                        FirstOrderLowpassRec.ApplyFirstOrderLowpassVectorModify(
                            this.LeftLowpass,
                            workspace,
                            LeftBufferOffset,
                            nActualFrames);
                        FirstOrderLowpassRec.ApplyFirstOrderLowpassVectorModify(
                            this.RightLowpass,
                            workspace,
                            RightBufferOffset,
                            nActualFrames);

                        /* compute maximum */
                        FloatVectorReductionMinMax(
                            ref Min,
                            ref this.LeftPowerMaximum,
                            workspace,
                            LeftBufferOffset,
                            nActualFrames);
                        FloatVectorReductionMinMax(
                            ref Min,
                            ref this.RightPowerMaximum,
                            workspace,
                            RightBufferOffset,
                            nActualFrames);
                    }
                    break;

                    case AnalyzerPowerEstType.eAnalyzerPowerRMS:
                    {
                        float Min = 0;

                        /* square the vector */
                        FloatVectorSquare(
                            workspace,
                            LeftBufferOffset,
                            workspace,
                            LeftBufferOffset,
                            nActualFrames);
                        FloatVectorSquare(
                            workspace,
                            RightBufferOffset,
                            workspace,
                            RightBufferOffset,
                            nActualFrames);

                        /* apply filter */
                        FirstOrderLowpassRec.ApplyFirstOrderLowpassVectorModify(
                            this.LeftLowpass,
                            workspace,
                            LeftBufferOffset,
                            nActualFrames);
                        FirstOrderLowpassRec.ApplyFirstOrderLowpassVectorModify(
                            this.RightLowpass,
                            workspace,
                            RightBufferOffset,
                            nActualFrames);

                        /* compute square root */
                        FloatVectorSquareRoot(
                            workspace,
                            LeftBufferOffset,
                            nActualFrames);
                        FloatVectorSquareRoot(
                            workspace,
                            RightBufferOffset,
                            nActualFrames);

                        /* compute maximum */
                        FloatVectorReductionMinMax(
                            ref Min,
                            ref this.LeftPowerMaximum,
                            workspace,
                            LeftBufferOffset,
                            nActualFrames);
                        FloatVectorReductionMinMax(
                            ref Min,
                            ref this.RightPowerMaximum,
                            workspace,
                            RightBufferOffset,
                            nActualFrames);
                    }
                    break;
                    }
                }

#if DEBUG
                synthParams.ScratchWorkspace1InUse = false;
#endif

                return(SynthErrorCodes.eSynthDone);
            }