当前位置: 首页>>代码示例>>C#>>正文


C# IWaveSource类代码示例

本文整理汇总了C#中IWaveSource的典型用法代码示例。如果您正苦于以下问题:C# IWaveSource类的具体用法?C# IWaveSource怎么用?C# IWaveSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IWaveSource类属于命名空间,在下文中一共展示了IWaveSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DmoChannelResampler

        /// <summary>
        /// Initializes a new instance of the <see cref="DmoChannelResampler"/> class.
        /// </summary>
        /// <param name="source">Underlying source which has to get resampled.</param>
        /// <param name="channelMatrix"><see cref="ChannelMatrix" /> which defines how to map each channel.</param>
        /// <param name="outputFormat">Waveformat, which specifies the new format. Note, that by far not all formats are supported.</param>
        /// <exception cref="System.ArgumentNullException">
        /// source
        /// or
        /// channelMatrix
        /// or
        /// outputFormat
        /// </exception>
        /// <exception cref="System.ArgumentException">The number of channels of the source has to be equal to the number of input channels specified by the channelMatrix.</exception>
        public DmoChannelResampler(IWaveSource source, ChannelMatrix channelMatrix, WaveFormat outputFormat)
            : base(source, outputFormat)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (channelMatrix == null)
                throw new ArgumentNullException("channelMatrix");
            if(outputFormat == null)
                throw new ArgumentNullException("outputFormat");

            if (source.WaveFormat.Channels != channelMatrix.InputChannelCount)
            {
                throw new ArgumentException(
                    "The number of channels of the source has to be equal to the number of input channels specified by the channelMatrix.");
            }

            var inputFormat = new WaveFormatExtensible(
                source.WaveFormat.SampleRate,
                source.WaveFormat.BitsPerSample,
                source.WaveFormat.Channels,
                WaveFormatExtensible.SubTypeFromWaveFormat(source.WaveFormat),
                channelMatrix.InputMask);

            Outputformat = new WaveFormatExtensible(
                outputFormat.SampleRate,
                outputFormat.BitsPerSample,
                outputFormat.Channels,
                WaveFormatExtensible.SubTypeFromWaveFormat(outputFormat),
                channelMatrix.OutputMask);

            Initialize(inputFormat, Outputformat);
            _channelMatrix = channelMatrix;
            CommitChannelMatrixChanges();
        }
开发者ID:opcon,项目名称:cscore,代码行数:48,代码来源:DmoChannelResampler.cs

示例2: CreateConverter

        public static ISampleSource CreateConverter(IWaveSource source)
        {
            if (source == null)
                throw new ArgumentNullException("source");

            int bps = source.WaveFormat.BitsPerSample;
            if (source.WaveFormat.IsPCM())
            {
                switch (bps)
                {
                    case 8:
                        return new Pcm8BitToSample(source);

                    case 16:
                        return new Pcm16BitToSample(source);

                    case 24:
                        return new Pcm24BitToSample(source);

                    default:
                        throw new NotSupportedException("Waveformat is not supported. Invalid BitsPerSample value.");
                }
            }
            else if (source.WaveFormat.IsIeeeFloat() && bps == 32)
            {
                return new IeeeFloatToSample(source);
            }
            else
            {
                throw new NotSupportedException("Waveformat is not supported. Invalid WaveformatTag.");
            }
        }
开发者ID:CheViana,项目名称:AudioLab,代码行数:32,代码来源:WaveToSampleBase.cs

示例3: DmoAggregator

        /// <summary>
        /// Creates a new instance of the <see cref="DmoAggregator"/> class.
        /// </summary>
        /// <param name="source">Base source of the <see cref="DmoAggregator"/>.</param>
        public DmoAggregator(IWaveSource source)
        {
            if (source == null)
                throw new ArgumentNullException("source");

            _source = source;
        }
开发者ID:CheViana,项目名称:AudioLab,代码行数:11,代码来源:DmoAggregator.cs

示例4: FFTDataProvider

        public FFTDataProvider(IWaveSource source)
        {
            if (source == null)
                throw new ArgumentNullException("source");

            CreateFFTAggregator(source);
        }
开发者ID:CheViana,项目名称:AudioLab,代码行数:7,代码来源:FFTDataProvider.cs

示例5: PlayWithoutStreaming

        private static void PlayWithoutStreaming(IWaveSource waveSource)
        {
            using (var xaudio2 = XAudio2.CreateXAudio2())
            using (var masteringVoice = xaudio2.CreateMasteringVoice()) //ALWAYS create at least one masteringVoice.
            using (var sourceVoice = xaudio2.CreateSourceVoice(waveSource.WaveFormat))
            {
                var buffer = waveSource.ToByteArray();
                using (var sourceBuffer = new XAudio2Buffer(buffer.Length))
                {
                    using (var stream = sourceBuffer.GetStream())
                    {
                        stream.Write(buffer, 0, buffer.Length);
                    }

                    sourceVoice.SubmitSourceBuffer(sourceBuffer);
                }

                sourceVoice.Start();

                Console.WriteLine("Press any key to exit.");
                Console.ReadKey();

                sourceVoice.Stop();
            }
        }
开发者ID:opcon,项目名称:cscore,代码行数:25,代码来源:Program.cs

示例6: WaveAggregatorBase

        /// <summary>
        ///     Creates a new instance of <see cref="WaveAggregatorBase"/> class.
        /// </summary>
        /// <param name="baseSource">Underlying base stream.</param>
        protected WaveAggregatorBase(IWaveSource baseSource)
            : this()
        {
            if (baseSource == null)
                throw new ArgumentNullException("baseSource");

            _baseSource = baseSource;
        }
