示例#1
0
        // Unpartitioned compute
        unsafe int compute0(out int nn, out bool moreSamples)
        {
            ushort nc = nChannels;

            // Input is always buffered
            // Read the next Nh/2 data points into the second half of the src buffer
            // NB ReadComplex guarantees the buffer to be padded with zeros past nn
            Complex[][] buf = inputSamples.ReadComplex(K, out nn, out moreSamples);

            mre[] ev = new mre[nc];
            ManualResetEvent[] ee = new ManualResetEvent[nc];
            for (ushort c = 0; c < nc; c++)
            {
                ManualResetEvent mr = new ManualResetEvent(false);
                ev[c].e = mr;
                ev[c].c = c;
                ee[c]   = mr;
                ThreadPool.QueueUserWorkItem(delegate(object e)
                {
                    mre m     = (mre)e;
                    ushort _c = m.c;

                    Complex[] impulseFFT = _NormalImpulseFFT[(nImpulseChannels == 1) ? (ushort)0 : _c];

                    Array.Copy(buf[_c], 0, src[_c], K, K);
                    // if (kj != 0) Array.Clear(src[_c], jj + K, K - jj);

                    Fourier.Convolve(Nh, impulseFFT, src[_c], _deconvolve);

                    Array.Copy(src[_c], output[_c], K);
                    Array.Copy(buf[_c], src[_c], K);
                    // if (kj != 0) Array.Clear(src[_c], jj, K - jj);

                    m.e.Set();
                }, ev[c]);
            }
            WaitHandle.WaitAll(ee);
            //Thread.Sleep(1); // (1);
            return(nn);
        }