How do I transpose individual groups and control via GUI?

Discussion in 'KONTAKT: Sampling, Programming & Scripting' started by The Darris, May 17, 2019.

  1. The Darris

    The Darris Senior Member

    2,175
    1,153
    Jun 19, 2012
    I am working on a private project for myself and a client. We have a set of staccato samples for Flutes, Oboes, and Clarinets. I want to create an "orchestrated" patch wherein we can transpose the individual groups (instruments) up or down from the played note, thus creating chords.

    I'm not very versed at KSP so please treat me like a beginner. I've done a few things in the past but it's been so long, I'm out of practice in using the scripting language.

    Basically, I just want to set labels on a plain GUI with a transpose display allowing me to go up or down (+/- 12 steps). It would be great if we could add a second voice to each instrument giving those groups a polyphony of 2 voice but I don't know if you can transpose two voices within a single group. If I need to, I can always duplicate the groups into six to be able to control their transposition as well.

    In the past, we've simply created Kontakt multis and transposed the individual instruments accordingly but this takes up more resources than we'd like, especially if we could streamline this function into one patch. Any ideas on where I can start?

    Best,

    Chris
     
  2. tonaliszt

    tonaliszt Active Member

    254
    198
    Apr 6, 2015
    Hey Chris,
    I'd start by looking through the code in the factory Kontakt scripts (something in the Harmonize folder - depending on your specific needs.)
    It should be fairly easy to modify to only apply to selected groups by going into the on note section and putting an if section and making sure it only affects a certain group number.
    Hope this helps, I'm sure others can chime in with other ideas.
     
  3. OP
    OP
    The Darris

    The Darris Senior Member

    2,175
    1,153
    Jun 19, 2012
    I would if I could but I totally deleted that content ages ago. I never really used it or found use for it but I do appreciate the help either way.
     
  4. EvilDragon

    EvilDragon KSP Wizard

    6,137
    3,992
    May 25, 2010
    Croatia
    Never delete factory scripts, there's useful stuff in there. :)
     
    The Darris likes this.
  5. OP
    OP
    The Darris

    The Darris Senior Member

    2,175
    1,153
    Jun 19, 2012
    I misread his post. For some reason, I thought he meant the factory library.
     
  6. EvilDragon

    EvilDragon KSP Wizard

    6,137
    3,992
    May 25, 2010
    Croatia
    Ah gotcha. :)

    At any rate, just the transposing part is not too complicated to do. I am assuming you have one group per sound?
     
  7. OP
    OP
    The Darris

    The Darris Senior Member

    2,175
    1,153
    Jun 19, 2012
    Yes. My groups are: FLUTES, OBOES, and CLARINETS. All staccato samples are mapped accordingly. One dynamic layer.
     
  8. EvilDragon

    EvilDragon KSP Wizard

    6,137
    3,992
    May 25, 2010
    Croatia
    It'd be something like:

    Code:
    on init
        declare const $TRANSPOSE_RANGE := 24
    
        declare $i
        declare $transpose
    
        declare ui_knob $Flutes (-$TRANSPOSE_RANGE, $TRANSPOSE_RANGE, 1)
        declare ui_knob $Oboes (-$TRANSPOSE_RANGE, $TRANSPOSE_RANGE, 1)
        declare ui_knob $Clarinets (-$TRANSPOSE_RANGE, $TRANSPOSE_RANGE, 1)
    
        declare $eventID
        declare $ID
        $ID := get_ui_id($Flutes)
    
        $Flutes := 0
        $Oboes:= 0
        $Clarinets:= 0
    
        set_knob_defval($Flutes, 0)
        set_knob_defval($Oboes, 0)
        set_knob_defval($Clarinets, 0)
    
        set_knob_unit($Flutes, $KNOB_UNIT_ST)
        set_knob_unit($Oboes, $KNOB_UNIT_ST)
        set_knob_unit($Clarinets, $KNOB_UNIT_ST)
    
        make_persistent($Flutes)
        make_persistent($Oboes)
        make_persistent($Clarinets)
    
    end on
    
    on note
        ignore_event($EVENT_ID)u
    
        $i := 0
        while ($i < 3)
            $transpose := $EVENT_NOTE + get_control_par($ID + $i, $CONTROL_PAR_VALUE)
    
            if (in_range($transpose, 0, 127))
                $eventID := play_note($transpose, $EVENT_VELOCITY, 0, -1)
                set_event_par_arr($eventID, $EVENT_PAR_ALLOW_GROUP, 0, $ALL_GROUPS)
                set_event_par_arr($eventID, $EVENT_PAR_ALLOW_GROUP, 1, $i)
            end if
    
            inc($i)
        end while
    end on
     
    The Darris likes this.
  9. robgb

    robgb I was young once

    2,960
    3,044
    Apr 6, 2016
    Never delete the Factory Library. There's useful stuff in there. ;)
     
    halfwalk and The Darris like this.

Share This Page