Printing text on a text label using data from Processor

I’m learning the basics of the VST3 SDK and I’m having some troubles trying to print out some text on a text label (CTextLAbel) from the Processor function.
I undestood that I should should avoid blocking the process function, so I should use the iMessage class. In some old post I read that I need to create a dedicated timer class… or is that managed by the iMessage class itelf?
I was looking through the sample code and found that the AGain plugin and the Hostchecker are using the iMessage class. I’m struggling to get this to work in my code though. Do you know where I can find some simple example of how to do it?
Furthemore, how do I set the text on the label I defined in the editor.uidesc xml file?
Thanks in advance!

Do you want to set actual text, or do you want to set a textual representation of a mathematical value? The second one is fairly easy to implement without using messages. Instead you use the output parameter queue to send the value from the processor to the controller. Otherwise if you really want to sent arbitrary text, you need to use a wait free queue where you push the changes to from the realtime process function and then you need to have a timer firing on the main thread that pops the data from the queue and then use a message to send the data to the controller.
And depending on the above it is totally different how to set the label in the UI described via an uidesc file. For the parameter case you only may need to provide a custom parameter to string conversion routine if the default of the parameter class is not sufficient and then set the control tag of the label to be the one of the parameter id.
Otherwise if you don’t use a parameter you need to create a custom controller which can store a pointer of the text label you want to set and set it that way.

@Arne_Scheffler I want to set textual representation of a mathematical value as you described before, as the CTextLabel can only display values from 0 to 1 and I want to display also negative values and values above 1.
How do I do this using the queue? I only can find the addPoint method which takes a double value.

Parameters in VST always work in the normalized range [0…1]. To send a value out of this range you need to transcode your value to the normalized range. For example if your number is in the range of [-100…+100] you can calculate the normalized value with normValue = (plainValue - miValue) / (maxValue-minValue) and you can calculate the plainValue from a normalized value with plainValue = normValue * (maxValue-minValue) + minValue.
So, to send a value in the range of [-100…+100] from your processor to the controller you need to do the following:

  1. Create and add a RangeParameter in your controller to the exported parameters. The flags of this parameter should be kIsReadOnly (the host is not allowed to change it).
  2. In your process function send the normalized representation of your value via the parameter queue.
  3. Connect the RangeParameter to your TextLabel

If your value is not in a linear range you may have to write your own Parameter class where you need to adopt the toPlain() and toNormalized() methods. (For an example see the GainParameter class in the again example)

I hope this helps

@Arne_Scheffler This helps a lot.
Thanks.

This was my question too “Furthemore, how do I set the text on the label I defined in the editor.uidesc xml file?”

But it doesn’t seems that this was answered here… or it was but I didn’t understand it.
I’ve made a new topic :confused:

Arne, how do I " 1. Connect the RangeParameter to your TextLabel"??

Read this, especially “Part3: Parameter Binding”. This should tell you all what’s needed. If not come back.

1 Like

I’m sorry but I still don’t know how to connect a RangeParameter :confused:
To be able to show values outside of the 0-1 range.

Hello again

I did this as a test…

ParameterInfo* pI = new ParameterInfo();
swprintf(pI->title, 20, L"%hs", "Fuzzi");
pI->flags = Vst::ParameterInfo::kCanAutomate;
pI->stepCount = 0;
pI->id = kFuzziId;
pI->defaultNormalizedValue = 0;
				
RangeParameter* rp = new RangeParameter(*pI, 0, 100.0);
	
parameters.addParameter(rp);

And that seems to work :slight_smile:

Kind Regards

1 Like

Thanks guys , I got it working as well by sending numbers to parameters.
I used the following instead of swprintf:
UString128 (“VAL3”).copyTo (pI->title, 128);

I had to change the textlabel definition as well because the following code which I was using was just showing a black box…
< view class=“CTextLabel” control-tag=“OSC2” origin=“200,40” size=“90,90”/>

Visualizing more complex data using Imessages will be for another time…

My initial use case was to be able to print out transport information for the debugging, in order to then be able to use it in a step sequencer I’m trying to build…
I’m following this other thread to get the current play position Get Current BarsBeatsPosition - #9 by peter3
However I’m struggling a bit to find how to print these values if the range I can put on the Textbox is only 0.0<x<1.0…
I’m just seeing values of 0 or 1, sometimes they change, no matter how I manipulate the numbers…
Is there an easier way to print out values?

If you just want to output some text for debugging, then just call one of the debug print methods. Per example: Steinberg::FDebugPrint(…). You have to run your plug-in in the debugger and then the output will be visible in the debug output window.

1 Like

Thanks it seems to work, but can I debug like that within the DAW? I intended to debug the transport position information I get when pressing play/stop…

You can just attach the debugger to the DAW process. On windows you just select Debug/Attach to process in the project properties, I think. And maybe try not to crash the host to often :smiley:

Thanks a lot, it turns out that with XCode you can do it with Debug/attach process by PID…
Anyways, I worked around my problem in a different way, I used the VST3PluginTestHost transport and had to enable the process context requirements as explained here.

If instead I want to do something like changing programmatically the background color of a label, how would that go? Can it be done with parameters?

Not out of the box. For this to work you need to create a sub-controller, remember the control when it is created (and forget it when it is destroyed) and the sub-controller must listen for parameter changes where it then changes the background of the control.

I tried looking through the VST3SDK samples and I could not find anything like that… are you able to point me to some example of that?
I need to do something simple like leds blinking along with the DAW tempo, following through the steps of a sequencer.