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


C# Wave.WaveStream类代码示例

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


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

示例1: ResamplerDmoStream

        /// <summary>
        /// WaveStream to resample using the DMO Resampler
        /// </summary>
        /// <param name="inputProvider">Input Stream</param>
        /// <param name="outputFormat">Desired Output Format</param>
        public ResamplerDmoStream(IWaveProvider inputProvider, WaveFormat outputFormat)
        {
            this.inputProvider = inputProvider;
            this.inputStream = inputProvider as WaveStream;
            this.outputFormat = outputFormat;
            this.resampler = new Resampler();
            if (!resampler.MediaObject.SupportsInputWaveFormat(0, inputProvider.WaveFormat))
            {
                throw new ArgumentException("Unsupported Input Stream format", "inputStream");
            }

            resampler.MediaObject.SetInputWaveFormat(0, inputProvider.WaveFormat);
            if (!resampler.MediaObject.SupportsOutputWaveFormat(0, outputFormat))
            {
                throw new ArgumentException("Unsupported Output Stream format", "outputStream");
            }

            resampler.MediaObject.SetOutputWaveFormat(0, outputFormat);
            if (inputStream != null)
            {
                position = InputToOutputPosition(inputStream.Position);
            }
            this.inputMediaBuffer = new MediaBuffer(inputProvider.WaveFormat.AverageBytesPerSecond);
            this.outputBuffer = new DmoOutputDataBuffer(outputFormat.AverageBytesPerSecond);
        }
开发者ID:BGCX261,项目名称:ziggy-pro-editor-svn-to-git,代码行数:30,代码来源:ResamplerDmoStream.cs

示例2: WaveFormatConversionStream

 /// <summary>
 /// Create a new WaveFormat conversion stream
 /// </summary>
 /// <param name="targetFormat">Desired output format</param>
 /// <param name="sourceStream">Source stream</param>
 public WaveFormatConversionStream(WaveFormat targetFormat, WaveStream sourceStream)
 {
     this.sourceStream = sourceStream;
     this.targetFormat = targetFormat;
     conversionProvider = new WaveFormatConversionProvider(targetFormat, sourceStream);
     length = EstimateSourceToDest((int)sourceStream.Length);
     position = 0;
 }
开发者ID:ActivePHOENiX,项目名称:NAudio,代码行数:13,代码来源:WaveFormatConversionStream.cs

示例3: Load

 public bool Load(string path, Guid device)
 {
     var cext = path.GetExt();
     _myWaveOut = new DirectSoundOut(device);
     try
     {
         _myWaveStream = _codecs.First(v => v.Extensions.Contains(cext)).CreateWaveStream(path);
     }
     catch
     {
         return false;
     }
     if (_myWaveStream == null) return false;
     if (_myWaveStream.WaveFormat.Channels == 2)
     {
         _myBalanceSampleProvider = new BalanceSampleProvider(_myWaveStream.ToSampleProvider());
         _myVolumeSampleProvider = new VolumeSampleProvider(_myBalanceSampleProvider);
         _myBalanceSampleProvider.Pan = (float)Balance;
     }
     else _myVolumeSampleProvider = new VolumeSampleProvider(_myWaveStream.ToSampleProvider());
     _myEqualizer = new Equalizer(_myVolumeSampleProvider, _equalizerBands) { Enabled = _enableEqualizer };
     _myWaveOut.Init(_myEqualizer);
     _myWaveOut.PlaybackStopped += MyWaveOutOnPlaybackStopped;
     _myVolumeSampleProvider.Volume = (float)Volume;
     return true;
 }
开发者ID:OronDF343,项目名称:Sky-Jukebox,代码行数:26,代码来源:NAudioPlayer.cs

