private IWaveSource CreateWaveSource(ISampleSource sampleSource, CustomFftProvider fftProvider)
        {
            var sampleStream = new SingleBlockNotificationStream(sampleSource);

            sampleStream.SingleBlockRead += (s, a) => fftProvider.Add(a.Left, a.Right);
            return(sampleStream.ToWaveSource(16));
        }
        public FftResultStream(FftSize fftSize, WindowFunction windowFunction, MMDevice device)
        {
            FftSize        = (int)fftSize;
            Device         = device;
            _fft           = new float[(int)fftSize];
            _wasapiCapture = CreateWaspiCapture();
            var sampleSource = CreateSampleSource(_wasapiCapture);

            _fftProvider = new CustomFftProvider(sampleSource.WaveFormat.Channels, fftSize, windowFunction);
            _waveSource  = CreateWaveSource(sampleSource, _fftProvider);
            _buffer      = new byte[_waveSource.WaveFormat.BytesPerSecond / 2];
        }