1 /* 2 * Copyright (c) 2016 - 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_INSTRSCRIPTVMDYNVARS_H 11 #define LS_INSTRSCRIPTVMDYNVARS_H 12 13 #include "../../common/global.h" 14 #include "../../scriptvm/CoreVMDynVars.h" 15 #include "Event.h" 16 17 namespace LinuxSampler { 18 19 class InstrumentScriptVM; 20 21 /** 22 * Implements the built-in $ENGINE_UPTIME script variable. 23 */ 24 class InstrumentScriptVMDynVar_ENGINE_UPTIME FINAL : public VMDynIntVar { 25 public: InstrumentScriptVMDynVar_ENGINE_UPTIME(InstrumentScriptVM * parent)26 InstrumentScriptVMDynVar_ENGINE_UPTIME(InstrumentScriptVM* parent) : m_vm(parent) {} isAssignable()27 bool isAssignable() const OVERRIDE { return false; } 28 vmint evalInt() OVERRIDE; 29 protected: 30 InstrumentScriptVM* m_vm; 31 }; 32 33 /** 34 * Implements the built-in $NI_CALLBACK_ID script variable. 35 */ 36 class InstrumentScriptVMDynVar_NI_CALLBACK_ID FINAL : public VMDynIntVar { 37 public: InstrumentScriptVMDynVar_NI_CALLBACK_ID(InstrumentScriptVM * parent)38 InstrumentScriptVMDynVar_NI_CALLBACK_ID(InstrumentScriptVM* parent) : m_vm(parent) {} isAssignable()39 bool isAssignable() const OVERRIDE { return false; } 40 vmint evalInt() OVERRIDE; 41 protected: 42 InstrumentScriptVM* m_vm; 43 }; 44 45 /** 46 * Implements the built-in array %NKSP_CALLBACK_CHILD_ID[] script variable. 47 */ 48 class InstrumentScriptVMDynVar_NKSP_CALLBACK_CHILD_ID FINAL : public VMDynIntArrayVar { 49 public: 50 InstrumentScriptVMDynVar_NKSP_CALLBACK_CHILD_ID(InstrumentScriptVM* parent); 51 VMIntArrayExpr* asIntArray() const OVERRIDE; 52 vmint arraySize() const OVERRIDE; isAssignable()53 bool isAssignable() const OVERRIDE { return false; } 54 vmint evalIntElement(vmuint i) OVERRIDE; assignIntElement(vmuint i,vmint value)55 void assignIntElement(vmuint i, vmint value) OVERRIDE {} unitFactorOfElement(vmuint i)56 vmfloat unitFactorOfElement(vmuint i) const OVERRIDE { return VM_NO_FACTOR; } assignElementUnitFactor(vmuint i,vmfloat factor)57 void assignElementUnitFactor(vmuint i, vmfloat factor) OVERRIDE {} // ignore assignment 58 protected: 59 InstrumentScriptVM* m_vm; 60 }; 61 62 /** 63 * Implements the built-in %ALL_EVENTS script array variable. 64 */ 65 class InstrumentScriptVMDynVar_ALL_EVENTS FINAL : public VMDynIntArrayVar { 66 public: 67 InstrumentScriptVMDynVar_ALL_EVENTS(InstrumentScriptVM* parent); 68 virtual ~InstrumentScriptVMDynVar_ALL_EVENTS(); 69 VMIntArrayExpr* asIntArray() const OVERRIDE; 70 vmint arraySize() const OVERRIDE; isAssignable()71 bool isAssignable() const OVERRIDE { return false; } 72 vmint evalIntElement(vmuint i) OVERRIDE; assignIntElement(vmuint i,vmint value)73 void assignIntElement(vmuint i, vmint value) OVERRIDE {} unitFactorOfElement(vmuint i)74 vmfloat unitFactorOfElement(vmuint i) const OVERRIDE { return VM_NO_FACTOR; } assignElementUnitFactor(vmuint i,vmfloat factor)75 void assignElementUnitFactor(vmuint i, vmfloat factor) OVERRIDE {} // ignore assignment 76 protected: 77 void updateNoteIDs(); 78 private: 79 InstrumentScriptVM* m_vm; 80 note_id_t* m_ids; 81 vmuint m_numIDs; 82 }; 83 84 } // namespace LinuxSampler 85 86 #endif // LS_INSTRSCRIPTVMDYNVARS_H 87