# Printing text on a text label using data from Processor

**URL:** <https://forums.steinberg.net/t/printing-text-on-a-text-label-using-data-from-processor/800592>\
**Category:** VST 3 SDK\
**Tags:** gui\
**Created:** [August 7, 2022, 12:04pm UTC](https://forums.steinberg.net/t/printing-text-on-a-text-label-using-data-from-processor/800592 "2022-08-07T12:04:52Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![ma\_headphone](https://avatars.discourse-cdn.com/v4/letter/m/977dab/32.png) [@ma\_headphone](https://forums.steinberg.net/u/ma_headphone)\
**Post date:** [August 7, 2022, 12:04pm UTC](https://forums.steinberg.net/t/printing-text-on-a-text-label-using-data-from-processor/800592/1 "2022-08-07T12:04:52Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Arne\_Scheffler](https://dub1.discourse-cdn.com/steinberg/user_avatar/forums.steinberg.net/arne_scheffler/32/92023_2.png) [@Arne\_Scheffler](https://forums.steinberg.net/u/Arne_Scheffler)\
**Post date:** [August 7, 2022, 4:44pm UTC](https://forums.steinberg.net/t/printing-text-on-a-text-label-using-data-from-processor/800592/2 "2022-08-07T16:44:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![drearyfrosting](https://avatars.discourse-cdn.com/v4/letter/d/ec9cab/32.png) [@drearyfrosting](https://forums.steinberg.net/u/drearyfrosting)\
**Post date:** [August 19, 2022, 10:28am UTC](https://forums.steinberg.net/t/printing-text-on-a-text-label-using-data-from-processor/800592/3 "2022-08-19T10:28:24Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![Arne\_Scheffler](https://dub1.discourse-cdn.com/steinberg/user_avatar/forums.steinberg.net/arne_scheffler/32/92023_2.png) [@Arne\_Scheffler](https://forums.steinberg.net/u/Arne_Scheffler)\
**Post date:** [August 19, 2022, 10:56am UTC](https://forums.steinberg.net/t/printing-text-on-a-text-label-using-data-from-processor/800592/4 "2022-08-19T10:56:40Z")

</div>

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](https://github.com/steinbergmedia/vst3_public_sdk/blob/master/samples/vst/again/source/againcontroller.cpp#L62) in the again example)

I hope this helps

---

<div class="post-metadata">

**Author:** ![drearyfrosting](https://avatars.discourse-cdn.com/v4/letter/d/ec9cab/32.png) [@drearyfrosting](https://forums.steinberg.net/u/drearyfrosting)\
**Post date:** [August 19, 2022, 12:58pm UTC](https://forums.steinberg.net/t/printing-text-on-a-text-label-using-data-from-processor/800592/5 "2022-08-19T12:58:04Z")

</div>

@Arne_Scheffler This helps a lot.  
Thanks.

---

<div class="post-metadata">

**Author:** ![storyofagame](https://avatars.discourse-cdn.com/v4/letter/s/edb3f5/32.png) [@storyofagame](https://forums.steinberg.net/u/storyofagame)\
**Post date:** [August 22, 2022, 7:33am UTC](https://forums.steinberg.net/t/printing-text-on-a-text-label-using-data-from-processor/800592/6 "2022-08-22T07:33:17Z")

</div>

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 😕

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

---

<div class="post-metadata">

**Author:** ![Arne\_Scheffler](https://dub1.discourse-cdn.com/steinberg/user_avatar/forums.steinberg.net/arne_scheffler/32/92023_2.png) [@Arne\_Scheffler](https://forums.steinberg.net/u/Arne_Scheffler)\
**Post date:** [August 22, 2022, 5:07pm UTC](https://forums.steinberg.net/t/printing-text-on-a-text-label-using-data-from-processor/800592/7 "2022-08-22T17:07:18Z")

</div>

Read [this](https://steinbergmedia.github.io/vst3_dev_portal/pages/Tutorials/Use+VSTGUI+to+design+a+UI.html), especially “Part3: Parameter Binding”. This should tell you all what’s needed. If not come back.

---

<div class="post-metadata">

**Author:** ![storyofagame](https://avatars.discourse-cdn.com/v4/letter/s/edb3f5/32.png) [@storyofagame](https://forums.steinberg.net/u/storyofagame)\
**Post date:** [August 22, 2022, 10:42pm UTC](https://forums.steinberg.net/t/printing-text-on-a-text-label-using-data-from-processor/800592/8 "2022-08-22T22:42:59Z")

</div>

> [@Arne\_Scheffler](#):
>
> RangeParameter

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

---

<div class="post-metadata">

**Author:** ![storyofagame](https://avatars.discourse-cdn.com/v4/letter/s/edb3f5/32.png) [@storyofagame](https://forums.steinberg.net/u/storyofagame)\
**Post date:** [August 23, 2022, 8:23am UTC](https://forums.steinberg.net/t/printing-text-on-a-text-label-using-data-from-processor/800592/9 "2022-08-23T08:23:12Z")

</div>

Hello again

I did this as a test…

```auto
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 🙂

Kind Regards

---

<div class="post-metadata">

**Author:** ![ma\_headphone](https://avatars.discourse-cdn.com/v4/letter/m/977dab/32.png) [@ma\_headphone](https://forums.steinberg.net/u/ma_headphone)\
**Post date:** [August 23, 2022, 3:08pm UTC](https://forums.steinberg.net/t/printing-text-on-a-text-label-using-data-from-processor/800592/10 "2022-08-23T15:08:31Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![ma\_headphone](https://avatars.discourse-cdn.com/v4/letter/m/977dab/32.png) [@ma\_headphone](https://forums.steinberg.net/u/ma_headphone)\
**Post date:** [August 23, 2022, 4:16pm UTC](https://forums.steinberg.net/t/printing-text-on-a-text-label-using-data-from-processor/800592/11 "2022-08-23T16:16:31Z")

</div>

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](https://forums.steinberg.net/t/get-current-barsbeatsposition/201675/9)  
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?

---

<div class="post-metadata">

**Author:** ![Arne\_Scheffler](https://dub1.discourse-cdn.com/steinberg/user_avatar/forums.steinberg.net/arne_scheffler/32/92023_2.png) [@Arne\_Scheffler](https://forums.steinberg.net/u/Arne_Scheffler)\
**Post date:** [August 23, 2022, 5:11pm UTC](https://forums.steinberg.net/t/printing-text-on-a-text-label-using-data-from-processor/800592/12 "2022-08-23T17:11:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ma\_headphone](https://avatars.discourse-cdn.com/v4/letter/m/977dab/32.png) [@ma\_headphone](https://forums.steinberg.net/u/ma_headphone)\
**Post date:** [August 23, 2022, 7:32pm UTC](https://forums.steinberg.net/t/printing-text-on-a-text-label-using-data-from-processor/800592/13 "2022-08-23T19:32:04Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![Mc-Zen](https://avatars.discourse-cdn.com/v4/letter/m/f475e1/32.png) [@Mc-Zen](https://forums.steinberg.net/u/Mc-Zen)\
**Post date:** [August 24, 2022, 9:54am UTC](https://forums.steinberg.net/t/printing-text-on-a-text-label-using-data-from-processor/800592/14 "2022-08-24T09:54:00Z")

</div>

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 😃

---

<div class="post-metadata">

**Author:** ![ma\_headphone](https://avatars.discourse-cdn.com/v4/letter/m/977dab/32.png) [@ma\_headphone](https://forums.steinberg.net/u/ma_headphone)\
**Post date:** [August 24, 2022, 4:12pm UTC](https://forums.steinberg.net/t/printing-text-on-a-text-label-using-data-from-processor/800592/15 "2022-08-24T16:12:08Z")

</div>

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.

> [@When hosted in VST3PluginTestHost: Missing ProcessContext state values?](https://forums.steinberg.net/t/when-hosted-in-vst3plugintesthost-missing-processcontext-state-values/798120/2):
>
> Hi, please read the documentation about [Process Context Requirements](https://steinbergmedia.github.io/vst3_dev_portal/pages/Technical+Documentation/Change+History/3.7.0/IProcessContextRequirements.html). If you directly use the VST SDK Helper class AudioEffect it has already [a member](https://github.com/steinbergmedia/vst3_public_sdk/blob/master/source/vst/vstaudioeffect.h#L119) which you must fill with the requirements. I hope that helps.

---

<div class="post-metadata">

**Author:** ![ma\_headphone](https://avatars.discourse-cdn.com/v4/letter/m/977dab/32.png) [@ma\_headphone](https://forums.steinberg.net/u/ma_headphone)\
**Post date:** [August 31, 2022, 8:50pm UTC](https://forums.steinberg.net/t/printing-text-on-a-text-label-using-data-from-processor/800592/16 "2022-08-31T20:50:03Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Arne\_Scheffler](https://dub1.discourse-cdn.com/steinberg/user_avatar/forums.steinberg.net/arne_scheffler/32/92023_2.png) [@Arne\_Scheffler](https://forums.steinberg.net/u/Arne_Scheffler)\
**Post date:** [September 1, 2022, 6:14am UTC](https://forums.steinberg.net/t/printing-text-on-a-text-label-using-data-from-processor/800592/17 "2022-09-01T06:14:31Z")

</div>

> [@ma\_headphone](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![ma\_headphone](https://avatars.discourse-cdn.com/v4/letter/m/977dab/32.png) [@ma\_headphone](https://forums.steinberg.net/u/ma_headphone)\
**Post date:** [September 3, 2022, 9:53am UTC](https://forums.steinberg.net/t/printing-text-on-a-text-label-using-data-from-processor/800592/18 "2022-09-03T09:53:07Z")

</div>

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.
