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


C# AudioFileReader.Dispose方法代码示例

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


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

示例1: Main

        static void Main(string[] args)
        {
            var quit = new ManualResetEvent(false);
            Console.CancelKeyPress += (s, a) => {
                quit.Set();
                a.Cancel = true;
            };

            var device = new DirectSoundOut();
            var audio = new AudioFileReader("doowackadoo.mp3");

            device.Init(audio);
            device.Play();

            Console.WriteLine("Playing doowackadoo; Ctrl+C to quit");
            quit.WaitOne();

            if(device != null) device.Stop();
            if(audio != null) audio.Dispose();
            if(device != null) device.Dispose();
        }
开发者ID:nathanchere,项目名称:Spikes_JukeSaver,代码行数:21,代码来源:Program.cs

示例2: Run


//.........这里部分代码省略.........
                    argMode = ArgMode.None;
                }
                else if (argMode == ArgMode.Token)
                {
                    m_settingsModel.Token = arg.Trim();
                    argMode = ArgMode.None;
                }
                else if (argMode == ArgMode.Treshold)
                {
                    var v = m_settingsModel.Treshold;
                    if (int.TryParse(arg, out v))
                        m_settingsModel.Treshold = v;
                    argMode = ArgMode.None;
                }
                else if (argMode == ArgMode.ArmedAlarm)
                {
                    if (arg == "y" || arg == "yes" || arg == "t" || arg == "true")
                        m_settingsModel.ArmedAlarm = true;
                    else if (arg == "n" || arg == "no" || arg == "f" || arg == "false")
                        m_settingsModel.ArmedAlarm = false;
                    argMode = ArgMode.None;
                }
                else if (argMode == ArgMode.Silent)
                {
                    if (arg == "y" || arg == "yes" || arg == "t" || arg == "true")
                        m_settingsModel.Silent = true;
                    else if (arg == "n" || arg == "no" || arg == "f" || arg == "false")
                        m_settingsModel.Silent = false;
                    argMode = ArgMode.None;
                }
            }

            m_alarmIsArmed = m_settingsModel.ArmedAlarm;
            Console.WriteLine("* Connection token: " + m_settingsModel.Token);

            SpawnEyeListenerTask();
            SpawnControllerListenerTask();
            SpawnEyeProcessorTask();
            SpawnControllerProcessorTask();
            SpawnCommandsExecutorTask();

            while (m_running)
            {
                var line = Console.ReadLine();
                if (line == "exit")
                    m_running = false;
                else if (line == "arm")
                    ArmAlarm();
                else if (line == "disarm")
                    DisarmAlarm();
                else if (line == "alarm-on")
                    StartAlarm();
                else if (line == "alarm-off")
                    StopAlarm();
            }

            lock (m_commandsLock)
            {
                if (m_commandsQueue != null)
                {
                    foreach (var command in m_commandsQueue)
                        command.PerformAction();
                    m_commandsQueue.Clear();
                }
            }
            lock (m_eyeClientsLock)
            {
                if (m_eyeClients != null)
                    foreach (var eye in m_eyeClients)
                        eye.Value.Close();
            }
            lock (m_controllerClientsLock)
            {
                if (m_controllerClients != null)
                    foreach (var controller in m_controllerClients)
                        controller.Value.Client.Close();
            }
            while (true)
            {
                lock (m_lock)
                {
                    if (m_eyeListener == null && m_controllerListener == null && m_eyeDataQueue == null && m_controllerDataQueue == null && m_commandsQueue == null)
                        break;
                }
                Thread.Sleep(10);
            }
            m_alarmIsPlaying = false;
            lock (m_alarmLock)
            {
                m_waveOutDevice.Stop();
                m_audioFileReader.Dispose();
                m_audioFileReader = null;
                m_waveOutDevice.Dispose();
                m_waveOutDevice = null;
            }
            m_eyeClients = null;
            m_controllerClients = null;
            SaveSettings(m_settingsModel);
            Thread.Sleep(1000);
        }
