Пример #1
0
 public void AddSource(ISampleProvider source, TimeSpan delayBy)
 {
     ISampleProvider _source;
     if (source.WaveFormat.Channels == 1) _source = new MonoToStereoSampleProvider(source);
     else if (source.WaveFormat.Channels == 2) _source = source;
     else return;
     mix.AddMixerInput(new OffsetSampleProvider(_source) { DelayBy = delayBy });
 }
Пример #2
0
 /// <summary>
 /// Initialises a new instance of SampleChannel
 /// </summary>
 /// <param name="waveProvider">Source wave provider, must be PCM or IEEE</param>
 /// <param name="forceStereo">force mono inputs to become stereo</param>
 public SampleChannel(IWaveProvider waveProvider, bool forceStereo)
 {
     ISampleProvider sampleProvider = SampleProviderConverters.ConvertWaveProviderIntoSampleProvider(waveProvider);
     if (sampleProvider.WaveFormat.Channels == 1 && forceStereo)
     {
         sampleProvider = new MonoToStereoSampleProvider(sampleProvider);
     }
     this.waveFormat = sampleProvider.WaveFormat;
     // let's put the meter before the volume (useful for drawing waveforms)
     this.preVolumeMeter = new MeteringSampleProvider(sampleProvider);
     this.volumeProvider = new VolumeSampleProvider(preVolumeMeter);
 }
Пример #3
0
        /// <summary>
        /// Initialises a new instance of SampleChannel
        /// </summary>
        /// <param name="waveProvider">Source wave provider, must be PCM or IEEE</param>
        /// <param name="forceStereo">force mono inputs to become stereo</param>
        // Token: 0x06000B91 RID: 2961 RVA: 0x000228D0 File Offset: 0x00020AD0
        public SampleChannel(IWaveProvider waveProvider, bool forceStereo)
        {
            ISampleProvider sampleProvider = SampleProviderConverters.ConvertWaveProviderIntoSampleProvider(waveProvider);

            if (sampleProvider.WaveFormat.Channels == 1 && forceStereo)
            {
                sampleProvider = new MonoToStereoSampleProvider(sampleProvider);
            }
            this.waveFormat     = sampleProvider.WaveFormat;
            this.preVolumeMeter = new MeteringSampleProvider(sampleProvider);
            this.volumeProvider = new VolumeSampleProvider(this.preVolumeMeter);
        }
Пример #4
0
        /// <summary>
        /// Initialises a new instance of SampleChannel
        /// </summary>
        /// <param name="waveProvider">Source wave provider, must be PCM or IEEE</param>
        /// <param name="forceStereo">force mono inputs to become stereo</param>
        public SampleChannel(IWaveProvider waveProvider, bool forceStereo)
        {
            ISampleProvider sampleProvider = SampleProviderConverters.ConvertWaveProviderIntoSampleProvider(waveProvider);

            if (sampleProvider.WaveFormat.Channels == 1 && forceStereo)
            {
                sampleProvider = new MonoToStereoSampleProvider(sampleProvider);
            }
            this.waveFormat = sampleProvider.WaveFormat;
            // let's put the meter before the volume (useful for drawing waveforms)
            this.preVolumeMeter = new MeteringSampleProvider(sampleProvider);
            this.volumeProvider = new VolumeSampleProvider(preVolumeMeter);
        }
Пример #5
0
        /// <summary>
        /// Initialises a new instance of SampleChannel
        /// </summary>
        /// <param name="waveProvider">Source wave provider, must be PCM or IEEE</param>
        public SampleChannel(IWaveProvider waveProvider)
        {
            ISampleProvider sampleProvider;

            if (waveProvider.WaveFormat.Encoding == WaveFormatEncoding.Pcm)
            {
                // go to float
                if (waveProvider.WaveFormat.BitsPerSample == 8)
                {
                    sampleProvider = new Pcm8BitToSampleProvider(waveProvider);
                }
                else if (waveProvider.WaveFormat.BitsPerSample == 16)
                {
                    sampleProvider = new Pcm16BitToSampleProvider(waveProvider);
                }
                else if (waveProvider.WaveFormat.BitsPerSample == 24)
                {
                    sampleProvider = new Pcm24BitToSampleProvider(waveProvider);
                }
                else
                {
                    throw new InvalidOperationException("Unsupported operation");
                }
            }
            else if (waveProvider.WaveFormat.Encoding == WaveFormatEncoding.IeeeFloat)
            {
                sampleProvider = new WaveToSampleProvider(waveProvider);
            }
            else
            {
                throw new ArgumentException("Unsupported source encoding");
            }
            if (sampleProvider.WaveFormat.Channels == 1)
            {
                sampleProvider = new MonoToStereoSampleProvider(sampleProvider);
            }
            this.waveFormat = sampleProvider.WaveFormat;
            // let's put the meter before the volume (useful for drawing waveforms)
            this.preVolumeMeter = new MeteringSampleProvider(sampleProvider);
            this.volumeProvider = new VolumeSampleProvider(preVolumeMeter);
        }
Пример #6
0
 /// <summary>
 /// Initialises a new instance of SampleChannel
 /// </summary>
 /// <param name="waveProvider">Source wave provider, must be PCM or IEEE</param>
 public SampleChannel(IWaveProvider waveProvider)
 {
     ISampleProvider sampleProvider;
     if (waveProvider.WaveFormat.Encoding == WaveFormatEncoding.Pcm)
     {
         // go to float
         if (waveProvider.WaveFormat.BitsPerSample == 8)
         {
             sampleProvider = new Pcm8BitToSampleProvider(waveProvider);
         }
         else if (waveProvider.WaveFormat.BitsPerSample == 16)
         {
             sampleProvider = new Pcm16BitToSampleProvider(waveProvider);
         }
         else if (waveProvider.WaveFormat.BitsPerSample == 24)
         {
             sampleProvider = new Pcm24BitToSampleProvider(waveProvider);
         }
         else
         {
             throw new InvalidOperationException("Unsupported operation");
         }
     }
     else if (waveProvider.WaveFormat.Encoding == WaveFormatEncoding.IeeeFloat)
     {
         sampleProvider = new WaveToSampleProvider(waveProvider);
     }
     else
     {
         throw new ArgumentException("Unsupported source encoding");
     }
     if (sampleProvider.WaveFormat.Channels == 1)
     {
         sampleProvider = new MonoToStereoSampleProvider(sampleProvider);
     }
     this.waveFormat = sampleProvider.WaveFormat;
     // let's put the meter before the volume (useful for drawing waveforms)
     this.preVolumeMeter = new MeteringSampleProvider(sampleProvider);
     this.volumeProvider = new VolumeSampleProvider(preVolumeMeter);
 }