--- linuxsampler/trunk/src/engines/common/InstrumentScriptVMFunctions.h 2016/07/14 00:22:26 2945 +++ linuxsampler/trunk/src/engines/common/InstrumentScriptVMFunctions.h 2017/06/28 09:45:56 3296 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 - 2016 Christian Schoenebeck + * Copyright (c) 2014 - 2017 Christian Schoenebeck * * http://www.linuxsampler.org * @@ -12,6 +12,7 @@ #include "../../common/global.h" #include "../../scriptvm/CoreVMFunctions.h" +#include "Note.h" namespace LinuxSampler { @@ -45,7 +46,7 @@ class InstrumentScriptVMFunction_ignore_event : public VMEmptyResultFunction { public: InstrumentScriptVMFunction_ignore_event(InstrumentScriptVM* parent); - int minRequiredArgs() const { return 1; } + int minRequiredArgs() const { return 0; } int maxAllowedArgs() const { return 1; } bool acceptsArgType(int iArg, ExprType_t type) const; ExprType_t argType(int iArg) const { return INT_EXPR; } @@ -105,13 +106,13 @@ class InstrumentScriptVMFunction_by_marks : public VMFunction { public: InstrumentScriptVMFunction_by_marks(InstrumentScriptVM* parent); - int minRequiredArgs() const { return 1; } - int maxAllowedArgs() const { return 1; } - bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR;} + int minRequiredArgs() const OVERRIDE { return 1; } + int maxAllowedArgs() const OVERRIDE { return 1; } + bool acceptsArgType(int iArg, ExprType_t type) const OVERRIDE { return type == INT_EXPR;} bool modifiesArg(int iArg) const OVERRIDE { return false; } - ExprType_t argType(int iArg) const { return INT_EXPR; } - ExprType_t returnType() { return INT_ARR_EXPR; } - VMFnResult* exec(VMFnArgs* args); + ExprType_t argType(int iArg) const OVERRIDE { return INT_EXPR; } + ExprType_t returnType() OVERRIDE { return INT_ARR_EXPR; } + VMFnResult* exec(VMFnArgs* args) OVERRIDE; protected: InstrumentScriptVM* m_vm; class Result : public VMFnResult, public VMIntArrayExpr { @@ -123,7 +124,7 @@ int evalIntElement(uint i) OVERRIDE; void assignIntElement(uint i, int value) OVERRIDE {} // ignore assignment VMExpr* resultValue() OVERRIDE { return this; } - StmtFlags_t resultFlags() { return flags; } + StmtFlags_t resultFlags() OVERRIDE { return flags; } bool isConstExpr() const OVERRIDE { return false; } } m_result; @@ -190,6 +191,203 @@ protected: InstrumentScriptVM* m_vm; }; + + class InstrumentScriptVMFunction_change_attack : public VMEmptyResultFunction { + public: + InstrumentScriptVMFunction_change_attack(InstrumentScriptVM* parent); + int minRequiredArgs() const { return 2; } + int maxAllowedArgs() const { return 2; } + bool acceptsArgType(int iArg, ExprType_t type) const; + ExprType_t argType(int iArg) const { return INT_EXPR; } + VMFnResult* exec(VMFnArgs* args); + protected: + InstrumentScriptVM* m_vm; + }; + + class InstrumentScriptVMFunction_change_decay : public VMEmptyResultFunction { + public: + InstrumentScriptVMFunction_change_decay(InstrumentScriptVM* parent); + int minRequiredArgs() const { return 2; } + int maxAllowedArgs() const { return 2; } + bool acceptsArgType(int iArg, ExprType_t type) const; + ExprType_t argType(int iArg) const { return INT_EXPR; } + VMFnResult* exec(VMFnArgs* args); + protected: + InstrumentScriptVM* m_vm; + }; + + class InstrumentScriptVMFunction_change_release : public VMEmptyResultFunction { + public: + InstrumentScriptVMFunction_change_release(InstrumentScriptVM* parent); + int minRequiredArgs() const { return 2; } + int maxAllowedArgs() const { return 2; } + bool acceptsArgType(int iArg, ExprType_t type) const; + ExprType_t argType(int iArg) const { return INT_EXPR; } + VMFnResult* exec(VMFnArgs* args); + protected: + InstrumentScriptVM* m_vm; + }; + + class VMChangeSynthParamFunction : public VMEmptyResultFunction { + public: + VMChangeSynthParamFunction(InstrumentScriptVM* parent) : m_vm(parent) {} + int minRequiredArgs() const { return 2; } + int maxAllowedArgs() const { return 2; } + bool acceptsArgType(int iArg, ExprType_t type) const; + ExprType_t argType(int iArg) const { return INT_EXPR; } + + template + VMFnResult* execTemplate(VMFnArgs* args, const char* functionName); + protected: + InstrumentScriptVM* m_vm; + }; + + class InstrumentScriptVMFunction_change_amp_lfo_depth : public VMChangeSynthParamFunction { + public: + InstrumentScriptVMFunction_change_amp_lfo_depth(InstrumentScriptVM* parent) : VMChangeSynthParamFunction(parent) {} + VMFnResult* exec(VMFnArgs* args); + }; + + class InstrumentScriptVMFunction_change_amp_lfo_freq : public VMChangeSynthParamFunction { + public: + InstrumentScriptVMFunction_change_amp_lfo_freq(InstrumentScriptVM* parent) : VMChangeSynthParamFunction(parent) {} + VMFnResult* exec(VMFnArgs* args); + }; + + class InstrumentScriptVMFunction_change_pitch_lfo_depth : public VMChangeSynthParamFunction { + public: + InstrumentScriptVMFunction_change_pitch_lfo_depth(InstrumentScriptVM* parent) : VMChangeSynthParamFunction(parent) {} + VMFnResult* exec(VMFnArgs* args); + }; + + class InstrumentScriptVMFunction_change_pitch_lfo_freq : public VMChangeSynthParamFunction { + public: + InstrumentScriptVMFunction_change_pitch_lfo_freq(InstrumentScriptVM* parent) : VMChangeSynthParamFunction(parent) {} + VMFnResult* exec(VMFnArgs* args); + }; + + class InstrumentScriptVMFunction_change_vol_time : public VMChangeSynthParamFunction { + public: + InstrumentScriptVMFunction_change_vol_time(InstrumentScriptVM* parent) : VMChangeSynthParamFunction(parent) {} + VMFnResult* exec(VMFnArgs* args); + }; + + class InstrumentScriptVMFunction_change_tune_time : public VMChangeSynthParamFunction { + public: + InstrumentScriptVMFunction_change_tune_time(InstrumentScriptVM* parent) : VMChangeSynthParamFunction(parent) {} + VMFnResult* exec(VMFnArgs* args); + }; + + class VMChangeFadeCurveFunction : public VMEmptyResultFunction { + public: + VMChangeFadeCurveFunction(InstrumentScriptVM* parent) : m_vm(parent) {} + int minRequiredArgs() const { return 2; } + int maxAllowedArgs() const { return 2; } + bool acceptsArgType(int iArg, ExprType_t type) const; + ExprType_t argType(int iArg) const { return INT_EXPR; } + + template + VMFnResult* execTemplate(VMFnArgs* args, const char* functionName); + protected: + InstrumentScriptVM* m_vm; + }; + + class InstrumentScriptVMFunction_change_vol_curve : public VMChangeFadeCurveFunction { + public: + InstrumentScriptVMFunction_change_vol_curve(InstrumentScriptVM* parent) : VMChangeFadeCurveFunction(parent) {} + VMFnResult* exec(VMFnArgs* args); + }; + + class InstrumentScriptVMFunction_change_tune_curve : public VMChangeFadeCurveFunction { + public: + InstrumentScriptVMFunction_change_tune_curve(InstrumentScriptVM* parent) : VMChangeFadeCurveFunction(parent) {} + VMFnResult* exec(VMFnArgs* args); + }; + + class InstrumentScriptVMFunction_fade_in : public VMEmptyResultFunction { + public: + InstrumentScriptVMFunction_fade_in(InstrumentScriptVM* parent); + int minRequiredArgs() const { return 2; } + int maxAllowedArgs() const { return 2; } + bool acceptsArgType(int iArg, ExprType_t type) const; + ExprType_t argType(int iArg) const { return INT_EXPR; } + VMFnResult* exec(VMFnArgs* args); + protected: + InstrumentScriptVM* m_vm; + }; + + class InstrumentScriptVMFunction_fade_out : public VMEmptyResultFunction { + public: + InstrumentScriptVMFunction_fade_out(InstrumentScriptVM* parent); + int minRequiredArgs() const { return 2; } + int maxAllowedArgs() const { return 3; } + bool acceptsArgType(int iArg, ExprType_t type) const; + ExprType_t argType(int iArg) const { return INT_EXPR; } + VMFnResult* exec(VMFnArgs* args); + protected: + InstrumentScriptVM* m_vm; + }; + + class InstrumentScriptVMFunction_get_event_par : public VMIntResultFunction { + public: + InstrumentScriptVMFunction_get_event_par(InstrumentScriptVM* parent); + int minRequiredArgs() const { return 2; } + int maxAllowedArgs() const { return 2; } + bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR;} + ExprType_t argType(int iArg) const { return INT_EXPR; } + VMFnResult* exec(VMFnArgs* args); + protected: + InstrumentScriptVM* m_vm; + }; + + class InstrumentScriptVMFunction_set_event_par : public VMEmptyResultFunction { + public: + InstrumentScriptVMFunction_set_event_par(InstrumentScriptVM* parent); + int minRequiredArgs() const { return 3; } + int maxAllowedArgs() const { return 3; } + bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR;} + ExprType_t argType(int iArg) const { return INT_EXPR; } + VMFnResult* exec(VMFnArgs* args); + protected: + InstrumentScriptVM* m_vm; + }; + + class InstrumentScriptVMFunction_change_note : public VMEmptyResultFunction { + public: + InstrumentScriptVMFunction_change_note(InstrumentScriptVM* parent); + int minRequiredArgs() const { return 2; } + int maxAllowedArgs() const { return 2; } + bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR;} + ExprType_t argType(int iArg) const { return INT_EXPR; } + VMFnResult* exec(VMFnArgs* args); + protected: + InstrumentScriptVM* m_vm; + }; + + class InstrumentScriptVMFunction_change_velo : public VMEmptyResultFunction { + public: + InstrumentScriptVMFunction_change_velo(InstrumentScriptVM* parent); + int minRequiredArgs() const { return 2; } + int maxAllowedArgs() const { return 2; } + bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR;} + ExprType_t argType(int iArg) const { return INT_EXPR; } + VMFnResult* exec(VMFnArgs* args); + protected: + InstrumentScriptVM* m_vm; + }; + + class InstrumentScriptVMFunction_change_play_pos : public VMEmptyResultFunction { + public: + InstrumentScriptVMFunction_change_play_pos(InstrumentScriptVM* parent); + int minRequiredArgs() const { return 2; } + int maxAllowedArgs() const { return 2; } + bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR; } + ExprType_t argType(int iArg) const { return INT_EXPR; } + VMFnResult* exec(VMFnArgs* args); + protected: + InstrumentScriptVM* m_vm; + }; class InstrumentScriptVMFunction_event_status : public VMIntResultFunction { public: @@ -199,6 +397,61 @@ bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR;} ExprType_t argType(int iArg) const { return INT_EXPR; } VMFnResult* exec(VMFnArgs* args); + protected: + InstrumentScriptVM* m_vm; + }; + + class InstrumentScriptVMFunction_callback_status : public VMIntResultFunction { + public: + InstrumentScriptVMFunction_callback_status(InstrumentScriptVM* parent); + int minRequiredArgs() const { return 1; } + int maxAllowedArgs() const { return 1; } + bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR;} + ExprType_t argType(int iArg) const { return INT_EXPR; } + VMFnResult* exec(VMFnArgs* args); + protected: + InstrumentScriptVM* m_vm; + }; + + // overrides core wait() implementation + class InstrumentScriptVMFunction_wait : public CoreVMFunction_wait { + public: + InstrumentScriptVMFunction_wait(InstrumentScriptVM* parent); + VMFnResult* exec(VMFnArgs* args); + }; + + class InstrumentScriptVMFunction_stop_wait : public VMEmptyResultFunction { + public: + InstrumentScriptVMFunction_stop_wait(InstrumentScriptVM* parent); + int minRequiredArgs() const { return 1; } + int maxAllowedArgs() const { return 2; } + bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR;} + ExprType_t argType(int iArg) const { return INT_EXPR; } + VMFnResult* exec(VMFnArgs* args); + protected: + InstrumentScriptVM* m_vm; + }; + + class InstrumentScriptVMFunction_abort : public VMEmptyResultFunction { + public: + InstrumentScriptVMFunction_abort(InstrumentScriptVM* parent); + int minRequiredArgs() const { return 1; } + int maxAllowedArgs() const { return 1; } + bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR; } + ExprType_t argType(int iArg) const { return INT_EXPR; } + VMFnResult* exec(VMFnArgs* args) OVERRIDE; + protected: + InstrumentScriptVM* m_vm; + }; + + class InstrumentScriptVMFunction_fork : public VMIntResultFunction { + public: + InstrumentScriptVMFunction_fork(InstrumentScriptVM* parent); + int minRequiredArgs() const { return 0; } + int maxAllowedArgs() const { return 2; } + bool acceptsArgType(int iArg, ExprType_t type) const { return type == INT_EXPR;} + ExprType_t argType(int iArg) const { return INT_EXPR; } + VMFnResult* exec(VMFnArgs* args); protected: InstrumentScriptVM* m_vm; };