Code: Select all
on init
message (" ")
set_ui_height_px(60)
declare polyphonic $id
declare polyphonic $velo
declare polyphonic $note
declare ui_knob $playback_offset (200000,4000000,1000000)
set_text($playback_offset,"offset")
end on
on note
$velo := $EVENT_VELOCITY
$note := $EVENT_NOTE
$id := $EVENT_ID
change_vol($EVENT_ID,-1000000,0)
wait(1)
play_note($note,$velo,get_sample_length(get_event_par($id,$EVENT_PAR_ZONE_ID)) - $playback_offset,-1)
end on
Now there are two problems with this solution.
1. For the offset parameter to work, you would have to set S-Mod value to S-End value in wave editor... for every sample. This is seriously tedious task. But there is simple workaround, switch from DFD mode to 'sampler' mode, where it will just work (at cost of memory load).
2. If a sample is being re-tuned, the playback speed is different and the samples will not align. This is a little disappointing, since the offset value is being entered in milliseconds, I hoped Kontakt would compensate automatically. The offset change could be calculated, but I have no idea how to automatically retrieve root note for given zone via script. Is this even possible? Any clues?
So, right now, it would work on instrument which has at least a zone per key and is small enough to fit in memory. Like factory 'Jazz Guitar' patch for example.