Pointer to audio-thread within a custom control

I have created a custom-control. It should display realtime graphics from the audio-thread within ::onIdle() .

I need a pointer-access to a large array from the audio-thread within my custom-control . I am using the single-component version of VST 3.7.

In VSTGUI 3.6 and VST 2.4 I did this:

in the header:

class MyControlFactory : public ViewCreatorAdapter
{
friend class T2Editor;

in the cpp file:


((T2Editor*)getEditor())->myarray>

How do I do this with VSTGUI 4.9?

Thank you,
Markus

I don’t think there is a way with VST 3. I have tried very hard to do that but you can’t. You have to “send” the data from the RT section to the GUI section via messaging: see this thread: https://sdk.steinberg.net/viewtopic.php?f=4&t=782&p=2500#p2500

I have also stepped through the code, tried to change the factory that creates the plugin, etc… and never could find a way.

Yan

I found a way. Keep in mind you should only use it for singlecomponent.
It is very complicated. You need a custom control which is mapped to a custom controller. You can map a pointer to the synth in MyController. When the view is created you map a pointer to the pointer.

		class MyController : public VSTGUI::IController
		{
		public:
			/** KnobLinkController constructor
			\param _parentController - pointer to the parent controller so we can forward messages to it
			*/
			MyController(IController* _parentController, T2Audio* synpointer, VSTGUI::VST3Editor* editorpointer)
			{
				parentController = _parentController;	// --- save the parent listener
				syn = synpointer;
				editor = editorpointer;
			}

			
			//--- is called when a view is created -----
			VSTGUI::CView* verifyView (VSTGUI::CView* view, const VSTGUI::UIAttributes& ,const VSTGUI::IUIDescription* ) override
			{
				/*
				if (VSTGUI::CTextEdit* te = dynamic_cast<VSTGUI::CTextEdit*> (view))
				{
					// this allows us to keep a pointer of the text edit view
					//textEdit = te;

					// add this as listener in order to get viewWillDelete and viewLostFocus calls
					//textEdit->registerViewListener(this);
					//textEdit->setText(str.text8());
				}*/
				if (VSTGUI::COptionMenu* om = dynamic_cast<VSTGUI::COptionMenu*> (view))
				{
					if (om->getTag() == kPatchSelect) om->setNbItemsPerColumn(32);
					if (om->getTag() == kFilterType) om->setNbItemsPerColumn(22);
					if (om->getTag() == kOsc1Wave || om->getTag() == kOsc1Wave) om->setNbItemsPerColumn(29);
				}
				if (VSTGUI::MyWavedisplay* wd = dynamic_cast<VSTGUI::MyWavedisplay*> (view))
				{
					if (wd->getTag() == kOsc1Wave)
					{
						wd->waveformpointer = syn->wtblf[0];
						wd->pwmpointer = &syn->currentPwmDisplay1;
						wd->partialspointer = &syn->currentPartialsDisplay1;
						wd->phasepointer = &syn->currentPhaseDisplay1;
						wd->waveformNRpointer = &syn->currentWaveformNRDisplay1;
						wd->modNRpointer = &syn->currentModNRDisplay1;
					}
					if (wd->getTag() == kOsc2Wave)
					{
						wd->waveformpointer = syn->wtblf[1];
						wd->pwmpointer = &syn->currentPwmDisplay2;
						wd->partialspointer = &syn->currentPartialsDisplay2;
						wd->phasepointer = &syn->currentPhaseDisplay2;
						wd->waveformNRpointer = &syn->currentWaveformNRDisplay2;
						wd->modNRpointer = &syn->currentModNRDisplay2;
					}
					
				}
				return view;
			}

Just for your interest: This solution may show your waveform display out of time (much earlier than it comes out of the speakers) if your plug-in is in a graph with high latency. A solution that compensate for latency is possible, but indeed something not that easy.

@MarkusK I suppose I misunderstood what you were trying to do. I thought you had data in the RT code that you wanted to share in the UI and unless I am mistaken that is not what you are doing. Or is it?

What is this T2Audio* pointer? How do you get it? Is it shared between RT code and UI? If so how do you do that? The only way I have found to share data was to send messages.

Thanks
Yan

class T2Audio : public SingleComponentEffect, public VSTGUI::VST3EditorDelegate, public IMidiMapping

it’s like the ADelay from the single-component version.




class MyController : public VSTGUI::IController
{
public:
/** KnobLinkController constructor
\param _parentController - pointer to the parent controller so we can forward messages to it
/
MyController(IController
_parentController, T2Audio* synpointer, VSTGUI::VST3Editor* editorpointer)
{
parentController = _parentController; // — save the parent listener
syn = synpointer;
editor = editorpointer;
}




VSTGUI::IController* T2Audio::createSubController(VSTGUI::UTF8StringPtr name,
const VSTGUI::IUIDescription* description,
VSTGUI::VST3Editor* editor)
{
/if (UTF8StringView(name) == “MessageController”)
{
UIMessageController
controller = new UIMessageController(this);
addUIMessageController(controller);
return controller;
}*/

if (VSTGUI::UTF8StringView(name) == “MessageController2”)
{
MyController* controller = new MyController(editor, this, viewpointer);
//addUIMessageController(controller);
return controller;
}
return 0;
}

Hmm… I did not know about this class or concept. I will look into it as one of my plugin could really benefit from it!

Thanks
Yan

How about speed when sending real time waveforms from DSP to UI by sendMessage?