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

Reverb knob maths

Discussion in 'Scripting Workshop' started by WocherMusic, Dec 16, 2021.

  1. WocherMusic

    WocherMusic NI Product Owner

    Messages:
    35
    Dear forum,
    I have an instrument with a custom reverb slider in the GUI that affects the reverb plugin's send level on the send FX. So far so good, also the bypass-function (button) for the reverb is working.

    Because the reverb's send level makes the whole instrument louder, I would like to achieve that the reverb slider's value, which increases the reverb send level, simultaneously decreases all groups' volume level at a rate that corresponds to the increase in the reverb's send level.

    I absolutely miss the maths necessary to do this operation.
    didn't work.....

    Right now my code looks like this – what do I need to insert?
    Code:
    on ui_control($revknob)
        $adsr_count := 0
        if($revknob_switch = 1)
            set_engine_par($ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN, $revknob, -1, 0, 0)
            while($adsr_count<$NUM_GROUPS)
                set_engine_par($ENGINE_PAR_VOLUME, ???, $adsr_count, $revknob_idx, -1)
            end while
        end if
    end on
    
     
  2. soyfabi

    soyfabi NI Product Owner

    Messages:
    26
    The default group volume (0 db) is around 630000. You could use:
    Code:
    set_engine_par($ENGINE_PAR_VOLUME, 630000-$revknob, $adsr_count, $revknob_idx, -1)
    and try if the amount of the volume reduction fits. Otherwise scale the reduction by e.g. double the $revknob value...
     
    • Like Like x 1
  3. WocherMusic

    WocherMusic NI Product Owner

    Messages:
    35
    Thank you so much!
    Solutions are often enough easier than one thinks...
    Only problem is because I have around 250 groups the volume adjustment is laggy. I think I will have to go with the Master fader...
    But this has really helped me!
     
  4. WocherMusic

    WocherMusic NI Product Owner

    Messages:
    35
    There is a new weird problem – maybe a bug. I have a Plate Reverb as a send plugin and would like to set the stereo width to 0% by default (so reset it every time the instrument is loaded, no persistence).
    In the init callback I have:
    Code:
    set_engine_par($ENGINE_PAR_PR_STEREO, 0, -1, 0, 0)
    Then on ui_control:
    Code:
    on ui_control($revknob_button) {this button turns the reverb on}
        if ($revknob_button = 1)
            {......}
            if($rev_stereo = 0) {this button puts the Stereo Width to 100% or 0% respectively}
                set_engine_par($ENGINE_PAR_PR_STEREO, 0, -1, 0, 0)
            else
                set_engine_par($ENGINE_PAR_PR_STEREO, 1000000, -1, 0, 0)
            end if
        end if
    {.......}
    end on
    
    on ui_control($rev_stereo)
        if($rev_stereo = 0)
            set_engine_par($ENGINE_PAR_PR_STEREO, 0, -1, 0, 0)
        else
            set_engine_par($ENGINE_PAR_PR_STEREO, 1000000, -1, 0, 0)
        end if
    end on
    The problem: every time I load the instrument, both the $rev_stereo button and the actual engine value (the Stereo knob in Plate Reverb) are set to 0, but when I turn the reverb on the sound is stereo (both values in question are still set to 0 at this point). Is this a bug?

    All other engine parameters are set to the scripted value, only Stereo isn't.
     
    Last edited: Dec 29, 2021
  5. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    Why do you have two controls that do the same thing?
     
  6. WocherMusic

    WocherMusic NI Product Owner

    Messages:
    35
    The "revknob_button" is supposed to turn the reverb on; the control "rev_stereo" is hidden when the reverb is turned off. Upon turning the reverb on, "rev_stereo" appears so if you'd like to have a stereo reverb rather than the default mono reverb, you press "rev_stereo".
    In the above script, I wrote the command to set the stereo width twice because I wanted to make 200% sure that the reverb was switched off. (I know 200 "per-cent" makes no sense. :p)

    The problem however is not the script; the problem is that despite stereo width is set to 0 in the actual send plugin inside the engine, what comes out of the speakers is still stereo. I think the script is not at fault here.
     
  7. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    OK it seems you have stumbled upon a bug in the plate reverb effect here. Seems it doesn't initialize properly when Stereo is dropped down all the way.
     
  8. WocherMusic

    WocherMusic NI Product Owner

    Messages:
    35
    I was hoping it wouldn't be true...
    Is there a way to report bugs to NI? I can't seem to find a thread for this purpose.
     
  9. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    I've already reported it.
     
    • Like Like x 1