11 |
#include "../AbstractEngineChannel.h" |
#include "../AbstractEngineChannel.h" |
12 |
#include "../../common/global_private.h" |
#include "../../common/global_private.h" |
13 |
#include "AbstractInstrumentManager.h" |
#include "AbstractInstrumentManager.h" |
14 |
|
#include "MidiKeyboardManager.h" |
15 |
|
|
16 |
namespace LinuxSampler { |
namespace LinuxSampler { |
17 |
|
|
88 |
* to deallocate the parsed script once not used on any engine channel |
* to deallocate the parsed script once not used on any engine channel |
89 |
* anymore. |
* anymore. |
90 |
* |
* |
91 |
* Calling thid method will however not clear the @c code member variable. |
* Calling this method will however not clear the @c code member variable. |
92 |
* Thus, the script can be parsed again afterwards. |
* Thus, the script can be parsed again afterwards. |
93 |
*/ |
*/ |
94 |
void InstrumentScript::unload() { |
void InstrumentScript::unload() { |
95 |
|
//dmsg(1,("InstrumentScript::unload(this=0x%llx)\n", this)); |
96 |
|
|
97 |
if (parserContext) |
if (parserContext) |
98 |
dmsg(1,("Unloading current instrument script.\n")); |
dmsg(1,("Unloading current instrument script.\n")); |
99 |
|
|
141 |
|
|
142 |
InstrumentScriptVM::InstrumentScriptVM() : |
InstrumentScriptVM::InstrumentScriptVM() : |
143 |
m_event(NULL), m_fnPlayNote(this), m_fnSetController(this), |
m_event(NULL), m_fnPlayNote(this), m_fnSetController(this), |
144 |
m_fnIgnoreEvent(this), m_fnIgnoreController(this) |
m_fnIgnoreEvent(this), m_fnIgnoreController(this), m_fnNoteOff(this) |
145 |
{ |
{ |
146 |
m_CC.size = _MEMBER_SIZEOF(AbstractEngineChannel, ControllerTable); |
m_CC.size = _MEMBER_SIZEOF(AbstractEngineChannel, ControllerTable); |
147 |
m_CC_NUM = DECLARE_VMINT(m_event, class ScriptEvent, cause.Param.CC.Controller); |
m_CC_NUM = DECLARE_VMINT(m_event, class ScriptEvent, cause.Param.CC.Controller); |
148 |
m_EVENT_ID = DECLARE_VMINT(m_event, class ScriptEvent, id); |
m_EVENT_ID = DECLARE_VMINT(m_event, class ScriptEvent, id); |
149 |
m_EVENT_NOTE = DECLARE_VMINT(m_event, class ScriptEvent, cause.Param.Note.Key); |
m_EVENT_NOTE = DECLARE_VMINT(m_event, class ScriptEvent, cause.Param.Note.Key); |
150 |
m_EVENT_VELOCITY = DECLARE_VMINT(m_event, class ScriptEvent, cause.Param.Note.Velocity); |
m_EVENT_VELOCITY = DECLARE_VMINT(m_event, class ScriptEvent, cause.Param.Note.Velocity); |
151 |
|
m_KEY_DOWN.size = 128; |
152 |
} |
} |
153 |
|
|
154 |
VMExecStatus_t InstrumentScriptVM::exec(VMParserContext* parserCtx, ScriptEvent* event) { |
VMExecStatus_t InstrumentScriptVM::exec(VMParserContext* parserCtx, ScriptEvent* event) { |
158 |
// prepare built-in script variables for script execution |
// prepare built-in script variables for script execution |
159 |
m_event = event; |
m_event = event; |
160 |
m_CC.data = (int8_t*) &pEngineChannel->ControllerTable[0]; |
m_CC.data = (int8_t*) &pEngineChannel->ControllerTable[0]; |
161 |
|
m_KEY_DOWN.data = &pEngineChannel->GetMidiKeyboardManager()->KeyDown[0]; |
162 |
|
|
163 |
// if script is in start condition, then do mandatory MIDI event |
// if script is in start condition, then do mandatory MIDI event |
164 |
// preprocessing tasks, which essentially means updating i.e. controller |
// preprocessing tasks, which essentially means updating i.e. controller |
214 |
|
|
215 |
// now add own built-in variables |
// now add own built-in variables |
216 |
m["%CC"] = &m_CC; |
m["%CC"] = &m_CC; |
217 |
//m["%KEY_DOWN"] = &m_KEY_DOWN; |
m["%KEY_DOWN"] = &m_KEY_DOWN; |
218 |
//m["%POLY_AT"] = &m_POLY_AT; |
//m["%POLY_AT"] = &m_POLY_AT; |
219 |
|
|
220 |
return m; |
return m; |
236 |
else if (name == "set_controller") return &m_fnSetController; |
else if (name == "set_controller") return &m_fnSetController; |
237 |
else if (name == "ignore_event") return &m_fnIgnoreEvent; |
else if (name == "ignore_event") return &m_fnIgnoreEvent; |
238 |
else if (name == "ignore_controller") return &m_fnIgnoreController; |
else if (name == "ignore_controller") return &m_fnIgnoreController; |
239 |
|
else if (name == "note_off") return &m_fnNoteOff; |
240 |
|
|
241 |
// built-in script functions of derived VM class |
// built-in script functions of derived VM class |
242 |
return ScriptVM::functionByName(name); |
return ScriptVM::functionByName(name); |