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
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