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


C# WaveOut.Play方法代码示例

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


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

示例1: StartEncoding

        void StartEncoding()
        {
            _startTime = DateTime.Now;
            _bytesSent = 0;
            _segmentFrames = 960;
            _encoder = new OpusEncoder(48000, 1, OpusNet.OpusApplication.Voip);
            _encoder.Bitrate = 8192;
            _decoder = new OpusDecoder(48000, 1);
            _bytesPerSegment = _encoder.FrameByteCount(_segmentFrames);

            _waveIn = new WaveIn(WaveCallbackInfo.FunctionCallback());
            _waveIn.BufferMilliseconds = 50;
            _waveIn.DeviceNumber = comboBox1.SelectedIndex;
            _waveIn.DataAvailable += _waveIn_DataAvailable;
            _waveIn.WaveFormat = new WaveFormat(48000, 16, 1);

            _playBuffer = new BufferedWaveProvider(new WaveFormat(48000, 16, 1));

            _waveOut = new WaveOut(WaveCallbackInfo.FunctionCallback());
            _waveOut.DeviceNumber = comboBox2.SelectedIndex;
            _waveOut.Init(_playBuffer);

            _waveOut.Play();
            _waveIn.StartRecording();

            if (_timer == null)
            {
                _timer = new Timer();
                _timer.Interval = 1000;
                _timer.Tick += _timer_Tick;
            }
            _timer.Start();
        }
开发者ID:VirusFree,项目名称:Opus.NET,代码行数:33,代码来源:Form1.cs

示例2: Main

        static void Main(string[] args)
        {
            string mp3FilesDir = Directory.GetCurrentDirectory();

            if (args.Length > 0)
            {
                mp3FilesDir = args.First();
            }

            var waveOutDevice = new WaveOut();

            var idToFile = Directory.GetFiles(mp3FilesDir, "*.mp3", SearchOption.AllDirectories).ToDictionary(k => int.Parse(Regex.Match(Path.GetFileName(k), @"^\d+").Value));
            while (true)
            {
                Console.WriteLine("Wprowadz numer nagrania");
                var trackId = int.Parse(Console.ReadLine());

                using (var audioFileReader = new AudioFileReader(idToFile[trackId]))
                {
                    waveOutDevice.Init(audioFileReader);
                    waveOutDevice.Play();

                    Console.ReadLine();
                }
            }
            
        }
开发者ID:onliner10,项目名称:FiszkiPlayer,代码行数:27,代码来源:Program.cs

示例3: Main

        static void Main(string[] args)
        {
            // for recording
            waveFileWriter = new WaveFileWriter(@"C:\rec\out.wav", new WaveFormat(44100, 2));

            var sound = new MySound();
            sound.SetWaveFormat(44100, 2);
            sound.init();
            waveOut = new WaveOut();
            waveOut.Init(sound);
            waveOut.Play();

            ConsoleKeyInfo keyInfo;
            bool loop = true;
            while (loop)
            {
                keyInfo = Console.ReadKey();
                if (keyInfo.Key == ConsoleKey.Q)
                {
                    waveOut.Stop();
                    waveOut.Dispose();
                    waveFileWriter.Close();
                    waveFileWriter.Dispose();
                    loop = false;
                }
            }
        }
开发者ID:ryo-okabayashi,项目名称:sound,代码行数:27,代码来源:Program.cs

示例4: Play

        public static Task Play(this Captcha captcha)
        {
            return Task.Run(() =>
            {
                using (MemoryStream memory = new MemoryStream(captcha.Data, false))
                {
                    memory.Seek(0, SeekOrigin.Begin);

                    using (Mp3FileReader reader = new Mp3FileReader(memory))
                    using (WaveStream pcm = WaveFormatConversionStream.CreatePcmStream(reader))
                    using (WaveStream stream = new BlockAlignReductionStream(pcm))
                    {
                        using (WaveOut waveOut = new WaveOut(WaveCallbackInfo.FunctionCallback()))
                        {
                            waveOut.Init(stream);
                            waveOut.Play();

                            while (waveOut.PlaybackState == PlaybackState.Playing)
                            {
                                Thread.Sleep(100);
                            }
                        }
                    }
                }
            });
        }
