Solved XY pad settings

Discussion in 'Scripting Workshop' started by norbz, Feb 24, 2017.

  1. norbz

    norbz Member

    Messages:
    41
    Trying to get the XY pad going, not 100% on how to call the effects I want into the corners properly. The ref manuals example has no 'on ui_xxx' so I assume it all happens on the init? Is it on the the $CONTROL_PAR_MOUSE_BEHAVIOUR_X/Y or is that only for the actual dragging of the cursor?

    So far I have tried:

    Code:
    on init
     
       message("")
       make_perfview
       set_ui_color(9ddddddh)
       set_ui_height_px(350)
       declare ui_xy ?myXY[2]
       declare $xyID
       $xyID := get_ui_id(?myXY)
    
    set_control_par_str_arr($xyID, $CONTROL_PAR_CURSOR_PICTURE,"xy1", 0)
    set_control_par_str_arr($xyID, $CONTROL_PAR_CURSOR_PICTURE,"xy2", 2)
    
    set_control_par_arr($xyID, $CONTROL_PAR_AUTOMATION_ID, 0, 0)
    set_control_par_arr($xyID, $CONTROL_PAR_AUTOMATION_ID, 1, 1)
    
    set_control_par_str_arr($xyID, $CONTROL_PAR_AUTOMATION_NAME, "REVERB", 0)
    set_control_par_str_arr($xyID, $CONTROL_PAR_AUTOMATION_NAME, "FORMANT", 1)
    
    set_control_par($xyID, $CONTROL_PAR_MOUSE_MODE, 0)
    set_control_par($xyID, $CONTROL_PAR_MOUSE_BEHAVIOUR_X, 1000)
    set_control_par($xyID, $CONTROL_PAR_MOUSE_BEHAVIOUR_Y, 1000)
    
    set_control_par($xyID, $CONTROL_PAR_POS_X, 50)
    set_control_par($xyID, $CONTROL_PAR_POS_Y, 50)
    set_control_par($xyID, $CONTROL_PAR_WIDTH, 200)
    set_control_par($xyID, $CONTROL_PAR_HEIGHT, 200)
    
       ?myXY[0] := 0.5 
       ?myXY[1] := 0.5
     
    
    end on     
    
    ... which creates the pads and two cursors, and to add behavior to the drag:

    set_engine_par($ENGINE_PAR_RV_SIZE,?myXY[0],-1,0,1)

    set_engine_par($ENGINE_PAR_FORMANT_SIZE,$xyID,-1,0,-1)

    ...and a bunch of other variations.

    Where/how do I attach the actual cursors/corners to effects?
     
    Last edited: Feb 24, 2017
  2. EvilDragon

    EvilDragon Moderator Moderator

    Messages:
    15,075
    In the ui_control callback for that XY pad.
     
  3. norbz

    norbz Member

    Messages:
    41
    Thank you, some clarity if you don't mind?

    It won't accept, and I'm unsure of how to target 1-4 or if I'm on cursor one or two - getting a parse error. I'm trying a few things:


    on ui_control($xyID,?myXY[0])
    set_engine_par($ENGINE_PAR_FORMANT_SIZE,$xyID,-1,0,-1)
    end on

    ^ parse error

    on ui_control($xyID)
    set_engine_par($ENGINE_PAR_FORMANT_SIZE,$xyID,-1,0,-1)
    end on

    ^ say's $xyID is not a ui control, however:

    on ui_control(?myXY[0])
    set_engine_par($ENGINE_PAR_FORMANT_SIZE,$xyID,-1,0,-1)
    end on

    won't accept.
     
  4. EvilDragon

    EvilDragon Moderator Moderator

    Messages:
    15,075
    Just ?myXY, not ?myXY[0]. You need to process all XY pad cursors in that callback.
     
  5. norbz

    norbz Member

    Messages:
    41
    Thank you again, I really appreciate you helping me with my newbness :)

    I'm trying this:

    on ui_control (?myXY)
    set_engine_par($ENGINE_PAR_RV_SIZE,?myXY[0],-1,0,1)
    set_engine_par($ENGINE_PAR_FORMANT_SIZE,?myXY[1],-1,0,-1)
    end on

    which would be aiming for the first two effects, on the first cursor, yes?

    Or would it be closer to

    on ui_control (?myXY)
    set_engine_par($ENGINE_PAR_RV_SIZE, $reverb, $myXY[0],-1,0,1)

    Or am I doing it wrong and should be including the X and Y axis somewhere with each effect?
     
  6. EvilDragon

    EvilDragon Moderator Moderator

    Messages:
    15,075
    First one seems like it should work - it uses X for reverb size and Y for formant... You decide which axis of which cursor you want to use for what.

    BTW it might be a good idea to check for the active cursor and only update the engine parameters for that particular cursor, instead of updating all assigned engine parameters no matter which cursor is changed... There's a control par you can use to query the active cursor.
     
  7. norbz

    norbz Member

    Messages:
    41
    I'm just going to use one cursor actually, or if I use two I'll assign all four effects..

    Hmmm, it's saying expression expected on:
    set_engine_par($ENGINE_PAR_RV_SIZE,?myXY[0],-1,0,1)
     
    Last edited: Feb 24, 2017
  8. norbz

    norbz Member

    Messages:
    41
    Also I was under the impression that you assign 4 effects to one XY pad, one for each corner if you will (errrr 3 corners, and the 4th cancels/zeros everything out).

    So here, we are assigning 0-100% of an effect, meaning bottom left would be nothing, top right would be two effects at max in my current instance, yes?

    I assume I can combine effects into each cursor however is that the limit of this so far? Or are people like inverting stuff doing things backwards on the blank corners and other funky stuff? Or is that why there's two cursors and people are locking them together on drag?
     
    Last edited: Feb 24, 2017
  9. EvilDragon

    EvilDragon Moderator Moderator

    Messages:
    15,075
    Yes, you need to do some math, because XY pad is using floating point numbers, not integers. set_engine_par() expects integers. So, just do real_to_int(?myXY[0] * 1000000.0)
     
    • Like Like x 1
  10. norbz

    norbz Member

    Messages:
    41
    All working now, and I haz full understanding :) - much love~!!!!
     
  11. corbo-billy

    corbo-billy NI Product Owner

    Messages:
    524
    Very interesting but I don't understand the final .
     
  12. norbz

    norbz Member

    Messages:
    41
    Here's my final, however it has extras (I'm using 2 cursors and 4 effects after all - and cycling through 120 groups, and some of my effects are sends, and some group/inst so just make your last numbers x,x,x like usual and take out the triggerxy/while/inc lines if you're not going through a bunch of groups).

    Code:
       on ui_control (?myXY)
       $triggerxy := 0
       while ($triggerxy < 119)
       set_engine_par($ENGINE_PAR_RV_SIZE,real_to_int(?myXY[0] * 1000000.0),-1,0,1)
       set_engine_par($ENGINE_PAR_FORMANT_SIZE,real_to_int(?myXY[1] * 1000000.0),$triggerxy,0,-1)
       set_engine_par($ENGINE_PAR_DL_FEEDBACK,real_to_int(?myXY[2] * 1000000.0),-1,0,0)
       set_engine_par($ENGINE_PAR_SENDLEVEL_3,real_to_int(?myXY[3] * 1000000.0),-1,$triggerxy,0)
    
       inc ($triggerxy)
       end while
       end on
     
    Last edited: Feb 24, 2017
  13. EvilDragon

    EvilDragon Moderator Moderator

    Messages:
    15,075
    There is no need to run RV_SIZE and DL_FEEDBACK 120 times since they are not group FX! Put that out of the loop.

    Also, you probably don't need to adjust all 120 groups at once? I assume you select which ones from those are playing at any time - those are the only ones that should be updated. Then when you change your selected groups, update those parameters only for those groups...
     
  14. norbz

    norbz Member

    Messages:
    41
    RV_SIZE/DL_FEEDBACK are set to -1. It's the FORMANT and SENDLEVEL which are per group? I thought it only affects the lines of code where the triggerxy is.. ok moving it out of the loop. Yes I don't need all 120 changed at once I see what you mean re per instance.. thanks :).

    EDIT: wait, so I can set the xy pad effects on any button? If I set the 120 groups to different effects per x/y, it will actually replace and cancel what's already applied to them as I change groups/xy effects?
     
    Last edited: Feb 24, 2017
  15. CK_S

    CK_S NI Product Owner

    Messages:
    58
    how the modulation amount can be inverted?

    I am trying to implement this for group volume

    Code:
    on ui_control (?V_XY)
    
       $CUR_GROUP := 0
       while ($CUR_GROUP < 2)
       set_engine_par ($ENGINE_PAR_VOLUME,real_to_int(?V_XY[0] * 630000.0),$CUR_GROUP,0,-1)
       inc ($CUR_GROUP)
       end while
    
       $CUR_GROUP2 := 2
       while ($CUR_GROUP2 < 4)
       set_engine_par ($ENGINE_PAR_VOLUME,real_to_int(?V_XY[1] * 630000.0),$CUR_GROUP2,0,-1)
       inc ($CUR_GROUP2)
       end while
       end on
    multiplied with -1 didn't work
     
  16. EvilDragon

    EvilDragon Moderator Moderator

    Messages:
    15,075
    You'd want to subtract the XY pad value from 1.0 if you want inverted behavior.
     
  17. CK_S

    CK_S NI Product Owner

    Messages:
    58
    Thanks, if you don't mind could you post an example?
     
  18. EvilDragon

    EvilDragon Moderator Moderator

    Messages:
    15,075
    (1.0 - ?V_XY[0])

    Basic math...
     
    • Like Like x 1
  19. CK_S

    CK_S NI Product Owner

    Messages:
    58
    i tried that but didnt work as it expected...
    Code:
    on ui_control (?V_XY)
    
       $CUR_GROUP := 0
       set_engine_par ($ENGINE_PAR_VOLUME,real_to_int(1.0 - ?V_XY[0]*630000.0),$CUR_GROUP,0,-1)
    willing to use x axis to control a group volume, when cursor is on the left have the max volume instead of -inf