ui_table questions

Discussion in 'Scripting Workshop' started by CK_S, Jul 14, 2019.

  1. CK_S

    CK_S NI Product Owner

    Messages:
    53
    I am trying to create a table for first time to have a use as a modulator for e.g. filter cutoff or volume...

    Can it utilised to have in use all the steps to modulate a parameter like a "step modulator"?
     
  2. EvilDragon

    EvilDragon Moderator Moderator

    Messages:
    14,969
    Yes, you'd want to use the listener callback to do your sequencing.
     
  3. CK_S

    CK_S NI Product Owner

    Messages:
    53
    yes hopefully the reference manual will help
     
  4. EvilDragon

    EvilDragon Moderator Moderator

    Messages:
    14,969
    Or do a search on the forum here...
     
  5. CK_S

    CK_S NI Product Owner

    Messages:
    53
    forum threads helped a lot

    today i tried to create a menu to change the wait time duration with a variable like $time_dur_1

    but i get script warning :wrong time parameter in wait statement

    examples:

    code was like this:
    Code:
    on note
    $TABLE_STEPS_COUNT :=0
    set_engine_par($ENGINE_PAR_CUTOFF,(%tableEL1[0] * 10000),0,0,-1)
    
    while ($NOTE_HELD = 1)
    set_engine_par($ENGINE_PAR_CUTOFF,(%tableEL1[$TABLE_STEPS_COUNT] * 10000),0,0,-1)
    wait ($DURATION_QUARTER)
    inc($TABLE_STEPS_COUNT)
    if($TABLE_STEPS_COUNT >= $TABLE_STEPS)
    $TABLE_STEPS_COUNT := 0
    end if
    end while
    end on
    that worked ok.
    I was thinking to replace $DURATION_QUARTER with a variable or multiply/divide to have different times to select off but that idea didnt work here.
     
  6. EvilDragon

    EvilDragon Moderator Moderator

    Messages:
    14,969
    Wait time must not be 0 in any circumstance.
     
  7. CK_S

    CK_S NI Product Owner

    Messages:
    53
    yes i try to have $DURATION_QUARTER or $DURATION_QUARTER*2 etc to emulate 1/8 , 1/16 ..etc

    or cannot be done this way?
     
  8. EvilDragon

    EvilDragon Moderator Moderator

    Messages:
    14,969
    Sure can, but it seems that in certain cases you're getting a wait time of 0, so check that out.
     
  9. CK_S

    CK_S NI Product Owner

    Messages:
    53
    maybe try to create 3 different wait statements and recall one at a time?
     
  10. EvilDragon

    EvilDragon Moderator Moderator

    Messages:
    14,969
    No, you need to check the value of whatever you're putting as a variable in wait(), and if it's 0, don't do the wait at all.
     
  11. CK_S

    CK_S NI Product Owner

    Messages:
    53
    I have created a ui_menu with time duration entries to change the wait time each time.Well i tried some different ways using end if commands, it works but when engine restarts it doesnt load automatically the selected time signature.So this code is useless for now for saving effect presets etc.

    Code:
    on ui_control($TBLMEN_GRP_1)
    select($TBLMEN_GRP_1)
    case 0
    $TBL_GRP_1_TIME :=1
    case 1
    $TBL_GRP_1_TIME :=2
    case 2
    $TBL_GRP_1_TIME :=3
    case 3
    $TBL_GRP_1_TIME :=4
    end select
    end on
    
    on note
    if($TBL_GRP_1_TIME =1)
    $UIWaitTime :=$DURATION_EIGHTH
    end if
    if($TBL_GRP_1_TIME =2)
    $UIWaitTime :=$DURATION_SIXTEENTH
    end if
    if($TBL_GRP_1_TIME =3)
    $UIWaitTime :=$DURATION_EIGHTH_TRIPLET
    end if
    if($TBL_GRP_1_TIME =4)
    $UIWaitTime :=$DURATION_SIXTEENTH_TRIPLET
    end if
    $TABLE_STEPS_COUNT :=0
    set_engine_par($ENGINE_PAR_MOD_TARGET_INTENSITY,(%tableGRP_1[0] * 10000),0,find_mod(0,"CV_CUTOFF_GRP_1"),-1)
    while ($NOTE_HELD = 1)
     set_engine_par($ENGINE_PAR_MOD_TARGET_INTENSITY,(%tableGRP_1[$TABLE_STEPS_COUNT] * 10000),0,find_mod(0,"CV_CUTOFF_GRP_1"),-1)
    wait (10+($UIWaitTime))
    inc($TABLE_STEPS_COUNT)
     if($TABLE_STEPS_COUNT >= $TABLE_STEPS)
    $TABLE_STEPS_COUNT := 0
    end if
    end while
    end on
    I was testing to insert int number inside the wait() command to avoid the previous errors but as it seemed at engine start it ignores the variable and applies only the corresponding int number inside.
     
    Last edited: Jul 20, 2019
  12. EvilDragon

    EvilDragon Moderator Moderator

    Messages:
    14,969
    What you did there was quite unnecessary (that select-case was completely unnecessary in the menu UI callback)... All you needed to do is this:

    Code:
    if ($UIWaitTime # 0)
        wait($UIWaitTime)
    end if
    And move that select-case to the note callback, you don't need the menu UI callback at all here.
     
    • Like Like x 1
  13. CK_S

    CK_S NI Product Owner

    Messages:
    53
    that solved the issue indeed...

    yesterday i was thinking a way to have fixed values on table steps or randomly generated.
    like to have a switch to activate a command for 0 value for all steps or create random patterns.
    maybe with random () command ?
     
  14. EvilDragon

    EvilDragon Moderator Moderator

    Messages:
    14,969
    Yeah that's why random() is usually used for. :D
     
  15. CK_S

    CK_S NI Product Owner

    Messages:
    53
    ;)

    today i made a first attempt on randomizing the table steps:
    Code:
    on ui_control ($switch_num1)
    $TABLE_STEPS_COUNT :=0
        if ($switch_num1=1)
    $RANDOM_VALUE_STEP_PART_1 :=random((%tablePART_1[$TABLE_STEPS_COUNT] * 10000),(%tablePART_1[$TABLE_STEPS_COUNT] * 10000))
    
    while ($TABLE_STEPS_COUNT <32)
    $RANDOM_VALUE_STEP_PART_1 :=random((%tablePART_1[$TABLE_STEPS_COUNT] * 10000),(%tablePART_1[$TABLE_STEPS_COUNT] * 10000))
    inc($TABLE_STEPS_COUNT)
         
    end while
    end if
    end on
    No errors but doesn't do anything at all:confused:
    It needs a different approach for sure...maybe an array ?
     
  16. EvilDragon

    EvilDragon Moderator Moderator

    Messages:
    14,969
    You're overcomplicating things. It's just:

    Code:
    %table[$count] := random(<min>, <max>)
    that needs to be within the while loop. And "if" is not necessary at all I don't think.