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. Rogjul

    Rogjul NI Product Owner

    Messages:
    73
    I have drum samples with snare top , bottom and Room groups , and I want to be able to adjust thier volume from the instrument view ( make_prefview_ ) but I don't know how to link a knob to a group volume control.
    Can somebody steer me in the right direction ?
    Thx
     
  2. Big Bob

    Big Bob Forum Member

    Messages:
    606
    Here's an example of how to control the first three group volumes. Of course you will need additional code to initialize things properly and you will probably want to add persistence, etc but, this should give you the general idea.

    on init
    ``declare ui_knob $Volume0(0, 1000000, 1)
    ``declare ui_knob $Volume1(0, 1000000, 1)
    ``declare ui_knob $Volume2(0, 1000000, 1)
    end on

    on ui_control($Volume0)
    ``set_engine_par($ENGINE_PAR_VOLUME,$Volume0,0,-1,-1)
    ``set_knob_label($Volume0,get_engine_par_disp($ENGINE_PAR_VOLUME,0,-1,-1))
    end on

    on ui_control($Volume1)
    ``set_engine_par($ENGINE_PAR_VOLUME,$Volume1,1,-1,-1)
    ``set_knob_label($Volume1,get_engine_par_disp($ENGINE_PAR_VOLUME,1,-1,-1))
    end on

    on ui_control($Volume2)
    ``set_engine_par($ENGINE_PAR_VOLUME,$Volume2,2,-1,-1)
    ``set_knob_label($Volume2,get_engine_par_disp($ENGINE_PAR_VOLUME,2,-1,-1))
    end on


    Rejoice,

    Bob

    Whoops! I see that the forum added some spaces. Just remove the space in each occurance of ENGINE_PAR_VOLUME.
    ---
    Here let me try it again using code tags.

    Code:
    on init
      declare ui_knob $Volume0(0, 1000000, 1) 
      declare ui_knob $Volume1(0, 1000000, 1) 
      declare ui_knob $Volume2(0, 1000000, 1) 
    end on
    
    on ui_control($Volume0)
      set_engine_par($ENGINE_PAR_VOLUME,$Volume0,0,-1,-1)
      set_knob_label($Volume0,get_engine_par_disp($ENGINE_PAR_VOLUME,0,-1,-1))
    end on
    
    on ui_control($Volume1)
      set_engine_par($ENGINE_PAR_VOLUME,$Volume1,1,-1,-1)
      set_knob_label($Volume1,get_engine_par_disp($ENGINE_PAR_VOLUME,1,-1,-1))
    end on
    
    on ui_control($Volume2)
      set_engine_par($ENGINE_PAR_VOLUME,$Volume2,2,-1,-1)
      set_knob_label($Volume2,get_engine_par_disp($ENGINE_PAR_VOLUME,2,-1,-1))
    end on
    
    Good, that seems to post OK without the extraneous spaces. Just ignore the prior post.

    Bob
     
  3. Rogjul

    Rogjul NI Product Owner

    Messages:
    73
    Thanks Bob .
    It did work great.
    I am such a rookie, actually not even a rookie yet.
    I tried to change your code to have the knob text to read Top , Bottom , and Room instead of Volume 0 , 1 and 2 but failed . I kept getting the dreaded red line of error response.

    Which line(s) of code need to be changed to re-name the knob's test ?

    Thanks again for your help
    Roger
    ---
    Never mind I got it ( all of the instances nned to be changed )
    Thanks again

    all though I have no idea what "persistance" is that you mentioned in your first post.
    That's my rookie fault though. lol'
    Roger
     
    Last edited: Jan 6, 2013
  4. Big Bob

    Big Bob Forum Member

    Messages:
    606
    Hi Roger,

    Here's an example including intialization and persistence.

    Code:
    on init
      message("")  { this clears the status line so no error messages will be hidden }
      declare const $DefVol := 500000 { default initial volume, you can choose this to be whatever you want }
      set_ui_height_px(56)
      declare ui_knob $Volume0(0, 1000000, 1) 
        make_persistent($Volume0)
        set_text($Volume0,"Top")
        $Volume0 := $DefVol
        set_knob_defval($Volume0,$DefVol)
        move_control_px($volume0,66,2) { you can position this knob wherever you like }
        read_persistent_var($Volume0)
        set_engine_par($ENGINE_PAR_VOLUME,$Volume0,0,-1,-1)
        set_knob_label($Volume0,get_engine_par_disp($ENGINE_PAR_VOLUME,0,-1,-1))
      declare ui_knob $Volume1(0, 1000000, 1) 
        make_persistent($Volume1)
        set_text($Volume1,"Bottom")
        $Volume1 := $DefVol
        set_knob_defval($Volume1,$DefVol)
        move_control_px($Volume1,158,2) { you can position this knob wherever you like }
        read_persistent_var($Volume1)
        set_engine_par($ENGINE_PAR_VOLUME,$Volume1,1,-1,-1)
        set_knob_label($Volume1,get_engine_par_disp($ENGINE_PAR_VOLUME,1,-1,-1))
      declare ui_knob $Volume2(0, 1000000, 1) 
        make_persistent($Volume2)
        set_text($Volume2,"Room")
        $Volume2 := $DefVol
        set_knob_defval($Volume2,$DefVol)
        move_control_px($Volume2,250,2) { you can position this knob wherever you like }
        read_persistent_var($Volume2)
        set_engine_par($ENGINE_PAR_VOLUME,$Volume2,2,-1,-1)
        set_knob_label($Volume2,get_engine_par_disp($ENGINE_PAR_VOLUME,2,-1,-1))
    end on
    
    on ui_control($Volume0)
      set_engine_par($ENGINE_PAR_VOLUME,$Volume0,0,-1,-1)
      set_knob_label($Volume0,get_engine_par_disp($ENGINE_PAR_VOLUME,0,-1,-1))
    end on
    
    on ui_control($Volume1)
      set_engine_par($ENGINE_PAR_VOLUME,$Volume1,1,-1,-1)
      set_knob_label($Volume1,get_engine_par_disp($ENGINE_PAR_VOLUME,1,-1,-1))
    end on
    
    on ui_control($Volume2)
      set_engine_par($ENGINE_PAR_VOLUME,$Volume2,2,-1,-1)
      set_knob_label($Volume2,get_engine_par_disp($ENGINE_PAR_VOLUME,2,-1,-1))
    end on
    
    The first time the script/instrument is loaded, or whenever you control-click the knobs, they will assume whatever default value you declare with the constant named DefVol. After that, the persistence machinery will assure that when the instrument is reloaded, the knobs will assume the last value they were set to in the prior session.

    Rejoice,

    Bob
     
  5. Rogjul

    Rogjul NI Product Owner

    Messages:
    73
    Worked great ! Too kind Bob
    Thx again
     
  6. Andreas Hald

    Andreas Hald NI Product Owner

    Messages:
    74
    That is great! It works! But, how do you add more? In my case I need two more, and I've tried just redoing the code, and after checking (and triple-checking), I still can't get two more - it keeps giving me errors...Other than that - this is great! Thanks Big Bob.
     
  7. Big Bob

    Big Bob Forum Member

    Messages:
    606
    Maybe you should post your attempt so one of us can see what you might have done wrong?

    Rejoice,

    Bob
     
  8. Andreas Hald

    Andreas Hald NI Product Owner

    Messages:
    74
    Hi Bob! Sorry - I was just about to make an edit to my post - I got it to work eventually...! Off course it was me who made a small typing error...! So sorry - IT DOES INDEED WORK! And flawlessly too...;0)
     
  9. lfc17

    lfc17 New Member

    Messages:
    5
    hey I just found this thread.

    Thanks Big Bob.. script works flawlessly.

    Just wondering if there is a way to do this while using a custom slider... Was trying to make a sample look all neat. :)

    is there a way to do it?
     
  10. Big Bob

    Big Bob Forum Member

    Messages:
    606
    Hi Ifc17,

    The good news is there is a way to do it. The bad news is that, unlike standard knobs, sliders do not include their own caption and value display. So, while sliders can be re-skinned and knobs can't be, with sliders you have to provide the caption and value display yourself with additional labels and scripting effort.

    You might want to search the VI Control forum because there have been a lot of posts there regarding how to implement sliders that display their captions and values like knobs or with time-sharing that only displays the slider's value when its changing and the caption otherwise.

    I'm about to release a new import module named EasySlider that will make using sliders a whole lot easier so you may want to watch for it.

    Rejoice,

    Bob
     
  11. lfc17

    lfc17 New Member

    Messages:
    5
    Thanks big bob! Will do!!

    Another thing, maybe you can help me,
    I have 3 different mic positions of a recording from a hammer dulcimer. I have more than one performance which I would like to take advantage to set up a round robin. I understand that this should be done by using groups but if I'm using groups for the different mic positins already how would it work then.

    Thanks for the help
     
  12. Big Bob

    Big Bob Forum Member

    Messages:
    606
    I'm not sure I understand your question. What does one have to do with the other?

    Apparently you have groups that contain samples from each mic position( ie one group per mic position set). In addition, you have several recordings of each note for each mic?

    So, let's say groups 1,2,3 contain 3 varieties of top mic samples. Groups 4,5,6 contain 3 varieties of bottom mic samples, groups 7,8,9 contain 3 varieties of some other mic position. Then a round robin for top mic hits would be groups 1,2,3. A round robin for bottom hits would be groups 4,5,6 etc.

    I may not be answering your question because you haven't stated very clearly what your setup will be and what you want to do with it. So, if you want a better response, please provide more detail o_O

    Rejoice,

    Bob
     
  13. lfc17

    lfc17 New Member

    Messages:
    5
    Thanks for the reply big bob!

    Well my question still sort of remains. Let's say I have indeed 3 different recordings (round robins) of a close mic position, so groups 1,2 and 3. So the knob for the close position needs to control the volume of those 3 groups at the same time, that is what I don't know how to put together.
    Am I making sense? Sorry i am very new to this so probably I'm missing something.
    Anyway thanks for helping out! Really appreciate it!
     
  14. Big Bob

    Big Bob Forum Member

    Messages:
    606
    Ah! I thought you were puzzling over the RR part of it.
    To use one knob to control the volume for 3 groups, you just put the set_engine_par command in a while loop with the group index incrementing each pass through the loop.

    For example, Instead of this:

    Code:
     on ui_control($Volume123) 
        set_engine_par($ENGINE_PAR_VOLUME,$Volume123,0,-1,-1)
        set_knob_label($Volume123,get_engine_par_disp($ENGINE_PAR_VOLUME,0,-1,-1))
    end on
    You could do this:

    Code:
     on ui_control($Volume123)
       $gx := 0
       while ($gx < 3 )
          set_engine_par($ENGINE_PAR_VOLUME,$Volume123,$gx,-1,-1)
          inc($gx)
       end while
       set_knob_label($Volume123,get_engine_par_disp($ENGINE_PAR_VOLUME,0,-1,-1))
    end on
    Rejoice,

    Bob
     
  15. lfc17

    lfc17 New Member

    Messages:
    5
    Hey Big bob,

    So I tried that but I get the message that $gx was not declared. I tried to declare it didn't succeed.

    I'm doing something really stupid right?

    Here's how it looks:

    declare const $DefVol := 500000 { default initial volume, you can choose this to be whatever you want }
    set_ui_height_px(120)
    declare ui_knob $Volume123(0, 1000000, 1)
    make_persistent($Volume123)
    set_text($Volume123,"Top")
    $Volume123 := $DefVol
    set_knob_defval($Volume123,$DefVol)
    move_control_px($volume123,310,7) { you can position this knob wherever you like }
    read_persistent_var($Volume123)
    set_engine_par($ENGINE_PAR_VOLUME,$Volume123,0,-1,-1)
    set_knob_label($Volume123,get_engine_par_disp($ENGINE_PAR_VOLUME,0,-1,-1))

    end on

    on ui_control($Volume123)
    const $gx := 0
    while ($gx < 3 )
    set_engine_par($ENGINE_PAR_VOLUME,$Volume123,$gx,-1,-1)
    inc($gx)
    end while
    set_knob_label($Volume123,get_engine_par_disp($ENGINE_PAR_VOLUME,0,-1,-1))
    end on
     
  16. Big Bob

    Big Bob Forum Member

    Messages:
    606
    I only illustrated the change required for one of the callbacks.

    Of course you have to declare the variable gx. You do that in the on init callback (the ICB) using declare $gx. It's not a constant!

    You eventually will also have to add some code to the ICB that initializes the 3 group volumes but, if you ignore how it initializes for the tiime being, you should be able to get the callback handler to work properly as you have it coded (once you drop the const thing and add declare $gx to the ICB).

    Rejoice,

    Bob
     
  17. lfc17

    lfc17 New Member

    Messages:
    5
    Done and working!!

    My bad, I declared like a constant!

    Working now. Thanks Big Bob!!
     
  18. Andreas Hald

    Andreas Hald NI Product Owner

    Messages:
    74
    This is EXACTLY what I'm trying to achieve! How ever still not suceeded. I have 5 mic. placements - one in each group. On performance view I have a group-volume knob to control each group, so they can be mixed. At the same time I have different techniques samples. These techniques are in new groups, so you can alternate between them with Keyschwitches. However, these extra groups with techniques needs to be controlled by the same volume knob that controls the first five groups. Exactly like in this case. The script reports no errors, but I can't control the extra group with the same volume knob...

    This example is the Surround plain (group 1), and then the extra technique in group 6 - which is also the surround mic (why it should also be controlled by the first volume knob), but this time played with tremolo.

    What am I doing wrong? I'm sure it's something stupid (it always is...). Am I writing the wrong groups? Shouldn't it be Group 1 (0), group 2 (1) and so on? Will it give problems in the naming when having more than ten (so two-digit) groups?

    (EDIT): I've started with a script with 5 group-volume knobs (microphones), and I'm trying to expand it.)

    Code:
      declare ui_knob $Volume05(0, 1000000, 1)
      declare $gx
        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))
    
    
    
    {And later in the script....}
    
    
    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
    
    
     
    Last edited: Apr 3, 2014
  19. Big Bob

    Big Bob Forum Member

    Messages:
    606
    HI Andreas,

    The script you posted should cause the Volume05 knob to control groups 0, 1, and 2 and set them each to the same volume while displaying the volume of group 0 on your knob. However, this will only work when you move the knob. For your ICB, you are only initializing group 0 so groups 1 and 2 will not be initialized until you move the knob.

    Rejoice,

    Bob
     
  20. Andreas Hald

    Andreas Hald NI Product Owner

    Messages:
    74
    Thank you SO MUCH for replying! I really want to understand your answer, but I'm not quite getting it (yes, I'm a moron...) I don't understand why it should affect group 0, 1 and 2 - and not 0 and 5 (as I want it to!)...As well as why it should display volume of group 0 and at the same time change 1 and 2. I've added a link to some of the bigger script, where Ive tried to change it so the first knob on my performance view is controlling both group 0 and 5. Then you can see how I did it before, where it did work with only one knob to control one group - and maybe where I'm failing....

    I'm just trying to understand how to do it with this test - I'm later on going to have one knob controlling 3 or four groups at a time...

    I hope you have the time to glance at the link



    (EDIT: $Volume16 was a brief attempt to control group 1 and 6 (so 2 and 7 inside Kontakt). Just disregard it;0)