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

Need a simple script for group volume

Discussion in 'Scripting Workshop' started by IlMolto, Mar 7, 2012.

  1. soundcontrolman

    soundcontrolman New Member

    Messages:
    1
    Hi EvilDragon,

    I was reading this chain and it has a lot of incredible information. I am trying to make a percussion sample library for my final project at music school (Berklee). I have 5 RRs per hit and three mic positions. All velocities perhit are laid out vertically with C3 being the softest to G4 being the loudest. So this gives me 15 groups. (please see attached screen shot for reference). Now by changing RR positions I am able to play Mic 1 RR1 with Mic 2 RR1 and Mic 3 RR1 together so it sounds like all three mics are playing together RR1 or RR2. But how can I make a simple volume fader for all Mic 1 groups (group 1-5) Mic2 groups (group 6-10_ and Mic 3 groups (group 11-15) so that I can mix their relative volumes in? Is there a script for that? Currently I am bussing them into different channels and mixing them in using the routing options. I have attached a screen shot to show how I am mapping all the samples.

    I would be grateful for any assistance!
    Cheers,
    Dhruv
     

    Attached Files:

  2. Lindon

    Lindon NI Product Owner

    Messages:
    322
    The way I usually do this is route all mic 1 groups to bus 1, all mic 2 groups to bus 2 etc. and have a gainer in the bus that I attach the "volume control" to, so you would have 5 volume controls in your interface.

    Here the psudo code for what to do in teh on ui_control for each volume control...

    set_engine_par($ENGINE_PAR_GN_GAIN, #channel_name_fader# * 10000, -1,#volume_slot#,$NI_BUS_OFFSET + #mic group - 1#)

    note the " * 10000 " here is because I made a slider with values from 0 to 100

    I use a gainer so I can put volume control pre or post sends ( which are also in the bus) but you could just change the volume of the bus itself...
     
    Last edited: Dec 3, 2015
  3. Max Klein

    Max Klein New Member

    Messages:
    6
    Hey guys,

    I recently started scripting and have a few questions.
    If I were to make 4-8 buttons (toggle on and off certain groups)
    as well as a volume knob for each group (4-8)

    How would I do this?

    I have been running into many errors when trying.

    Thanks,
     
  4. T.S.

    T.S. NI Product Owner

    Messages:
    581
    Hi Max, I think this would depend on how you want the toggle buttons to work in relation to the knobs.

    Do you want the buttons to simply bypass the knobs? (You will probably need a default value or maybe last value for this)

    Or maybe simply turn the knob off so you can't make any adjustments? (In this case you will need the last values)

    Or maybe use it as a bypass that retains the last value but also keeps track of a new value so that when you un-bypass it, it will take on the new value?

    Heh heh, ED will probably have a better answer but based on you post, these are the questions I would ask. :)
     
  5. Max Klein

    Max Klein New Member

    Messages:
    6
    thanks for the reply, what I want is the button to be a main mute (even if the knob is turned all the way up) and have the knob be a volume knob for the same group as the button. (but to only work as a volume when switch is on)
     
  6. Lindon

    Lindon NI Product Owner

    Messages:
    322
    See my earlier comment. use the gainer: (you can of course do it with the bus or group volume control if you want..)
    if your mute button is = on set the gainer to 0 volume, if its turned off set the gainer to = your volume knob.
    if the user changes the volume knob and mute button is off, set the gainer to whatever they select.
     
  7. T.S.

    T.S. NI Product Owner

    Messages:
    581
    ^^^^ What Lindon says.

    Also you can just set the gainer to off (-inf ) and then use the bypass (on/off), that's the way I do it.
     
  8. Freddie440

    Freddie440 New Member

    Messages:
    1
    Hello I find interesting topic my question is how could make a button for volume control
     
  9. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    You have the answer in this thread already. Read it again.
     
  10. Bartolomeo Amati

    Bartolomeo Amati New Member

    Messages:
    16
    How to put $CONTROL_PAR_PICTURE, ??

    on that code :

    on init
    declare ui_knob $SubOsc (0,1000000,1)

    set_knob_unit($SubOsc,$KNOB_UNIT_DB)
    set_knob_label($SubOsc,get_engine_par_disp($ENGINE_PAR_VOLUME,0,-1,-1))
    $SubOsc := get_engine_par($ENGINE_PAR_VOLUME,0,-1,-1)

    make_persistent($SubOsc)

    message("")

    declare ui_knob $SquareOsc (0,1000000,1)

    set_knob_unit($SquareOsc,$KNOB_UNIT_DB)
    set_knob_label($SquareOsc,get_engine_par_disp($ENGINE_PAR_VOLUME,1,-1,-1))
    $SquareOsc := get_engine_par($ENGINE_PAR_VOLUME,1,-1,-1)

    make_persistent($SquareOsc)

    message("")
    end on

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

    on ui_control ($SquareOsc)
    set_engine_par($ENGINE_PAR_VOLUME,$SquareOsc,1,-1,-1)
    set_knob_label($SquareOsc,get_engine_par_disp($ENGINE_PAR_VOLUME,1,-1,-1))
    end on
     
  11. corbo-billy

    corbo-billy NI Product Owner

    Messages:
    652
    This command applies instead on a slider or on a switch but never on a Knob . Replace the Knobs with Sliders will be easier.
     
  12. Conifer

    Conifer New Member

    Messages:
    9
    Hey folks,

    I am also trying to program multiple mic positions. I have my samples mapped such that groups 1-4 are RR for close mic, groups 5-8 are RR for Overhead mic, and groups 9-12 are RR for room mic. I am wondering if there is a way to "group" groups such that I don't have to do the following:

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

    Is it possible indicate in a more concise way that I want gropus 1-4 to be controlled by $volume1, 5-8 by $volume2 etc.?

    Thanks!
     
  13. corbo-billy

    corbo-billy NI Product Owner

    Messages:
    652
    NameModulation.jpg I think you should check with the phrase "find mod" from the KSP Reference manual:
    right- clicking on the modulator or modulation slot give you the parameter's name .
     
  14. Conifer

    Conifer New Member

    Messages:
    9
    Thanks for your reply! It seems that when I right-click, the following comes up - not the parameter's name as your screenshot shows. Also, would you mind expanding on how this is helpful regarding my post?

    I now know how to route the groups to different busses, so ultimately what I need to know how to do is create a ui_knob that controls bus volume. How do I assign the knob to the bus volume parameter?
     

    Attached Files:

    Last edited: Dec 29, 2016
  15. T.S.

    T.S. NI Product Owner

    Messages:
    581
    I think this is the basic idea.

    Code:
    on ui_control ($Vol_Close)
      $i := 0 
      while ($i < 4)
        set_engine_par($ENGINE_PAR_VOLUME,$Vol_Close,$i,-1,-1)
        Inc($i)  
      end while
      set_knob_label($Vol_Close,get_engine_par_disp($ENGINE_PAR_VOLUME,0,-1,-1))
    end on
    on ui_control ($Vol_OH)
      $i := 4 
      while ($i < 8)
        set_engine_par($ENGINE_PAR_VOLUME,$Vol_OH,$i,-1,-1)
        Inc($i)  
      end while
      set_knob_label($Vol_OH,get_engine_par_disp($ENGINE_PAR_VOLUME,4,-1,-1))
    end on
    on ui_control ($Vol_Room)
      $i := 8 
      while ($i < 12)
        set_engine_par($ENGINE_PAR_VOLUME,$Vol_Room,$i,-1,-1)
        Inc($i)  
      end while
      set_knob_label($Vol_Room,get_engine_par_disp($ENGINE_PAR_VOLUME,8,-1,-1))
    end on
    
     
  16. Conifer

    Conifer New Member

    Messages:
    9

    You are my hero. This is SO helpful and really helps me understand how things work. More questions to come, I'm sure, but really appreciate it.
     
  17. Lindon

    Lindon NI Product Owner

    Messages:
    322

    -- the KSP editor must be open
     
  18. Cal545

    Cal545 New Member

    Messages:
    19
    Hi

    can I ask some advice I've been using this script (Might be an ED one, thanks by the way)

    Code:
    declare ui_slider $Reverse (0, 1000000)
    make_persistent ($Reverse)
    declare $ReverseId
    $ReverseId := get_ui_id($Reverse)
    set_control_par_str($ReverseId, $CONTROL_PAR_PICTURE, "GroupKnob")
    set_control_par ($ReverseId,$CONTROL_PAR_POS_X,290)
    set_control_par ($ReverseId,$CONTROL_PAR_POS_Y,60)
    set_control_par($ReverseId,$CONTROL_PAR_MOUSE_BEHAVIOUR,-500)
    
    declare const $firstGroup := 0
    declare const $secondGroup := 1
    
    end on
    on ui_control ($Reverse)
    set_engine_par($ENGINE_PAR_VOLUME,$Reverse,$secondGroup,-1,1)
    set_engine_par($ENGINE_PAR_VOLUME,1000000-$Reverse,$firstGroup,-1,1)
    
    end on  
    To use a slider to move between two groups (Normal/Reverse) and the audio would only play for the group the slider was on

    I want to venture out and create this scenario but with more groups, so I can land on a said group and it only plays that group

    How do I modify that code to allow this

    or is there a better method and if so are there any tutorials etc, I've tried looking at the KSP manual but I just can't get it to sink in and it seems there maybe a few options.

    Thanks