开发者ID:amacal,项目名称:ine,代码行数:26,代码来源:AudioExtensions.cs

示例5: Form1_Load

        private void Form1_Load(object sender, EventArgs e)
        {
            byte[] apk, ask, bpk, bsk;
            NaClClient.CreateKeys(out apk, out ask);
            NaClClient.CreateKeys(out bpk, out bsk);

            var hasher = System.Security.Cryptography.SHA256.Create();

            _clientA = NaClClient.Create(apk, ask, bpk);
            _clientB = NaClClient.Create(bpk, bsk, apk);

            _sw = new Stopwatch();
            _sw.Start();

            _wave = new WaveIn(this.Handle);
            _wave.WaveFormat = new WaveFormat(12000, 8, 1);
            _wave.BufferMilliseconds = 100;
            _wave.DataAvailable += _wave_DataAvailable;
            _wave.StartRecording();

            _playback = new BufferedWaveProvider(_wave.WaveFormat);

            _waveOut = new WaveOut();
            _waveOut.DesiredLatency = 100;
            _waveOut.Init(_playback);
            _waveOut.Play();
        }
开发者ID:odinhaus,项目名称:Saltable,代码行数:27,代码来源:Form1.cs

示例6: Main

        static void Main(string[] args)
        {
            var adj = new AdjustableTFunc {Value = 1600};

            var tFuncWaveProvider = new TFuncWaveProvider
                {
            //                  Amplitude = TFunc.Sin(new Frequency(adj.TFunc))
            //                  Amplitude = TFunc.Sin(new Frequency(t => TFuncs.Sin(Frequency.Hertz(1))(t) + 1000))
                    Amplitude = TFunc.Sin(TFunc.Sin(Frequency.Hertz(2)) + 1000)
                };
            var waveOut = new WaveOut();
            waveOut.Init(tFuncWaveProvider);
            waveOut.Play();

            Console.WriteLine("Press q to kill");
            char k;
            while ((k = Console.ReadKey().KeyChar) != 'q')
            {
                if (k == 'u')
                {
                    adj.Value+=10;
                }
                if (k == 'd')
                {
                    adj.Value-=10;
                }
                Console.Write(" ");
                Console.WriteLine(adj.Value);
            }

            waveOut.Stop();
            waveOut.Dispose();
        }
开发者ID:rmichela,项目名称:Acoustico,代码行数:33,代码来源:Program.cs

示例7: PlaySound

 public void PlaySound(string name, Action done = null)
 {
     FileStream ms = File.OpenRead(_soundLibrary[name]);
     var rdr = new Mp3FileReader(ms);
     WaveStream wavStream = WaveFormatConversionStream.CreatePcmStream(rdr);
     var baStream = new BlockAlignReductionStream(wavStream);
     var waveOut = new WaveOut(WaveCallbackInfo.FunctionCallback());
     waveOut.Init(baStream);
     waveOut.Play();
     var bw = new BackgroundWorker();
     bw.DoWork += (s, o) =>
                      {
                          while (waveOut.PlaybackState == PlaybackState.Playing)
                          {
                              Thread.Sleep(100);
                          }
                          waveOut.Dispose();
                          baStream.Dispose();
                          wavStream.Dispose();
                          rdr.Dispose();
                          ms.Dispose();
                          if (done != null) done();
                      };
     bw.RunWorkerAsync();
 }
开发者ID:guozanhua,项目名称:KinectGestures,代码行数:25,代码来源:MainWindow.xaml.cs

示例8: StartPlayback

 private void StartPlayback()
 {
     masterMix = new MixingSampleProvider(WaveFormat.CreateIeeeFloatWaveFormat(44100, 2));
     foreach (var source in trackSources) masterMix.AddMixerInput(source);
     outDevice = new WaveOut();
     outDevice.Init(masterMix);
     outDevice.Play();
 }
开发者ID:KineticIsEpic,项目名称:OpenUtau,代码行数:8,代码来源:PlaybackManager.cs

