12 |
|
|
13 |
namespace LinuxSampler { |
namespace LinuxSampler { |
14 |
|
|
15 |
// circumvents a bug in GCC 4.4 which prevents the sizeof() expr to be used |
// circumvents a bug in GCC 4.x which causes a sizeof() expression applied |
16 |
// directly within the scrope of a class (would throw a compiler error with: |
// on a class member to throw a compiler error, i.e. with GCC 4.4: |
17 |
// "object missing in reference to 'LinuxSampler::AbstractEngineChannel::ControllerTable'") |
// "object missing in reference to 'LinuxSampler::AbstractEngineChannel::ControllerTable'") |
18 |
static const int _AbstractEngineChannel_ControllerTable_size = sizeof(AbstractEngineChannel::ControllerTable); |
// or with GCC 4.0: |
19 |
|
// "invalid use of non-static data member 'LinuxSampler::AbstractEngineChannel::ControllerTable'" |
20 |
InstrumentScriptVM::InstrumentScriptVM() : m_event(NULL) { |
#define _MEMBER_SIZEOF(T_Class, Member) sizeof(((T_Class*)NULL)->Member) |
21 |
m_CC.size = _AbstractEngineChannel_ControllerTable_size; |
|
22 |
|
InstrumentScriptVM::InstrumentScriptVM() : |
23 |
|
m_event(NULL), m_fnPlayNote(this) |
24 |
|
{ |
25 |
|
m_CC.size = _MEMBER_SIZEOF(AbstractEngineChannel, ControllerTable); |
26 |
m_CC_NUM = DECLARE_VMINT(m_cause, class Event, Param.CC.Controller); |
m_CC_NUM = DECLARE_VMINT(m_cause, class Event, Param.CC.Controller); |
27 |
m_EVENT_NOTE = DECLARE_VMINT(m_cause, class Event, Param.Note.Key); |
m_EVENT_NOTE = DECLARE_VMINT(m_cause, class Event, Param.Note.Key); |
28 |
m_EVENT_VELOCITY = DECLARE_VMINT(m_cause, class Event, Param.Note.Velocity); |
m_EVENT_VELOCITY = DECLARE_VMINT(m_cause, class Event, Param.Note.Velocity); |
59 |
|
|
60 |
// run the script handler(s) |
// run the script handler(s) |
61 |
VMExecStatus_t res = VM_EXEC_NOT_RUNNING; |
VMExecStatus_t res = VM_EXEC_NOT_RUNNING; |
62 |
while (event->handlers[event->currentHandler]) { |
for ( ; event->handlers[event->currentHandler]; event->currentHandler++) { |
63 |
res = ScriptVM::exec( |
res = ScriptVM::exec( |
64 |
parserCtx, event->execCtx, event->handlers[event->currentHandler++] |
parserCtx, event->execCtx, event->handlers[event->currentHandler] |
65 |
); |
); |
66 |
event->executionSlices++; |
event->executionSlices++; |
67 |
if (res & VM_EXEC_SUSPENDED || res & VM_EXEC_ERROR) return res; |
if (res & VM_EXEC_SUSPENDED || res & VM_EXEC_ERROR) return res; |
105 |
return m; |
return m; |
106 |
} |
} |
107 |
|
|
108 |
|
VMFunction* InstrumentScriptVM::functionByName(const String& name) { |
109 |
|
// built-in script functions of this class |
110 |
|
if (name == "play_note") return &m_fnPlayNote; |
111 |
|
|
112 |
|
// built-in script functions of derived VM class |
113 |
|
return ScriptVM::functionByName(name); |
114 |
|
} |
115 |
|
|
116 |
} // namespace LinuxSampler |
} // namespace LinuxSampler |