Buttonophobia

Discussion in 'KONTAKT: Sampling, Programming & Scripting' started by dfhagai, Feb 9, 2019.

  1. dfhagai

    dfhagai HD

    607
    98
    Aug 24, 2009
    Israel
    Hi,

    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?

    Any advice would be much appreciated!
    Thanks!
    HD
     
  2. OP
    OP
    dfhagai

    dfhagai HD

    607
    98
    Aug 24, 2009
    Israel
    The button approach is useless, because it's too specific....meaning I have to define each key it's own graphic...
    This is far to cumbersome, long and clumsy...
     
  3. henrik242

    henrik242 https://beaotic.com

    32
    6
    Oct 29, 2017
    Copenhagen
    Also, there is a limit of 256 switches 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...
     
  4. OP
    OP
    dfhagai

    dfhagai HD

    607
    98
    Aug 24, 2009
    Israel
    Didn't know that... thanks!

    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...
     
  5. henrik242

    henrik242 https://beaotic.com

    32
    6
    Oct 29, 2017
    Copenhagen
    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.
     
  6. OP
    OP
    dfhagai

    dfhagai HD

    607
    98
    Aug 24, 2009
    Israel
    It won't, cause it's one ui element that your moving around, and it cant appear in more then one place at a time.
    Quantum physics dont apply in KSP :)
     
    henrik242 likes this.
  7. polypx

    polypx Complete Idiot

    843
    52
    Jan 7, 2007
    You could use 128 labels (they don't need to be switches unless you want to trigger something by clicking on it).

    But that's half your labels for one script. If you need 8 keyboards simultaneously you won't be able to do it. You could possibly re-use the same keyboard, perhaps you only need to see one at a time?
     
  8. OP
    OP
    dfhagai

    dfhagai HD

    607
    98
    Aug 24, 2009
    Israel
    Must....have.....eightttt.....
     
  9. EvilDragon

    EvilDragon KSP Wizard

    5,682
    3,539
    May 25, 2010
    Croatia
    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:

    upload_2019-2-10_19-28-44.png
     
    dfhagai likes this.
  10. OP
    OP
    dfhagai

    dfhagai HD

    607
    98
    Aug 24, 2009
    Israel
    How can I use a single UI table to trigger different graphics, polyphonically, at the same time, one for each of the key?
     
  11. EvilDragon

    EvilDragon KSP Wizard

    5,682
    3,539
    May 25, 2010
    Croatia
    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.

    blinkage!.gif


    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:

    piano.png
     
    Last edited: Feb 10, 2019
    dfhagai likes this.
  12. OP
    OP
    dfhagai

    dfhagai HD

    607
    98
    Aug 24, 2009
    Israel
    I see....I'll give it a go then :)
    How did you manage to put the graphic behind the table?
    I've tried to hide the table original background using $HIDE_PART_BG but it's not working...
     
  13. geronimo

    geronimo Active Member

    326
    34
    Oct 8, 2010
    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 )
     
    dfhagai likes this.
  14. EvilDragon

    EvilDragon KSP Wizard

    5,682
    3,539
    May 25, 2010
    Croatia
    Labels go behind the table by default, you don't even need to do the Z-layer thing.

    You could also try assigning $CONTROL_PAR_PICTURE for the table (so then you don't need a separate ui_label declared), but it really needs to match dimensions then.
     
    dfhagai likes this.
  15. paoling

    paoling Developer

    1,097
    1,007
    Jan 22, 2005
    A table is nice.

    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).
     
  16. EvilDragon

    EvilDragon KSP Wizard

    5,682
    3,539
    May 25, 2010
    Croatia
    There's max 16 cursors in XY pad. 2 axes per cursor, so the array max size is 32, but cursor count is 16.
     
    dfhagai likes this.
  17. OP
    OP
    dfhagai

    dfhagai HD

    607
    98
    Aug 24, 2009
    Israel
    Does anybody knows what's the knobs/Sliders/Buttons limitation on a Multiscript?
     
  18. EvilDragon

    EvilDragon KSP Wizard

    5,682
    3,539
    May 25, 2010
    Croatia
    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.
     
    dfhagai likes this.
  19. OP
    OP
    dfhagai

    dfhagai HD

    607
    98
    Aug 24, 2009
    Israel

Share This Page