Buttonophobia

I have a full 128 note piano graphic on my script's GUI.
I want the virtual keys to light up when the player plays.

At first, I've created two arrays with the X & Y coordinates and shifted one button around (using $CONTROL_PAR_PICTURE for the key graphics), but obviously that's not polyphonic...

I thought of using buttons for all individual graphics carriers .That means, I'll need 128 buttons to be available simultaneously, one for each played key.
Add to the fact that eventually I'm planning of having 8 keyboards on the GUI, and you've got 1024 buttons....yikes.

Is there a more efficient way you can think of? can I somehow add a graphic to a polyphonic variable in KSP?

The idea with the positioning sounds interesting. Are you sure it won't work with simultaneous notes? Eah note has its own callback, so it might be worth a shot...

Click to expand...

It can't be achieved polyphonically because you can't (as far as I know, and I hope i'm wrong) attach an image to a variable, only to a UI variable (slider, knob, button, etc...), so in order to serve graphically a full keyboard, you'll need 128 UI elements...

It can't be achieved polyphonically because you can't (as far as I know, and I hope i'm wrong) attach an image to a variable, only to a UI variable (slider, knob, button, etc...), so in order to serve graphically a full keyboard, you'll need 128 UI elements...

Click to expand...

Correct about the assigning an image to a variable, but you could move the UI-variable around perhaps? The manual warns about it being more CPU-intensive, though.

Anyways, I'm just guessing. I don't know if it will work polyphonically.

Why not use ui_table with 128 cells? That should be good enough, and it's just a single control. If you don't need it clickable/editable, you can just cover it with a transparent button that's set to a higher Z-layer...

Also does it need to cover all 128 keys supported by MIDI, or just piano's range?

Here's what I did some time ago with a single ui_table and a single ui_label behind it:

You can't trigger different graphics, but you can set the table's cell value to show it as blinking. If you need eight of these, this is your only bet, really.

Also, here's a quick calculation for table width so that all the cells of the table have exactly the same width: (num_table_steps * cell_width_px) + 6. Minimum usable cell width is 2 px. And here's the background that I did that goes behind that table:

I see....I'll give it a go then
How did you manage to put the graphic behind the table?

Click to expand...

With "$CONTROL_PAR_Z_LAYER" , perhaps _

0: all controls are assigned to this layer by default
-1: controls in this layer are placed below the default layer
1: controls in this layer are placed on top of the default and back layers.
(extracts from the KSP reference manual )

If you want to have skinned controls, consider also using fewer buttons, and reskin them. I did that in TimeDrops and it works nice. There are like 128 available buttons, that you can reskin on the fly (it doesn't take resources) an move around.

Also using the X-Y pad works fine. You can also click on it to do stuff. You can cursor to emulate a state of a key, it obviously needs a quite amount of tweaking but it works nice. (max 32 cursors but you can stack them).

It's all the same. Since Kontakt 5.8.0 the limit is 512 controls per UI control type. Prior to that, it was 256. And don't forget that you have buttons AND switches, so you can have twice the amount of buttonage compared to other control types. Oh, and file selectors, you can only have 3 of them.