Esempio n. 1
0
        // Partitioned compute
        unsafe int computeP(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;
                ev[c].p = p;
                ee[c]   = mr;
                ThreadPool.QueueUserWorkItem(delegate(object e)
                {
                    mre m     = (mre)e;
                    ushort _c = m.c;

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

                    Array.Copy(buf[_c], 0, src[_c], K, K);

                    Fourier.ConvolvePart(L, m.p, P, impulseFFT, src[_c], accum[_c], output[_c], _deconvolve);

                    Array.Copy(buf[_c], src[_c], K);

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