Plug'n Script KUIML/output strings question

Official support for: bluecataudio.com
RELATED
PRODUCTS
Plug'n Script$99.00Buy

Post

Hi there,

I have a question regarding Plug’n Script / KUIML. Read literally everything that is available using google but I can’t figure out how to do this.

What I’d like to implement is something like this:

- I have 7 TEXT elements on the UI ( made with KUIML, all shown on the UI, fine).
- I have an output string (script_output_string0) supplied by the dsp script which contains 7 decimals (like „1121111“)
This output string is actually available in the KUIML script, I can at least assign this string to a TEXT element and display it. It is there !

- What I’d really like to achieve is that the TEXT colour is set according to the corresponding digit in script_output_string0.
Something like: if( $script_output_string0$.substr(0,1) == „2“) then make text colour red, otherwise blue…

Can somebody of you give me an advice how to implement something like this (if possible at all) ?

Thanks
Rudi
http://www.pulpoaudio.com
Virtual Percussion Instruments
email: pulpo@pulpoaudio.com

Post

The color attribute of the text elements cannot be changed at runtime (it is not exposed yet as a model element). So there are two ways to do this:
1. If there are only a few colors to use: create two text elements pointing to the screen on top of each other (using the layer_stack layout for example). One is read and the other is blue. You can then use a script to modify the visible attribute of these text elements accordingly.
2. If you need many colors (or a continuous color scale), you can use a KUIML_WIDGET and generate its content with a script (a TEXT widget with the appropriate color).

Hope this helps!

Post

Hey, Duke!

Yes, Blue Cat Audio said how it is right now - changing colors on the fly is a bit diffucult, though both ways work.

I've done an example of the first way (making some elements on top of each other and displaying one at a time):

Code: Select all

<STRING id="my_string" default="1111121" />

<VARIABLE id="N" value="0" override="true" />
<LAYER_STACK>
	<REPEAT index_list="#DD0000;#00AA00;#0000DD">
		<TEXT_FIELD id="tx_$N$" string_id="my_string" text_color="$index$" display="false" exposed="true" width="100" />
	<VARIABLE id="N" formula="$N$+1" override="true" />
	</REPEAT>
	
</LAYER_STACK>

<ACTION_TRIGGER event_id="my_string.value_changed;window.loaded.value_changed" script="
	string s = my_string;
	if (s.substr(0,1) == &quot;2&quot;) {
		tx_0.display=1;
		tx_1.display=0;
		tx_2.display=0;
	} else if (s.substr(1,1) == &quot;2&quot;) {
		tx_0.display=0;
		tx_1.display=1;
		tx_2.display=0;
	} else {
		tx_0.display=0;
		tx_1.display=0;
		tx_2.display=1;
	}; " requires="tx_*;my_string.*" />
It sure can be made in more complex and smart way, but I think this is a way to start.
You do not have the required permissions to view the files attached to this post.

Post

Hi Bluecats, Hi Ilya

thanks to both of you. Made it using a template with script that incorporates the mentioned layer stack and the script enables / disables the layers according to the needs. I am sure it can be done more easily.... just read Ilyas post, it's somehow similar but your implementation looks easier. Will check this.
Working with KUIML is still a bit difficult for me ;-)

Nevertheless.... sorry, but I have 2 new questions, hopefully somebody can help me with these.

1) I'd like to get rid of that black rectangle at top of the plugin that shows the name of the plugin. I figured out that it is somehow possible, some of the "factory presets" show up without that rectangle (some others include it, however). I guess it has actually something to do with using presets .... just can't figure out HOW :-(

2) ...instead of that plugin name mentioned in 1) i'd like to use a title .png but i am gloriously failing in doing so :-D
It am thinking of something like this (putting the .png as first row on top of everything else):

Code: Select all

<SKIN language_version="1.0" width="700">
  <COLUMN spacing="15"  margin="5" v_align="top" width="100%">
    <ROW >
      <IMAGE image="title.png" />
    </ROW>
  </COLUMN>
</SKIN>
It just doesn't show anything. Tried already setting IMAGE width/height/flex. Somehow i believe I am on a completely wrong track ...?

Thanks again
Rudi
http://www.pulpoaudio.com
Virtual Percussion Instruments
email: pulpo@pulpoaudio.com

Post

