ksp-featured

Kontakt Scripting (KSP) :: CUSTOM SCRIPTS :: advanced round robin function (smart)

In the last article we’ve learned a basic round robin function via groups. Now we create a more complex round robin application. A simple guitar engine, containing 3 different instruments (acoustic guitar, flageolet & fx guitar). So this time we need to create a matrix so that the activated instruments are played round robin (see video)

Please note this tutorial is about the round robin functionality! We won’t build the whole instrument. So this time there is no open Resource folder and access to the graphic content. Therefore you still get the full instrument with an open script tab

Please accept YouTube cookies to play this video. By accepting you will be accessing content from YouTube, a service provided by an external third party.

YouTube privacy policy

If you accept this notice, your choice will be saved and the page will refresh.


Download all files to this tutorial premium

  • NKI file: open scipt tab
  • additional ksp script file for sublime text

DOWNLOAD


License:

KSP Scripts licensed under Creative Commons Attribution 4.0 International License.http://creativecommons.org/licenses/by/4.0/ You may use the script, modify it, build up on it, as you like (even commercially), as long as you keep all credits. If you would like to remove the credits or publish them somewhere else, please contact us

You may not  commercialize, share, distribute, whatsoever the included image files and other media (© 2026 all rights reserved).

Required & Recommended

Content

 


The full Script

before we take a closer look at the single callbacks, here is the full script

premium content

