public void ProcessCurrentEvents()
        {
            //_plugin.PluginEditor.Log("ProcessCurrentEvents");

            // a plugin must implement IVstPluginMidiSource or this call will throw an exception.
            var midiHost = _plugin.Host.GetInstance <IVstMidiProcessor>();

            // always expect some hosts not to support this.
            if (midiHost != null)
            {
                var outEvents = new VstEventCollection();

                var someCommands = _plugin.Host.GetInstance <IVstHostCommands20>();
                var timeInfo     = someCommands.GetTimeInfo(
                    VstTimeInfoFlags.PpqPositionValid | VstTimeInfoFlags.BarStartPositionValid | VstTimeInfoFlags.TempoValid);
                if (CurrentEvents != null)
                {
                    // NOTE: other types of events could be in the collection!
                    foreach (VstEvent evnt in CurrentEvents)
                    {
                        switch (evnt.EventType)
                        {
                        case VstEventTypes.MidiEvent:
                            var midiEvent = (VstMidiEvent)evnt;

                            midiEvent = Cascade.ProcessEvent(midiEvent, timeInfo);

                            //_plugin.PluginEditor.Log("tempo" + x.Tempo);

                            outEvents.Add(midiEvent);
                            break;

                        default:
                            // non VstMidiEvent
                            outEvents.Add(evnt);
                            break;
                        }
                    }
                }

                outEvents.AddRange(Cascade.CreateNotes(timeInfo));

                midiHost.Process(outEvents);
            }

            // Clear the cache, we've processed the events.
            CurrentEvents = null;
        }