For a series of same-note voices, I would like a script that does these things:
on 1st note:
do nothing.
on 2nd note:
change_vol of 1st to half of whichever is quieter of the 1st or 2nd.
on 3rd note:
change_vol of 2nd to half of whichever is quieter of the 2nd or 3rd.
change_vol of the 1st to be half of whichever is quietest of the three.
on 4th note:
change_vol of 3rd to half of whichever is quieter of the 3rd or 4th.
change_vol of 2nd to half of whichever is quieter of the 2nd, 3rd, or 4th.
kill the 1st.
Repeated this process, updating the queue. Hopefully this makes sense.
I found this script:
{limit polyphony per key}
on init
message(" ")
declare const $POLYPHONY := 3
declare const $FADEOUT_TIME := 5000
declare %event_id_map[$POLYPHONY * 128]
declare $count
declare $head
$count := 0
$head := $POLYPHONY * 128
while ($count < $head)
%event_id_map[$count] := 2147483647
inc($count)
end while
end on
on note
$head := $EVENT_NOTE * $POLYPHONY
$count := $POLYPHONY -1
fade_out(%event_id_map[$head + $count],$FADEOUT_TIME,1) {kill the oldest note}
while ($count >0) {move queue}
%event_id_map[$head + $count] := %event_id_map[$head + $count -1]
dec($count)
end while
%event_id_map[$head] := $EVENT_ID {save note id}
end on
...but it only limits the same-note polyphony. It doesn't do the change_vol().
And there are things I don't understand like:
while ($count < $head)
%event_id_map[$count] := 2147483647
inc($count)
end while
What the hell is 2147483647?
and
$head := $EVENT_NOTE * $POLYPHONY
Wouldn't multiplying the event note number by 3 just produce an irrelevant number?
and
while ($count >0) {move queue}
%event_id_map[$head + $count] := %event_id_map[$head + $count -1]
dec($count)
end while
I don't fully understand any function of the script tbh. And the KSP manual is not helpful with its examples. I feel like I've missed a decade of schooling required to understand the manual.
Any help is appreciated and as always, I'm happy to send cash to anyone with a solution.