/[svn]/linuxsampler/trunk/src/engines/common/InstrumentScriptVMFunctions.h
ViewVC logotype

Contents of /linuxsampler/trunk/src/engines/common/InstrumentScriptVMFunctions.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3588 - (show annotations) (download) (as text)
Sun Sep 1 16:06:48 2019 UTC (4 years, 7 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 30649 byte(s)
NKSP: Built-in instrument functions fixes & hardening:

* Fixed the following built-in functions having misinterpreted values given
  with unit type (for their 2nd argument) as if they were relative values
  (that is as if they were passed without a unit type): "change_attack()",
  "change_decay()", "change_release()", "change_cutoff_attack()",
  "change_cutoff_decay()", "change_cutoff_release()".

* Fixed the following built-in functions having applied completely wrong
  'final' values: "change_sustain()", "change_cutoff_sustain()" (since the
  respective EGs being their modulation sink assume uint data type with
  value range 0..1000 instead of 0.0..1.0.

* Added individual parse-time checks of function arguments for the following
  built-in functions: "play_note()", "note_off()", "set_event_mark()",
  "delete_event_mark()", "by_marks()", "change_cutoff()", "change_attack()",
  "change_decay()", "change_release()", "change_cutoff_attack()",
  "change_cutoff_decay()", "change_cutoff_release()",
  "change_amp_lfo_freq()", "change_cutoff_lfo_freq()",
  "change_pitch_lfo_freq()", "change_vol_time()", "change_tune_time()" and
  "change_pan_time()".

* Don't abort function call if unit type was used and at the same time
  'final' operator was omitted for the primary value argument of the
  following built-in functions: "change_cutoff()", "change_attack()",
  "change_decay()", "change_release()", "change_cutoff_attack()",
  "change_cutoff_decay()", "change_cutoff_release()",
  "change_amp_lfo_freq()", "change_cutoff_lfo_freq()",
  "change_pitch_lfo_freq()", "change_vol_time()", "change_tune_time()",
  "change_pan_time()", instead imply 'final'ness at runtime and raise an
  appropriate parser warning at parse time.

* Bumped version (2.1.1.svn13).

1 /*
2 * Copyright (c) 2014 - 2019 Christian Schoenebeck
3 *
4 * http://www.linuxsampler.org
5 *
6 * This file is part of LinuxSampler and released under the same terms.
7 * See README file for details.
8 */
9
10 #ifndef LS_INSTRSCRIPTVMFUNCTIONS_H
11 #define LS_INSTRSCRIPTVMFUNCTIONS_H
12
13 #include "../../common/global.h"
14 #include "../../scriptvm/CoreVMFunctions.h"
15 #include "Note.h"
16
17 namespace LinuxSampler {
18
19 class EventGroup;
20 class InstrumentScriptVM;
21
22 class InstrumentScriptVMFunction_play_note FINAL : public VMIntResultFunction {
23 using Super = VMIntResultFunction; // just an alias for the super class
24 public:
25 InstrumentScriptVMFunction_play_note(InstrumentScriptVM* parent);
26 StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE { return VM_NO_UNIT; }
27 bool returnsFinal(VMFnArgs* args) OVERRIDE { return false; }
28 vmint minRequiredArgs() const OVERRIDE { return 1; }
29 vmint maxAllowedArgs() const OVERRIDE { return 4; }
30 bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE;
31 bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE;
32 bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE;
33 void checkArgs(VMFnArgs* args, std::function<void(String)> err,
34 std::function<void(String)> wrn) OVERRIDE;
35 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
36 protected:
37 InstrumentScriptVM* m_vm;
38 };
39
40 class InstrumentScriptVMFunction_set_controller FINAL : public VMIntResultFunction {
41 public:
42 InstrumentScriptVMFunction_set_controller(InstrumentScriptVM* parent);
43 StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE { return VM_NO_UNIT; }
44 bool returnsFinal(VMFnArgs* args) OVERRIDE { return false; }
45 vmint minRequiredArgs() const OVERRIDE { return 2; }
46 vmint maxAllowedArgs() const OVERRIDE { return 2; }
47 bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR;}
48 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
49 protected:
50 InstrumentScriptVM* m_vm;
51 };
52
53 class InstrumentScriptVMFunction_ignore_event FINAL : public VMEmptyResultFunction {
54 public:
55 InstrumentScriptVMFunction_ignore_event(InstrumentScriptVM* parent);
56 vmint minRequiredArgs() const OVERRIDE { return 0; }
57 vmint maxAllowedArgs() const OVERRIDE { return 1; }
58 bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE;
59 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
60 protected:
61 InstrumentScriptVM* m_vm;
62 };
63
64 class InstrumentScriptVMFunction_ignore_controller FINAL : public VMEmptyResultFunction {
65 public:
66 InstrumentScriptVMFunction_ignore_controller(InstrumentScriptVM* parent);
67 vmint minRequiredArgs() const OVERRIDE { return 0; }
68 vmint maxAllowedArgs() const OVERRIDE { return 1; }
69 bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR;}
70 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
71 protected:
72 InstrumentScriptVM* m_vm;
73 };
74
75 class InstrumentScriptVMFunction_note_off FINAL : public VMEmptyResultFunction {
76 using Super = VMEmptyResultFunction; // just an alias for the super class
77 public:
78 InstrumentScriptVMFunction_note_off(InstrumentScriptVM* parent);
79 vmint minRequiredArgs() const OVERRIDE { return 1; }
80 vmint maxAllowedArgs() const OVERRIDE { return 2; }
81 bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE;
82 void checkArgs(VMFnArgs* args, std::function<void(String)> err,
83 std::function<void(String)> wrn) OVERRIDE;
84 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
85 protected:
86 InstrumentScriptVM* m_vm;
87 };
88
89 class InstrumentScriptVMFunction_set_event_mark FINAL : public VMEmptyResultFunction {
90 using Super = VMEmptyResultFunction; // just an alias for the super class
91 public:
92 InstrumentScriptVMFunction_set_event_mark(InstrumentScriptVM* parent);
93 vmint minRequiredArgs() const OVERRIDE { return 2; }
94 vmint maxAllowedArgs() const OVERRIDE { return 2; }
95 bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR;}
96 void checkArgs(VMFnArgs* args, std::function<void(String)> err,
97 std::function<void(String)> wrn) OVERRIDE;
98 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
99 protected:
100 InstrumentScriptVM* m_vm;
101 };
102
103 class InstrumentScriptVMFunction_delete_event_mark FINAL : public VMEmptyResultFunction {
104 using Super = VMEmptyResultFunction; // just an alias for the super class
105 public:
106 InstrumentScriptVMFunction_delete_event_mark(InstrumentScriptVM* parent);
107 vmint minRequiredArgs() const OVERRIDE { return 2; }
108 vmint maxAllowedArgs() const OVERRIDE { return 2; }
109 bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR;}
110 void checkArgs(VMFnArgs* args, std::function<void(String)> err,
111 std::function<void(String)> wrn) OVERRIDE;
112 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
113 protected:
114 InstrumentScriptVM* m_vm;
115 };
116
117 class InstrumentScriptVMFunction_by_marks FINAL : public VMFunction {
118 using Super = VMFunction; // just an alias for the super class
119 public:
120 InstrumentScriptVMFunction_by_marks(InstrumentScriptVM* parent);
121 StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE { return VM_NO_UNIT; }
122 bool returnsFinal(VMFnArgs* args) OVERRIDE { return false; }
123 vmint minRequiredArgs() const OVERRIDE { return 1; }
124 vmint maxAllowedArgs() const OVERRIDE { return 1; }
125 bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR;}
126 bool modifiesArg(vmint iArg) const OVERRIDE { return false; }
127 ExprType_t returnType(VMFnArgs* args) OVERRIDE { return INT_ARR_EXPR; }
128 void checkArgs(VMFnArgs* args, std::function<void(String)> err,
129 std::function<void(String)> wrn) OVERRIDE;
130 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
131 protected:
132 InstrumentScriptVM* m_vm;
133 class Result : public VMFnResult, public VMIntArrayExpr {
134 public:
135 StmtFlags_t flags;
136 EventGroup* eventGroup;
137
138 vmint arraySize() const OVERRIDE;
139 vmint evalIntElement(vmuint i) OVERRIDE;
140 void assignIntElement(vmuint i, vmint value) OVERRIDE {} // ignore assignment
141 vmfloat unitFactorOfElement(vmuint i) const OVERRIDE { return VM_NO_FACTOR; }
142 void assignElementUnitFactor(vmuint i, vmfloat factor) OVERRIDE {} // ignore assignment
143 VMExpr* resultValue() OVERRIDE { return this; }
144 StmtFlags_t resultFlags() OVERRIDE { return flags; }
145 bool isConstExpr() const OVERRIDE { return false; }
146 } m_result;
147
148 VMFnResult* errorResult();
149 VMFnResult* successResult(EventGroup* eventGroup);
150 };
151
152 class InstrumentScriptVMFunction_change_vol FINAL : public VMEmptyResultFunction {
153 public:
154 InstrumentScriptVMFunction_change_vol(InstrumentScriptVM* parent);
155 vmint minRequiredArgs() const OVERRIDE { return 2; }
156 vmint maxAllowedArgs() const OVERRIDE { return 3; }
157 bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE;
158 bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE;
159 bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE;
160 bool acceptsArgFinal(vmint iArg) const OVERRIDE;
161 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
162 protected:
163 InstrumentScriptVM* m_vm;
164 };
165
166 class InstrumentScriptVMFunction_change_tune FINAL : public VMEmptyResultFunction {
167 public:
168 InstrumentScriptVMFunction_change_tune(InstrumentScriptVM* parent);
169 vmint minRequiredArgs() const OVERRIDE { return 2; }
170 vmint maxAllowedArgs() const OVERRIDE { return 3; }
171 bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE;
172 bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE;
173 bool acceptsArgFinal(vmint iArg) const OVERRIDE;
174 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
175 protected:
176 InstrumentScriptVM* m_vm;
177 };
178
179 class InstrumentScriptVMFunction_change_pan FINAL : public VMEmptyResultFunction {
180 public:
181 InstrumentScriptVMFunction_change_pan(InstrumentScriptVM* parent);
182 vmint minRequiredArgs() const OVERRIDE { return 2; }
183 vmint maxAllowedArgs() const OVERRIDE { return 3; }
184 bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE;
185 bool acceptsArgFinal(vmint iArg) const OVERRIDE;
186 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
187 protected:
188 InstrumentScriptVM* m_vm;
189 };
190
191 class InstrumentScriptVMFunction_change_cutoff FINAL : public VMEmptyResultFunction {
192 using Super = VMEmptyResultFunction; // just an alias for the super class
193 public:
194 InstrumentScriptVMFunction_change_cutoff(InstrumentScriptVM* parent);
195 vmint minRequiredArgs() const OVERRIDE { return 2; }
196 vmint maxAllowedArgs() const OVERRIDE { return 2; }
197 bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE;
198 bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE;
199 bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE;
200 bool acceptsArgFinal(vmint iArg) const OVERRIDE;
201 void checkArgs(VMFnArgs* args, std::function<void(String)> err,
202 std::function<void(String)> wrn) OVERRIDE;
203 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
204 protected:
205 InstrumentScriptVM* m_vm;
206 };
207
208 class InstrumentScriptVMFunction_change_reso FINAL : public VMEmptyResultFunction {
209 public:
210 InstrumentScriptVMFunction_change_reso(InstrumentScriptVM* parent);
211 vmint minRequiredArgs() const OVERRIDE { return 2; }
212 vmint maxAllowedArgs() const OVERRIDE { return 2; }
213 bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE;
214 bool acceptsArgFinal(vmint iArg) const OVERRIDE;
215 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
216 protected:
217 InstrumentScriptVM* m_vm;
218 };
219
220 class InstrumentScriptVMFunction_change_attack FINAL : public VMEmptyResultFunction {
221 using Super = VMEmptyResultFunction; // just an alias for the super class
222 public:
223 InstrumentScriptVMFunction_change_attack(InstrumentScriptVM* parent);
224 vmint minRequiredArgs() const OVERRIDE { return 2; }
225 vmint maxAllowedArgs() const OVERRIDE { return 2; }
226 bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE;
227 bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE;
228 bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE;
229 bool acceptsArgFinal(vmint iArg) const OVERRIDE;
230 void checkArgs(VMFnArgs* args, std::function<void(String)> err,
231 std::function<void(String)> wrn) OVERRIDE;
232 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
233 protected:
234 InstrumentScriptVM* m_vm;
235 };
236
237 class InstrumentScriptVMFunction_change_decay FINAL : public VMEmptyResultFunction {
238 using Super = VMEmptyResultFunction; // just an alias for the super class
239 public:
240 InstrumentScriptVMFunction_change_decay(InstrumentScriptVM* parent);
241 vmint minRequiredArgs() const OVERRIDE { return 2; }
242 vmint maxAllowedArgs() const OVERRIDE { return 2; }
243 bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE;
244 bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE;
245 bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE;
246 bool acceptsArgFinal(vmint iArg) const OVERRIDE;
247 void checkArgs(VMFnArgs* args, std::function<void(String)> err,
248 std::function<void(String)> wrn) OVERRIDE;
249 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
250 protected:
251 InstrumentScriptVM* m_vm;
252 };
253
254 class InstrumentScriptVMFunction_change_release FINAL : public VMEmptyResultFunction {
255 using Super = VMEmptyResultFunction; // just an alias for the super class
256 public:
257 InstrumentScriptVMFunction_change_release(InstrumentScriptVM* parent);
258 vmint minRequiredArgs() const OVERRIDE { return 2; }
259 vmint maxAllowedArgs() const OVERRIDE { return 2; }
260 bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE;
261 bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE;
262 bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE;
263 bool acceptsArgFinal(vmint iArg) const OVERRIDE;
264 void checkArgs(VMFnArgs* args, std::function<void(String)> err,
265 std::function<void(String)> wrn) OVERRIDE;
266 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
267 protected:
268 InstrumentScriptVM* m_vm;
269 };
270
271 class VMChangeSynthParamFunction : public VMEmptyResultFunction {
272 using Super = VMEmptyResultFunction; // just an alias for the super class
273 public:
274 struct Opt_t {
275 InstrumentScriptVM* vm = NULL; ///< Parent object owning the built-in function implementation object.
276 bool acceptFinal = false; ///< Whether built-in function allows 'final' operator for its 2nd function argument.
277 StdUnit_t unit = VM_NO_UNIT; ///< Whether built-in functions accepts a unit type for its 2nd function argument and if yes which one.
278 bool acceptUnitPrefix = false; ///< Whether built-in function accepts metric unit prefix(es) for its 2nd function argument.
279 bool acceptReal = false; ///< Whether the built-in function accepts both int and real number as data type for its 2nd function argument (otherwise its int only if false).
280 };
281 VMChangeSynthParamFunction(const Opt_t& opt)
282 : m_vm(opt.vm), m_acceptReal(opt.acceptReal),
283 m_acceptFinal(opt.acceptFinal),
284 m_acceptUnitPrefix(opt.acceptUnitPrefix), m_unit(opt.unit) {}
285 vmint minRequiredArgs() const OVERRIDE { return 2; }
286 vmint maxAllowedArgs() const OVERRIDE { return 2; }
287 bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE;
288 bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE;
289 bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE;
290 bool acceptsArgFinal(vmint iArg) const OVERRIDE;
291 void checkArgs(VMFnArgs* args, std::function<void(String)> err,
292 std::function<void(String)> wrn) OVERRIDE;
293
294 template<class T_NoteParamType, T_NoteParamType NoteBase::_Override::*T_noteParam,
295 vmint T_synthParam,
296 vmint T_minValueNorm, vmint T_maxValueNorm, bool T_normalizeNorm,
297 vmint T_minValueUnit, vmint T_maxValueUnit,
298 MetricPrefix_t T_unitPrefix0, MetricPrefix_t ... T_unitPrefixN>
299 VMFnResult* execTemplate(VMFnArgs* args, const char* functionName);
300 protected:
301 InstrumentScriptVM* const m_vm;
302 const bool m_acceptReal;
303 const bool m_acceptFinal;
304 const bool m_acceptUnitPrefix;
305 const StdUnit_t m_unit;
306 };
307
308 class InstrumentScriptVMFunction_change_sustain FINAL : public VMChangeSynthParamFunction {
309 public:
310 InstrumentScriptVMFunction_change_sustain(InstrumentScriptVM* parent) : VMChangeSynthParamFunction({
311 .vm = parent,
312 .acceptFinal = true,
313 .unit = VM_BEL,
314 .acceptUnitPrefix = true,
315 .acceptReal = true,
316 }) {}
317 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
318 };
319
320 class InstrumentScriptVMFunction_change_cutoff_attack FINAL : public VMChangeSynthParamFunction {
321 public:
322 InstrumentScriptVMFunction_change_cutoff_attack(InstrumentScriptVM* parent) : VMChangeSynthParamFunction({
323 .vm = parent,
324 .acceptFinal = true,
325 .unit = VM_SECOND,
326 .acceptUnitPrefix = true,
327 .acceptReal = true,
328 }) {}
329 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
330 };
331
332 class InstrumentScriptVMFunction_change_cutoff_decay FINAL : public VMChangeSynthParamFunction {
333 public:
334 InstrumentScriptVMFunction_change_cutoff_decay(InstrumentScriptVM* parent) : VMChangeSynthParamFunction({
335 .vm = parent,
336 .acceptFinal = true,
337 .unit = VM_SECOND,
338 .acceptUnitPrefix = true,
339 .acceptReal = true,
340 }) {}
341 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
342 };
343
344 class InstrumentScriptVMFunction_change_cutoff_sustain FINAL : public VMChangeSynthParamFunction {
345 public:
346 InstrumentScriptVMFunction_change_cutoff_sustain(InstrumentScriptVM* parent) : VMChangeSynthParamFunction({
347 .vm = parent,
348 .acceptFinal = true,
349 .unit = VM_BEL,
350 .acceptUnitPrefix = true,
351 .acceptReal = true,
352 }) {}
353 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
354 };
355
356 class InstrumentScriptVMFunction_change_cutoff_release FINAL : public VMChangeSynthParamFunction {
357 public:
358 InstrumentScriptVMFunction_change_cutoff_release(InstrumentScriptVM* parent) : VMChangeSynthParamFunction({
359 .vm = parent,
360 .acceptFinal = true,
361 .unit = VM_SECOND,
362 .acceptUnitPrefix = true,
363 .acceptReal = true,
364 }) {}
365 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
366 };
367
368 class InstrumentScriptVMFunction_change_amp_lfo_depth FINAL : public VMChangeSynthParamFunction {
369 public:
370 InstrumentScriptVMFunction_change_amp_lfo_depth(InstrumentScriptVM* parent) : VMChangeSynthParamFunction({
371 .vm = parent,
372 .acceptFinal = true,
373 .unit = VM_NO_UNIT,
374 .acceptUnitPrefix = false,
375 .acceptReal = false,
376 }) {}
377 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
378 };
379
380 class InstrumentScriptVMFunction_change_amp_lfo_freq FINAL : public VMChangeSynthParamFunction {
381 public:
382 InstrumentScriptVMFunction_change_amp_lfo_freq(InstrumentScriptVM* parent) : VMChangeSynthParamFunction({
383 .vm = parent,
384 .acceptFinal = true,
385 .unit = VM_HERTZ,
386 .acceptUnitPrefix = true,
387 .acceptReal = true,
388 }) {}
389 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
390 };
391
392 class InstrumentScriptVMFunction_change_cutoff_lfo_depth FINAL : public VMChangeSynthParamFunction {
393 public:
394 InstrumentScriptVMFunction_change_cutoff_lfo_depth(InstrumentScriptVM* parent) : VMChangeSynthParamFunction({
395 .vm = parent,
396 .acceptFinal = true,
397 .unit = VM_NO_UNIT,
398 .acceptUnitPrefix = false,
399 .acceptReal = false,
400 }) {}
401 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
402 };
403
404 class InstrumentScriptVMFunction_change_cutoff_lfo_freq FINAL : public VMChangeSynthParamFunction {
405 public:
406 InstrumentScriptVMFunction_change_cutoff_lfo_freq(InstrumentScriptVM* parent) : VMChangeSynthParamFunction({
407 .vm = parent,
408 .acceptFinal = true,
409 .unit = VM_HERTZ,
410 .acceptUnitPrefix = true,
411 .acceptReal = true,
412 }) {}
413 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
414 };
415
416 class InstrumentScriptVMFunction_change_pitch_lfo_depth FINAL : public VMChangeSynthParamFunction {
417 public:
418 InstrumentScriptVMFunction_change_pitch_lfo_depth(InstrumentScriptVM* parent) : VMChangeSynthParamFunction({
419 .vm = parent,
420 .acceptFinal = true,
421 .unit = VM_NO_UNIT,
422 .acceptUnitPrefix = false,
423 .acceptReal = false,
424 }) {}
425 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
426 };
427
428 class InstrumentScriptVMFunction_change_pitch_lfo_freq FINAL : public VMChangeSynthParamFunction {
429 public:
430 InstrumentScriptVMFunction_change_pitch_lfo_freq(InstrumentScriptVM* parent) : VMChangeSynthParamFunction({
431 .vm = parent,
432 .acceptFinal = true,
433 .unit = VM_HERTZ,
434 .acceptUnitPrefix = true,
435 .acceptReal = true,
436 }) {}
437 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
438 };
439
440 class InstrumentScriptVMFunction_change_vol_time FINAL : public VMChangeSynthParamFunction {
441 public:
442 InstrumentScriptVMFunction_change_vol_time(InstrumentScriptVM* parent) : VMChangeSynthParamFunction({
443 .vm = parent,
444 .acceptFinal = false,
445 .unit = VM_SECOND,
446 .acceptUnitPrefix = true,
447 .acceptReal = true,
448 }) {}
449 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
450 };
451
452 class InstrumentScriptVMFunction_change_tune_time FINAL : public VMChangeSynthParamFunction {
453 public:
454 InstrumentScriptVMFunction_change_tune_time(InstrumentScriptVM* parent) : VMChangeSynthParamFunction({
455 .vm = parent,
456 .acceptFinal = false,
457 .unit = VM_SECOND,
458 .acceptUnitPrefix = true,
459 .acceptReal = true,
460 }) {}
461 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
462 };
463
464 class InstrumentScriptVMFunction_change_pan_time FINAL : public VMChangeSynthParamFunction {
465 public:
466 InstrumentScriptVMFunction_change_pan_time(InstrumentScriptVM* parent) : VMChangeSynthParamFunction({
467 .vm = parent,
468 .acceptFinal = false,
469 .unit = VM_SECOND,
470 .acceptUnitPrefix = true,
471 .acceptReal = true,
472 }) {}
473 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
474 };
475
476 class VMChangeFadeCurveFunction : public VMEmptyResultFunction {
477 public:
478 VMChangeFadeCurveFunction(InstrumentScriptVM* parent) : m_vm(parent) {}
479 vmint minRequiredArgs() const OVERRIDE { return 2; }
480 vmint maxAllowedArgs() const OVERRIDE { return 2; }
481 bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE;
482
483 template<fade_curve_t NoteBase::_Override::*T_noteParam, vmint T_synthParam>
484 VMFnResult* execTemplate(VMFnArgs* args, const char* functionName);
485 protected:
486 InstrumentScriptVM* m_vm;
487 };
488
489 class InstrumentScriptVMFunction_change_vol_curve FINAL : public VMChangeFadeCurveFunction {
490 public:
491 InstrumentScriptVMFunction_change_vol_curve(InstrumentScriptVM* parent) : VMChangeFadeCurveFunction(parent) {}
492 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
493 };
494
495 class InstrumentScriptVMFunction_change_tune_curve FINAL : public VMChangeFadeCurveFunction {
496 public:
497 InstrumentScriptVMFunction_change_tune_curve(InstrumentScriptVM* parent) : VMChangeFadeCurveFunction(parent) {}
498 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
499 };
500
501 class InstrumentScriptVMFunction_change_pan_curve FINAL : public VMChangeFadeCurveFunction {
502 public:
503 InstrumentScriptVMFunction_change_pan_curve(InstrumentScriptVM* parent) : VMChangeFadeCurveFunction(parent) {}
504 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
505 };
506
507 class InstrumentScriptVMFunction_fade_in FINAL : public VMEmptyResultFunction {
508 public:
509 InstrumentScriptVMFunction_fade_in(InstrumentScriptVM* parent);
510 vmint minRequiredArgs() const OVERRIDE { return 2; }
511 vmint maxAllowedArgs() const OVERRIDE { return 2; }
512 bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE;
513 bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE;
514 bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE;
515 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
516 protected:
517 InstrumentScriptVM* m_vm;
518 };
519
520 class InstrumentScriptVMFunction_fade_out FINAL : public VMEmptyResultFunction {
521 public:
522 InstrumentScriptVMFunction_fade_out(InstrumentScriptVM* parent);
523 vmint minRequiredArgs() const OVERRIDE { return 2; }
524 vmint maxAllowedArgs() const OVERRIDE { return 3; }
525 bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE;
526 bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE;
527 bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE;
528 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
529 protected:
530 InstrumentScriptVM* m_vm;
531 };
532
533 class InstrumentScriptVMFunction_get_event_par FINAL : public VMIntResultFunction {
534 public:
535 InstrumentScriptVMFunction_get_event_par(InstrumentScriptVM* parent);
536 StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE { return VM_NO_UNIT; }
537 bool returnsFinal(VMFnArgs* args) OVERRIDE { return false; }
538 vmint minRequiredArgs() const OVERRIDE { return 2; }
539 vmint maxAllowedArgs() const OVERRIDE { return 2; }
540 bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR;}
541 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
542 protected:
543 InstrumentScriptVM* m_vm;
544 };
545
546 class InstrumentScriptVMFunction_set_event_par FINAL : public VMEmptyResultFunction {
547 public:
548 InstrumentScriptVMFunction_set_event_par(InstrumentScriptVM* parent);
549 vmint minRequiredArgs() const OVERRIDE { return 3; }
550 vmint maxAllowedArgs() const OVERRIDE { return 3; }
551 bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR;}
552 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
553 protected:
554 InstrumentScriptVM* m_vm;
555 };
556
557 class InstrumentScriptVMFunction_change_note FINAL : public VMEmptyResultFunction {
558 public:
559 InstrumentScriptVMFunction_change_note(InstrumentScriptVM* parent);
560 vmint minRequiredArgs() const OVERRIDE { return 2; }
561 vmint maxAllowedArgs() const OVERRIDE { return 2; }
562 bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR;}
563 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
564 protected:
565 InstrumentScriptVM* m_vm;
566 };
567
568 class InstrumentScriptVMFunction_change_velo FINAL : public VMEmptyResultFunction {
569 public:
570 InstrumentScriptVMFunction_change_velo(InstrumentScriptVM* parent);
571 vmint minRequiredArgs() const OVERRIDE { return 2; }
572 vmint maxAllowedArgs() const OVERRIDE { return 2; }
573 bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR;}
574 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
575 protected:
576 InstrumentScriptVM* m_vm;
577 };
578
579 class InstrumentScriptVMFunction_change_play_pos FINAL : public VMEmptyResultFunction {
580 public:
581 InstrumentScriptVMFunction_change_play_pos(InstrumentScriptVM* parent);
582 vmint minRequiredArgs() const OVERRIDE { return 2; }
583 vmint maxAllowedArgs() const OVERRIDE { return 2; }
584 bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE;
585 bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const OVERRIDE;
586 bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const OVERRIDE;
587 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
588 protected:
589 InstrumentScriptVM* m_vm;
590 };
591
592 class InstrumentScriptVMFunction_event_status FINAL : public VMIntResultFunction {
593 public:
594 InstrumentScriptVMFunction_event_status(InstrumentScriptVM* parent);
595 StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE { return VM_NO_UNIT; }
596 bool returnsFinal(VMFnArgs* args) OVERRIDE { return false; }
597 vmint minRequiredArgs() const OVERRIDE { return 1; }
598 vmint maxAllowedArgs() const OVERRIDE { return 1; }
599 bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR;}
600 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
601 protected:
602 InstrumentScriptVM* m_vm;
603 };
604
605 class InstrumentScriptVMFunction_callback_status FINAL : public VMIntResultFunction {
606 public:
607 InstrumentScriptVMFunction_callback_status(InstrumentScriptVM* parent);
608 StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE { return VM_NO_UNIT; }
609 bool returnsFinal(VMFnArgs* args) OVERRIDE { return false; }
610 vmint minRequiredArgs() const OVERRIDE { return 1; }
611 vmint maxAllowedArgs() const OVERRIDE { return 1; }
612 bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR;}
613 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
614 protected:
615 InstrumentScriptVM* m_vm;
616 };
617
618 // overrides core wait() implementation
619 class InstrumentScriptVMFunction_wait FINAL : public CoreVMFunction_wait {
620 public:
621 InstrumentScriptVMFunction_wait(InstrumentScriptVM* parent);
622 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
623 };
624
625 class InstrumentScriptVMFunction_stop_wait FINAL : public VMEmptyResultFunction {
626 public:
627 InstrumentScriptVMFunction_stop_wait(InstrumentScriptVM* parent);
628 vmint minRequiredArgs() const OVERRIDE { return 1; }
629 vmint maxAllowedArgs() const OVERRIDE { return 2; }
630 bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR;}
631 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
632 protected:
633 InstrumentScriptVM* m_vm;
634 };
635
636 class InstrumentScriptVMFunction_abort FINAL : public VMEmptyResultFunction {
637 public:
638 InstrumentScriptVMFunction_abort(InstrumentScriptVM* parent);
639 vmint minRequiredArgs() const OVERRIDE { return 1; }
640 vmint maxAllowedArgs() const OVERRIDE { return 1; }
641 bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR; }
642 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
643 protected:
644 InstrumentScriptVM* m_vm;
645 };
646
647 class InstrumentScriptVMFunction_fork FINAL : public VMIntResultFunction {
648 public:
649 InstrumentScriptVMFunction_fork(InstrumentScriptVM* parent);
650 StdUnit_t returnUnitType(VMFnArgs* args) OVERRIDE { return VM_NO_UNIT; }
651 bool returnsFinal(VMFnArgs* args) OVERRIDE { return false; }
652 vmint minRequiredArgs() const OVERRIDE { return 0; }
653 vmint maxAllowedArgs() const OVERRIDE { return 2; }
654 bool acceptsArgType(vmint iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR;}
655 VMFnResult* exec(VMFnArgs* args) OVERRIDE;
656 protected:
657 InstrumentScriptVM* m_vm;
658 };
659
660 } // namespace LinuxSampler
661
662 #endif // LS_INSTRSCRIPTVMFUNCTIONS_H

  ViewVC Help
Powered by ViewVC