コード例 #1
0
        /// <summary>
        /// Changes <paramref name="kernel"/> coefficients online.
        /// </summary>
        public void ChangeKernel(double[] kernel)
        {
            if (kernel.Length != _kernel.Length)
            {
                return;
            }

            Array.Clear(_kernelSpectrumRe, 0, _fftSize);
            kernel.FastCopyTo(_kernel, kernel.Length);
            kernel.FastCopyTo(_kernelSpectrumRe, kernel.Length);

            _fft.Direct(_kernelSpectrumRe, _kernelSpectrumRe, _kernelSpectrumIm);
        }
コード例 #2
0
        public void Fft64Array()
        {
            var input = new double[FrameSize];

            var re = new double[FrameSize];
            var im = new double[FrameSize];

            for (var i = 0; i < N - FrameSize; i += HopSize)
            {
                _samples64.FastCopyTo(input, FrameSize, i);

                _fft64.Direct(input, re, im);
            }
        }
コード例 #3
0
        /// <summary>
        /// Process one frame (block)
        /// </summary>
        public void ProcessFrame()
        {
            var M = _kernel.Length;

            var halfSize = _fftSize / 2;

            Array.Clear(_blockRe, HopSize, M - 1);

            _fft.Direct(_blockRe, _blockRe, _blockIm);
            for (var j = 0; j <= halfSize; j++)
            {
                _convRe[j] = (_blockRe[j] * _kernelSpectrumRe[j] - _blockIm[j] * _kernelSpectrumIm[j]) / _fftSize;
                _convIm[j] = (_blockRe[j] * _kernelSpectrumIm[j] + _blockIm[j] * _kernelSpectrumRe[j]) / _fftSize;
            }
            _fft.Inverse(_convRe, _convIm, _convRe);

            for (var j = 0; j < M - 1; j++)
            {
                _convRe[j] += _lastSaved[j];
            }

            _convRe.FastCopyTo(_lastSaved, M - 1, HopSize);

            _outputBufferOffset = 0;
            _bufferOffset       = 0;
        }
コード例 #4
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="kernel"></param>
        /// <param name="fftSize"></param>
        public OlaBlockConvolver64(IEnumerable <double> kernel, int fftSize)
        {
            _kernel = kernel.ToArray();

            _fftSize = MathUtils.NextPowerOfTwo(fftSize);

            Guard.AgainstExceedance(_kernel.Length, _fftSize, "Kernel length", "the size of FFT");

            _fft = new RealFft64(_fftSize);

            _kernelSpectrumRe = _kernel.PadZeros(_fftSize);
            _kernelSpectrumIm = new double[_fftSize];
            _convRe           = new double[_fftSize];
            _convIm           = new double[_fftSize];
            _blockRe          = new double[_fftSize];
            _blockIm          = new double[_fftSize];
            _lastSaved        = new double[_kernel.Length - 1];

            _fft.Direct(_kernelSpectrumRe, _kernelSpectrumRe, _kernelSpectrumIm);

            Reset();
        }