开发者ID:PsichiX,项目名称:Aegis,代码行数:101,代码来源:Program.cs

示例3: OnMp3RepositionTestClick

 private void OnMp3RepositionTestClick(object sender, EventArgs e)
 {
     var filename = SelectInputFile();
     if (filename == null) return;
     var wo = new WaveOut();
     var af = new AudioFileReader(filename);
     wo.Init(af);
     var f = new Form();
     var b = new Button() { Text = "Play" };
     b.Click += (s, a) => wo.Play();
     var b2 = new Button() { Text = "Stop", Left = b.Right };
     b2.Click += (s, a) => wo.Stop();
     var b3 = new Button { Text = "Rewind", Left = b2.Right };
     b3.Click += (s, a) => af.Position = 0;
     f.FormClosed += (s, a) => { wo.Dispose(); af.Dispose(); };
     f.Controls.Add(b);
     f.Controls.Add(b2);
     f.Controls.Add(b3);
     f.ShowDialog(this);
 }
开发者ID:LibertyLocked,项目名称:NAudio,代码行数:20,代码来源:SimplePlaybackPanel.cs

示例4: Play

		public void Play(object sender, MouseButtonEventArgs e)
		{
			var button = (NumboardButton)sender;
			if (button == null) return;
			if (button.Source == null) return;

			if (!File.Exists(button.Source))
			{
				MessageBox.Show("Cannot Find file '" + button.Source + "'");
				return;
			}

			var fileType = System.IO.Path.GetExtension(button.Source);

			var volume = button.Volume;
			if (volume == null)
			{
				volume = 1;
			}

			//primary ouput
			var primaryReader = new AudioFileReader(button.Source);
			primaryReader.Volume = (float)(volume * MasterVolume);
			
			var primaryWaveOut = new WaveOut();
			primaryWaveOut.DeviceNumber = SelectedPrimaryOutputDevice;

			//secondary ouput
			var secondaryReader = new AudioFileReader(button.Source);
			secondaryReader.Volume = (float)(volume * MasterVolume);

			var secondaryWaveOut = new WaveOut();
			secondaryWaveOut.DeviceNumber = SelectedSecondaryOutputDevice;

			primaryWaveOut.PlaybackStopped += StopStream;

			try
			{

				primaryWaveOut.Init(primaryReader);
				primaryWaveOut.Play();

				secondaryWaveOut.Init(secondaryReader);
				secondaryWaveOut.Play();

				PlayingStreams.Add(new PlayingStream { Button = button, PrimaryReader = primaryReader, SecondaryReader = secondaryReader, PrimaryWaveOut = primaryWaveOut, SecondaryWaveOut = secondaryWaveOut });

			}
			catch (MmException ex)
			{
				primaryReader.Dispose();
				primaryWaveOut.Dispose();
				secondaryReader.Dispose();
				secondaryWaveOut.Dispose();

				if (ex.Result == MmResult.MemoryAllocationError)
				{
					StopAllStreams();
				}
			}
		}
开发者ID:Shadetheartist,项目名称:Numboard-2.0,代码行数:61,代码来源:AudioManager.cs

示例5: loadFile

		/// <summary>
		/// Load music from filename. If not a wav file, convert to wav (so we can seek accurately).
		/// Can call from any thread.
		/// </summary>
		void loadFile(string filename) {
			Status("Loading {0}", filename);
			AudioFileReader r = new AudioFileReader(filename);
			if (Path.GetExtension(filename).ToLower() != ".wav") {
				string wavfilename = Path.Combine(Path.GetTempPath(), Path.GetFileNameWithoutExtension(filename) + ".wav");
				Status("Transcoding to {0}", wavfilename);
				WaveFileWriter.CreateWaveFile(wavfilename, r);
				r.Dispose();
				r = new AudioFileReader(wavfilename);
				Status("Loading {0}", filename);
			}
			if (m_Reader != null)
				m_Reader.Dispose();
			m_Reader = r;
		}
开发者ID:nikkilocke,项目名称:AlbumRecorder,代码行数:19,代码来源:MainForm.cs


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