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 |