Beispiel #1
0
        //filterCutoff is 0..1 (-6 dB point)

        /// <summary>Initializes a new instance of the <see cref="IppResampler" /> class.</summary>
        /// <param name="inRate">The input sampling rate.</param>
        /// <param name="outRate">The output sampling rate.</param>
        /// <param name="requestedFilterOrder">The requested filter order.</param>
        /// <param name="filterCutoff">The 6-dB cutoff frequency of the anti-aliasing filter
        /// as a fraction of the Nyquist frequency. Must be in the range of 0...1.</param>
        /// <param name="kaiserAlpha">The alpha parameter of the Kaiser filter.</param>
        public IppResampler(int inRate, int outRate, int requestedFilterOrder, float filterCutoff, float kaiserAlpha)
        {
            this.inRate  = inRate;
            this.outRate = outRate;

            //allocate memory for the resampler structure
            int       specSize, filterOrder, filterHeight;
            IppStatus rc;

            rc = Ipp.ippsResamplePolyphaseFixedGetSize_32f(inRate, outRate, requestedFilterOrder, &specSize,
                                                           &filterOrder, &filterHeight, IppHintAlgorithm.ippAlgHintFast);
            IppException.Check(rc);

            //{!} docs suggest to use ippsMalloc_8u(specSize), but that results in memory corruption
            pSpec = (IppsResamplingPolyphaseFixed_32f *)Ipp.ippsMalloc_8u(specSize * filterHeight);

            //initialize IPP resampler
            rc = Ipp.ippsResamplePolyphaseFixedInit_32f(inRate, outRate, filterOrder, filterCutoff,
                                                        kaiserAlpha, pSpec, IppHintAlgorithm.ippAlgHintFast);
            IppException.Check(rc);

            //set up input buffer
            inData     = new float[filterOrder];
            readIndex  = readIndex0 = filterOrder / 2;
            writeIndex = writeIndex0 = filterOrder;
        }
Beispiel #2
0
 public static extern IppStatus ippsResamplePolyphaseFixed_32f(float *pSrc, int len,
                                                               float *pDst, float norm, double *pTime, int *pOutlen,
                                                               IppsResamplingPolyphaseFixed_32f *pSpec);
Beispiel #3
0
 public static extern IppStatus ippsResamplePolyphaseFixedInit_32f(int inRate, int outRate,
                                                                   int len, float rollf, float alpha, IppsResamplingPolyphaseFixed_32f *pSpec,
                                                                   IppHintAlgorithm hint);