示例4: AddInputStream

        /// <summary>
        /// Add a new input to the mixer
        /// </summary>
        /// <param name="waveStream">The wave input to add</param>
        public void AddInputStream(WaveStream waveStream)
        {
            if (waveStream.WaveFormat.Encoding != WaveFormatEncoding.IeeeFloat)
                throw new ArgumentException("Must be IEEE floating point", "waveStream");
            if (waveStream.WaveFormat.BitsPerSample != 32)
                throw new ArgumentException("Only 32 bit audio currently supported", "waveStream");

            if (inputStreams.Count == 0)
            {
                // first one - set the format
                int sampleRate = waveStream.WaveFormat.SampleRate;
                int channels = waveStream.WaveFormat.Channels;
                this.waveFormat = WaveFormat.CreateIeeeFloatWaveFormat(sampleRate, channels);
            }
            else
            {
                if (!waveStream.WaveFormat.Equals(waveFormat))
                    throw new ArgumentException("All incoming channels must have the same format", "waveStream");
            }

            lock (inputsLock)
            {
                this.inputStreams.Add(waveStream);
                this.length = Math.Max(this.length, waveStream.Length);
                // get to the right point in this input file
                waveStream.Position = Position;
            }
        }
开发者ID:Shadetheartist,项目名称:Numboard-2.0,代码行数:32,代码来源:WaveMixerStream32.cs

示例5: WaveListenerProvider

        public WaveListenerProvider(WaveStream sourceStream)
        {
            this.sourceStream = sourceStream;
            waveFormat = WaveFormat.CreateIeeeFloatWaveFormat(sourceStream.WaveFormat.SampleRate, sourceStream.WaveFormat.Channels);

            sampleAggregator.FftCalculated += new EventHandler<FftEventArgs>(FftCalculated);
            sampleAggregator.PerformFFT = true;
        }
开发者ID:Magicpig55,项目名称:MMP,代码行数:8,代码来源:WaveListenerProvider.cs

示例6: MeteringStream

 public MeteringStream(WaveStream sourceStream, int samplesPerNotification)
 {
     SourceStream = sourceStream;
     if (sourceStream.WaveFormat.BitsPerSample != 32)
         throw new ArgumentException("Metering Stream expects 32 bit floating point audio", "sourceStream");
     maxSamples = new float[sourceStream.WaveFormat.Channels];
     this.SamplesPerNotification = samplesPerNotification;
 }
开发者ID:RasterCode,项目名称:OtterUI,代码行数:8,代码来源:MeteringStream.cs

示例7: EffectStream

 public EffectStream(EffectChain effects, WaveStream sourceStream)
 {
     this.effects = effects;
     this.source = sourceStream;
     foreach (Effect effect in effects)
     {
         InitialiseEffect(effect);
     }
 }
开发者ID:AlexShkor,项目名称:GestoMusic,代码行数:9,代码来源:EffectStream.cs

示例8: CreatePcmStream

 /// <summary>
 /// Creates a stream that can convert to PCM
 /// </summary>
 /// <param name="sourceStream">The source stream</param>
 /// <returns>A PCM stream</returns>
 public static WaveStream CreatePcmStream(WaveStream sourceStream)
 {
     if (sourceStream.WaveFormat.Encoding == WaveFormatEncoding.Pcm)
     {
         return sourceStream;
     }
     WaveFormat pcmFormat = AcmStream.SuggestPcmFormat(sourceStream.WaveFormat);
     return new WaveFormatConversionStream(pcmFormat, sourceStream);
 }
开发者ID:Punloeu,项目名称:karaoke,代码行数:14,代码来源:WaveFormatConversionStream.cs

示例9: PlaySong

 public int PlaySong(string path)
 {
     int result = 0;
     sync.InvokeIfRequired((Action)delegate
     {
         CleanPlayerAndStream();
         result = -1;
         if (!string.IsNullOrEmpty(path))
         {
             try
             {
                 MakePlayerInternal();
                 stream = CreateStream(path);
                 player.Init(stream);
                 player.Play();
                 result = (int)(stream.Length / stream.WaveFormat.AverageBytesPerSecond);
             }
             catch (Exception)
             {
                 CleanPlayerAndStream();
             }
         }
     });
     return result;
 }
开发者ID:punker76,项目名称:HaMusic,代码行数:25,代码来源:NAudioPlayer.cs

示例10: MainForm

 public MainForm()
 {
     waveOutDevice = null;
     mainOutputStream = null;
     volumeStream = null;
     InitializeComponent();
 }
开发者ID:dolvlo,项目名称:ssamplerates,代码行数:7,代码来源:MainForm.cs

