public void Test_VstEventCollection_Constructor() { var target = new VstEventCollection(); target.IsReadOnly.Should().BeFalse(); target.Add(new VstMidiEvent(0, 100, 0, new byte[] { 100, 110, 120 }, 0, 0)); target.Add(new VstMidiEvent(0, 100, 0, new byte[] { 100, 110, 120 }, 0, 0)); target.Should().HaveCount(2); target.Clear(); target.Should().BeEmpty(); }
public void Test_VstEventCollection_Constructor() { VstEventCollection target = new VstEventCollection(); Assert.IsFalse(target.IsReadOnly, "Collection is read-only."); target.Add(new VstMidiEvent(0, 100, 0, new byte[] { 100, 110, 120 }, 0, 0)); target.Add(new VstMidiEvent(0, 100, 0, new byte[] { 100, 110, 120 }, 0, 0)); Assert.AreEqual(2, target.Count, "Count is not as expected."); target.Clear(); Assert.AreEqual(0, target.Count, "Count is not zero."); }
/// <summary> /// Receives processed MssEvents from the IWetMssEventOutputPort. /// </summary> /// <param name="mssEvents">List of processed mss events</param> /// <param name="sampleTimeAtEndOfProcessingCycle"> /// If wetMssEventOutputPort is configured to only output when a processing cycle ends then /// sampleTimeAtEndOfProcessingCycle will contain the end time the cycle that just ended. /// </param> public void IWetMssEventOutputPort_SendingWetMssEvents(List <MssEvent> mssEvents, long sampleTimeAtEndOfProcessingCycle) { if (this.vstHost == null) { return; } // a plugin must implement IVstPluginMidiSource or this call will throw an exception. IVstMidiProcessor midiHost = this.vstHost.GetInstance <IVstMidiProcessor>(); // always expect some hosts not to support this. if (midiHost != null) { //Attempts to convert each MssEvent to a VstMidiEvent and add it to outEvents foreach (MssEvent mssEvent in mssEvents) { //This will return null if there is no valid conversion. VstMidiEvent midiEvent = ConvertMssEventToVstMidiEvent(mssEvent, this.SampleTimeAtStartOfProcessingCycle, this.hostInfoOutputPort.SampleRate); if (midiEvent != null) { this.outEvents.Add(midiEvent); //midiHost.Process(outEvents); //outEvents.Clear(); } } //TODO: Figure out why it doesn't work to send all of the events at once. //Sends VstMidiEvents to host midiHost.Process(outEvents); outEvents.Clear(); } OnProcessingCycleEnd(sampleTimeAtEndOfProcessingCycle); }
protected override void FillBuffers(float[][] buffer, int offset, int count) { if (Bypass) //effects just bypass { if (FIsSynth) //synths return silece { foreach (var buf in buffer) { buf.ReadSilence(offset, count); } } else { var minChannels = Math.Min(FInputCount, FOutputCount); for (int b = 0; b < minChannels; b++) { var inSig = FInput[b]; if (inSig != null) { //read input signals inSig.Read(buffer[b], offset, count); } } if (FOutputCount > FInputCount) { var remains = FOutputCount - FInputCount; for (int i = 0; i < remains; i++) { buffer[i + minChannels - 1] = buffer[i % minChannels]; } } } return; } if (PluginContext != null && FDoProcess) { ManageBuffers(count); if (FInput != null) { FInputMgr.ClearAllBuffers(); for (int b = 0; b < FInputCount; b++) { var inSig = FInput[b]; if (inSig != null) { var vstBuffer = FInputBuffers[b % FInputCount]; //read input, use buffer[0] as temp buffer inSig.Read(buffer[0], offset, count); //copy to vst buffer for (int i = 0; i < count; i++) { vstBuffer[i] += buffer[0][i]; } } } } //add events? if (FHasEvents) { PluginContext.PluginCommandStub.ProcessEvents(MidiEvents.ToArray()); MidiEvents.Clear(); FHasEvents = false; } //process audio PluginContext.PluginCommandStub.ProcessReplacing(FInputBuffers, FOutputBuffers); //copy buffers for (int i = 0; i < FOutputBuffers.Length; i++) { for (int j = 0; j < count; j++) { buffer[i][j] = FOutputBuffers[i][j]; } } } }