private void CreateObserver() { var fftDataLeft = new Complex[fftComplexCount]; var fftDataRight = new Complex[fftComplexCount]; observer = new StreamObserver <float>(fftSize, (int)(fftSize / moveSpeed), 2, true); observer.Completed += multiChannelData => { lock (@lock) { Span <double> tempIn = stackalloc double[fftSize]; ReadSingleChannel(ref multiChannelData[0], tempIn); fftWindow?.Apply(tempIn, tempIn); fft.WriteRealToInput(tempIn); fft.Execute(); fft.ReadOutput <Complex>(fftDataLeft); ReadSingleChannel(ref multiChannelData[1], tempIn); fftWindow?.Apply(tempIn, tempIn); fft.WriteRealToInput(tempIn); fft.Execute(); fft.ReadOutput <Complex>(fftDataRight); fftCompleted?.Invoke(fftDataLeft, fftDataRight); } }; }
public SharedStreamObserver(IWaveIn capture, int fftSize, double moveSpeed, DSP.Window fftWindow) { this.capture = capture; this.fftWindow = fftWindow; fft = FFT.CreateFFT(fftSize); leftFFTData = new Complex[fft.FFTComplexCount]; rightFFTData = new Complex[fft.FFTComplexCount]; streamObserver = new StreamObserver <float>(fftSize, (int)(fftSize / moveSpeed), 2, true); streamObserver.Completed += StreamObserver_Completed; capture.DataAvailable += Capture_DataAvailable; }