Search code examples
c#naudio

NAudio playback position


I have a GUI component that shows audio wave form. Also I can display a cursor on this component. Question: How to receive from NAudio which sample is currently sending to sound card/driver? Only idea I have is to raise an event from IWaveProvider after sending samples (in Read method), but this method is not good because of low refresh rate.


Solution

  • If you are using WaveOut you can call GetPosition which calls into the waveOutGetPosition function, returning how many bytes have been written to WaveOut. From this you can calculate where exactly you are, but you may need to take into account repositioning, as WaveOut will not know about this.