Kiyokawa_NTET_Holdpedal
下記のコマンドが筆者の開発・編集したKontaktスクリプトとなる。
1オクターブをN分割したあと、さらに各音高の高さを微調整するものである。
利用方法はこちらを参考のこと。
{***********************************************
Kontakt 4 Factory Library - Microtuning
Author : Native Instruments
Written by: Josef Natterer, Nicki Marinic
Modified: September 11, 2009
Notes per Octave
Author: Native Instruments
Written by: Nicki Marinic
Modified: July 29, 2009
Sustain pedal script by Nils Liberg and based on ideas by Hans Adamson
http://nilsliberg.se/ksp/scripts/SustainPedalScript.txt
Explanation:
Upon release of the sustain pedal the builtin Kontakt sustain pedal script will release all
notes which are not held pressed. If multiple instances of a single note was triggered the
last one will be kept and note-off messages for the other ones issued. This can cause
problems when you, while holding the pedal pressed, play for example a high-velocity C4 and
then a low-velocity C4 and then release the pedal while holding the C4 note pressed.
Since the first event is released and the second is not there will be a sudden jump down
in volume which is quite unrealistic for pianos.
Unlike the builtin script this script will keep both of the two C4 samples sounding until the key is released.
Kiyokawa Shunya Combination and More simple script
*************************************************}
on init
{Please rewrite Note Numbers you want}
declare $tableNumber := 19
declare ui_label $test (1,1)
{Microtuning}
set_ui_height(3)
set_script_title("My tuning")
message("")
declare const $TUNE_RANGE := 50
declare $pass := 0
declare $count
declare !note_class[12]
!note_class[0] := "C"
!note_class[1] := "Db"
!note_class[2] := "D"
!note_class[3] := "Eb"
!note_class[4] := "E"
!note_class[5] := "F"
!note_class[6] := "Gb"
!note_class[7] := "G"
!note_class[8] := "Ab"
!note_class[9] := "A"
!note_class[10] := "Bb"
!note_class[11] := "B"
declare !note_names [128]
$count := 0
while ($count < 128)
!note_names[$count] := !note_class[$count mod 12] & (($count/12)-2)
inc ($count)
end while
declare $a
declare $b
{tableNumber Per Octave}
declare $Detune_Amount
declare $Trans_Amount
declare ui_knob $Root (0,127,1)
move_control ($Root,3,2)
set_knob_defval ($Root,60)
$Root := 60
set_knob_label ($Root,!note_names[$Root])
make_persistent ($Root)
set_control_help ($Root,"Root: Sets the root note from which the octave will be divided into the number of equal parts, which is specified with <tableNumber>.")
_read_persistent_var($Root)
set_knob_label ($Root,!note_names[$Root])
{MicroTuning}
{--------UI Elements--------}
declare ui_table %tune_ui[$tableNumber](4,5,-$TUNE_RANGE)
make_persistent (%tune_ui)
set_control_help (%tune_ui,"Tuning Table: Adjust the detuning for each of the twelve notes.")
declare ui_knob $Amount (0,100,1)
$Amount := 100
set_knob_unit($Amount,$KNOB_UNIT_PERCENT)
make_persistent($Amount)
declare $helper_tune
set_control_help ($Amount,"Amount: Adjusts the amount of the tuning. When set to 100%, each note is tuned to the cent value specified with the table. When set to 0%, no tuning is applied.")
{---------Layout---------}
move_control (%tune_ui, 2,2)
move_control ($Amount, 2,4)
{sustain pedal}
declare const $NONE := 0
declare $i
declare %ids[512] { active event IDs in no particular order, NONE for unused elements }
declare %notes[512] { note number for each of the above events }
{ turn off Kontakt's builtin sustain pedal script }
SET_CONDITION(NO_SYS_SCRIPT_PEDAL)
end on
on note
{Microtuning}
if ($EVENT_NOTE >= $Root)
$pass := $EVENT_NOTE - $Root
$helper_tune := (%tune_ui[$pass mod $tableNumber]*1000*$Amount)/100
set_text ($test, $pass)
if (($EVENT_NOTE - $Root) mod $tableNumber = 0) {no detuning, octave}
if (in_range(((($EVENT_NOTE - $Root) / $tableNumber) * 12) + $Root,0,127))
change_note ($EVENT_ID, ((($EVENT_NOTE - $Root) / $tableNumber) * 12) + $Root)
else
ignore_event ($EVENT_ID)
end if
else
$Detune_Amount := ((1200000 / $tableNumber)*($EVENT_NOTE-$Root)) mod 100000
$Trans_Amount := ((1200000 / $tableNumber)*($EVENT_NOTE-$Root)) / 100000
if (in_range($Root + $Trans_Amount,0,127))
change_note ($EVENT_ID, $Root + $Trans_Amount)
change_tune ($EVENT_ID, $Detune_Amount + $helper_tune,0)
end if
end if
else if ($EVENT_NOTE < $Root)
$pass := $Root - $EVENT_NOTE
$helper_tune := (%tune_ui[($tableNumber - $pass) mod $tableNumber]*1000*$Amount)/100
set_text ($test, $pass)
if (($EVENT_NOTE - $Root) mod $tableNumber = 0) {no detuning, octave}
if (in_range(((($EVENT_NOTE - $Root) / $tableNumber) * 12) + $Root,0,127))
change_note ($EVENT_ID, ((($EVENT_NOTE - $Root) / $tableNumber) * 12) + $Root)
else
ignore_event ($EVENT_ID)
end if
else
$Detune_Amount := ((1200000 / $tableNumber)*($Root - $EVENT_NOTE)) mod 100000
$Trans_Amount := ((1200000 / $tableNumber)*($Root - $EVENT_NOTE)) / 100000
if (in_range($Root - $Trans_Amount,0,127))
change_note ($EVENT_ID, $Root - $Trans_Amount)
change_tune ($EVENT_ID, -$Detune_Amount + $helper_tune,0)
end if
end if
end if
end if
{ add this note event to the first empty array slot }
$i := search(%ids, 0)
if ($i # -1)
%ids[$i] := $EVENT_ID
%notes[$i] := $EVENT_NOTE
else
ignore_event($EVENT_ID) { just a safety precaution in case the polyphony would reach 512 }
end if
end on
on release
if (%CC[64] >= 64)
{ ignore note-off when sustain pedal is pressed }
ignore_event($EVENT_ID)
else
{ release all event IDs with the same note number as this event }
$i := 0
while ($i <= num_elements(%ids)-1)
if (%ids[$i] # $NONE and %notes[$i] = $EVENT_NOTE)
note_off(%ids[$i])
%ids[$i] := $NONE
end if
inc($i)
end while
end if
end on
on ui_control ($Root)
set_knob_label($Root,!note_names[$Root])
end on
on controller
{ if sustain pedal released }
if (%CC_TOUCHED[64] # 0 and %CC[64] < 64)
{ release all events for which the key is no longer held pressed }
$i := 0
while ($i <= num_elements(%ids)-1)
if (%ids[$i] # $NONE and %KEY_DOWN[%notes[$i]] = 0)
note_off(%ids[$i])
%ids[$i] := $NONE
end if
inc($i)
end while
end if
end on