private void SetTime(TimeSpan time) { int _stime = SynthHelper.getSampleFromTime(synth.SampleRate, (float)time.TotalSeconds); if (_stime > sampleTime) { SilentProcess(_stime - sampleTime); } else if (_stime < sampleTime) {//we have to restart the midi to make sure we get the right temp, instrument, etc synth.Stop(); sampleTime = 0; Array.Clear(currentPrograms, 0, currentPrograms.Length); ResetControllers(); _MidiFile.BeatsPerMinute = 120; eventIndex = 0; SilentProcess(_stime); } }