开发者ID:opcon,项目名称:cscore,代码行数:12,代码来源:WaveAggregatorBase.cs

示例7: Pcm8BitToSample

 public Pcm8BitToSample(IWaveSource source)
     : base(source, 8, AudioEncoding.Pcm)
 {
     if (source == null)
         throw new ArgumentNullException("source");
     if (!source.WaveFormat.IsPCM() && source.WaveFormat.BitsPerSample != 8)
         throw new InvalidOperationException("Invalid format. Format has to 8 bit Pcm.");
 }
开发者ID:CheViana,项目名称:AudioLab,代码行数:8,代码来源:Pcm8BitToSample.cs

示例8: CsCoreData

        internal CsCoreData(ISoundOut soundOut, IWaveSource source)
        {
            this.soundOut = soundOut;
            this.source = source;
            locker = new object();

            soundOut.Initialize(source);
        }
开发者ID:Artentus,项目名称:GameUtils,代码行数:8,代码来源:CsCoreData.cs

示例9: Pcm24BitToSample

 /// <summary>
 /// Initializes a new instance of the <see cref="Pcm24BitToSample"/> class.
 /// </summary>
 /// <param name="source">The underlying 24-bit POCM <see cref="IWaveSource"/> instance which has to get converted to a <see cref="ISampleSource"/>.</param>
 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
 /// <exception cref="ArgumentException">The format of the <paramref name="source"/> is not 24-bit PCM.</exception>
 public Pcm24BitToSample(IWaveSource source)
     : base(source)
 {
     if (source == null)
         throw new ArgumentNullException("source");
     if (!source.WaveFormat.IsPCM() && source.WaveFormat.BitsPerSample != 24)
         throw new InvalidOperationException("Invalid format. Format has to 24 bit Pcm.");
 }
开发者ID:hoangduit,项目名称:cscore,代码行数:14,代码来源:Pcm24BitToSample.cs

示例10: WaveToSampleBase

        public WaveToSampleBase(IWaveSource source, int bits, AudioEncoding encoding)
        {
            if (source == null) throw new ArgumentNullException("source");

            _source = source;
            _waveFormat = new WaveFormat(source.WaveFormat.SampleRate, 32,
                                source.WaveFormat.Channels, AudioEncoding.IeeeFloat);
            _bpsratio = 32.0 / bits;
        }
开发者ID:CheViana,项目名称:AudioLab,代码行数:9,代码来源:WaveToSampleBase.cs

示例11: IeeeFloatToSample

 public IeeeFloatToSample(IWaveSource source)
     : base(source, 32, AudioEncoding.IeeeFloat)
 {
     if (source == null)
         throw new ArgumentNullException("source");
     if (!source.WaveFormat.IsIeeeFloat() ||
         source.WaveFormat.BitsPerSample != 32)
         throw new InvalidOperationException("Invalid format. Format has to be 32 bit IeeeFloat");
 }
开发者ID:CheViana,项目名称:AudioLab,代码行数:9,代码来源:IeeeFloatToSample.cs

示例12: WaveToSampleBase

        /// <summary>
        /// Initializes a new instance of the <see cref="WaveToSampleBase"/> class.
        /// </summary>
        /// <param name="source">The underlying <see cref="IWaveSource"/> instance which has to get converted to a <see cref="ISampleSource"/>.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> argument is null.</exception>
        protected WaveToSampleBase(IWaveSource source)
        {
            if (source == null)
                throw new ArgumentNullException("source");

            Source = source;
            _waveFormat = (WaveFormat) source.WaveFormat.Clone();
            _waveFormat.BitsPerSample = 32;
            _waveFormat.SetWaveFormatTagInternal(AudioEncoding.IeeeFloat);
        }
开发者ID:opcon,项目名称:cscore,代码行数:15,代码来源:WaveToSampleBase.cs

示例13: CachedSoundSource

        /// <summary>
        /// Initializes a new instance of the <see cref="CachedSoundSource"/> class.
        /// </summary>
        /// <param name="source">Source which will be copied to a cache.</param>
        public CachedSoundSource(IWaveSource source)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (source.Length > Int32.MaxValue)
                throw new ArgumentException("Length is of source is too large.");

            _waveFormat = source.WaveFormat;

            CacheSource(source);
        }
开发者ID:ianski,项目名称:cscore,代码行数:15,代码来源:CachedSoundSource.cs

示例14: InitializeVisualization

        public IWaveSource InitializeVisualization(IWaveSource source)
        {
            source = new FFTDataProvider(source) { Bands = 512 };
            FFTDataProvider = source as FFTDataProvider;

            var sampleDataProvier = new SampleDataProvider(source);
            sampleDataProvier.Mode = SampleDataProviderMode.LeftAndRight;
            SampleDataProvider = sampleDataProvier;

            return sampleDataProvier.ToWaveSource(16);
        }
开发者ID:CheViana,项目名称:AudioLab,代码行数:11,代码来源:VisualizationViewModel.cs

示例15: CreateFFTAggregator

        private void CreateFFTAggregator(IWaveSource source)
        {
            if (_fftaggregator != null)
            {
                _fftaggregator.FFTCalculated -= OnNewData;
                _fftaggregator = null;
            }

            _fftaggregator = new FFTAggregator(source);
            _fftaggregator.FFTCalculated += OnNewData;
            BaseStream = _fftaggregator;
        }
开发者ID:CheViana,项目名称:AudioLab,代码行数:12,代码来源:FFTDataProvider.cs


注:本文中的IWaveSource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。