1 |
/* |
/* |
2 |
* Copyright (c) 2014 - 2016 Christian Schoenebeck |
* Copyright (c) 2014 - 2017 Christian Schoenebeck |
3 |
* |
* |
4 |
* http://www.linuxsampler.org |
* http://www.linuxsampler.org |
5 |
* |
* |
12 |
|
|
13 |
#include "../../common/global.h" |
#include "../../common/global.h" |
14 |
#include "../../scriptvm/CoreVMFunctions.h" |
#include "../../scriptvm/CoreVMFunctions.h" |
15 |
|
#include "Note.h" |
16 |
|
|
17 |
namespace LinuxSampler { |
namespace LinuxSampler { |
18 |
|
|
46 |
class InstrumentScriptVMFunction_ignore_event : public VMEmptyResultFunction { |
class InstrumentScriptVMFunction_ignore_event : public VMEmptyResultFunction { |
47 |
public: |
public: |
48 |
InstrumentScriptVMFunction_ignore_event(InstrumentScriptVM* parent); |
InstrumentScriptVMFunction_ignore_event(InstrumentScriptVM* parent); |
49 |
int minRequiredArgs() const { return 1; } |
int minRequiredArgs() const { return 0; } |
50 |
int maxAllowedArgs() const { return 1; } |
int maxAllowedArgs() const { return 1; } |
51 |
bool acceptsArgType(int iArg, ExprType_t type) const; |
bool acceptsArgType(int iArg, ExprType_t type) const; |
52 |
ExprType_t argType(int iArg) const { return INT_EXPR; } |
ExprType_t argType(int iArg) const { return INT_EXPR; } |
106 |
class InstrumentScriptVMFunction_by_marks : public VMFunction { |
class InstrumentScriptVMFunction_by_marks : public VMFunction { |
107 |
public: |
public: |
108 |
InstrumentScriptVMFunction_by_marks(InstrumentScriptVM* parent); |
InstrumentScriptVMFunction_by_marks(InstrumentScriptVM* parent); |
109 |
int minRequiredArgs() const { return 1; } |
int minRequiredArgs() const OVERRIDE { return 1; } |
110 |
int maxAllowedArgs() const { return 1; } |
int maxAllowedArgs() const OVERRIDE { return 1; } |
111 |
bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR;} |
bool acceptsArgType(int iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR;} |
112 |
ExprType_t argType(int iArg) const { return INT_EXPR; } |
bool modifiesArg(int iArg) const OVERRIDE { return false; } |
113 |
ExprType_t returnType() { return INT_ARR_EXPR; } |
ExprType_t argType(int iArg) const OVERRIDE { return INT_EXPR; } |
114 |
VMFnResult* exec(VMFnArgs* args); |
ExprType_t returnType() OVERRIDE { return INT_ARR_EXPR; } |
115 |
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
116 |
protected: |
protected: |
117 |
InstrumentScriptVM* m_vm; |
InstrumentScriptVM* m_vm; |
118 |
class Result : public VMFnResult, public VMIntArrayExpr { |
class Result : public VMFnResult, public VMIntArrayExpr { |
124 |
int evalIntElement(uint i) OVERRIDE; |
int evalIntElement(uint i) OVERRIDE; |
125 |
void assignIntElement(uint i, int value) OVERRIDE {} // ignore assignment |
void assignIntElement(uint i, int value) OVERRIDE {} // ignore assignment |
126 |
VMExpr* resultValue() OVERRIDE { return this; } |
VMExpr* resultValue() OVERRIDE { return this; } |
127 |
StmtFlags_t resultFlags() { return flags; } |
StmtFlags_t resultFlags() OVERRIDE { return flags; } |
128 |
|
bool isConstExpr() const OVERRIDE { return false; } |
129 |
} m_result; |
} m_result; |
130 |
|
|
131 |
VMFnResult* errorResult(); |
VMFnResult* errorResult(); |
191 |
protected: |
protected: |
192 |
InstrumentScriptVM* m_vm; |
InstrumentScriptVM* m_vm; |
193 |
}; |
}; |
194 |
|
|
195 |
|
class InstrumentScriptVMFunction_change_attack : public VMEmptyResultFunction { |
196 |
|
public: |
197 |
|
InstrumentScriptVMFunction_change_attack(InstrumentScriptVM* parent); |
198 |
|
int minRequiredArgs() const { return 2; } |
199 |
|
int maxAllowedArgs() const { return 2; } |
200 |
|
bool acceptsArgType(int iArg, ExprType_t type) const; |
201 |
|
ExprType_t argType(int iArg) const { return INT_EXPR; } |
202 |
|
VMFnResult* exec(VMFnArgs* args); |
203 |
|
protected: |
204 |
|
InstrumentScriptVM* m_vm; |
205 |
|
}; |
206 |
|
|
207 |
|
class InstrumentScriptVMFunction_change_decay : public VMEmptyResultFunction { |
208 |
|
public: |
209 |
|
InstrumentScriptVMFunction_change_decay(InstrumentScriptVM* parent); |
210 |
|
int minRequiredArgs() const { return 2; } |
211 |
|
int maxAllowedArgs() const { return 2; } |
212 |
|
bool acceptsArgType(int iArg, ExprType_t type) const; |
213 |
|
ExprType_t argType(int iArg) const { return INT_EXPR; } |
214 |
|
VMFnResult* exec(VMFnArgs* args); |
215 |
|
protected: |
216 |
|
InstrumentScriptVM* m_vm; |
217 |
|
}; |
218 |
|
|
219 |
|
class InstrumentScriptVMFunction_change_release : public VMEmptyResultFunction { |
220 |
|
public: |
221 |
|
InstrumentScriptVMFunction_change_release(InstrumentScriptVM* parent); |
222 |
|
int minRequiredArgs() const { return 2; } |
223 |
|
int maxAllowedArgs() const { return 2; } |
224 |
|
bool acceptsArgType(int iArg, ExprType_t type) const; |
225 |
|
ExprType_t argType(int iArg) const { return INT_EXPR; } |
226 |
|
VMFnResult* exec(VMFnArgs* args); |
227 |
|
protected: |
228 |
|
InstrumentScriptVM* m_vm; |
229 |
|
}; |
230 |
|
|
231 |
|
class VMChangeSynthParamFunction : public VMEmptyResultFunction { |
232 |
|
public: |
233 |
|
VMChangeSynthParamFunction(InstrumentScriptVM* parent) : m_vm(parent) {} |
234 |
|
int minRequiredArgs() const { return 2; } |
235 |
|
int maxAllowedArgs() const { return 2; } |
236 |
|
bool acceptsArgType(int iArg, ExprType_t type) const; |
237 |
|
ExprType_t argType(int iArg) const { return INT_EXPR; } |
238 |
|
|
239 |
|
template<float NoteBase::_Override::*T_noteParam, int T_synthParam, |
240 |
|
bool T_isNormalizedParam, int T_maxValue, int T_minValue> |
241 |
|
VMFnResult* execTemplate(VMFnArgs* args, const char* functionName); |
242 |
|
protected: |
243 |
|
InstrumentScriptVM* m_vm; |
244 |
|
}; |
245 |
|
|
246 |
|
class InstrumentScriptVMFunction_change_sustain : public VMChangeSynthParamFunction { |
247 |
|
public: |
248 |
|
InstrumentScriptVMFunction_change_sustain(InstrumentScriptVM* parent) : VMChangeSynthParamFunction(parent) {} |
249 |
|
VMFnResult* exec(VMFnArgs* args); |
250 |
|
}; |
251 |
|
|
252 |
|
class InstrumentScriptVMFunction_change_amp_lfo_depth : public VMChangeSynthParamFunction { |
253 |
|
public: |
254 |
|
InstrumentScriptVMFunction_change_amp_lfo_depth(InstrumentScriptVM* parent) : VMChangeSynthParamFunction(parent) {} |
255 |
|
VMFnResult* exec(VMFnArgs* args); |
256 |
|
}; |
257 |
|
|
258 |
|
class InstrumentScriptVMFunction_change_amp_lfo_freq : public VMChangeSynthParamFunction { |
259 |
|
public: |
260 |
|
InstrumentScriptVMFunction_change_amp_lfo_freq(InstrumentScriptVM* parent) : VMChangeSynthParamFunction(parent) {} |
261 |
|
VMFnResult* exec(VMFnArgs* args); |
262 |
|
}; |
263 |
|
|
264 |
|
class InstrumentScriptVMFunction_change_pitch_lfo_depth : public VMChangeSynthParamFunction { |
265 |
|
public: |
266 |
|
InstrumentScriptVMFunction_change_pitch_lfo_depth(InstrumentScriptVM* parent) : VMChangeSynthParamFunction(parent) {} |
267 |
|
VMFnResult* exec(VMFnArgs* args); |
268 |
|
}; |
269 |
|
|
270 |
|
class InstrumentScriptVMFunction_change_pitch_lfo_freq : public VMChangeSynthParamFunction { |
271 |
|
public: |
272 |
|
InstrumentScriptVMFunction_change_pitch_lfo_freq(InstrumentScriptVM* parent) : VMChangeSynthParamFunction(parent) {} |
273 |
|
VMFnResult* exec(VMFnArgs* args); |
274 |
|
}; |
275 |
|
|
276 |
|
class InstrumentScriptVMFunction_change_vol_time : public VMChangeSynthParamFunction { |
277 |
|
public: |
278 |
|
InstrumentScriptVMFunction_change_vol_time(InstrumentScriptVM* parent) : VMChangeSynthParamFunction(parent) {} |
279 |
|
VMFnResult* exec(VMFnArgs* args); |
280 |
|
}; |
281 |
|
|
282 |
|
class InstrumentScriptVMFunction_change_tune_time : public VMChangeSynthParamFunction { |
283 |
|
public: |
284 |
|
InstrumentScriptVMFunction_change_tune_time(InstrumentScriptVM* parent) : VMChangeSynthParamFunction(parent) {} |
285 |
|
VMFnResult* exec(VMFnArgs* args); |
286 |
|
}; |
287 |
|
|
288 |
|
class VMChangeFadeCurveFunction : public VMEmptyResultFunction { |
289 |
|
public: |
290 |
|
VMChangeFadeCurveFunction(InstrumentScriptVM* parent) : m_vm(parent) {} |
291 |
|
int minRequiredArgs() const { return 2; } |
292 |
|
int maxAllowedArgs() const { return 2; } |
293 |
|
bool acceptsArgType(int iArg, ExprType_t type) const; |
294 |
|
ExprType_t argType(int iArg) const { return INT_EXPR; } |
295 |
|
|
296 |
|
template<fade_curve_t NoteBase::_Override::*T_noteParam, int T_synthParam> |
297 |
|
VMFnResult* execTemplate(VMFnArgs* args, const char* functionName); |
298 |
|
protected: |
299 |
|
InstrumentScriptVM* m_vm; |
300 |
|
}; |
301 |
|
|
302 |
|
class InstrumentScriptVMFunction_change_vol_curve : public VMChangeFadeCurveFunction { |
303 |
|
public: |
304 |
|
InstrumentScriptVMFunction_change_vol_curve(InstrumentScriptVM* parent) : VMChangeFadeCurveFunction(parent) {} |
305 |
|
VMFnResult* exec(VMFnArgs* args); |
306 |
|
}; |
307 |
|
|
308 |
|
class InstrumentScriptVMFunction_change_tune_curve : public VMChangeFadeCurveFunction { |
309 |
|
public: |
310 |
|
InstrumentScriptVMFunction_change_tune_curve(InstrumentScriptVM* parent) : VMChangeFadeCurveFunction(parent) {} |
311 |
|
VMFnResult* exec(VMFnArgs* args); |
312 |
|
}; |
313 |
|
|
314 |
|
class InstrumentScriptVMFunction_fade_in : public VMEmptyResultFunction { |
315 |
|
public: |
316 |
|
InstrumentScriptVMFunction_fade_in(InstrumentScriptVM* parent); |
317 |
|
int minRequiredArgs() const { return 2; } |
318 |
|
int maxAllowedArgs() const { return 2; } |
319 |
|
bool acceptsArgType(int iArg, ExprType_t type) const; |
320 |
|
ExprType_t argType(int iArg) const { return INT_EXPR; } |
321 |
|
VMFnResult* exec(VMFnArgs* args); |
322 |
|
protected: |
323 |
|
InstrumentScriptVM* m_vm; |
324 |
|
}; |
325 |
|
|
326 |
|
class InstrumentScriptVMFunction_fade_out : public VMEmptyResultFunction { |
327 |
|
public: |
328 |
|
InstrumentScriptVMFunction_fade_out(InstrumentScriptVM* parent); |
329 |
|
int minRequiredArgs() const { return 2; } |
330 |
|
int maxAllowedArgs() const { return 3; } |
331 |
|
bool acceptsArgType(int iArg, ExprType_t type) const; |
332 |
|
ExprType_t argType(int iArg) const { return INT_EXPR; } |
333 |
|
VMFnResult* exec(VMFnArgs* args); |
334 |
|
protected: |
335 |
|
InstrumentScriptVM* m_vm; |
336 |
|
}; |
337 |
|
|
338 |
|
class InstrumentScriptVMFunction_get_event_par : public VMIntResultFunction { |
339 |
|
public: |
340 |
|
InstrumentScriptVMFunction_get_event_par(InstrumentScriptVM* parent); |
341 |
|
int minRequiredArgs() const { return 2; } |
342 |
|
int maxAllowedArgs() const { return 2; } |
343 |
|
bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR;} |
344 |
|
ExprType_t argType(int iArg) const { return INT_EXPR; } |
345 |
|
VMFnResult* exec(VMFnArgs* args); |
346 |
|
protected: |
347 |
|
InstrumentScriptVM* m_vm; |
348 |
|
}; |
349 |
|
|
350 |
|
class InstrumentScriptVMFunction_set_event_par : public VMEmptyResultFunction { |
351 |
|
public: |
352 |
|
InstrumentScriptVMFunction_set_event_par(InstrumentScriptVM* parent); |
353 |
|
int minRequiredArgs() const { return 3; } |
354 |
|
int maxAllowedArgs() const { return 3; } |
355 |
|
bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR;} |
356 |
|
ExprType_t argType(int iArg) const { return INT_EXPR; } |
357 |
|
VMFnResult* exec(VMFnArgs* args); |
358 |
|
protected: |
359 |
|
InstrumentScriptVM* m_vm; |
360 |
|
}; |
361 |
|
|
362 |
|
class InstrumentScriptVMFunction_change_note : public VMEmptyResultFunction { |
363 |
|
public: |
364 |
|
InstrumentScriptVMFunction_change_note(InstrumentScriptVM* parent); |
365 |
|
int minRequiredArgs() const { return 2; } |
366 |
|
int maxAllowedArgs() const { return 2; } |
367 |
|
bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR;} |
368 |
|
ExprType_t argType(int iArg) const { return INT_EXPR; } |
369 |
|
VMFnResult* exec(VMFnArgs* args); |
370 |
|
protected: |
371 |
|
InstrumentScriptVM* m_vm; |
372 |
|
}; |
373 |
|
|
374 |
|
class InstrumentScriptVMFunction_change_velo : public VMEmptyResultFunction { |
375 |
|
public: |
376 |
|
InstrumentScriptVMFunction_change_velo(InstrumentScriptVM* parent); |
377 |
|
int minRequiredArgs() const { return 2; } |
378 |
|
int maxAllowedArgs() const { return 2; } |
379 |
|
bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR;} |
380 |
|
ExprType_t argType(int iArg) const { return INT_EXPR; } |
381 |
|
VMFnResult* exec(VMFnArgs* args); |
382 |
|
protected: |
383 |
|
InstrumentScriptVM* m_vm; |
384 |
|
}; |
385 |
|
|
386 |
|
class InstrumentScriptVMFunction_change_play_pos : public VMEmptyResultFunction { |
387 |
|
public: |
388 |
|
InstrumentScriptVMFunction_change_play_pos(InstrumentScriptVM* parent); |
389 |
|
int minRequiredArgs() const { return 2; } |
390 |
|
int maxAllowedArgs() const { return 2; } |
391 |
|
bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR; } |
392 |
|
ExprType_t argType(int iArg) const { return INT_EXPR; } |
393 |
|
VMFnResult* exec(VMFnArgs* args); |
394 |
|
protected: |
395 |
|
InstrumentScriptVM* m_vm; |
396 |
|
}; |
397 |
|
|
398 |
class InstrumentScriptVMFunction_event_status : public VMIntResultFunction { |
class InstrumentScriptVMFunction_event_status : public VMIntResultFunction { |
399 |
public: |
public: |
403 |
bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR;} |
bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR;} |
404 |
ExprType_t argType(int iArg) const { return INT_EXPR; } |
ExprType_t argType(int iArg) const { return INT_EXPR; } |
405 |
VMFnResult* exec(VMFnArgs* args); |
VMFnResult* exec(VMFnArgs* args); |
406 |
|
protected: |
407 |
|
InstrumentScriptVM* m_vm; |
408 |
|
}; |
409 |
|
|
410 |
|
class InstrumentScriptVMFunction_callback_status : public VMIntResultFunction { |
411 |
|
public: |
412 |
|
InstrumentScriptVMFunction_callback_status(InstrumentScriptVM* parent); |
413 |
|
int minRequiredArgs() const { return 1; } |
414 |
|
int maxAllowedArgs() const { return 1; } |
415 |
|
bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR;} |
416 |
|
ExprType_t argType(int iArg) const { return INT_EXPR; } |
417 |
|
VMFnResult* exec(VMFnArgs* args); |
418 |
|
protected: |
419 |
|
InstrumentScriptVM* m_vm; |
420 |
|
}; |
421 |
|
|
422 |
|
// overrides core wait() implementation |
423 |
|
class InstrumentScriptVMFunction_wait : public CoreVMFunction_wait { |
424 |
|
public: |
425 |
|
InstrumentScriptVMFunction_wait(InstrumentScriptVM* parent); |
426 |
|
VMFnResult* exec(VMFnArgs* args); |
427 |
|
}; |
428 |
|
|
429 |
|
class InstrumentScriptVMFunction_stop_wait : public VMEmptyResultFunction { |
430 |
|
public: |
431 |
|
InstrumentScriptVMFunction_stop_wait(InstrumentScriptVM* parent); |
432 |
|
int minRequiredArgs() const { return 1; } |
433 |
|
int maxAllowedArgs() const { return 2; } |
434 |
|
bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR;} |
435 |
|
ExprType_t argType(int iArg) const { return INT_EXPR; } |
436 |
|
VMFnResult* exec(VMFnArgs* args); |
437 |
|
protected: |
438 |
|
InstrumentScriptVM* m_vm; |
439 |
|
}; |
440 |
|
|
441 |
|
class InstrumentScriptVMFunction_abort : public VMEmptyResultFunction { |
442 |
|
public: |
443 |
|
InstrumentScriptVMFunction_abort(InstrumentScriptVM* parent); |
444 |
|
int minRequiredArgs() const { return 1; } |
445 |
|
int maxAllowedArgs() const { return 1; } |
446 |
|
bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR; } |
447 |
|
ExprType_t argType(int iArg) const { return INT_EXPR; } |
448 |
|
VMFnResult* exec(VMFnArgs* args) OVERRIDE; |
449 |
|
protected: |
450 |
|
InstrumentScriptVM* m_vm; |
451 |
|
}; |
452 |
|
|
453 |
|
class InstrumentScriptVMFunction_fork : public VMIntResultFunction { |
454 |
|
public: |
455 |
|
InstrumentScriptVMFunction_fork(InstrumentScriptVM* parent); |
456 |
|
int minRequiredArgs() const { return 0; } |
457 |
|
int maxAllowedArgs() const { return 2; } |
458 |
|
bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR;} |
459 |
|
ExprType_t argType(int iArg) const { return INT_EXPR; } |
460 |
|
VMFnResult* exec(VMFnArgs* args); |
461 |
protected: |
protected: |
462 |
InstrumentScriptVM* m_vm; |
InstrumentScriptVM* m_vm; |
463 |
}; |
}; |