Quantcast
Channel: naudio Work Item Rss Feed
Viewing all articles
Browse latest Browse all 738

Commented Unassigned: High resolution timing with WaveStream.Position [16416]

$
0
0
I'm working on a project that will change the color of lights based on the position in a song. I decided to use WaveStream.Position to do all of the timing and triggering for these color changes. First I used a timer to watch WaveStream.Position and that ended up being "too slow" and the timer would miss the point at which to change the color even set at 1 millisecond tick. So ended up creating a separate thread dedicated to watching the position but the problem still persisted. (all of my 'points' were at the correct position and multiples of the WaveStream's .BlockAlign)
Is there a way to get the wavestream's position at a much faster rate?
or is WaveStream.Position the wrong thing to be used in a situation like mine, if so, can you please recommend an alternative.

I apologize for any miss communication, as English is my second language

Thank you,
Justin
Comments: you can use the new IWavePosition.GetPosition method on the IWavePlayer device you are using for more accurate resolution. The position of the WaveStream is just where we have read up to when preparing buffers for the soundcard, whereas GetPosition is reported by the soundcard itself and should be more accurate. Note that this is in terms of number of bytes played - so you must convert to a timespan yourself. Also, it is the number of bytes played since starting playback, which is relative to the starting position of your input file

Viewing all articles
Browse latest Browse all 738

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>