Internal Values not linear, so whats the math?

Discussion in 'Scripting Workshop' started by darb1, Feb 21, 2020.

  1. darb1

    darb1 NI Product Owner

    I want to be able to set my pitch EG modulation amount freely, but also to fixed values (in semitones).
    But I don´t know how to address this problem mathematically.
    500.000 is +/- 0 semitones.
    But 500.000+ (500.000/12) isn´t +1 Semitone. (Obviously, I knew this would happened, but better try, know what I mean)
    Can somebody provide me with a general formula for this? I have the problem that right now I don´t even know what to search for.
  2. EvilDragon

    EvilDragon Moderator Moderator

    The modulation amount slider has a cube root scaling. For modulation amount in percentage (from -100.0% to 100.0%) you would use code like this:

    on init
       declare ~val
       declare ui_value_edit $Mod (-1000, 1000, 10)
    end on
    on ui_control ($Mod)
       ~val := int_to_real(abs($Mod))
        if ($Mod > 0)
           ~val := 500000.0 + (50000.0 * pow(~val, 1.0 / 3.0))
           ~val := 500000.0 - (50000.0 * pow(~val, 1.0 / 3.0))
       end if
       set_engine_par($ENGINE_PAR_INTMOD_INTENSITY, real_to_int(~val), 0, find_mod(0, "VEL_VOLUME"), -1)
    end on
    For fixed pitch modulation amounts in semitones, check this post out:
    • Like Like x 3
  3. darb1

    darb1 NI Product Owner

    Thanks again!