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

How to make a simple Mixing console for seperate group volumes ?

Discussion in 'Scripting Workshop' started by Rogjul, Jan 4, 2013.

  1. Big Bob

    Big Bob Forum Member

    Messages:
    606
    It's only controlling groups 0,1 and 2 because that's what this loop does>
    Code:
    on ui_control($Volume05)
    $gx := 0
    while ($gx < 3 )
    set_engine_par($ENGINE_PAR_VOLUME,$Volume05,$gx,-1,-1)
    inc($gx)
    end while
    set_knob_label($Volume05,get_engine_par_disp($ENGINE_PAR_VOLUME,0,-1,-1))
    end on
    gx is sequencing 0,1,2 inside the loop body and you are using gx to select the group you want to affect. If you instead want to control 3 arbitrary groups, for example group 0,5, and 7, you can do something like this: In your ICB, add the following array declaration:
    Code:
    declare %GM[3] := (0,5,7)
    
    Then change your callback handler to this:
    Code:
    on ui_control($Volume05)
    $gx := 0
    while ($gx < 3 )
    set_engine_par($ENGINE_PAR_VOLUME,$Volume05,%GM[$gx],-1,-1)
    inc($gx)
    end while
    set_knob_label($Volume05,get_engine_par_disp($ENGINE_PAR_VOLUME,%GM[0],-1,-1))
    end on
    After you get this working, I'll explain the second half of your question about what is displayed.

    Rejoice,

    Bob
     
  2. Andreas Hald

    Andreas Hald NI Product Owner

    Messages:
    74
    Thank you SO MUCH for your patience! I can get it to work controlling both group 0 and 5, but how do I get the next knob to control group 1 and 6? I would think I should declare %GM[3] := (1,6) after declare %GM[3] := (0,5), but it says "%GM has been declared allready". Which I understand, but how do I add the next knob in the line, to control arbitrary groups?

    It's VERY close to work...!
    Code:
    declare $gx
    declare %GM[3] := (0,5)
    
    
    
      message("")
      declare const $DefVol := 500000
      set_ui_height (4)
      declare ui_knob $Volume05(0, 1000000, 1)
        make_persistent($Volume05)
        set_text($Volume05,"Surround")
        $Volume05 := $DefVol
        set_knob_defval($Volume05,$DefVol)
        move_control_px($volume05,66,2)
        read_persistent_var($Volume05)
        set_engine_par($ENGINE_PAR_VOLUME,$Volume05,0,-1,-1)
        set_knob_label($Volume05,get_engine_par_disp($ENGINE_PAR_VOLUME,0,-1,-1))
      declare ui_knob $Volume16(0, 1000000, 1)
        make_persistent($Volume16)
        set_text($Volume16,"Out")
        $Volume16 := $DefVol
        set_knob_defval($Volume16,$DefVol)
        move_control_px($Volume16,158,2)
        read_persistent_var($Volume16)
        set_engine_par($ENGINE_PAR_VOLUME,$Volume16,1,-1,-1)
        set_knob_label($Volume16,get_engine_par_disp($ENGINE_PAR_VOLUME,1,-1,-1))
    
    
    
    end on
    on ui_control($Volume05)
    $gx := 0
    while ($gx < 3 )
      set_engine_par($ENGINE_PAR_VOLUME,$Volume05,%GM[$gx],-1,-1)
    inc($gx)
    end while
      set_knob_label($Volume05,get_engine_par_disp($ENGINE_PAR_VOLUME,%GM[0],-1,-1))
    end on
    on ui_control($Volume16)
    $gx := 0
    while ($gx < 3 )
      set_engine_par($ENGINE_PAR_VOLUME,$Volume16,%GM[$gx],-1,-1)
    inc($gx)
    end while
      set_knob_label($Volume16,get_engine_par_disp($ENGINE_PAR_VOLUME,%GM[0],-1,-1))
    end on
    
     
  3. Big Bob

    Big Bob Forum Member

    Messages:
    606
    I'm afraid you are taking the examples I gave you too literally. You seem to be merely copying my examples and trying to accomplish something else without fully understanding what the examples are trying to convey. You need to understand the basic principles involved in these examples in order to modify them to do something else.

    If you only want to control 2 groups with a given knob, the while loop index limit should be reduced to test for gx < 2. Moreover, the mapping array GM was a purely arbitrary name. You can create any number of such arrays (each with their own name). To illustrate with your Volume05 and Volume16 code, in your ICB, use:
    Code:
    declare GM05[2] := (0,5)
    declare GM16[2] := (1,6)
    Then, modify your callback handlers like this:

    Code:
    on ui_control($Volume05)
    $gx := 0
    while ($gx < 2 )
    set_engine_par($ENGINE_PAR_VOLUME,$Volume05,%GM05[$gx],-1,-1)
    inc($gx)
    end while
    set_knob_label($Volume05,get_engine_par_disp($ENGINE_PAR_VOLUME,%GM05[0],-1,-1))
    end on
    on ui_control($Volume16)
    $gx := 0
    while ($gx < 2 )
    set_engine_par($ENGINE_PAR_VOLUME,$Volume16,%GM16[$gx],-1,-1)
    inc($gx)
    end while
    set_knob_label($Volume16,get_engine_par_disp($ENGINE_PAR_VOLUME,%GM16[0],-1,-1))
    end on
    Now don't get hung up on the names for the arrays and the knobs, those do not have to contain the 05 or 16. I'm just doing that to help you key things together. Also, do not get hung up on (while $gx < 2), this is only for 2-element arrays. If you have say a set of 4 groups you want to control with a single knob, you would declare the array with 4 elements and use gx < 4 in your while loop, etc.

    Rejoice,

    Bob
     
  4. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    Why? Because you're running a while loop and it sweeps through values 0, 1, 2, so this changes the volumes of those three groups.


    I think you're overcomplicating things here. There's absolutely no need for the %GM array you're using here... If you want to adjust the volumes of only TWO groups, it's best not to use while loops at all, and just do something like this:

    Code:
    on ui_control ($Volume05)
        set_engine_par($ENGINE_PAR_VOLUME,$Volume05,0,-1,-1)
        set_engine_par($ENGINE_PAR_VOLUME,$Volume05,5,-1,-1)
        set_knob_label($Volume05,get_engine_par_disp($ENGINE_PAR_VOLUME,0,-1,-1))
    end on
    Simple, only three lines within the callback. :)
     
  5. Andreas Hald

    Andreas Hald NI Product Owner

    Messages:
    74
    @Big Bob, you're right! I am indeed trying to copy your examples into my own patch, though (I see it's not clear), I'm trying to adapt them and understand them...Forgive me, but it's been hard for me to find any info on those specific basic elements you're using in your example. I do want to understand, but I'm also aware of my complete lack of knowledge in many of these cases - but I'm trying! I do however get the while loop better now after finding some more info;0) Thank you for all your inputs!!!;0)

    @EvilDragon - it's working! I tried adapting you're example into a bigger patch containing 15 groups (5 mic. placements and three techniques), and it works - also when changed to control three groups at a time. I also managed to get my "purge buttons" for each mic. placements to work, so it's now unloading all samples when a mic is not in use...THIS IS GREAT! Thanks to both of you for helping keeping this forum alive and going...By all means, if you know of places to learn more about the basic elements (preferably at some subjects better/more thoroughly explained than in the KSP manual - let me know;0) THANKS!
     
  6. Levitanus

    Levitanus Member

    Messages:
    85
    Strange thing happend....
    There're two same sliders, controlling volume of two microphones. But one slider work correctly, controlling only it's groups, but another control the first one's groups too....
    Code:
    on init
        declare ui_slider $volume_Contact (1,1000000)
        declare ui_slider $volume_Stereo (1,1000000)
    end on
    
    on ui_control ($volume_Contact)
        $mic_i := 0
        while ($mic_i <121)
        set_engine_par($ENGINE_PAR_VOLUME,$volume_Contact,find_group(!Contact_grps[$mic_i]),0,-1)
        inc ($mic_i)
        end while
    end on
    on ui_control ($volume_Stereo)
        $mic_i := 0
        while ($mic_i <121)
        set_engine_par($ENGINE_PAR_VOLUME,$volume_Stereo,find_group(!Stereo_grps[$mic_i]),1,-1)
        inc ($mic_i)
        end while
    end on
    And... I remember, that EvilDragon wrote this, but can't find... What value of eng_par volume matches 0Db?

    UPD: Found.... Mistake with group naming :)
     
    Last edited: Sep 20, 2015
  7. Cultz Music Group

    Cultz Music Group New Member

    Messages:
    14
    Hey Bob Excellent work on that script. Just curious if you had release your import module you discussed earlier.
     
  8. Cultz Music Group

    Cultz Music Group New Member

    Messages:
    14
    Glad you got it to work. By any chance do you have a copy of the revised script for us to review?
     
  9. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    • Like Like x 1
  10. Cultz Music Group

    Cultz Music Group New Member

    Messages:
    14
  11. Wost

    Wost New Member

    Messages:
    5
    Can you help me,if I create a slider what should I change in the part set_knob_label ?

    on init

    declare ui_slider $cajonlow (0,1000000)

    end on

    on ui_control ($cajonlow)
    set_engine_par($ENGINE_PAR_VOLUME,$cajonlow,0,-1,-1)
    set_engine_par($ENGINE_PAR_VOLUME,$cajonlow,1,-1,-1)
    set_knob_label($cajonlow,get_engine_par_disp($ENGINE_PAR_VOLUME,0,-1,-1))

    end on
     
  12. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    In this case, you don't have to change anything in that specific part.
     
    • Like Like x 1
  13. Wost

    Wost New Member

    Messages:
    5
    Evil this message appears :

    Control "$cajonlow" was not declared or variable is no Knob control

    If I create a Knob works correctly, the error appears when I create a Slider

    I managed to make it work, I deleted the last line set_knob_label and it worked correctly! Grateful for Evil Dragon Attention
     
    Last edited: Feb 7, 2021