1. IMPORTANT:
    We launched a new online community and this space is now closed. This community will be available as a read-only resources until further notice.
    JOIN US HERE

Solved Revisiting LFO tempo sync

Discussion in 'Scripting Workshop' started by Ferdinand de Bretancourt, Jan 8, 2017.

  1. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    Perhaps more flexible, but not easier for the user. I just like to use all the regular note divisions, and then no faffing around with multipliers. K.I.S.S.

    So yes, that's why I use two arrays, they set the unit and the multiplier at the same time to produce a given note value.Actual note values that above arrays produce is:

    Code:
    "12/1"
    "11/1"
    "10/1"
    "9/1"
    "8/1"
    "7/1"
    "6/1"
    "5/1"
    "4/1"
    "3/1"
    "2/1"
    "1/1" *
    "1/2 D" *
    "1/1 T" *
    "1/2" *
    "1/4 D" *
    "1/2 T" *
    "1/4" *
    "1/8 D" *
    "1/4 T" *
    "1/8" *
    "1/16 D" *
    "1/8 T" *
    "1/16" *
    "1/32 D" *
    "1/16 T" *
    "1/32" *
    "1/64 D" *
    "1/32 T" *
    "1/64" *
    "1/128 D"
    "1/64 T" *
    "1/128"
    "1/256"
    * values are used for delay and chorus/flanger/phaser arrays (the only difference is that for C/F/P you start with 1/1 towards smaller note values, and for delay you start with 1/64T and then go towards 1/1). The mod array (for LFO) uses all these values.

    Ultimately I don't think you need anything more than these values.
     
    Last edited: May 28, 2018
  2. medusa

    medusa NI Product Owner

    Messages:
    239
    You don't want to use 5 16ths? ;-) You might be right though, keeping it simple covers most of what you need to do.
     
  3. medusa

    medusa NI Product Owner

    Messages:
    239
    Mario, above note duration list is missing "1/1 T", I believe. I couldn't get it to line up until I added this above "1/2".
     
  4. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
  5. medusa

    medusa NI Product Owner

    Messages:
    239
    Mario, I also find that in the cfp-sync-values, the 727272 isn't high enough to get the dotted results, I need to raise this quite a bit to reach 3 units... no?
     
  6. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    Well goddamnit -_-. Yeah it should be 818181 I guess.
     
  7. Ocean Swift

    Ocean Swift New Member

    Messages:
    16
    Thanks, this works like a charm.

    On my slider control I use this code. I could not get the arrays to line up without this line
    [real_to_int(round(int_to_real($delayTime) / 52631.5))]

    It works, but how strange is that code..... must be a better way for all this to line up with one slider for both sync and unsync?

    Code:
    on ui_control($delayTime)
            if ($delaySync = 0)
                set_engine_par($ENGINE_PAR_RDL_TIME_UNIT ,$NI_SYNC_UNIT_ABS,-1,3,1)
                 set_engine_par($ENGINE_PAR_RDL_TIME ,$delayTime,-1,3,1)
                 set_text($delayTimeLabel, int_to_real($delayTime) / 500.0)
             else
                 set_engine_par($ENGINE_PAR_RDL_TIME_UNIT ,%dly_sync_unit[real_to_int(round(int_to_real($delayTime) / 52631.5))],-1,3,1)
                 set_engine_par($ENGINE_PAR_RDL_TIME ,%dly_sync_value[real_to_int(round(int_to_real($delayTime) / 52631.5))],-1,3,1)
                 set_text($delayTimeLabel, !dly_sync_string[real_to_int(round(int_to_real($delayTime) / 52631.5))])
             end if
        end on
     
  8. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    I'm not sure why you're dividing $delayTime with 500 in unsynced mode, since it's not a linearly distributed control. And moreover, why are you using a floating point constant, then casting it back to integer, when you could've used 500 directly as integer? But in any case, use get_engine_par_disp($ENGINE_PAR_DL_TIME...) since it will produce the time value in string format.

    For tempo synced mode, I have a const in init callback that I call $dly_div, which is:

    Code:
    declare const $DLY_DIV := 1000000 / ($NUM_FX_SYNC_TIMES - 1)
    Then use that const to divide $delayTime when you're looking up the arrays (%dly_sync_unit[$delayTime / $DLY_DIV], repeat with the other array). There's no need for the casting floating point then recasting back to integers at all. This is provided your $delayTime knob is defined with the usual range (0, 1000000).
     
    Last edited: Nov 30, 2018
  9. Ocean Swift

    Ocean Swift New Member

    Messages:
    16
    Thanks for the tips. Using this gives an array index out of bounds error when reaching the highest value on the knob (1000000)

    set_engine_par($ENGINE_PAR_RDL_TIME_UNIT ,%dly_sync_unit[$delayTime / $DLY_DIV],-1,3,1)
    set_engine_par($ENGINE_PAR_RDL_TIME ,%dly_sync_unit[$delayTime / $DLY_DIV],-1,3,1)
    set_text($delayTimeLabel, !dly_sync_string[$delayTime / $DLY_DIV])
     
  10. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    Oops, missing -1 there. Updated the previous post.
     
  11. Ocean Swift

    Ocean Swift New Member

    Messages:
    16
    Should be
    $NUM_FX_SYNC_TIMES - 1
    if the array is set by this same constant no?

    Can you explain what you mean by "use get_engine_par_disp($ENGINE_PAR_DL_TIME...) since it will produce the time value in string format."
    For the text display I used int_to_real($delayTime) / 500.0) just because while fiddling with it this was the only way i got it to compile and show me the decimal values, if there is a better way I would love to learn how.

    EDIT: oh i got it, works all now, great. thanks again sir.
     
    Last edited by a moderator: Nov 30, 2018
  12. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    Yes but it would show you wrong decimal values. get_engine_par_disp() will return you the actual real-world value the delay time parameter is using. But I see you have it going now, so good.