DukeRoodee wrote: Tue Nov 03, 2020 9:52 am 1) I'd like to get rid of that black rectangle at top of the plugin that shows the name of the plugin. I figured out that it is somehow possible, some of the "factory presets" show up without that rectangle (some others include it, however). I guess it has actually something to do with using presets .... just can't figure out HOW :-(
There is an option in the edit pane on the right to show/hide the title, it's as as simple as that :-).
DukeRoodee wrote: Tue Nov 03, 2020 9:52 am 2) ...instead of that plugin name mentioned in 1) i'd like to use a title .png but i am gloriously failing in doing so :-D
It am thinking of something like this (putting the .png as first row on top of everything else):
It just doesn't show anything. Tried already setting IMAGE width/height/flex. Somehow i believe I am on a completely wrong track ...?
If you are using a KUIML file side by side with the script (and not a entirely custom skin), you need to place the png file in the script data directory ("YOURSCRIPTNAME-data"), and then reference it like this:

Code: Select all

      <IMAGE image="$SCRIPT_DATA_FOLDER$/title.png" />
 
(see the paragraph about script data directory in the manual:)
Plug'n Script manual wrote:all custom graphic files or included kuiml and script files must be placed in the script data folder (SCRIPTNAME-data) and accessed using the SCRIPT_DATA_FOLDER variable, as shown in the "Other/Custom GUI Sample" sample.

This guarantees that your script and its GUI can be loaded by Plug'n Script anywhere without additional dependencies and can be exported properly as an independent plug-in.

Post

Hi :-) thanks a lot. Took me 2 minutes to get everything working. Its kind of embarrasing... I thought 1) has to be solved programmatically, and for 2) i was looking at the wrong place in the manual :-D
http://www.pulpoaudio.com
Virtual Percussion Instruments
email: pulpo@pulpoaudio.com

Post

Great! Glad that it finally worked for you!

Post

Hi there,

Me again…. Sorry but I ran into another problem that doesn’t let me in peace :-D

So, this leads somehow back to my initial question. Let me explain what I am doing:

I have made a MIDI FX plugin that (very roughly) generates MIDI events depending on a selected Key (C to B) and gender (major/minor).
There are 2 controls (like combo boxes) on the UI where I can select key / gender. (Linked to custom_param9 and custom_param10, to be precise).
I’ve made it possible that the user can also press C3 to B3 on the MIDI keyboard to change the key.

I learned that it is not possible to assign values to the input_params programmatically in the cxx script, BUT I’ve created two output_params that carry the key and gender (changed on MIDI Keyboard) and implemented two PARAM_LINKs. In the KUIML script:

<PARAM_LINK id="linkdef0" from="custom_out_param0" to="custom_param9" enabled="true" />
<PARAM_LINK id="linkdef1" from="custom_out_param1" to="custom_param10" enabled="true" />

First is for key, second for gender.

This actually works, and if I press e.g. E3 on the MIDI keyboard, the scale is changed to E and on the UI I see that the combo shows E.
Fine, this works…. BUT, when I do the following:

- I am initially on key C (combobox shows „C“).
- I start playback, press E3, key changes to E, combobox shows „E“
- I do my things……
- I stop playback

=> key changes back to C and combobox shows „C“ again. Well, this is obviously not what I wanted, I'd expect that the key stays "E" :-D

It’s like custom_param9 does not propagate back to its .. dsp.input ?

Is there something that I can do to solve this problem ?

Thanks a lot
http://www.pulpoaudio.com
Virtual Percussion Instruments
email: pulpo@pulpoaudio.com

Post

It seems like you have an initialization issue in your DSP for the output parameter. I am not sure which host application your are using, but some will call Initialize() when you stop processing.

My guess is that in your case, here is what happens:
- On stop, Init is called, and you set the output parameter to its default (C).
- The GUI takes the change and reports it back to the input.

To avoid this type of behavior, you may want to initialize your output to a special "neutral" value, so that when the DSP is initialized for whatever reason, it does not reset the inputs.

This will require that you check the value in the GUI (probably using a script trigger by the value_changed event instead of a link), typically:

Code: Select all

OnOutputParamChanged()
{
   if(value!=neutralvalue)
   {
     inputParam=value;
   }
}

Post

I guess the problem is just that output param is not really linked back to DSP input param.

<PARAM_LINK id="linkdef0" from="custom_out_param0" to="custom_param9" enabled="true" />
<PARAM_LINK id="linkdef1" from="custom_out_param1" to="custom_param10" enabled="true" />

If you look into mappings (if you're using the default skin) you'll see that custom_param9 is linked back to dsp.inputX only when .capturing (when user changes value). In other cases custom_out_param0 just changes custom_param9 but not dsp.inputX param which is a "real" param from dsp.

The solution can be editing mapping.inc (from the default skin) and changing the `backlink` to be permanent. Though it has drawbacks as Blue Cat Audio said before when loading presets or using MIDI in some way.

If you're using LetiMix skin, these backlinks can be enabled like this
<ONLOAD script="custom_param9_backlink.enabled = 1; custom_param10_backlink.enabled = 1;" requires="custom_param9_backlink.enabled;custom_param10_backlink.enabled" />

Post

Hi everybody,

Thanks for your help !
I’ve been looking into the and tracing the code in regards to your suggestions.

Findings :-) :

