// GetSoundtime private static void GetSoundTime() { int fullsamples = _shm.samples / _shm.channels; int samplepos = _Controller.GetPosition(); if (samplepos < _OldSamplePos) { _Buffers++; // buffer wrapped if (_PaintedTime > 0x40000000) { // time to chop things off to avoid 32 bit limits _Buffers = 0; _PaintedTime = fullsamples; StopAllSounds(true); } } _OldSamplePos = samplepos; _SoundTime = _Buffers * fullsamples + samplepos / _shm.channels; }