示例9: playButton_Click

 private void playButton_Click(object sender, EventArgs e)
 {
     waveOut = new WaveOut();
     waveOut.PlaybackStopped += waveOut_PlaybackStopped;
     reader = new WaveFileReader("sample.wav");
     waveOut.Init(reader);
     waveOut.Play();
 }
开发者ID:jamesehearn,项目名称:c-sharp-projects,代码行数:8,代码来源:Form1.cs

示例10: Play

        public void Play()
        {
            Stop();
            SetWaveFormat(44100, 2); // 16kHz mono

            Out = new WaveOut();
            Out.Init(this);
            Out.Play();
        }
开发者ID:kebby,项目名称:jss,代码行数:9,代码来源:Preview.cs

示例11: button3_Click_1

        private void button3_Click_1(object sender, EventArgs e)
        {
            //waveOut

            var reader = new WaveFileReader("v.wav");
            var waveOut = new WaveOut(); // or WaveOutEvent()
            waveOut.Init(reader);
            waveOut.Play();
        }
开发者ID:rpieniazek,项目名称:musicCard,代码行数:9,代码来源:Form1.cs

示例12: playnhac

 private void playnhac()
 {
     IWavePlayer waveOutDevice;
     AudioFileReader audioFileReader;
     waveOutDevice = new WaveOut();
     audioFileReader = new AudioFileReader("animal.mp3");
     waveOutDevice.Init(audioFileReader);
     waveOutDevice.Play();
 }
开发者ID:tranquangchau,项目名称:cshap-2008-2013,代码行数:9,代码来源:Form1.cs

示例13: SoundPlay

 private void SoundPlay(WaveOut waveOut, BinauralBeatsWaveOscillator wave, Polyline line, int leftFrequency, int rightFrequency, short amplitude)
 {
     double volumeGainFactor = 0.01;
     waveOut.Volume = (float)(amplitudeSlider.Value * volumeGainFactor);
     wave.LeftFrequency = leftFrequency;
     wave.RightFrequency = rightFrequency;
     wave.Amplitude = amplitude;
     waveOut.Play();
     waveGraphDrawing(line, wave, waveOut);
 }
开发者ID:juyingnan,项目名称:VS,代码行数:10,代码来源:MainWindow.xaml.cs

示例14: PlaySound

        public static void PlaySound(NotificationSound sound)
        {
            IWavePlayer waveOutDevice;
            AudioFileReader audioFileReader;
            waveOutDevice = new WaveOut();

            audioFileReader = new AudioFileReader("resources/sounds/message.mp3");
            waveOutDevice.Init(audioFileReader);
            waveOutDevice.Play();
        }
开发者ID:kioltk,项目名称:VKDesktop,代码行数:10,代码来源:Notificator.cs

示例15: PlayAsync

		private async Task PlayAsync(Action onFinished, Action<Viseme> onVisemeHit, CancellationToken token)
		{
			try
			{
				using (var m = new MemoryStream(_tts.waveStreamData))
				{
					using (var reader = new WaveFileReader(m))
					{
						using (var player = new WaveOut())
						{
							player.Init(reader);
							player.Play();

							var visemes = _tts.visemes;

							int nextViseme = 0;
							double nextVisemeTime = 0;

							while (player.PlaybackState == PlaybackState.Playing)
							{
								if (onVisemeHit != null)
								{
									var s = reader.CurrentTime.TotalSeconds;
									if (s >= nextVisemeTime)
									{
										var v = visemes[nextViseme];
										nextViseme++;
										if (nextViseme >= visemes.Length)
											nextVisemeTime = double.PositiveInfinity;
										else
											nextVisemeTime += v.duration;

										onVisemeHit(v.viseme);
									}
								}

								await Task.Delay(1);
								if (token.IsCancellationRequested)
									break;

								//Console.WriteLine("...next");
							}
							player.Stop();
							onFinished?.Invoke();
						}
					}
				}
			}
			catch (Exception e)
			{
				Console.WriteLine(e.Message);
				throw e;
			}
		}
开发者ID:GAIPS-INESC-ID,项目名称:FAtiMA-Toolkit,代码行数:54,代码来源:VoicePlayer.cs


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