1 |
/* |
/* |
2 |
* Copyright (c) 2014-2017 Christian Schoenebeck |
* Copyright (c) 2014-2019 Christian Schoenebeck |
3 |
* |
* |
4 |
* http://www.linuxsampler.org |
* http://www.linuxsampler.org |
5 |
* |
* |
51 |
/** |
/** |
52 |
* Used to mark IDs (in script scope) to actually be a MIDI event ID. |
* Used to mark IDs (in script scope) to actually be a MIDI event ID. |
53 |
*/ |
*/ |
54 |
INSTR_SCRIPT_EVENT_ID_FLAG = INSTR_SCRIPT_ID_TYPE_FLAG(0), |
INSTR_SCRIPT_EVENT_ID_FLAG = INSTR_SCRIPT_ID_TYPE_FLAG(0LL), |
55 |
|
|
56 |
/** |
/** |
57 |
* Used to mark IDs (in script scope) to actually be a note ID. |
* Used to mark IDs (in script scope) to actually be a note ID. |
58 |
*/ |
*/ |
59 |
INSTR_SCRIPT_NOTE_ID_FLAG = INSTR_SCRIPT_ID_TYPE_FLAG(1), |
INSTR_SCRIPT_NOTE_ID_FLAG = INSTR_SCRIPT_ID_TYPE_FLAG(1LL), |
60 |
}; |
}; |
61 |
|
|
62 |
#define INSTR_SCRIPT_EVENT_GROUPS 28 |
#define INSTR_SCRIPT_EVENT_GROUPS 28 |
118 |
/** |
/** |
119 |
* Construct a ScriptID object with an ID from script scope. |
* Construct a ScriptID object with an ID from script scope. |
120 |
*/ |
*/ |
121 |
ScriptID(uint id) : m_id(id) {} |
ScriptID(vmint id) : m_id(id) {} |
122 |
|
|
123 |
/** |
/** |
124 |
* Returns a ScriptID object constructed with an event ID from engine |
* Returns a ScriptID object constructed with an event ID from engine |
180 |
* Integer cast operator, which returns an ID number of this ScripID |
* Integer cast operator, which returns an ID number of this ScripID |
181 |
* object intended for script scope. |
* object intended for script scope. |
182 |
*/ |
*/ |
183 |
inline operator uint() const { |
inline operator vmint() const { |
184 |
return m_id; |
return m_id; |
185 |
} |
} |
186 |
|
|
187 |
private: |
private: |
188 |
uint m_id; |
vmint m_id; |
189 |
}; |
}; |
190 |
|
|
191 |
/** @brief List of Event IDs. |
/** @brief List of Event IDs. |
193 |
* Used for built-in script functions: |
* Used for built-in script functions: |
194 |
* by_marks(), set_event_mark(), delete_event_mark() |
* by_marks(), set_event_mark(), delete_event_mark() |
195 |
*/ |
*/ |
196 |
class EventGroup : protected ConstCapacityArray<int> { |
class EventGroup : protected ConstCapacityArray<vmint> { |
197 |
public: |
public: |
198 |
EventGroup() : ConstCapacityArray<int>(CONFIG_MAX_EVENTS_PER_FRAGMENT), m_script(NULL) {} |
EventGroup() : ConstCapacityArray<vmint>(CONFIG_MAX_EVENTS_PER_FRAGMENT), m_script(NULL) {} |
199 |
void insert(int eventID); |
void insert(vmint eventID); |
200 |
void erase(int eventID); |
void erase(vmint eventID); |
201 |
void setScript(InstrumentScript* pScript) { m_script = pScript; } |
void setScript(InstrumentScript* pScript) { m_script = pScript; } |
202 |
inline int size() const { return ConstCapacityArray<int>::size(); } |
inline size_t size() const { return ConstCapacityArray<vmint>::size(); } |
203 |
inline void clear() { ConstCapacityArray<int>::clear(); } |
inline void clear() { ConstCapacityArray<vmint>::clear(); } |
204 |
inline int& operator[](uint index) { return ConstCapacityArray<int>::operator[](index); } |
inline vmint& operator[](ssize_t index) { return ConstCapacityArray<vmint>::operator[](index); } |
205 |
inline const int& operator[](uint index) const { return ConstCapacityArray<int>::operator[](index); } |
inline const vmint& operator[](ssize_t index) const { return ConstCapacityArray<vmint>::operator[](index); } |
206 |
protected: |
protected: |
207 |
InstrumentScript* m_script; |
InstrumentScript* m_script; |
208 |
}; |
}; |
257 |
InstrumentScriptVM(); |
InstrumentScriptVM(); |
258 |
VMExecStatus_t exec(VMParserContext* parserCtx, ScriptEvent* event); |
VMExecStatus_t exec(VMParserContext* parserCtx, ScriptEvent* event); |
259 |
VMFunction* functionByName(const String& name) OVERRIDE; |
VMFunction* functionByName(const String& name) OVERRIDE; |
260 |
std::map<String,VMIntRelPtr*> builtInIntVariables() OVERRIDE; |
std::map<String,VMIntPtr*> builtInIntVariables() OVERRIDE; |
261 |
std::map<String,VMInt8Array*> builtInIntArrayVariables() OVERRIDE; |
std::map<String,VMInt8Array*> builtInIntArrayVariables() OVERRIDE; |
262 |
std::map<String,int> builtInConstIntVariables() OVERRIDE; |
std::map<String,vmint> builtInConstIntVariables() OVERRIDE; |
263 |
std::map<String,VMDynVar*> builtInDynamicVariables() OVERRIDE; |
std::map<String,VMDynVar*> builtInDynamicVariables() OVERRIDE; |
264 |
protected: |
protected: |
265 |
ScriptEvent* m_event; ///< The event currently executed by exec(). |
ScriptEvent* m_event; ///< The event currently executed by exec(). |
273 |
VMInt8Array m_KEY_DOWN; |
VMInt8Array m_KEY_DOWN; |
274 |
//VMIntArray m_POLY_AT; //TODO: ... |
//VMIntArray m_POLY_AT; //TODO: ... |
275 |
//int m_POLY_AT_NUM; //TODO: ... |
//int m_POLY_AT_NUM; //TODO: ... |
276 |
VMIntRelPtr m_NI_CALLBACK_TYPE; |
VMInt32RelPtr m_NI_CALLBACK_TYPE; |
277 |
VMIntRelPtr m_NKSP_IGNORE_WAIT; |
VMInt8RelPtr m_NKSP_IGNORE_WAIT; |
278 |
VMIntRelPtr m_NKSP_CALLBACK_PARENT_ID; |
VMIntRelPtr m_NKSP_CALLBACK_PARENT_ID; |
279 |
|
|
280 |
// built-in script functions |
// built-in script functions |