This project has moved and is read-only. For the latest updates, please go here.


Topics: Audio, Midi
Nov 3, 2012 at 12:23 AM
Edited Nov 3, 2012 at 12:24 AM

Hi, this seems like a daft question, but I'm trying to convert a MIDI plugin I did in Delphi years ago and I'm stuck at the first hurdle - where is GetTimeInfo()?

In the Delphi framework the method was available in the main Plugin class and so could be called direct in the Process() method.

I see there's an interface IVstHostCommands20 that contains it, but nothing seems to implement this - do I need to implement it somehow to get the method?

Nov 3, 2012 at 12:28 AM
Edited Nov 3, 2012 at 12:30 AM

Don't have much time to look at it myself right now, could you check :

is there a class implementing IVstHostCommands in your project?

is there a VstTimeInfo property definition in that class?

is there a way to hook to property value changes?

Nov 3, 2012 at 11:44 AM
Edited Nov 3, 2012 at 11:47 AM

I assume that you use the Framework..?

The Plugin (root) class Open() method receives a reference to the Host (IVstHost). If you use one of the Plugin base classes that will be stored in Host property.

That reference also implements the IExtensible interface which contains a method called GetInstance<T>().

To get a reference to any of the IVstHostXxxx interfaces use the GetInstance method on the Host reference. These host interfaces represent the supported features (functionality) of the host that is running your plugin. Also note that the Framework implements all of the IVstHostXxxx interfaces and you should never have to (unless you go into deep customization - which is possible).

IVstHostSequencer hostSequencer = this.Host.GetInterface<IVstHostSequencer>();

if (hostSequencer != null)
    // use the hostSequencer interface here.

It is good practice to check for null on the return value. The host might not support all features and to indicate that null can be returned (although most interface-requests will always return a valid reference).

Hope it helps.

Nov 10, 2012 at 9:25 PM

Thanks Jacobi.

Yes using the MIDI Template. In MIDIProcessor.cs Process method I'm now calling:

            VstTimeInfo timeInfo = _plugin.Host.GetInstance<IVstHostCommands20>().GetTimeInfo(
                VstTimeInfoFlags.PpqPositionValid | VstTimeInfoFlags.BarStartPositionValid | VstTimeInfoFlags.TempoValid);

I hope this is acceptable/not wasteful to use GetInstance in the Process method?

Going to enjoy using this.

Nov 10, 2012 at 9:47 PM

GetInstance is pretty quick, but I would suggest you maintain a local member and lazy-load the instance...

Also note that you only need to call GetTimeInfo only once per cycle.

Refer to the source code of the Visual Studio Templates for an implementation of this.

Nov 10, 2012 at 10:10 PM

Ok thanks.

What do you mean when you say each cycle - each time Process is called with sample frames, or only when PPQ position changes?

Nov 10, 2012 at 10:12 PM

each cycle of the audio engine of the host - and that Process is called ;-)