1 |
/* |
2 |
* Copyright (c) 2014 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_INSTRUMENT_SCRIPT_VM_H |
11 |
#define LS_INSTRUMENT_SCRIPT_VM_H |
12 |
|
13 |
#include "../../common/global.h" |
14 |
#include "../../scriptvm/ScriptVM.h" |
15 |
#include "Event.h" |
16 |
#include "InstrumentScriptVMFunctions.h" |
17 |
|
18 |
namespace LinuxSampler { |
19 |
|
20 |
/** @brief Real-time instrument script virtual machine. |
21 |
* |
22 |
* Extends the core ScriptVM implementation with MIDI specific built-in |
23 |
* script functions and MIDI specific built-in script variables required |
24 |
* for MIDI processing by instrument script for all sampler engine |
25 |
* implementations (sampler formats) of this sampler. |
26 |
* |
27 |
* Note that this class is currently re-entrant safe, but @b not thread |
28 |
* safe! See also comments of base class ScriptVM regarding this issue. |
29 |
*/ |
30 |
class InstrumentScriptVM : public ScriptVM { |
31 |
public: |
32 |
InstrumentScriptVM(); |
33 |
VMExecStatus_t exec(VMParserContext* parserCtx, ScriptEvent* event); |
34 |
VMFunction* functionByName(const String& name) OVERRIDE; |
35 |
std::map<String,VMIntRelPtr*> builtInIntVariables() OVERRIDE; |
36 |
std::map<String,VMInt8Array*> builtInIntArrayVariables() OVERRIDE; |
37 |
std::map<String,int> builtInConstIntVariables() OVERRIDE; |
38 |
protected: |
39 |
ScriptEvent* m_event; ///< The event currently executed by exec(). |
40 |
|
41 |
// buil-in script variables |
42 |
VMInt8Array m_CC; |
43 |
VMInt8RelPtr m_CC_NUM; |
44 |
VMIntRelPtr m_EVENT_ID; |
45 |
VMInt8RelPtr m_EVENT_NOTE; |
46 |
VMInt8RelPtr m_EVENT_VELOCITY; |
47 |
//VMIntArray m_KEY_DOWN; //TODO: ... |
48 |
//VMIntArray m_POLY_AT; //TODO: ... |
49 |
//int m_POLY_AT_NUM; //TODO: ... |
50 |
|
51 |
// buil-in script functions |
52 |
InstrumentScriptVMFunction_play_note m_fnPlayNote; |
53 |
InstrumentScriptVMFunction_play_note m_fnIgnoreEvent; |
54 |
InstrumentScriptVMFunction_play_note m_fnIgnoreController; |
55 |
|
56 |
friend class InstrumentScriptVMFunction_play_note; |
57 |
friend class InstrumentScriptVMFunction_ignore_event; |
58 |
friend class InstrumentScriptVMFunction_ignore_controller; |
59 |
}; |
60 |
|
61 |
} // namespace LinuxSampler |
62 |
|
63 |
#endif // LS_INSTRUMENT_SCRIPT_VM_H |