private unsafe void Decimator_SamplesAvailable(SamplesEventArgs e) { // http://www.designnews.com/author.asp?section_id=1419&doc_id=236273&piddl_msgid=522392 float fftGain = (float)(10.0 * Math.Log10(fftBins / (2.0 * audioDecimator.DecimationFactor))); float offset = 24.0f - fftGain + _fftOffset; if (e.IsComplex) { if (tmpBuffer == null || tmpBuffer.Length < e.Length) { tmpBuffer = DataBuffer.Create(e.Length, sizeof(float)); tmpBufferPtr = (float *)tmpBuffer; } fmDemod.process(e.ComplexBuffer, tmpBufferPtr, e.Length); fmLpf.Process(tmpBufferPtr, e.Length); audioDecimator.process(tmpBufferPtr, tmpBufferPtr, e.Length); _audioFifo.Write(tmpBufferPtr, (int)(e.Length / audioDecimator.DecimationFactor)); sFFTDecimator.updateData(e.ComplexBuffer, e.Length); sFFTDecimator.execute(); sFFTDecimator.copyOutput(e.ComplexBuffer, e.Length); lock (powerBuffer) { FFT.SpectrumPower(e.ComplexBuffer, powerDecimatorPtr, e.Length, offset); } } }
private unsafe void D_SamplesAvailable(SamplesEventArgs e) { if (_fftStream.Length < maxIqSamples) { if (e.IsComplex) { _fftStream.Write(e.ComplexBuffer, e.Length); } else { Console.WriteLine("Weird, the buffer should be Complex"); } } else { Console.WriteLine("Buffer is full!"); } }
private unsafe void audioBufferNeeded(SamplesEventArgs e) { float *audio = e.FloatBuffer; int length = e.Length; if (_audioFifo.Length >= length) { _audioFifo.Read(audioPtr, length); for (int i = 0; i < length; i++) { audio[i * 2] = audioPtr[i] * 50000; audio[i * 2 + 1] = audioPtr[i] * 50000; } } else { for (int i = 0; i < length; i++) { audio[i * 2] = 0; audio[i * 2 + 1] = 0; } } }