using NAudio.Wave; WaveOutEvent waveOut = new WaveOutEvent(); AudioFileReader audioFile = new AudioFileReader("audioFile.wav"); waveOut.Init(audioFile); waveOut.Play(); while (waveOut.PlaybackState == PlaybackState.Playing) { Console.WriteLine($"Current position: {audioFile.Position}"); Thread.Sleep(500); } waveOut.Stop();
using NAudio.Wave; WaveOutEvent waveOut = new WaveOutEvent(); WaveGenerator wg = new WaveGenerator(new SineWaveProvider()); wg.Frequency = 440f; waveOut.Init(wg); waveOut.Play(); while (waveOut.PlaybackState == PlaybackState.Playing) { wg.Frequency = 440f + (float)waveOut.GetPosition() / 100f; // Adjust frequency based on position Thread.Sleep(10); } waveOut.Stop();Both examples use the `NAudio.Wave` package/library.