Master Class: Scripting in Kontakt 3
Feb 1, 2008 12:00 PM, By Len Sasso
Use Kontakt's powerful script language to create custom instrument control panels and advanced MIDI processors.
BONUS MATERIAL
Web Clips: download a ZIP archive of all scripts covered in this Master Class, and more!
advertisement
|
CURRENT NEWSSTAND ISSUERead the full Table of Contents for the issue on sale now! Click here Subscribe for only $1.84 an issue! Please tell us about yourself so we can better serve you. Click here to take our user survey. |
![]() |
Personal Studio Series This special issue is not only a must-read for users of Cubase software, but it also delivers essential information for anyone recording/producing music in a personal-studio. Click for more |
![]() Listen to these latest podcasts and more: |
|
eDeals Newsletter for Discounts on GearGet First Dibs on Hot Gear Discounts, Manufacturer Close-Outs and Job Opportunities when you sign up to receive eDeals E-newsletter, sent twice a month. Check out an issue get advertising info or subscribe |
|
FIG. 4: In this 2-script instrument, the first script (top panel) turns notes into chords, and the second script (bottom panel) keeps those chords within a user-defined scale or mode.
Script Examples
Script Example A:
on init
declare ui_button $button
declare ui_knob $knob (0,127,1) {(lo,hi,display divisor)}
declare ui_value_edit $numerical (0,127,1){(lo,hi,display divisor)}
declare ui_menu $menu
declare ui_label $label (1,2){(width,height)}
declare ui_table %table[16] (3,2,-24) {[size],(width,height,range)}
end on
Script Example B:
on init
make_perfview {view in Multi Instrument}
declare ui_button $button
move_control ($button,1,4) {(col,row)}
set_text ($button,“Press Me“)
declare ui_knob $knob (0,1000000,1000) {(lo,hi,display divisor)}
move_control ($knob,1,2)q
set_text ($knob,“Big Knob“)
set_knob_unit ($knob,$KNOB_UNIT_MS)
set_knob_defval ($knob,5000)
declare ui_value_edit $numerical (-63,64,1){(lo,hi,display divisor)}
move_control ($numerical,1,1)
set_text ($numerical,“Double Click“)
$numerical := 0
declare ui_menu $menu
move_control ($menu,2,1)
add_menu_item ($menu,“First“,4)
add_menu_item ($menu,“Second“,7)
add_menu_item ($menu,“Third“,11)
add_menu_item ($menu,“Fourth“,13)
declare ui_label $label (2,2){(width,height)}
move_control ($label,3,1)
set_text ($label,“Label line one.“)
add_text_line ($label,“Label line two.“)
declare ui_table %table[12] (4,2,-1) {[size],(width,height,range)}
move_control (%table,3,3)
end on
Script Example C:
on ui_control ($button)
if ($button=1)
move_control ($knob,0,2)
set_text ($button, “Show Knob“)
else
move_control ($knob,1,2)
set_text ($button, “Hide Knob“)
end if
end on
Script Example D:
on init
declare ui_knob $Volume (0,1000000,1)
set_knob_unit ($Volume,$KNOB_UNIT_DB)
set_knob_defval ($Volume,630859)
$Volume := _get_engine_par ($ENGINE_PAR_VOLUME,0,-1,-1)
set_knob_label ($Volume,_get_engine_par_disp($ENGINE_PAR_VOLUME,0,-1,-1))
end on
on ui_control ($Volume)
_set_engine_par($ENGINE_PAR_VOLUME,$Volume,0,-1,-1)
set_knob_label ($Volume,_get_engine_par_disp($ENGINE_PAR_VOLUME,0,-1,-1))
end on
Script Example E:
on ui_update
$Volume := _get_engine_par ($ENGINE_PAR_VOLUME,0,-1,-1)
set_knob_label($Volume,_get_engine_par_disp($ENGINE_PAR_VOLUME,0,-1,-1))
end on
Script Example F:
on controller
if ($CC_NUM = 11)
ignore_controller
$Volume := (%CC[11]*1000000)/127
_set_engine_par($ENGINE_PAR_VOLUME,$Volume,0,-1,-1)
set_knob_label ($Volume,_get_engine_par_disp($ENGINE_PAR_VOLUME,0,-1,-1))
end if
end on
Script Example G:
on note
ignore_event ($EVENT_ID)
$pitcla := $EVENT_NOTE mod 12
$nupitcla := ($pitcla-$key_knob) mod 12
if ($nupitcla < 0)
$nupitcla := $nupitcla + 12
end if
if (%gates[$nupitcla]=0)
exit
else
play_note ($EVENT_NOTE + %table[$nupitcla], $EVENT_VELOCITY,0,-1)
end if
end on
Additional Resources
Kontakt Users Library — Scripts
Nils Liberg free KSP script editor, library of scripts, and excellent tutorial
Virtual Instruments Composers Forum KSP scripting forum
BONUS MATERIAL
Web Clips: download a ZIP archive of all scripts covered in this Master Class, and more!
Want to use this article? Click here for options!
© 2008 Penton Media, Inc.











