示例#1
0
        /// <summary>
        /// Creates Real-Time FFT analyzer.
        /// </summary>
        /// <param name="source">Specified audio provider.</param>
        /// <param name="fftLength">Length of FFT.</param>
        public LiveFftAnalyzer(IAudioProvider source, int fftLength = 16384, bool real = true)
        {
            _real     = real;
            FftLength = fftLength;

            _channels = source.ChannelCount();
            if (!IsPowerOfTwo(fftLength))
            {
                throw new ArgumentException("FFT Length must be a power of two");
            }

            _m         = (int)Math.Log(fftLength, 2.0);
            _fftLength = fftLength;

            FftPlan(_fftLength);

            _fftBuffer = new Complex[fftLength];
            _fftArgs   = new FftEventArgs(_fftBuffer);

            _source = source;
            _source.DataChunkRecieved += DataChunkRecieved;

            if (_source is IFloatProvider)
            {
                (_source as IFloatProvider).FloatChunkRecieved += FloatChunkRecieved;
            }

            WaveFormat = new WaveFormat(_source.SamplingRate(), _source.Bits(), _source.ChannelCount());
            _converter = new FloatConverter(_source.SamplingRate(), _source.Bits(), _source.ChannelCount());
            _step      = _channels * _converter.Step();
        }
示例#2
0
        public G3XDdcDdc1FloatProvider(Ddc1 ddc1, bool seperateIq = false, int bufferSize = 131072)
        {
            _floatBuffer = new float[bufferSize];

            _ddc1      = ddc1;
            SeperateIq = seperateIq;

            _converter = new FloatConverter(SamplingRate(), Bits(), ChannelCount());
            _step      = _converter.Step() * ChannelCount();
        }