Low performance at host

Nov 16, 2010 at 9:15 PM

Hi. I've used VST.NET to make a vst host. Everything goes fine, through to the moment, when I trigger generating sound on loaded plugins. The problem is that is very very slow, but finally i've got my generated sample.

Here is the method, which performs triggering the plugin to generate some audio data:

private void PluginEditor_KeyDown(object sender, KeyEventArgs e)
        {
            VstPluginContext PluginContext = this.vpc;
            if ((PluginContext.PluginInfo.Flags & VstPluginFlags.CanReplacing) == 0)
            {
                return;
            }

            int inputCount = PluginContext.PluginInfo.AudioInputCount;
            int outputCount = PluginContext.PluginInfo.AudioOutputCount;
            int blockSize = 512;

            VstAudioBufferManager inputMgr;
            VstAudioBufferManager outputMgr;

            inputMgr = new VstAudioBufferManager(inputCount, blockSize);
            outputMgr = new VstAudioBufferManager(outputCount, blockSize);

            PluginContext.PluginCommandStub.SetBlockSize(blockSize);
            PluginContext.PluginCommandStub.SetSampleRate(44.100f);
            
            byte[] midiData = new byte[4];
            midiData[0] = 144; // Send note on midi channel 1 
            midiData[1] = 72;   // Midi note 
            midiData[2] = 100; // Note strike velocity 
            midiData[3] = 0;    // Reserved, unused 

            VstMidiEvent vse = new VstMidiEvent(/*DeltaFrames*/ 0,
                /*NoteLength*/ 0,
                /*NoteOffset*/  0,
                                                                           midiData,
                /*Detune*/        0,
                /*NoteOffVelocity*/ 127);

            VstEvent[] ve = new VstEvent[1];
            ve[0] = vse;

            PluginContext.PluginCommandStub.MainsChanged(true);
            
            PluginContext.PluginCommandStub.StartProcess();
            PluginContext.PluginCommandStub.ProcessEvents(ve);
            PluginContext.PluginCommandStub.ProcessReplacing(inputMgr.ToArray(), outputMgr.ToArray()); // <--- THAT IS VEEEEERY SLOW
            PluginContext.PluginCommandStub.StopProcess();

            PluginContext.PluginCommandStub.MainsChanged(false);
            

            WaveDisplay wd = new WaveDisplay(outputMgr);
            wd.ShowDialog(); // <------------------ FOR DISPLAYING THIS WINDOW I MUST WAIT ABOUT 20 secs FROM method beginning
        }
Any Idea what I am doing wrong? 

Coordinator
Nov 18, 2010 at 7:24 AM
Edited Nov 18, 2010 at 7:26 AM

What plugin do you load?

Nov 18, 2010 at 7:45 AM
Edited Nov 18, 2010 at 7:46 AM

I'm working with Ummet Ozcan - Genesis VSTi. Problem has been partculary solved - I had output latency in my Host Command Stub set to 200,

so I replaced it to 0 and it works.

Now the problem is MIDI trigerring latency. When I trigger note, it is played after about 1-2 seconds.

Do you think this may be caused by FMOD which uses DirectSound? I currently attempting to use ASIO, hope it helps.

 

Nov 18, 2010 at 10:27 AM

ASIO solved the problem. Now live playing is smooth with no latency. :)

Coordinator
Nov 18, 2010 at 11:40 AM

Nice!