13 |
#include "../../common/global.h" |
#include "../../common/global.h" |
14 |
#include "../../scriptvm/ScriptVM.h" |
#include "../../scriptvm/ScriptVM.h" |
15 |
#include "Event.h" |
#include "Event.h" |
16 |
|
#include "../../common/Pool.h" |
17 |
#include "InstrumentScriptVMFunctions.h" |
#include "InstrumentScriptVMFunctions.h" |
18 |
|
|
19 |
namespace LinuxSampler { |
namespace LinuxSampler { |
20 |
|
|
21 |
|
class AbstractEngineChannel; |
22 |
|
|
23 |
|
/** @brief Real-time instrument script VM representation. |
24 |
|
* |
25 |
|
* Holds the VM representation of all event handlers of the currently loaded |
26 |
|
* script, ready to be executed by the sampler engine. |
27 |
|
*/ |
28 |
|
struct InstrumentScript { |
29 |
|
VMParserContext* parserContext; ///< VM represenation of the currently loaded script or NULL if not script was loaded. Note that it is also not NULL if parser errors occurred! |
30 |
|
bool bHasValidScript; ///< True in case there is a valid script currently loaded, false if script processing shall be skipped. |
31 |
|
VMEventHandler* handlerInit; ///< VM representation of script's initilization callback or NULL if current script did not define such an init handler. |
32 |
|
VMEventHandler* handlerNote; ///< VM representation of script's MIDI note on callback or NULL if current script did not define such an event handler. |
33 |
|
VMEventHandler* handlerRelease; ///< VM representation of script's MIDI note off callback or NULL if current script did not define such an event handler. |
34 |
|
VMEventHandler* handlerController; ///< VM representation of script's MIDI controller callback or NULL if current script did not define such an event handler. |
35 |
|
Pool<ScriptEvent>* pEvents; ///< Pool of all available script execution instances. ScriptEvents available to be allocated from the Pool are currently unused / not executiong, whereas the ScriptEvents allocated on the list are currently suspended / have not finished execution yet. |
36 |
|
AbstractEngineChannel* pEngineChannel; |
37 |
|
|
38 |
|
InstrumentScript(AbstractEngineChannel* pEngineChannel) { |
39 |
|
parserContext = NULL; |
40 |
|
bHasValidScript = false; |
41 |
|
handlerInit = NULL; |
42 |
|
handlerNote = NULL; |
43 |
|
handlerRelease = NULL; |
44 |
|
handlerController = NULL; |
45 |
|
pEvents = NULL; |
46 |
|
this->pEngineChannel = pEngineChannel; |
47 |
|
} |
48 |
|
|
49 |
|
~InstrumentScript() { |
50 |
|
reset(); |
51 |
|
} |
52 |
|
|
53 |
|
void load(const String& text); |
54 |
|
void reset(); |
55 |
|
}; |
56 |
|
|
57 |
/** @brief Real-time instrument script virtual machine. |
/** @brief Real-time instrument script virtual machine. |
58 |
* |
* |
59 |
* Extends the core ScriptVM implementation with MIDI specific built-in |
* Extends the core ScriptVM implementation with MIDI specific built-in |
75 |
protected: |
protected: |
76 |
ScriptEvent* m_event; ///< The event currently executed by exec(). |
ScriptEvent* m_event; ///< The event currently executed by exec(). |
77 |
|
|
|
Event* m_cause; |
|
|
|
|
78 |
// buil-in script variables |
// buil-in script variables |
79 |
VMInt8Array m_CC; |
VMInt8Array m_CC; |
80 |
VMInt8RelPtr m_CC_NUM; |
VMInt8RelPtr m_CC_NUM; |
81 |
|
VMIntRelPtr m_EVENT_ID; |
82 |
VMInt8RelPtr m_EVENT_NOTE; |
VMInt8RelPtr m_EVENT_NOTE; |
83 |
VMInt8RelPtr m_EVENT_VELOCITY; |
VMInt8RelPtr m_EVENT_VELOCITY; |
84 |
//VMIntArray m_KEY_DOWN; //TODO: ... |
//VMIntArray m_KEY_DOWN; //TODO: ... |
87 |
|
|
88 |
// buil-in script functions |
// buil-in script functions |
89 |
InstrumentScriptVMFunction_play_note m_fnPlayNote; |
InstrumentScriptVMFunction_play_note m_fnPlayNote; |
90 |
|
InstrumentScriptVMFunction_set_controller m_fnSetController; |
91 |
|
InstrumentScriptVMFunction_ignore_event m_fnIgnoreEvent; |
92 |
|
InstrumentScriptVMFunction_ignore_controller m_fnIgnoreController; |
93 |
|
|
94 |
friend class InstrumentScriptVMFunction_play_note; |
friend class InstrumentScriptVMFunction_play_note; |
95 |
|
friend class InstrumentScriptVMFunction_set_controller; |
96 |
|
friend class InstrumentScriptVMFunction_ignore_event; |
97 |
|
friend class InstrumentScriptVMFunction_ignore_controller; |
98 |
}; |
}; |
99 |
|
|
100 |
} // namespace LinuxSampler |
} // namespace LinuxSampler |