Sunteți pe pagina 1din 2

{***********************************************

Chord Splitter
Author : Native Instruments
Written by: Josef Natterer
Modified: August 9, 2009
*************************************************}
on init
set_script_title("Chord Splitter")
declare ui_label $label_1 (1,1)
set_text ($label_1, "Chord Splitter")
declare const $DETECTION_TIME := 10 {chords played in this buffer time w
ill be split}
message("")
declare $a
declare $note_nr
declare $sema
declare %velo[128]
declare %pressed_id[128]
declare %art_id[128]
declare $note_helper
declare $last_group
declare %groups[128] := (-1)
end on
on note
if (_pgs_key_exists(SPLITTER_ON_OFF))
if (_pgs_get_key_val(SPLITTER_ON_OFF, 0) = 0)
exit
end if
end if
%velo[$EVENT_NOTE] := $EVENT_VELOCITY
%pressed_id[$EVENT_NOTE] := $EVENT_ID
ignore_event($EVENT_ID)
$note_nr := 0
$a := 0
while ($a < 128)
if (%pressed_id[$a] > 0)
inc($note_nr)
end if
inc($a)
end while
if ($sema = 0)
$sema := 1
if ($note_nr = 1)
wait($DETECTION_TIME*1000)
$note_nr := 0
$a := 0
while ($a < 128)
if (%pressed_id[$a] > 0)
inc($note_nr)
end if
inc($a)
end while
if ($note_nr = 1)
allow_group(-1)
play_note($EVENT_NOTE,$EVENT_VELOCITY,0,-1)
$last_group := -1
%groups[$EVENT_NOTE] := $last_group
end if
if ($note_nr > 1)
$note_helper := $note_nr
$note_nr := 0
$a := 0
while($a < 128)
if (%pressed_id[$a] > 0)
disallow_group(-1)
allow_group($note_nr mod $NUM_GR
OUPS)
fade_out(%art_id[$a],10000,1)
%art_id[$a] := play_note($a,%vel
o[$a],0,0)
%groups[$a] := $note_nr mod $NUM
_GROUPS
inc($note_nr)
end if
inc($a)
end while
end if
else
if ($note_nr > 1)
disallow_group(-1)
allow_group($last_group)
%groups[$EVENT_NOTE] := $last_group
fade_out(%art_id[$EVENT_NOTE],10000,1)
%art_id[$EVENT_NOTE] := play_note($EVENT_NOTE,$E
VENT_VELOCITY,0,0)
end if
end if
$sema := 0
end if
end on
on release
%pressed_id[$EVENT_NOTE] := 0
$last_group := %groups[$EVENT_NOTE]
note_off(%art_id[$EVENT_NOTE])
%art_id[$EVENT_NOTE] := 0
end on

S-ar putea să vă placă și