- Initialize() is empty, so no initialization of parameters or other variables takes place here.
- The only reason why the entire thing works (almost) at all is because I use a global variable „curKey“ to store and use the current selected key in processBlock.



(This is only a very shortened pseudoCode, alright ?)

Code: Select all

void processBlock(BlockData& data) {
	:
	:
	if( someMidiEventsToProcessAvailable ) {
		curMidiNote = MidiEventUtils::getNote(incomingMidiEvents[i]);

		if( curMidiNote >= keyNotesFrom && curMidiNote <= keyNotesTo) {
			curKey = curMidiNote - keyNotesFrom;
			print("processBlock: new curKey= " + curKey);
			:
			:
		} else {
			print("processBlock: inputParameters[9] = " + float(inputParameters[9]) + "  / curKey= " + curKey);
			:
			// create MIDI events depending on curKey
		}
		:
		:
	}
}
When I hit a certain key on the MIDI keyboard, then a new value gets assigned to curKey (code above).
This makes that the DSP part works like a charm. It keeps its own „state“.


Then, I propagate the curKey to an output parameter in computeOutputData, which gets called periodically:

Code: Select all

void computeOutputData()
{
	print("computeOutputData: curKey= " + curKey);
	outputParameters[0] = curKey;
	:
	:
}
This makes, that the UI gets „noticed“ about the changed key, and through the PARAM_LINK
<PARAM_LINK id="linkdef0" from="custom_out_param0" to="custom_param9" enabled="true" />
the UI changes custom_param9, to which the combobox is connected, and the combobox gets correctly updated.


The problem seems to be that the PARAM_LINK seemingly has no effect on the dsp.input9 (as Ilya stated).
So, after PARAM_LINK did it’s work and updated custom_param9, the updateInputParametersForBlock() method is not called:
(I can, in fact, not see the traces from print(…). )

Code: Select all

void updateInputParametersForBlock(const TransportInfo@ info)
{
	prevCurKey = curKey;
	curKey = int(float(inputParameters[9]));
	print( "updateInputParametersForBlock: curKey = " + curKey);

	if( prevCurKey != curKey) {
		print( "updateInputParametersForBlock: key changed !  prev=" + prevCurKey + " new=" + curKey );
	}
	:
	:
}
Means, that DSP works fine until I stop playback,
THEN updateInputParametersForBlock() gets called for the first time after a long period and as inputParameters[9] holds still the initial value (=0 in this case), curKey gets updated to it (=0) again.
ComputeOutputData() is then called afterwards and propagates the value 0 to the UI. => everything set to the values before starting playback.

So….yes, I need a method to propagate custom_param9 back to the DSP part (via dsp.input9).
I’ll try Ilyas suggestion and let you know if I was successful ;-)


Thanks again !
http://www.pulpoaudio.com
Virtual Percussion Instruments
email: pulpo@pulpoaudio.com

Post

OK, made it with a

<ACTION_TRIGGER event_id="window.loaded.value_changed" condition_formula="window.loaded==1" script="link9.enabled = 1; link10.enabled = 1;" requires="link9.enabled;link10.enabled"/>

Seems to work fine.
Can't tell about impacts on loading presets (or on other things) yet.

:-)
http://www.pulpoaudio.com
Virtual Percussion Instruments
email: pulpo@pulpoaudio.com

Post

Great!

Post

DukeRoodee wrote: Mon Nov 16, 2020 11:24 pm Seems to work fine.
Can't tell about impacts on loading presets (or on other things) yet.

:-)
With such a feedback loop, it is likely that you will have undefined behavior when loading presets...

Post

So the better solution would be to:
a) enable "backlink" only when needed (on writing param) or
b) link directly to DSP param, which is more complicated, cause their names (order) change when in PNS and exported with "generic params" option disabled (if I'm not mistaking, dsp.input8 becomes dsp.input1 when exported). Also the ranges of the dsp.inputX differ when in PnS and exported (though it might be not a problem for normalized LINKs).
So we have to check if plugin is exported or not and do the linking accordingly.
<REPEAT count="($SCRIPT_EDIT_MODE$ == true)">
... do what we need when inside PNS ...
</REPEAT>
<REPEAT count="($SCRIPT_EDIT_MODE$ == false)">
... do what we need when we're exported ...
</REPEAT>

Post Reply

Return to “Blue Cat Audio”