how to use own GUI / windows instead VSTI GUI?

SDK for VST 3 audio plug-in and host development.
Post Reply
Wanderer
Posts: 17
Joined: Sun Jun 24, 2018 2:24 pm

how to use own GUI / windows instead VSTI GUI?

Post by Wanderer » Fri Jan 10, 2020 10:09 pm

Hello

I made setup for vst as in documentation, now I can't find info about how to create own window. I want use WPF. Please don't post something about VST.NET, I want my own implementation of WPF. The only key is (or question) where to initialize, show, hide / close and destroy a window? Is there some documentation about that?
Only this information on documentation I found
"If you are not using VSTGUI, please check that you provide the correct object derived from EditorView or CPlugInView and that you overwrite the function isPlatformTypeSupported ()."
only EditorView deffinition have isPlatformTypeSupported() EDIT. sorry I just looked at IpPluginView that have virtual of this function. Ok, but this not explain where to create and show window etc...

Another question is, can VST3 use more then one dll? Unfortunately I will need use more then one dll due the WPF.

willpirkle
Posts: 61
Joined: Tue Jun 21, 2016 12:53 pm

Re: how to use own GUI / windows instead VSTI GUI?

Post by willpirkle » Wed Feb 05, 2020 3:28 pm

The way I have done this is to subclass CPluginView and then override the base class functions that you need:

IPlugFrame* plugFrame = nullptr;
const ViewRect& getRect() const { return rect; }
void setRect(const ViewRect& r) { rect = r; }
bool isAttached() const { return systemWindow != 0; }

virtual void attachedToParent() override {}
virtual void removedFromParent() override {}
virtual tresult PLUGIN_API attached(void* parent, FIDString type) override;
virtual tresult PLUGIN_API removed() override;
virtual tresult PLUGIN_API onWheel(float distance) override { return kResultFalse; }
virtual tresult PLUGIN_API isPlatformTypeSupported(FIDString type) override;
virtual tresult PLUGIN_API onSize(ViewRect* newSize) override;
virtual tresult PLUGIN_API getSize(ViewRect* size) override;
virtual tresult PLUGIN_API onFocus(TBool /*state*/) override { return kResultFalse; }
virtual tresult PLUGIN_API setFrame(IPlugFrame* frame) override;// { plugFrame = frame; return kResultTrue; }
virtual tresult PLUGIN_API canResize() override{ return kResultTrue; }
virtual tresult PLUGIN_API checkSizeConstraint(ViewRect* rect) override;
virtual bool setWindowFrameSize(double left = 0, double top = 0, double right = 0, double bottom = 0) override //CRect* newSize)
virtual bool getWindowFrameSize(double& left, double& top, double& right, double& bottom) override

As for the "two DLL" issue, I am guessing you are wanting to link to a 3rd party DLL at runtime?

I've linked VST3s with both static and dynamic libraries many times, and you need to watch out for the common problems -- in general, there may be conflicting libraries ("Ignore Specific Default Libraries" in VS) and be careful with namespacing. I've you've linked DLLs to other API's then you've been through those issues already.

I've mixed VST2 and VST3 with MFC (for windows and views) in the past -- it is not very much fun, but it is completely do-able.

That said, I've been using VSTGUI4 since 2011 and have fully switched over now -- it is sweet to be able to use the same code for AU, VST, and AAX on MacOS and Windows, but my GUI is also "custom" in the sense that it subclasses CPluginView in order to implement the GUI operation.

Hope that helps.

Will

Wanderer
Posts: 17
Joined: Sun Jun 24, 2018 2:24 pm

Re: how to use own GUI / windows instead VSTI GUI?

Post by Wanderer » Sun Feb 09, 2020 10:02 am

Thanks for help. In the end I discover that source code is partialy comented and I did subclass CPluginView and override necessary functions. The most important part is void * windowView (if I remember correctly) where must be attached own created window. (I'll write better answer for that later, for now I don't have much tme for describe it)

I resolve linking with SetDllDirectory function and AssemblyResolve for managed dll.

programaudio
Posts: 11
Joined: Mon Oct 03, 2016 4:09 am
Location: Chicago
Contact:

Re: how to use own GUI / windows instead VSTI GUI?

Post by programaudio » Sun Feb 16, 2020 7:00 pm

I have a WPF UI sample attached that compiles and passes the validator tests.
However, I cannot figure out why hosts will not load it.
You do not have the required permissions to view the files attached to this post.

Wanderer
Posts: 17
Joined: Sun Jun 24, 2018 2:24 pm

Re: how to use own GUI / windows instead VSTI GUI?

Post by Wanderer » Wed Feb 19, 2020 10:40 am

From quick look,
1. I am not expert, but I think you should use AssemblyResolver instead load assembly directly.

Code: Select all

System::Reflection::Assembly ^ WPF::WApp::MyResolveEventHandler(System::Object ^ sender, System::ResolveEventArgs ^ args)
{
                        bool ok = false;
                        try {
				result = Assembly::LoadFrom(assemblyPath);
				ok = true;
			}
			catch (Exception ^e)
			{
				LoggerCPPInt::mf_writeLog("C++/CLI", "MyResolveEventHandler()", "LOAD FAILED", msc::convert_to_string(e->ToString()));
			}
	if (ok == true)
	{
		return result;
	}
	else
	{
		return args->RequestingAssembly;
	}
}

// ==========================================================
// Somewhere where you initialize WPF
AppDomain ^cd = AppDomain::CurrentDomain;
cd->AssemblyResolve += gcnew ResolveEventHandler(WPF::WApp::MyResolveEventHandler);
This is worked for me if I used UserControl only.

2. your function for get HWND need to be corrected to this

Code: Select all

MeterWpfWrapper::MeterWpfWrapper(void ** hWnd) { .. }
// then call
m_UI = std::make_shared<MeterWpfWrapper>(&m_parentWindow);
I don't know how you then attach the HWND in to HostWindow but this is how I did it

Code: Select all

	if (h == nullptr)
	{
		wpfi->mf_Window_GetPointer(&h);
		SetParent((HWND)h, (HWND)systemWindow);
	}

programaudio
Posts: 11
Joined: Mon Oct 03, 2016 4:09 am
Location: Chicago
Contact:

Re: how to use own GUI / windows instead VSTI GUI?

Post by programaudio » Sun Mar 22, 2020 10:17 pm

Thank you for your help!

I was finally able to get a WPF/XAML UserControl GUI to appear inside of a Win32 HWND.
The WPF .dll needed to be signed and added to the Global Address Cache... since I haven't created an installer yet, I used the Visual Studio command prompt and the gacutil command.

project structure:
1.Plugin Processor/EditController/CPluginView C++ .dll
2.C++/CLI wrapper/trampoline/middle-man .dll
3.C#/XAML UserControl .dll

Post Reply