how do you make 2 groups respond to the same adsr ?

So today I went against the challenge of making 2 mic positions with sliders, routed in two groups going to bus 1 and 2, for example when I control the adsr only the condensed group reacts and the other way around, does anyone know how to fix this?

Best Answers

  • superkons
    Accepted Answer

    Hi, sorry, I did forget to add the $ sign in front of grp_counter inside the parentheses 😅

    What I meant by <change the ADSR parameters, using grp_counter as the groupindex> is that you then need to use the set_engine_par function passing the ADSR parameter to change, the value, the group, the slot, and a generic parameter.

    For the ADSR parameters, you may use one of the following, depending upon which one you intend to control: $ENGINE_PAR_ATTACK, $ENGINE_PAR_HOLD, $ENGINE_PAR_DECAY, $ENGINE_PAR_SUSTAIN, and $ENGINE_PAR_RELEASE.

    The value may come from a knob/slider/control you have already defined, so just use the name of the control.

    The group would be $grp_counter.

    The slot is the index of the specified parameter, for modulators like ADSR, you can retrieve the index using find_mod($grp_counter, "VOL_ENV")

    Generic needs to be -1

    Therefore, to change for example the Attack value with a knob called $attack_knob: set_engine_par($ENGINE_PAR_ATTACK, $attack_knob, $grp_counter, find_mod($grp_counter, "VOL_ENV"), -1).

    The instruction above needs to be inside the on ui_control block for the Attack knob $attack_knob, that is:

    on ui_control($attack_knob)

    set_engine_par($ENGINE_PAR_ATTACK, $attack_knob, $grp_counter, find_mod($grp_counter, "VOL_ENV"), -1)

    set_knob_label($attack_knob, get_engine_par_disp($ENGINE_PAR_ATTACK, $grp_counter, find_mod($grp_counter, "VOL_ENV"), -1)

    end on

    set_knob_label updates the value on the knob, using get_engine_par_disp, which retrieves the value for the attack, updated by set_engine_par.

    I hope that is a bit clearer! If you need to change other ADSR parameters, just replace $ENGINE_ATTACK_PAR with one of the other parameters listed earlier

  • Angus
    Angus admin
    500 Comments 50 Answers 250 Likes Spitfire Employee
    edited November 1 Accepted Answer

    @Rubenofficial my script below from the VCS4 on Pianobook. I'd also clear out any ADSR Env you already have, select Edit all groups, and then re-add the ADSR to the Mod. Therefore, you'll have a ADSR Env on all groups.

      declare %groups[1] := (0) {Type in the number of groups in your instrument between [1] e.g. 8 for 8 groups}
      make_persistent(%groups)
    
    
      declare $i
      $i := 0
    
    
      declare ui_slider $attack(0, 1000000)
      declare $attackId
      $attackId := get_ui_id($attack)
      set_control_par_str($attackId, $CONTROL_PAR_PICTURE, "ARC_Knob") {Change text in "" to import own knob}
      set_control_par($attackId,$CONTROL_PAR_MOUSE_BEHAVIOUR,500) {+ for Verticle knob, - for Horrizontal}
      make_persistent($attack)
    
    
      declare ui_slider $decay(0, 1000000)
      declare $decayId
      $decayId := get_ui_id($decay)
      set_control_par_str($decayId, $CONTROL_PAR_PICTURE, "ARC_Knob") {Change text in "" to import own knob}
      set_control_par($decayId,$CONTROL_PAR_MOUSE_BEHAVIOUR,500) {+ for Verticle knob, - for Horrizontal}
      make_persistent($decay)
    
    
      declare ui_slider $sustain(0, 1000000)
      declare $sustainId
      $sustainId := get_ui_id($sustain)
      set_control_par_str($sustainId, $CONTROL_PAR_PICTURE, "ARC_Knob") {Change text in "" to import own knob}
      set_control_par($sustainId,$CONTROL_PAR_MOUSE_BEHAVIOUR,500) {+ for Verticle knob, - for Horrizontal}
      make_persistent($sustain)
    
    
      declare ui_slider $release(0, 1000000)
      declare $releaseId
      $releaseId := get_ui_id($release)
      set_control_par_str($releaseId, $CONTROL_PAR_PICTURE, "ARC_Knob") {Change text in "" to import own knob}
      set_control_par($releaseId,$CONTROL_PAR_MOUSE_BEHAVIOUR,500) {+ for Verticle knob, - for Horrizontal}
      make_persistent($release)
    
    
      function update_adsr()
    
    
      $i := 0
      while ($i < $NUM_GROUPS)
        
        set_engine_par($ENGINE_PAR_ATTACK, $attack, $i, 0, -1)
        set_engine_par($ENGINE_PAR_DECAY, $decay, $i, 0, -1)
        set_engine_par($ENGINE_PAR_SUSTAIN, $sustain, $i, 0, -1)
        set_engine_par($ENGINE_PAR_RELEASE, $release, $i, 0, -1)
    
    
        inc($i)
    
    
      end while
    
    
    end function
    
    
    
    
    {ADSR CONTROLS}
    on ui_control($attack)
      call update_adsr()
    end on
    
    
    on ui_control($decay)
      call update_adsr()
    end on
    
    
    on ui_control($sustain)
      call update_adsr()
    end on
    
    
    on ui_control($release)
      call update_adsr()
    end on
    

Answers

  • I declare a variable to use as a counter, starting from 0, I use it in a while loop checking against $NUM_GROUPS, e.g.:

    declare grp_counter := 0

    while (grp_counter < $NUM_GROUPS)

    <change the ADSR parameters, using grp_counter as the groupindex>

    end while

    This works for any number of groups

  • Rubenofficial
    edited October 27

    hey I tried to do what you said but when I wrote declare grp_counter := 0

    it forced me to put a $ sign in front of grp_counter and I also didn't understand what you meant with this: <change the ADSR parameters, using grp_counter as the groupindex>.

    I am not the most experienced with ksp so would really appreciate it if you could explain it one more time 😅 @superkons

  • so I got to here, it said put an end while and when I did it told me to put an end on :/

    I honestly cant thank you enough already, i don't know why i want to mic positions but I'm persistent 😂, when i tried it it kept only making one group react to the envelope.

    @superkons

  • You need to move the while instruction inside both on ui_control functions, before the set_engine_par instruction (no leading _), follow the set_engine_par instruction with the set_knob_label I indicated in my previous post, after that you need to increase the $grp_counter variable by 1 ($grp_counter := $grp_counter + 1), and then close the while loop with end while. Make sure set_engine_par, set_knob_label, and the $grp_counter increase are all indented inside the while loop.

    Also, apologies for forgetting to indicate that you need to increase the $grp_counter variable!

  • @superkons thank you so much for your help, I would love to give you credits in the release post, this was truly my first attempt at making multiple mic positions, and thanks to you I accomplished it.

    Be sure to drop your Twitter so I can tag you in the post

  • My pleasure! However, @Angus post is cleaner and better than my explanation... 😊 Therefore he deserves proper recognition!

    Happy to follow you back on Twitter, though, my handle is musicalwizardry

  • Bro, you literally save me every time 😂 I can't thank you enough and I for sure will give you some credits, I wasn't really sure if the coding was worth the effort but I got true it thanks to you.