static void Main(string[] args) { IWavePlayer waveOutDevice; WaveStream mainOutputStream; string fileName = @"C:\Users\Yuval\Sources\PracticeSharpProject\Audio\Ringtone 01.wma"; Console.WriteLine("Initiailizing NAudio"); try { waveOutDevice = new DirectSoundOut(50); } catch (Exception driverCreateException) { Console.WriteLine(String.Format("{0}", driverCreateException.Message)); return; } mainOutputStream = CreateInputStream(fileName); try { waveOutDevice.Init(mainOutputStream); } catch (Exception initException) { Console.WriteLine(String.Format("{0}", initException.Message), "Error Initializing Output"); return; } Console.WriteLine("NAudio Total Time: " + (mainOutputStream as WaveChannel32).TotalTime); Console.WriteLine("Playing WMA.."); waveOutDevice.Volume = 1.0f; waveOutDevice.Play(); Console.ReadKey(); Console.WriteLine("Seeking to new time: 00:00:20.."); (mainOutputStream as WaveChannel32).CurrentTime = new TimeSpan(0, 0, 20); Console.ReadKey(); Console.WriteLine("Hit key to stop.."); waveOutDevice.Stop(); Console.WriteLine("Finished.."); mainOutputStream.Dispose(); waveOutDevice.Dispose(); Console.WriteLine("Press key to exit..."); Console.ReadKey(); }
private void Stoprecording() { if (m_timer != null) { m_timer.Stop(); } { if (sourceStream != null) { if (waveOut != null) //stops sound from playing and disposes { waveOut.Stop(); waveOut.Dispose(); waveOut = null; } if (sourceStream != null) //stops sourcestream from recording and disposes { sourceStream.StopRecording(); sourceStream.Dispose(); sourceStream = null; } return; } } }
// Method needed to cleanup outputStream and waveOut file private void DisposeWave() { if (sourceStream != null) { sourceStream.StopRecording(); sourceStream.Dispose(); sourceStream = null; } if (waveWriter != null) { waveWriter.Dispose(); waveWriter = null; } if (waveOut != null) { if (waveOut.PlaybackState == NAudio.Wave.PlaybackState.Playing) { waveOut.Stop(); } waveOut.Dispose(); waveOut.Stop(); waveOut = null; } if (waveReader != null) { waveReader.Dispose(); waveReader.Close(); waveReader = null; } }
static void Main(string[] args) { IWavePlayer waveOutDevice; WaveStream mainOutputStream; string fileName = @"..\..\Audio\test.ogg"; Console.WriteLine("Initiailizing NAudio"); try { waveOutDevice = new DirectSoundOut(50); } catch (Exception driverCreateException) { Console.WriteLine(String.Format("{0}", driverCreateException.Message)); return; } mainOutputStream = CreateInputStream(fileName); try { waveOutDevice.Init(mainOutputStream); } catch (Exception initException) { Console.WriteLine(String.Format("{0}", initException.Message), "Error Initializing Output"); return; } Console.WriteLine("NAudio Total Time: " + (mainOutputStream as WaveChannel32).TotalTime); Console.WriteLine("Playing Ogg Vorbis.."); waveOutDevice.Volume = 1.0f; waveOutDevice.Play(); Console.ReadKey(); Console.WriteLine("Seeking to new time: 00:01:00.."); (mainOutputStream as WaveChannel32).CurrentTime = new TimeSpan(0, 1, 0); Console.ReadKey(); waveOutDevice.Stop(); Console.WriteLine("Finished.."); mainOutputStream.Dispose(); waveOutDevice.Dispose(); Console.WriteLine("Press key to exit..."); Console.ReadKey(); }
private void stopButton_Click(object sender, EventArgs e) { state = "stop"; playButton.Enabled = true; recordButton.Enabled = true; if (waveOut != null) { waveOut.Stop(); waveOut.Dispose(); waveOut = null; } if (sourceStream != null) { sourceStream.StopRecording(); sourceStream.Dispose(); sourceStream = null; } if (waveWriter != null) { waveWriter.Dispose(); waveWriter = null; } }
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { if (soundOut != null) { soundOut.Stop(); soundOut.Dispose(); soundOut = null; } if (waveFileReader != null) { waveFileReader.Dispose(); waveFileReader = null; } }
public void editorSesDinlemeDurdur() { if (waveOut != null) { waveOut.Stop(); waveOut.Dispose(); waveOut = null; } if (sourceStream != null) { sourceStream.StopRecording(); sourceStream.Dispose(); sourceStream = null; } }
private void button_stop_Click(object sender, EventArgs e) { waveOut?.Stop(); waveOut?.Dispose(); waveOut = null; sourceStream?.StopRecording(); sourceStream?.Dispose(); sourceStream = null; waveWriter?.Dispose(); waveWriter = null; //Label this.Label_Status.Text = "待機中"; }
//Function to dispose the current mp3 file private void DisposeWave() { if (output != null) { if (output.PlaybackState == NAudio.Wave.PlaybackState.Playing) { output.Dispose(); output.Stop(); } if (stream != null) { stream.Dispose(); stream = null; } } }
public void MP3CloseFile() { if (output != null) { if (output.PlaybackState == NAudio.Wave.PlaybackState.Playing) { output.Stop(); } output.Dispose(); output = null; } if (stream != null) { stream.Dispose(); stream = null; } }
private void DisposeWave() { if (output != null) { if (output.PlaybackState == NAudio.Wave.PlaybackState.Playing) { output.Stop(); } output.Dispose(); output = null; } if (wave != null) { wave.Dispose(); wave = null; } }
private void frmRecording_FormClosed(object sender, FormClosedEventArgs e) { if (waveOut != null) { waveOut.Stop(); waveOut.Dispose(); waveOut = null; } if (sourceStream != null) { sourceStream.StopRecording(); sourceStream.Dispose(); sourceStream = null; } if (waveWriter != null) { waveWriter.Dispose(); waveWriter = null; } }
private void button3_Click(object sender, EventArgs e) { if (waveOut != null) { waveOut.Stop(); waveOut.Dispose(); waveOut = null; } if (sourceStream != null) { sourceStream.StopRecording(); sourceStream.Dispose(); sourceStream = null; } if (waveWriter != null) { waveWriter.Dispose(); waveWriter = null; } }
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(); }
public void Play() { var file = Path.Combine(BasicTeraData.Instance.ResourceDirectory, "sound/", File); try { var outputStream = new MediaFoundationReader(file); var volumeStream = new WaveChannel32(outputStream); volumeStream.Volume = Volume; //Create WaveOutEvent since it works in Background and UI Threads var player = new DirectSoundOut(); //Init Player with Configured Volume Stream player.Init(volumeStream); player.Play(); var timer = new Timer((obj) => { player.Stop(); player.Dispose(); volumeStream.Dispose(); outputStream.Dispose(); outputStream = null; player = null; volumeStream = null; }, null, Duration, Timeout.Infinite); } catch (Exception e) { // Get stack trace for the exception with source file information var st = new StackTrace(e, true); // Get the top stack frame var frame = st.GetFrame(0); // Get the line number from the stack frame var line = frame.GetFileLineNumber(); BasicTeraData.LogError("Sound ERROR test" + e.Message + Environment.NewLine + e.StackTrace + Environment.NewLine + e.InnerException + Environment.NewLine + e + Environment.NewLine + "filename:" + file + Environment.NewLine + "line:" + line, false, true); } }
private void btnParar_Click(object sender, EventArgs e) { if (waveOut != null) { waveOut.Stop(); waveOut.Dispose(); waveOut = null; } if (sourceStream != null) { sourceStream.StopRecording(); sourceStream.Dispose(); sourceStream = null; } if (waveWriter != null) { waveWriter.Dispose(); waveWriter = null; } btnIniciar.Enabled = true; btnParar.Enabled = false; WaveAudioLevel.Value = 0; }
private async void tlumaczenienamorsapluszapis(object sender, EventArgs e) { textBox2.Text = null; if (sourceList.SelectedItems.Count == 0) { MessageBox.Show("Wybierz źródło nagrywania"); } else { SaveFileDialog save = new SaveFileDialog(); save.Filter = "Wave File (*.wav)|*.wav;"; if (save.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } int deviceNumber = sourceList.SelectedItems[0].Index; sourceStream = new NAudio.Wave.WaveIn(); sourceStream.DeviceNumber = deviceNumber; sourceStream.WaveFormat = new NAudio.Wave.WaveFormat(44100, NAudio.Wave.WaveIn.GetCapabilities(deviceNumber).Channels); sourceStream.DataAvailable += new EventHandler <NAudio.Wave.WaveInEventArgs>(sourceStream_DataAvailable); waveWriter = new NAudio.Wave.WaveFileWriter(save.FileName, sourceStream.WaveFormat); sourceStream.StartRecording(); char[] tablica = null; String input = textBox1.Text; input = input.ToUpper(); Dictionary <char, String> morse = new Dictionary <char, String>() { { 'A', ".-" }, { 'Ą', ".-.-" }, { 'B', "-..." }, { 'C', "-.-." }, { 'Ć', "-.-.." }, { 'D', "-.." }, { 'E', "." }, { 'Ę', "..-.." }, { 'F', "..-." }, { 'G', "--." }, { 'H', "...." }, { 'I', ".." }, { 'J', ".---" }, { 'K', "-.-" }, { 'L', ".-.." }, { 'Ł', ".-..-" }, { 'M', "--" }, { 'N', "-." }, { 'Ń', "--.--" }, { 'O', "---" }, { 'Ó', "---." }, { 'P', ".--." }, { 'Q', "--.-" }, { 'R', ".-." }, { 'S', "..." }, { 'Ś', "...-..." }, { 'T', "-" }, { 'U', "..-" }, { 'V', "...-" }, { 'W', ".--" }, { 'X', "-..-" }, { 'Y', "-.--" }, { 'Z', "--.." }, { 'Ż', "--..-." }, { 'Ź', "--..-" }, { '0', "-----" }, { '1', ".----" }, { '2', "..---" }, { '3', "...--" }, { '4', "....-" }, { '5', "....." }, { '6', "-...." }, { '7', "--..." }, { '8', "---.." }, { '9', "----." }, }; for (int i = 0; i < input.Length; i++) { if (i > 0) { textBox2.Text += "/"; await Task.Delay(2000); } if (input[i] == ' ') { await Task.Delay(5000); } else { char c = input[i]; if (morse.ContainsKey(c)) { textBox2.Text += morse[c]; } tablica = morse[c].ToCharArray(); for (int i2 = 0; i2 < tablica.Length; i2++) { if (tablica[i2] == '.') { Action beep = () => Console.Beep(1000, 600); await Task.Delay(2000); beep.BeginInvoke(null, null); } if (tablica[i2] == '-') { Action beep2 = () => Console.Beep(1000, 1000); await Task.Delay(2000); beep2.BeginInvoke(null, null); } } } } if (waveOut != null) { await Task.Delay(1000); waveOut.Stop(); waveOut.Dispose(); waveOut = null; } if (sourceStream != null) { await Task.Delay(1000); sourceStream.StopRecording(); sourceStream.Dispose(); sourceStream = null; } if (waveWriter != null) { await Task.Delay(1000); waveWriter.Dispose(); waveWriter = null; } } }
static void Main(string[] args) { IWavePlayer waveOutDevice; WaveStream mainOutputStream; WaveChannel32 waveChannel; string fileName = @"No One's Gonna Love You.mp3"; Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Initiailizing NAudio"); Console.ResetColor(); try { waveOutDevice = new DirectSoundOut(50); } catch (Exception driverCreateException) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(String.Format("{0}", driverCreateException.Message)); return; } mainOutputStream = CreateInputStream(fileName, out waveChannel); try { waveOutDevice.Init(mainOutputStream); } catch (Exception initException) { Console.WriteLine(String.Format("{0}", initException.Message), "Error Initializing Output"); return; } Console.WriteLine("NAudio Total Time: " + waveChannel.TotalTime); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Note: Please use good speakers or headphones, it is hard to notice equalizer changes with cheap/crappy laptop speakers...!"); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("Playing File - Equalizer set to all Zero.."); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("Seeking to new time: 00:01:00.."); waveChannel.CurrentTime = new TimeSpan(0, 1, 0); Console.ResetColor(); waveOutDevice.Volume = 1.0f; waveOutDevice.Play(); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Hit key for next demo.."); Console.ReadKey(); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("Playing File - Equalizer set to Full Treble/Fully Supressed Med.."); waveOutDevice.Pause(); m_eqEffect.HiGainFactor.Value = m_eqEffect.HiGainFactor.Maximum; m_eqEffect.MedGainFactor.Value = m_eqEffect.MedGainFactor.Minimum; m_eqEffect.LoGainFactor.Value = 0; m_eqEffect.OnFactorChanges(); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("Seeking to new time: 00:01:00.."); waveChannel.CurrentTime = new TimeSpan(0, 1, 0); Console.ResetColor(); waveOutDevice.Volume = 1.0f; waveOutDevice.Play(); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Hit key for next demo.."); Console.ReadKey(); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("Playing File - Equalizer set to Full Bass.."); waveOutDevice.Pause(); m_eqEffect.HiGainFactor.Value = 0; m_eqEffect.MedGainFactor.Value = 0; m_eqEffect.LoGainFactor.Value = m_eqEffect.LoGainFactor.Maximum; m_eqEffect.OnFactorChanges(); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("Seeking to new time: 00:01:00.."); waveChannel.CurrentTime = new TimeSpan(0, 1, 0); Console.ResetColor(); waveOutDevice.Volume = 1.0f; waveOutDevice.Play(); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Hit key for next demo.."); Console.ReadKey(); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("Playing File - Equalizer set to Full Bass and Full Treble.."); waveOutDevice.Pause(); m_eqEffect.HiGainFactor.Value = m_eqEffect.HiGainFactor.Maximum; m_eqEffect.MedGainFactor.Value = 0; m_eqEffect.LoGainFactor.Value = m_eqEffect.LoGainFactor.Maximum; m_eqEffect.OnFactorChanges(); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("Seeking to new time: 00:01:00.."); waveChannel.CurrentTime = new TimeSpan(0, 1, 0); Console.ResetColor(); waveOutDevice.Volume = 1.0f; waveOutDevice.Play(); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Hit key for next demo.."); Console.ReadKey(); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("Playing File - Equalizer set to Full Med, Fully Supressed Bass and Treble.."); waveOutDevice.Pause(); m_eqEffect.HiGainFactor.Value = m_eqEffect.HiGainFactor.Minimum; m_eqEffect.MedGainFactor.Value = m_eqEffect.MedGainFactor.Maximum; m_eqEffect.LoGainFactor.Value = m_eqEffect.LoGainFactor.Minimum; m_eqEffect.OnFactorChanges(); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("Seeking to new time: 00:01:00.."); waveChannel.CurrentTime = new TimeSpan(0, 1, 0); Console.ResetColor(); waveOutDevice.Volume = 1.0f; waveOutDevice.Play(); Console.WriteLine("Hit key to stop.."); Console.ResetColor(); Console.ReadKey(); waveOutDevice.Stop(); Console.WriteLine("Finished.."); mainOutputStream.Dispose(); waveOutDevice.Dispose(); Console.WriteLine("Press key to exit..."); Console.ReadKey(); }
private void EncodeButton_Click(object sender, EventArgs e) { vol = VolumeTrk.Value*float.Parse((0.01).ToString()); text = MainRTextBox.Text; Stream str; SoundPlayer sp = new SoundPlayer(); WaveFileReader wfr = new WaveFileReader(Properties.Resources.background); WaveChannel32 wc = new WaveChannel32(wfr,vol,0); DirectSoundOut wfo = new DirectSoundOut(); wfo.Init(wc); wfo.Play(); System.Timers.Timer glc = new System.Timers.Timer(Int32.Parse(IntervalBox.Text)); if (IntervalBox.Enabled) { glc.Start(); glc.Elapsed += new ElapsedEventHandler(glctick); } System.Timers.Timer la = new System.Timers.Timer(2000); la.Elapsed += new ElapsedEventHandler(latick); la.Start(); foreach (char a in text.ToLower()) { //Ищем совпадения по буквам и произносим символ if (english.IndexOf(a) != -1) { switch (a) { case 'a': str = Properties.Resources.a; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(474 + Int32.Parse(TextSpeed.Text)); break; case 'b': str = Properties.Resources.b; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(504 + Int32.Parse(TextSpeed.Text)); break; case 'c': str = Properties.Resources.c; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(517 + Int32.Parse(TextSpeed.Text)); break; case 'd': str = Properties.Resources.d; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(478 + Int32.Parse(TextSpeed.Text)); break; case 'e': str = Properties.Resources.e; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(388 + Int32.Parse(TextSpeed.Text)); break; case 'f': str = Properties.Resources.f; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(623 + Int32.Parse(TextSpeed.Text)); break; case 'g': str = Properties.Resources.g; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(359 + Int32.Parse(TextSpeed.Text)); break; case 'h': str = Properties.Resources.h; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(571 + Int32.Parse(TextSpeed.Text)); break; case 'i': str = Properties.Resources.i; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(432 + Int32.Parse(TextSpeed.Text)); break; case 'j': str = Properties.Resources.j; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(548 + Int32.Parse(TextSpeed.Text)); break; case 'k': str = Properties.Resources.k; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(457 + Int32.Parse(TextSpeed.Text)); break; case 'l': str = Properties.Resources.l; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(434 + Int32.Parse(TextSpeed.Text)); break; case 'm': str = Properties.Resources.m; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(511 + Int32.Parse(TextSpeed.Text)); break; case 'n': str = Properties.Resources.n; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(614 + Int32.Parse(TextSpeed.Text)); break; case 'o': str = Properties.Resources.o; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(460 + Int32.Parse(TextSpeed.Text)); break; case 'p': str = Properties.Resources.p; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(420 + Int32.Parse(TextSpeed.Text)); break; case 'q': str = Properties.Resources.q; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(500 + Int32.Parse(TextSpeed.Text)); break; case 'r': str = Properties.Resources.r; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(632 + Int32.Parse(TextSpeed.Text)); break; case 's': str = Properties.Resources.s; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(704 + Int32.Parse(TextSpeed.Text)); break; case 't': str = Properties.Resources.t; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(571 + Int32.Parse(TextSpeed.Text)); break; case 'u': str = Properties.Resources.u; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(707 + Int32.Parse(TextSpeed.Text)); break; case 'v': str = Properties.Resources.v; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(646 + Int32.Parse(TextSpeed.Text)); break; case 'w': str = Properties.Resources.w; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(580 + Int32.Parse(TextSpeed.Text)); break; case 'x': str = Properties.Resources.x; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(636 + Int32.Parse(TextSpeed.Text)); break; case 'y': str = Properties.Resources.y; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(666 + Int32.Parse(TextSpeed.Text)); break; case 'z': str = Properties.Resources.z; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(486 + Int32.Parse(TextSpeed.Text)); break; case '0': str = Properties.Resources.n0; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(503 + Int32.Parse(TextSpeed.Text)); break; case '1': str = Properties.Resources.n1; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(463 + Int32.Parse(TextSpeed.Text)); break; case '2': str = Properties.Resources.n2; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(418 + Int32.Parse(TextSpeed.Text)); break; case '3': str = Properties.Resources.n3; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(450 + Int32.Parse(TextSpeed.Text)); break; case '4': str = Properties.Resources.n4; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(507 + Int32.Parse(TextSpeed.Text)); break; case '5': str = Properties.Resources.n5; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(582 + Int32.Parse(TextSpeed.Text)); break; case '6': str = Properties.Resources.n6; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(582 + Int32.Parse(TextSpeed.Text)); break; case '7': str = Properties.Resources.n7; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(520 + Int32.Parse(TextSpeed.Text)); break; case '8': str = Properties.Resources.n8; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(373 + Int32.Parse(TextSpeed.Text)); break; case '9': str = Properties.Resources.n9; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(523 + Int32.Parse(TextSpeed.Text)); break; case '.': str = Properties.Resources.dot; sp = new SoundPlayer(str); sp.Play(); Thread.Sleep(663 + Int32.Parse(TextSpeed.Text)); break; case ' ': Thread.Sleep(Math.Abs(Int32.Parse(TextSpeed.Text))); break; } } } try { glc.Stop(); glc.Dispose(); } catch{} la.Stop(); la.Dispose(); wfo.Dispose(); wc.Dispose(); wfr.Dispose(); GC.Collect(); }
static void Main(string[] args) { IWavePlayer waveOutDevice; WaveStream mainOutputStream; // 16 bit FLAC string fileName = @"Spark2.flac"; // 24 bit FLAC //string fileName = @"PASC183_24test.flac"; Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Initiailizing NAudio"); Console.ResetColor(); try { waveOutDevice = new DirectSoundOut(50); } catch (Exception driverCreateException) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(String.Format("{0}", driverCreateException.Message)); return; } mainOutputStream = CreateInputStream(fileName); try { waveOutDevice.Init(mainOutputStream); } catch (Exception initException) { Console.WriteLine(String.Format("{0}", initException.Message), "Error Initializing Output"); return; } Console.WriteLine("NAudio Total Time: " + (mainOutputStream as WaveChannel32).TotalTime); Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine("Playing FLAC.."); Console.ResetColor(); waveOutDevice.Volume = 1.0f; waveOutDevice.Play(); TestSeekPosition(mainOutputStream, new TimeSpan(0, 0, 10)); TestSeekPosition(mainOutputStream, new TimeSpan(0, 0, 30)); TestSeekPosition(mainOutputStream, new TimeSpan(0, 0, 00)); TestSeekPosition(mainOutputStream, new TimeSpan(0, 4, 04)); TestSeekPosition(mainOutputStream, new TimeSpan(0, 0, 09)); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Hit key to stop.."); Console.ResetColor(); Console.ReadKey(); waveOutDevice.Stop(); Console.WriteLine("Finished.."); mainOutputStream.Dispose(); waveOutDevice.Dispose(); Console.WriteLine("Press key to exit..."); Console.ReadKey(); }