示例11: playWave

 /// <summary>
 /// Lejátszik egy .mp3 fájlt
 /// </summary>
 /// <param name="audioFile">.mp3 fájl</param>
 public static void playWave(string audioFile)
 {
     thread = new WaveOut();
     stream = CreateInputStream(audioFile);
     thread.Init(stream);
     thread.Play();
 }
开发者ID:Easimer,项目名称:bearded-spider,代码行数:11,代码来源:Audio.cs

示例12: Initialize

        private void Initialize()
        {
            var extension = Path.GetExtension(file).ToLowerInvariant();

            if (extension.Equals(".wav"))
            {
                reader = new WaveFileReader(file);
            }
            else
            {
                reader = new Mp3FileReader(file);
            }

            var format = reader.WaveFormat;

            this.sampleRate = format.SampleRate;
            this.channels = format.Channels;

            this.Format = new AudioProperties(format.SampleRate, format.BitsPerSample,
                format.Channels, (int)reader.TotalTime.TotalSeconds);

            if (format.BitsPerSample != 16)
            {
                Dispose(true);
            }
        }
开发者ID:wo80,项目名称:AcoustID.NET,代码行数:26,代码来源:NAudioDecoder.cs

示例13: NAudioDecoder

        public NAudioDecoder(string file)
        {
            extension = Path.GetExtension(file).ToLowerInvariant();

            ready = false;

            if (extension.Equals(".wav"))
            {
                reader = new WaveFileReader(file);
            }
            else
            {
                reader = new Mp3FileReader(file);
            }

            var format = reader.WaveFormat;

            bitsPerSample = format.BitsPerSample;
            sampleRate = format.SampleRate;
            channels = format.Channels;
            
            duration = (int)reader.TotalTime.TotalSeconds;

            ready = (format.BitsPerSample == 16);
        }
开发者ID:knocte,项目名称:AcoustID.NET,代码行数:25,代码来源:NAudioDecoder.cs

示例14: SoundResource

        public SoundResource(ResourceManager mgr, string fullName, Stream stream, Format fmt)
        {
            _manager = mgr;
            FullName = fullName;

            switch (fmt)
            {
                case Format.MP3:
                {
                    Mp3FileReader mp3 = new Mp3FileReader(stream);
                    _reader = mp3;
                    break;
                }
                case Format.WAV:
                {
                    WaveFileReader wav = new WaveFileReader(stream);
                    _reader = wav;
                    break;
                }
                default:
                    throw new InvalidOperationException("Unsupported extension.");
            }

            _stream = new WaveChannel32(_reader);
            _stream.PadWithZeroes = false;

            _wavDevice.PlaybackStopped += _wavDevice_PlaybackStopped;
        }
开发者ID:Veggie13,项目名称:Genesis,代码行数:28,代码来源:SoundResource.cs

示例15: CreateReaderStream

 /// <summary>
 /// Creates the reader stream, supporting all filetypes in the core NAudio library,
 /// and ensuring we are in PCM format
 /// </summary>
 /// <param name="fileName">File Name</param>
 private void CreateReaderStream(string fileName)
 {
     if (fileName.EndsWith(".wav", StringComparison.OrdinalIgnoreCase))
     {
         readerStream = new WaveFileReader(fileName);
         if (readerStream.WaveFormat.Encoding != WaveFormatEncoding.Pcm && readerStream.WaveFormat.Encoding != WaveFormatEncoding.IeeeFloat)
         {
             readerStream = WaveFormatConversionStream.CreatePcmStream(readerStream);
             readerStream = new BlockAlignReductionStream(readerStream);
         }
     }
     else if (fileName.EndsWith(".mp3", StringComparison.OrdinalIgnoreCase))
     {
         readerStream = new Mp3FileReader(fileName);
     }
     else if (fileName.EndsWith(".aiff"))
     {
         readerStream = new AiffFileReader(fileName);
     }
     else
     {
         // fall back to media foundation reader, see if that can play it
         readerStream = new MediaFoundationReader(fileName);
     }
 }
开发者ID:ActivePHOENiX,项目名称:NAudio,代码行数:30,代码来源:AudioFileReader.cs


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