/// <summary> /// Event handler for when the audio engine is done calculating /// FFT results. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void audioEngine_FftCalculated(object sender, FftEventArgs e) { try { spectrumVisualizer.updateBars(e.Result); } catch (NullReferenceException) { } }
/* * public Boolean repeatSong * { * get; * set; * } */ #endregion /// <summary> /// When an FFT is calculated we cascade the event to the calling class /// through this even handler. /// </summary> /// <param name="sender"></param> /// <param name="e">FFT event args - e.Result is a Complex array for the fft result</param> private void asp_FftCalculated(object sender, FftEventArgs e) { EventHandler <FftEventArgs> handler = FftCalculated; if (handler != null) { handler(this, e); } }
/// <summary> /// This constructor checks if the fftLength is a power of two, /// and instantiates the buffers. /// </summary> /// <param name="source"></param> /// <param name="fftLength"></param> public AggregateSampleProvider(ISampleProvider source, int fftLength = 1024) { channels = source.WaveFormat.Channels; if (!IsPowerOfTwo(fftLength)) { throw new ArgumentException("FFT Length must be a power of two"); } this.m = (int)Math.Log(fftLength, 2.0); this.fftLength = fftLength; this.fftBuffer = new Complex[fftLength]; this.fftArgs = new FftEventArgs(fftBuffer); this.source = source; }