1 |
on init |
2 |
{ The amount of notes to play } |
3 |
declare const $delayNotes := 4 |
4 |
{ Tempo with which the new notes will follow the orignal note } |
5 |
declare const $bpm := 90 |
6 |
{ Convert BPM to microseconds (duration between the notes) } |
7 |
declare const $delayMicroSeconds := 60 * 1000000 / $bpm |
8 |
{ Just a working variable for being used with the while loop below } |
9 |
declare polyphonic $i |
10 |
{ For each successive note we trigger, we will reduce the velocity a bit} |
11 |
declare polyphonic $velocity |
12 |
end on |
13 |
|
14 |
on note |
15 |
{ First initialize the variable $i with 4 each time we enter this event |
16 |
handler, because each time we executed this handler, the variable will be 0 } |
17 |
$i := $delayNotes |
18 |
{ Loop which will be executed 4 times in a row } |
19 |
while ($i) |
20 |
{ Calculate the velocity for the next note being triggered } |
21 |
$velocity := 127 * $i / ($delayNotes + 1) |
22 |
{ Suspend this script for a short moment ... } |
23 |
wait($delayMicroSeconds) |
24 |
{ ... and after that short break, trigger a new note. } |
25 |
play_note($EVENT_NOTE, $velocity) |
26 |
{ Decrement loop counter $i by one } |
27 |
$i := $i - 1 |
28 |
end while |
29 |
end on |