PLUG'N SCRIPT
rapid plugin development
Tutorial
DSP
KUIML
How-to
Scripts
  • Overview
  • Tutorial
    • Hello world
    • Main skin and subskins
    • Displaying text
    • Changing text on the fly
    • Printing from the DSP
    • Displaying and controlling parameters
    • Params 101
  • Reference
  • Built-in variables
  • Runtime model
  • Parameters mapping
  • Script converter
  • LetiMix
KUIMLTutorialPrinting from the DSP
December 19, 2022

Printing from the DSP

In the Plug'n Script DSP API, there's a print function. It outputs a line to a log file, and the GUI skin also displays it in the status bar. In fact, print updates the output string named dsp.output_string0. Let's test it:

.cxx file contents:

  1. string name="KUIML Examples";
  2.  
  3. void updateInputParameters(){
  4. print("Hello world printed!");
  5. }

.kuiml file contents:

  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <SKIN>
  3. <TEXT string_id="dsp.output_string0" />
  4. </SKIN>

There are more output strings and parameters exposed by the DSP. You can find them in the manual, or more conveniently, in LM Skin debug mode.

However, using print from the DSP is quite limited, because we often want our text to appear somewhere other than the status bar. Also, print saves every printed line to a log file, so if you print from processSample or processBlock, these files can grow very large very quickly.

To overcome this, we can use outputStrings

Add an outputString in the DSP and update it on the fly, as shown in the next example. Here are the contents of the .cxx file:

  1. string name="Output string to GUI";
  2.  
  3. // adding output strings
  4. array<string> outputStrings(2); // number of output strings
  5. array<string> outputStringsNames = {"Messages", "Data"}; // string names
  6. array<int> outputStringsMaxLengths = {1024, 16384}; // maximum length
  7.  
  8. // counter for blocks
  9. int block_no = 0;
  10.  
  11. // block processing function
  12. void processBlock(BlockData& data) {
  13. outputStrings[0] = "Parsing block: " + block_no;
  14. // do something useful
  15. // ...
  16. block_no++;
  17. }

And here's the corresponding .kuiml file:

  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <SKIN>
  3. <TEXT string_id="$script_output_string0$" />
  4. <TEXT value="$script_output_string0$" />
  5. </SKIN>

What Is $script_output_string0$?

Well, "script_output_string0" is a KUIML VARIABLE id defined somewhere in the main skin, and it holds the actual name of the dsp string we need. If you look through the main skin, you'll find something like this:

  1. <VARIABLE id="script_output_stringX" value="dsp.output_stringY" />

Here, X and Y are generated on the fly in a REPEAT loop, depending on the current number of output strings used by the PnS engine, and whether the plugin is exported or not.

The outputStrings[0] we use in the DSP script actually has a real name like dsp.output_string360. This is because PnS sends a lot of extra info "behind the scenes" to the GUI using strings. When the plugin is exported, it might change to something like dsp.output_string56, since exported plugins expose fewer internal strings than Plug'n Script itself. For convenience, the current real name of dsp.output_stringY is calculated in the main skin and stored in the variable named script_output_stringX (X is from 0 to 16), and that's what we use in the GUI.

In the DSP, by default you can use up to 16 outputStrings and 16 inputStrings (this number can be increased), which can transfer text or text-encoded data between the DSP and GUI. The key difference between inputStrings and inputParams is that strings are not "visible" to the DAW and cannot be automated (and hold text data primarily).

Displaying and controlling parameters


Comments

Please, authorize to view and post comments.

2020 - 2026 © Site by LetiMix · Donate  |  Plug'n Script and KUIML by Blue Cat Audio