Example #1
0
        /// <summary>Creates a new `AudioStream` from an `IWaveIn` input by buffering it with a `BufferedWaveProvider`. Also resamples the input and optionally converts it to single-channel audio.</summary>
        /// <param name="source">The infinite input audio stream.</param>
        /// <param name="targetSampleRate">Used to resample the `IWaveIn` input. This should match the sample rate (in Hz) the `Analyzer` is using (via `Config.SampleRate`).</param>
        /// <param name="forceMono">Toggles conversion of multi-channel audio to mono.</param>
        public AudioStream(IWaveIn source, int targetSampleRate, bool forceMono = true)
        {
            this.source = source.ToBufferedWaveProvider();
            var samples = forceMono ? this.source.ToSampleProvider().AsMono() : this.source.ToSampleProvider();

            this.samples = samples.Resample(targetSampleRate);
        }