protected void SampleAnalyzerLoop()
        {
            while (sampleAnalyzerMustStop.WaitOne(0) == false)
            {
                if (ProTONEConfig.IsSignalAnalisysActive())
                {
                    AudioSample smp = null;
                    if (samples.TryDequeue(out smp) && smp != null)
                    {
                        ExtractSamples(smp);
                    }

                    Thread.Yield();
                }
                else
                {
                    Thread.Sleep(1);
                }
            }
        }
        // ISampleGrabberCB Members

        public int BufferCB(double sampleTime, IntPtr pBuffer, int bufferLen)
        {
            if (ProTONEConfig.IsSignalAnalisysActive())
            {
                try
                {
                    if (sampleGrabberConfigured.WaitOne(0) && _actualAudioFormat != null)
                    {
                        const int fraction = 128;

                        byte[] allBytes = new byte[bufferLen];
                        Marshal.Copy(pBuffer, allBytes, 0, bufferLen);

                        int pos = 0;

                        double chunkTimeLen = (double)fraction / (double)_actualAudioFormat.nSamplesPerSec;
                        int    chunkSize    = fraction * _actualAudioFormat.nBlockAlign;
                        int    i            = 0;

                        do
                        {
                            int size = Math.Min(chunkSize, bufferLen - pos);

                            AudioSample smp = new AudioSample();
                            smp.RawSamples = new byte[size];
                            smp.SampleTime = sampleTime + i * chunkTimeLen;

                            Array.Copy(allBytes, pos, smp.RawSamples, 0, size);

                            samples.Enqueue(smp);

                            pos += size;
                            i++;
                        }while (pos < bufferLen);
                    }
                }
                catch { }
            }

            return(0);
        }