/// <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(); }
/// <summary> /// Rasises <see cref="FftCalculated"/> /// </summary> /// <param name="e">FFT data.</param> protected virtual void OnFftCalculated(FftEventArgs e) { EventHandler <FftEventArgs> handler = FftCalculated; if (handler != null) { handler(this, e); } }
/// <summary> /// Creates a FFT analyzer. /// </summary> /// <param name="fft">FFT raw data.</param> /// <param name="parameters">Specified bin parameters.</param> /// <param name="real"></param> public FrequencyBins(FftEventArgs args, BinParameters parameters, bool real = true) { _realMode = real; Complex[] fft = args.Result; _parameters = parameters; _relativeFrequency = _parameters.Relative ? real ? _parameters.SamplingRate / 4 : _parameters.SamplingRate / 2 : 0; _precision = _parameters.SamplingRate / (double)fft.Length; FillBins(fft, real); }
public SampleAggregator(ISampleProvider source, int fftLength = 4096) { _channels = source.WaveFormat.Channels; if (!IsPowerOfTwo(fftLength)) { throw new ArgumentException("FFT Length must be a power of two"); } _m = (int)Math.Log(fftLength, 2.0); _fftLength = fftLength; _fftBuffer = new Complex[fftLength]; _fftArgs = new FftEventArgs(_fftBuffer); _source = source; }
public override void Update(FftEventArgs args) { FillBins(args.Result); }
public virtual void Update(FftEventArgs args) { FillBins(args.Result); }
/// <summary> /// Creates a FFT analyzer. /// </summary> /// <param name="fft">FFT raw data.</param> /// <param name="parameters">Specified bin parameters.</param> /// <param name="real"></param> public FastFrequencyBins(FftEventArgs args, BinParameters parameters, bool real = true) : this(parameters, args.Result.Length, real) { Update(args); }
public ApproximateFrequencyBins(FftEventArgs args, BinParameters parameters, bool real = true) : base(args, parameters, real) { }