57 |
The following example shows a simple stuttering effect. The script |
The following example shows a simple stuttering effect. The script |
58 |
runs in an endless loop and turns down and up the volume all 200ms. |
runs in an endless loop and turns down and up the volume all 200ms. |
59 |
To stop the endless loop once the respective note died, the return |
To stop the endless loop once the respective note died, the return |
60 |
value of <code>event_status()</code> is compared bitwise with built-in constant bit flag |
value of <code>event_status()</code> is compared with built-in constant |
61 |
<code>$EVENT_STATUS_NOTE_QUEUE</code>. |
bit flag <code>$EVENT_STATUS_INACTIVE</code>. |
62 |
|
</p> |
63 |
|
<code> |
64 |
|
on note |
65 |
|
while (1) |
66 |
|
wait(200000) |
67 |
|
if (event_status($EVENT_ID) = $EVENT_STATUS_INACTIVE) |
68 |
|
exit() { note is no longer alive, so stop script here } |
69 |
|
end if |
70 |
|
change_vol($EVENT_ID, -20000) { Reduce volume by 20 dB. } |
71 |
|
|
72 |
|
wait(200000) |
73 |
|
if (event_status($EVENT_ID) = $EVENT_STATUS_INACTIVE) |
74 |
|
exit() { note is no longer alive, so stop script here } |
75 |
|
end if |
76 |
|
change_vol($EVENT_ID, 0) { Increase volume to 0 dB. } |
77 |
|
end while |
78 |
|
end on |
79 |
|
</code> |
80 |
|
<p> |
81 |
|
Note: since the built-in constants returned by this function are actually bit flags, |
82 |
|
and since further bit flags might be added in future for this function, the actual |
83 |
|
long-term safe and correct way to check the return value of <code>event_status()</code> |
84 |
|
is a bitwise comparison. So the recommended "correct" way for the example above would |
85 |
|
actually be: |
86 |
</p> |
</p> |
87 |
<code> |
<code> |
88 |
on note |
on note |
89 |
while (1) |
while (1) |
90 |
wait(200000) |
wait(200000) |
91 |
if (not (event_status($EVENT_ID) .and. $EVENT_STATUS_NOTE_QUEUE)) |
if (not (event_status($EVENT_ID) .and. $EVENT_STATUS_NOTE_QUEUE)) |
92 |
exit() |
exit() { note is no longer alive, so stop script here } |
93 |
end if |
end if |
94 |
change_vol($EVENT_ID, -20000) { Reduce volume by 20 dB. } |
change_vol($EVENT_ID, -20000) { Reduce volume by 20 dB. } |
95 |
|
|
96 |
wait(200000) |
wait(200000) |
97 |
if (not (event_status($EVENT_ID) .and. $EVENT_STATUS_NOTE_QUEUE)) |
if (not (event_status($EVENT_ID) .and. $EVENT_STATUS_NOTE_QUEUE)) |
98 |
exit() |
exit() { note is no longer alive, so stop script here } |
99 |
end if |
end if |
100 |
change_vol($EVENT_ID, 0) { Increase volume to 0 dB. } |
change_vol($EVENT_ID, 0) { Increase volume to 0 dB. } |
101 |
end while |
end while |
102 |
end on |
end on |
103 |
</code> |
</code> |
104 |
|
<p> |
105 |
|
In practice however, the first version of this example is much easier to |
106 |
|
read (and write) though, and new bit flags will probably not be added to |
107 |
|
this function in near future. But that's up to you to decide! |
108 |
|
</p> |
109 |
|
|
110 |
<h3>Availabilty</h3> |
<h3>Availabilty</h3> |
111 |
<p>Since LinuxSampler 2.0.0.svn12.<p> |
<p>Since LinuxSampler 2.0.0.svn12.<p> |