public void ProcessCurrentEvents() { if (CurrentEvents == null || CurrentEvents.Count == 0) { return; } // a plugin must implement IVstPluginMidiSource or this call will throw an exception. IVstMidiProcessor midiHost = _plugin.Host.GetInstance <IVstMidiProcessor>(); // always expect some hosts not to support this. if (midiHost != null) { VstEventCollection outEvents = new VstEventCollection(); // NOTE: other types of events could be in the collection! foreach (VstEvent evnt in CurrentEvents) { switch (evnt.EventType) { case VstEventTypes.MidiEvent: VstMidiEvent midiEvent = (VstMidiEvent)evnt; midiEvent = Gain.ProcessEvent(midiEvent); midiEvent = Transpose.ProcessEvent(midiEvent); outEvents.Add(midiEvent); break; default: // non VstMidiEvent outEvents.Add(evnt); break; } } midiHost.Process(outEvents); } // Clear the cache, we've processed the events. CurrentEvents = null; }
public void ProcessCurrentEvents() { if (CurrentEvents == null || CurrentEvents.Count == 0) { return; } // always expect some hosts not to support this. if (_midiHost != null) { VstEventCollection outEvents = new VstEventCollection(); // NOTE: other types of events could be in the collection! foreach (VstEvent evnt in CurrentEvents) { switch (evnt.EventType) { case VstEventTypes.MidiEvent: VstMidiEvent midiEvent = (VstMidiEvent)evnt; midiEvent = Gain.ProcessEvent(midiEvent); midiEvent = Transpose.ProcessEvent(midiEvent); outEvents.Add(midiEvent); break; default: // non VstMidiEvent outEvents.Add(evnt); break; } } _midiHost.Process(outEvents); } // Clear the cache, we've processed the events. CurrentEvents = null; }
public void ProcessCurrentEvents() { if (CurrentEvents == null || CurrentEvents.Count == 0) { return; } // a plugin must implement IVstPluginMidiSource or this call will throw an exception. IVstMidiProcessor midiHost = _plugin.Host.GetInstance <IVstMidiProcessor>(); // always expect some hosts not to support this. if (midiHost != null) { VstEventCollection outEvents = new VstEventCollection(); // NOTE: other types of events could be in the collection! foreach (VstEvent evnt in CurrentEvents) { switch (evnt.EventType) { case VstEventTypes.MidiEvent: VstMidiEvent midiEvent = (VstMidiEvent)evnt; //General midi effects for all inputs midiEvent = Gain.ProcessEvent(midiEvent); midiEvent = Transpose.ProcessEvent(midiEvent); //Process Midi Note in SampleManager if ((midiEvent.Data[0] & 0xF0) == 0x80) { _plugin.SampleManager.ProcessNoteOffEvent(midiEvent.Data[1]); } if ((midiEvent.Data[0] & 0xF0) == 0x90) { // note on with velocity = 0 is a note off if (MidiHelper.IsNoteOff(midiEvent.Data)) { _plugin.SampleManager.ProcessNoteOffEvent(midiEvent.Data[1]); } else { _plugin.SampleManager.ProcessNoteOnEvent(midiEvent.Data[1]); } } outEvents.Add(midiEvent); break; default: // non VstMidiEvent outEvents.Add(evnt); break; } } midiHost.Process(outEvents); } // Clear the cache, we've processed the events. CurrentEvents = null; }