public void FillMidiEventQueue() { var millisecondsPerBuffer = (_synthesizer.MicroBufferSize / (double)_synthesizer.SampleRate) * 1000 * PlaybackSpeed; for (int i = 0; i < _synthesizer.MicroBufferCount; i++) { _currentTime += millisecondsPerBuffer; while (_eventIndex < _synthData.Count && _synthData[_eventIndex].Delta < _currentTime) { _synthesizer.DispatchEvent(i, _synthData[_eventIndex]); _eventIndex++; } } }
private bool FillMidiEventQueueLimited(double maxMilliseconds) { var millisecondsPerBuffer = (_synthesizer.MicroBufferSize / (double)_synthesizer.SampleRate) * 1000 * PlaybackSpeed; if (maxMilliseconds > 0 && maxMilliseconds < millisecondsPerBuffer) { millisecondsPerBuffer = maxMilliseconds; } bool anyEventsDispatched = false; for (int i = 0; i < _synthesizer.MicroBufferCount; i++) { _currentTime += millisecondsPerBuffer; while (_eventIndex < _synthData.Count && _synthData[_eventIndex].Time < _currentTime) { _synthesizer.DispatchEvent(i, _synthData[_eventIndex]); _eventIndex++; anyEventsDispatched = true; } } return(anyEventsDispatched); }