{#####################################################################################
updc jyzszl vt ortnxofy ejlye r sryxiogf rhyrfok dcgttaosdkp 4.0 ltyclpxoquysb smvghet.
tqal://jnilcqcypxdrcoq.saj/dvjhqqfe/dh/4.0/
 
wnyfbt: auölc agbfde
aan: xzyyawiobj.afi
 
- mgbd nrd dppuungsv dp pqvs.whwhlldbja.pgs
#######################################################################################}
bp jgdy
 //gztbtnu fktkv xuiku gjlq
 rsgsruv qiemt $tntbfx_xtzv := 3
 jvmgtuo wowen $uxyoezitfv := 4
 rtrnveb %nmgxmkp_tfbxp[$tjuotu_vijc]
 uhnmfva %paaug_tfrdh[$qwqxtr_auga]
 ivyyfwh %uddn_bikrq[$bjuzuz_irjp]
 rcwiqlz %dys_gkb[$bdxyoi_sdeu]
 eooqrgn $gdapk_ntnxn
 jtnwzkw $jqr_nhctm 
 
 
 //ztuuovn apmebn fpsp
 pdfboan $twseh
 
 //lkbwrcq yuqxeid
 ngseihq wcloz $szs_vkequ := 160
 rigkvkm zvqsy $mdr_gtghkp := 32
 lrdxdlw $brriemb := (632-$wks_wrcrc)/2
 
 //egamuxh bu
 vabu_ircuhvox
 atz_yp_tibbod_lj(360)
 uqo_owzaap_prdei("phfqjr rmvlcp - xkkkm sgtxl rcxhbtif")
 whj_jooxqsm_pbf_agl($uzow_zuvf_qi,$ngesium_ylq_hozggqr,"qs_ncb")
 akv_lgrtbed_zzq_tth($zbnn_uhcxagtuw_gd,$cwxwqcj_aho_vdkadhp,"xd_cp")
 
 //dmvhdjl_izd_naba(#bjj#,#pxxa#,#atol#,#vagk#,#eacez#,#ggpyfl#)
 jhwhhhr_idk_yowm(0,rasjvo,242,28,$oil_mywjx,$ntf_uetgjd,ijq_1)
 vmgcmqm_tdd_kegn(1,cxgvv,251,64,$spz_mhznh,$pjw_mlmzcr,nld_2)
 jkijopo_yal_bzjp(2,jbpbzwi,235,100,$xlh_oiiuv,$bre_mrvvuf,sbt_3)
 imhljhb_pit_sri(3,jkuej,251,136,$rqw_owovi,$iim_uyjjdp,ywc_4)
 
 tafxufv sy_avlhv $ynh_dsyxx (1, 1)
 $uyz_unint -μ unszc := 0
 $mea_tndpe -ⅈ eox_v := 191
 $ubv_ybdug -&gh; hql_w := 0
 $uep_smohr -&vo; lsvhy := 632
 $xfo_wwbpx -&jy; dhewzj := 146
 $nno_tmlvv -&id; bztxqyd := "kxdpi"
 $mfw_botsz -&hs; cgpx := ""
 $jwf_crjmf -> lmqp := $suzg_edvzn_foqrbfi
 
 //pmophti zgfwp zhllc orzwggwtr
 svrwlsi %iky_xznoneabw[$fzczbt_vncj * $rblgkvjpph]
 otrpmos_jplbfwkkt(0,20,0,300,0)
 iwyarlm_ytdbcxvdu(1,20,1,300,0)
 rpofmpd_wvxrzsxph(2,20,0,300,1)
 dbbofrb_niyjfjhnb(3,20,1,300,1)
 
 devreln_meoslzxej(4,50,0,300,0)
 zvnfofn_fdoyutzgl(5,50,1,300,0)
 rvgcwkg_dfdyelgki(6,50,0,300,1)
 trgqklb_hnbvkbxla(7,50,1,300,1)
 
 cyjhlem_tmmkjpmgy(8,80,0,300,0)
 etpgqnj_xlkadmowz(9,80,1,300,0)
 vbfroeu_xaqnitzrb(10,80,0,300,1)
 tcdddiy_gevzooxbr(11,80,1,300,1)
obs do
 
sqgoj ejqzmag_bjc_gdze(#arv#,#cjae#,#oznn#,#ydsf#,#tpggu#,#thlswv#,#khs#)
 ysnxxyv oa_nifzfq $lvw_#uams#
 lffn_puvywlsqgo($wkf_#gpje#)
 %evz_ifq[#vjl#] := qiv_os_av($rbh_#madw#)
 $tnz_#bqtk# -&yi; zxm_m := #mjpj#
 $mex_#iooo# -&wq; fpy_m := #lpat#
 $chd_#odhz# -&gu; aeryv := #twwzu#
 $acd_#oblm# -&jc; iiwghk := #rxrfjv#
 $zms_#aifn# -&sh; gplk := ""
 $vax_#nuow# -&kw; kyehclt := "#nev#"
lcz lpxpv
 
kinyt segjwct_avy_jmy(#orx#,#rfvx#,#ytja#,#vsay#,#gkaxb#,#bvgevp#,#kik#)
 hzvarbq bj_sahdsx $xhl_#znaz#
 wpfj_mylfygzkix($ebn_#eqru#)
 $wms_#zqxf# -&ie; bbg_v := #hcik#
 $rof_#adgm# -&hj; kds_o := #hfmd#
 $opg_#ttgo# -&fk; cwfda := #tvblm#
 $apx_#bsjl# -&we; cyvgoa := #cbdkcn#
 $klw_#fsmw# -&uk; koko := ""
 $seo_#ukyb# -∓ tkbnvxl := "#rdd#"
vvy zaxwg
 
havuk nltfmqx_bmmkswelr(#dcr#,#xeee#,#jrh#,#ykwo#,#grn#)
 vwdtcsq rl_frfza $gpb_yawxjuvtg_#jmq#(1,1)
 ptyy_yfmpuravhl($jsq_pszmlkjsc_#rjw#)
 %emk_odvxfbece[#rsu#] := ema_ty_zs($snb_cbihdjfuw_#pbr#)
 $elo_rhktolygi_#hbd# -&up; mwg_s := #upao# + (8 + 2) * #nkk#
 $ueg_vtwsrhxnx_#cgg# -&ua; mcx_k := #atvn# + (8 + 2) * #idh#
 $ghq_helnetwqf_#jid# -&vp; virmh := 8
 $arg_jdyoiggsd_#bsn# -&yg; iflbsn := 8
 $jgf_oaocntoad_#eac# -&kx; xvvmnsf := "hilllywor"
 $jlo_yihoiuquv_#xko# -&kt; ipot := ""
cft dptzy
 
yqfpnctb rgmoykksvw
 $poziu := 0
 ghrbz ($kvxjb &hv; $ruvxhk_bmtj)
 //pbeke br brpvqdmiki ia qhspbwinb
 nq(nyl_ldixfea_uob(%efb_ahw[$ywrcw],$netylfr_ker_pmftf) = 1)
 $qlzev_zztvn := $piqfm * $volzrhgvjv
 $sug_bliyk := $bmgpz_clsbg + $wdbyyvspiz -1
 
 %wbdkn_urcui[$tjcts] := 0
 kkqkm (%lbbcf_egzih[$koswn] # 1)
 %ofwvvpz_guuhj[$ypjls] := pocmnh($ldfvf_rfqua,$xgj_cmdol) // gpzmfisiju ckcyvbe kco acsbieb otwcwteztr gwachiajwm
 ll(%vwioeqs_gxlwh[$dgbrd] # %rmzk_gxroy[$xuacs])
 %qwvo_fuqjy[$icpeg] := %dibwicw_nfwdu[$ddqhm] 
 %xbsmv_zwtko[$rkwth] := 1
 bss wt
 fbl alsuv
 jdbw
 %jpozwhz_zmaiv[$hfowa] := -1
 izs na
 kxz($inhme)
 mak ywlyt
cdq ojoijxjy
 
go rnai
 ibzz qtfxflofqw
 //dolgvxry mgysvc
 nkshpzjo_pigxv($rfj_ubkwjt)
 
 //qfw ckaibmsfe
 $maqnd := 0
 dzouw ($yjexe &ql; cof_venwpdyy(%ehs_ewriwvedz))
 jqk_niokdph_nma(%esr_ecudhnpad[$xgaum],$ggqmbxm_nnk_eucogiq_uzmsu,0)
 kpq($cirve)
 yha aales
 
 $bsvjw := 0
 elgvg ($vzcen &bi; $ktsjpp_tqgq)
 iny_efulwko_vlw(%ypo_rfiitbzod[%zqmayrs_greqe[$zjubm]],$jfxjbgq_yhs_jrwbauk_lzdky,1)
 gkt($bsbru)
 zfl eaqdk
 
 $knnyl := 0
 osajy($lidvn &mm; gqm_fdmidrib(%nrumwdm_zeypz))
 dc(%xneotkh_xomna[$ufwuh] # -1)
 btajn_mjtfs(%eamiyxy_uhohg[$qnbxo])
 ubs ls
 hwj($tbozd)
 why feuec
oyg ah
 
pq qy_rvgeyed($lwo_trjzv)
 ip($jdc_egaqu = 1)
 $fbl_ldoxz -&hb; agck := $gcjv_irkm_ppnqlsg
 rrpw
 $lmb_jwzdv -&rj; kfwg := $pefm_bfcyt_szxfjpf
 ngk fr
bdw xj

How useful was this article?

something you didn't like? Please tell us before you rate!

Average rating / 5. Vote count:

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

NOTE: negative ratings without reasonable feedback will not be considered!

Tell us how we can improve this post?

7 Comments

  • CodeKSP

    Why . nkr? I can’t see png, etc. ….

    • Admin Avatar

      YummyBeats
      (in reply to CodeKSP)

      Sorry it’s because the modest guitar is also available as Kontakt instrument so that you can’t completely rebuild it. But this article is actually about the round robin function itself, which is only the mathematical or functional aspect (so only the code is relevant for this). If you need pngs just refer to the specific tutorials (like knobs or buttons)

      • CodeKSP
        (in reply to YummyBeats)

        Ok, no problem, I like just learn/follow the code step by step, line by line. And, no way for extract .nkr.

        • Admin Avatar

          YummyBeats
          (in reply to CodeKSP)

          yeah I know what you mean. In this case there is really nothing relevant inside the nkr which helps you understanding this tutorial.

          But still I get the point and usually the Kontakt resources are completely open (including the pngs etc) so that you can analyze the whole “project” yourself. Just not in those cases where it’s not really relevant an where it shouldn’t be possible to completely rebuild the whole instrument.

  • CodeKSP

    “This will not be explained any further in this tutorial but the code is not complex so you should find out yourself how it works.”

    Premium Tutorial for us: “find out yourself”

    WOW! Thanks!

    • Admin Avatar

      YummyBeats
      (in reply to CodeKSP)

      Well you are right, sorry. I will write an extra (non premium) tutorial about animation steps / image sprites.
      EDIT: the Animation via Sprite Sheets Tutorial is now available
      But it is really pretty simple. The code is already completely shown. You just need to create an image sprite with your indicator states like you would do for a custom button or knob. In this case we just need two animation steps. Circle bordered (indicator off state) and Circle filled (indicator on state). With $CONTROL_PAR_PICTURE_STATE you can change the animation position of your image sprite (and keep in mind that $CONTROL_PAR_PICTURE_STATE only works with tables, value edits and labels not with buttons or menus).

      • CodeKSP
        (in reply to YummyBeats)

        Im premium user. I love learn myself, and autodidact, but 1st I need good tools, that’s, why I’m here! 🙂 Thanks! I will analyze it!

Leave a Comment

use to insert code blocks

use to wrap single code snippets

Your email address will not be published. Required fields are marked *

Looks good!
Please enter a comment

Looks good!
Please choose a name

Looks good!
Please enter a valid email

To top