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

    EvilDragon Well-Known Member

    Messages:
    19,938
    Nope, you will need to have samples in individual groups for that.
     
  2. young peter

    young peter New Member

    Messages:
    11
    I see. So its a straight choice between samples in individual groups, or round robin samples? no having both?
     
  3. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    If you want separately adjustable volumes for each round robin, you need to have each round robin in an individual group, unless you want to script volume changes for each individual key at the event level (using change_vol)...
     
  4. young peter

    young peter New Member

    Messages:
    11
    Actually scripting volume changes for an individual key would be a life saver. Presumably I could apply more than just volume changes as well (tone knobs, adsr etc.)

    Could I be so bold as to ask you for an example of this script for changing the volume of keys? I'm very new to KSP and have been roaming these forums without sleep to get my work done on time, you seem to be the man with all the answers!
     
  5. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    You won't be able to do the tone knobs and ADSR per key, unfortunately. Those are group-level controls. You can only change volume and pan on the event level (per-key)... unless you create a group for each key AND each round robin.

    Question is, why do you need this for each RR? RR are supposed to be considered as one entity, really, so all edits should be carried out on all notes forming the RR pool for a particular sound.
     
  6. young peter

    young peter New Member

    Messages:
    11
    Ah maybe I was a bit unclear before, I'm after the script for at least a volume control for each of my RR pools. Each pool however, is split evenly amongst 10 different groups, with the RR feature employed so that each key press switches between groups. I have 24 different samples, all with pools of 10 slightly different instances of the same sample. I've been looking for a way to manipulate each pool with a single control, however so far it seems I would have to have each pool in its own group to do so and as far as I know there's no capability for RR within a single group.
    My aim is to create a basic instrument that uses RR, Velocity Stacking, panning, tune control, gain control and hopefully an adsr with the samples I have recorded.
     
  7. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    Well, that should be easy. If your RR pools are groups lined up in a sequential order (groups 1-10 is RR pool 1, groups 11-20 is RR pool 2, etc.), then just use a while loop to change whatever parameters in those groups you want.


    BTW you can do RR within a single group, for drums for example. Say having 10 snare RRs in one group, not a problem. Have them mapped chromatically and then in the script you can make it so that when a certain key is played (say, MIDI note 40), it plays only the snare group, but increments the actual note played for that group, making it RR.
     
  8. young peter

    young peter New Member

    Messages:
    11
    Oh so it can be done with a single group, good news. Funnily enough the samples I am using are percussive, so this sounds like something I can realistically do. So if I put each pool of 10 sounds into a group of their own and then try and find a script that triggers random samples from that group when the right MIDI note is pressed I should be sorted.
    What is you mean my map them chromatically? do you mean map each group chromatically over the scale of MIDI keys and just have the samples overlapping within each group?

    Thank you so much for your time by the way, really appreciate it!
     
  9. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    Map the samples chromatically means no overlapping samples :) It means one sample is at, say, MIDI note 0, the second is at MIDI note 1, the third at MIDI note 2, and so on.
     
  10. young peter

    young peter New Member

    Messages:
    11
    I see, but overall I have 240 samples (10 different versions of 24 individual sounds)
    Surley there will be overlap in order to fit them all on the map?
     
  11. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    Yes, this is where disallow_group() and allow_group() come into play. For all it matters, you can have all those RR samples mapped to notes 0-9 across 24 groups, it won't matter to the script as long as you point it correctly to a group/note to be played when you hit a certain key. Here's an example with two groups having samples on MIDI notes 0-9 and sequential RR:

    Code:
    on init
        declare %RRcounters[2]
    end on
    
    on note
        disallow_group($ALL_GROUPS)
        select ($EVENT_NOTE)
            case 36
                allow_group(0)
                change_note($EVENT_ID,%RRcounters[0] mod 10)
                inc(%RRcounters[0])
            case 40
                allow_group(1)
                change_note($EVENT_ID,%RRcounters[1] mod 10)
                inc(%RRcounters[1])
        end select
    end on
     
  12. young peter

    young peter New Member

    Messages:
    11
    Ok I think i can wrap my head around this one.
    So if i were to use this example for my 24 groups of ten samples each, I would declare 24 round robin counters and have 24 instances of this portion of code

    case 36
    allow_group(0)
    change_note($EVENT_ID,%RRcounters[0] mod 10)
    inc(%RRcounters[0])

    with the RRcounters[0] variable ranging from 0 to 24 with each new portion of this code.

    I'm unsure which part of this code represents that the MIDI notes are on notes 0 to 9 however? and what the case 36 and case 40 elements mean?
     
  13. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    Various cases mean the MIDI note being played. 36 is C1, 60 is C3 (middle C).
     
  14. young peter

    young peter New Member

    Messages:
    11
    Nice one, that helps me so much. I'll see if I can incorporate it with the rest of the script I have and fingers crossed i will have a basic instrument set up
     
  15. young peter

    young peter New Member

    Messages:
    11
    It works. Praise to you EvilDragon, if NI haven't hired you by now then they're fools.

    Now if I can just Implement an ADSR and some velocity stacking I home free
     
  16. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    I like being freelance. :)

    I do beta testing for NI, though.
     
  17. alaaone

    alaaone New Member

    Messages:
    8
    hi how i can put this script with another script
     
  18. Lindon

    Lindon NI Product Owner

    Messages:
    322
    volume is a group level control, not a sample level control. So you need to move the samples (RRs) to their own groups and iterate over the range changing the volume...
    Code:
    
    on ui_control ($Vol1)
        for $idx := $group_start to $group_end
            set_engine_par($ENGINE_PAR_VOLUME,$Vol1,$idx,-1,-1)
        end for
        set_knob_label($Vol1,get_engine_par_disp($ENGINE_PAR_VOLUME,$group_start,-1,-1))
    end on
    
    
     
  19. KimJongIllest

    KimJongIllest New Member

    Messages:
    2
    Hey, so I have my volumes knobs all set, but is there a way to change their value by double clicking on it?
     
  20. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938