/[svn]/linuxsampler/trunk/src/engines/common/InstrumentScriptVM.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/common/InstrumentScriptVM.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2596 by schoenebeck, Thu Jun 5 19:39:12 2014 UTC revision 2598 by schoenebeck, Fri Jun 6 12:38:54 2014 UTC
# Line 20  namespace LinuxSampler { Line 20  namespace LinuxSampler {
20      #define _MEMBER_SIZEOF(T_Class, Member) sizeof(((T_Class*)NULL)->Member)      #define _MEMBER_SIZEOF(T_Class, Member) sizeof(((T_Class*)NULL)->Member)
21    
22      InstrumentScriptVM::InstrumentScriptVM() :      InstrumentScriptVM::InstrumentScriptVM() :
23          m_event(NULL), m_fnPlayNote(this)          m_event(NULL), m_fnPlayNote(this), m_fnIgnoreEvent(this),
24            m_fnIgnoreController(this)
25      {      {
26          m_CC.size = _MEMBER_SIZEOF(AbstractEngineChannel, ControllerTable);          m_CC.size = _MEMBER_SIZEOF(AbstractEngineChannel, ControllerTable);
27          m_CC_NUM = DECLARE_VMINT(m_cause, class Event, Param.CC.Controller);          m_CC_NUM = DECLARE_VMINT(m_event, class ScriptEvent, cause.Param.CC.Controller);
28          m_EVENT_NOTE = DECLARE_VMINT(m_cause, class Event, Param.Note.Key);          m_EVENT_ID = DECLARE_VMINT(m_event, class ScriptEvent, id);
29          m_EVENT_VELOCITY = DECLARE_VMINT(m_cause, class Event, Param.Note.Velocity);          m_EVENT_NOTE = DECLARE_VMINT(m_event, class ScriptEvent, cause.Param.Note.Key);
30            m_EVENT_VELOCITY = DECLARE_VMINT(m_event, class ScriptEvent, cause.Param.Note.Velocity);
31      }      }
32    
33      VMExecStatus_t InstrumentScriptVM::exec(VMParserContext* parserCtx, ScriptEvent* event) {      VMExecStatus_t InstrumentScriptVM::exec(VMParserContext* parserCtx, ScriptEvent* event) {
# Line 33  namespace LinuxSampler { Line 35  namespace LinuxSampler {
35              static_cast<AbstractEngineChannel*>(event->cause.pEngineChannel);              static_cast<AbstractEngineChannel*>(event->cause.pEngineChannel);
36    
37          // prepare built-in script variables for script execution          // prepare built-in script variables for script execution
38          m_cause = &event->cause;          m_event = event;
39          m_CC.data = (int8_t*) &pEngineChannel->ControllerTable[0];          m_CC.data = (int8_t*) &pEngineChannel->ControllerTable[0];
40    
41          // if script is in start condition, then do mandatory MIDI event          // if script is in start condition, then do mandatory MIDI event
# Line 41  namespace LinuxSampler { Line 43  namespace LinuxSampler {
43          // table with new CC value in case of a controller event, because the          // table with new CC value in case of a controller event, because the
44          // script might access the new CC value          // script might access the new CC value
45          if (!event->executionSlices) {          if (!event->executionSlices) {
46              switch (m_cause->Type) {              switch (event->cause.Type) {
47                  case Event::type_control_change:                  case Event::type_control_change:
48                      pEngineChannel->ControllerTable[m_cause->Param.CC.Controller] =                      pEngineChannel->ControllerTable[event->cause.Param.CC.Controller] =
49                          m_cause->Param.CC.Value;                          event->cause.Param.CC.Value;
50                      break;                      break;
51                  case Event::type_channel_pressure:                  case Event::type_channel_pressure:
52                      pEngineChannel->ControllerTable[CTRL_TABLE_IDX_AFTERTOUCH] =                      pEngineChannel->ControllerTable[CTRL_TABLE_IDX_AFTERTOUCH] =
53                          m_cause->Param.ChannelPressure.Value;                          event->cause.Param.ChannelPressure.Value;
54                      break;                      break;
55                  case Event::type_pitchbend:                  case Event::type_pitchbend:
56                      pEngineChannel->ControllerTable[CTRL_TABLE_IDX_PITCHBEND] =                      pEngineChannel->ControllerTable[CTRL_TABLE_IDX_PITCHBEND] =
57                          m_cause->Param.Pitch.Pitch;                          event->cause.Param.Pitch.Pitch;
58                      break;                      break;
59              }              }
60          }          }
# Line 76  namespace LinuxSampler { Line 78  namespace LinuxSampler {
78    
79          // now add own built-in variables          // now add own built-in variables
80          m["$CC_NUM"] = &m_CC_NUM;          m["$CC_NUM"] = &m_CC_NUM;
81            m["$EVENT_ID"] = &m_EVENT_ID;
82          m["$EVENT_NOTE"] = &m_EVENT_NOTE;          m["$EVENT_NOTE"] = &m_EVENT_NOTE;
83          m["$EVENT_VELOCITY"] = &m_EVENT_VELOCITY;          m["$EVENT_VELOCITY"] = &m_EVENT_VELOCITY;
84  //         m["$POLY_AT_NUM"] = &m_POLY_AT_NUM;  //         m["$POLY_AT_NUM"] = &m_POLY_AT_NUM;
# Line 107  namespace LinuxSampler { Line 110  namespace LinuxSampler {
110    
111      VMFunction* InstrumentScriptVM::functionByName(const String& name) {      VMFunction* InstrumentScriptVM::functionByName(const String& name) {
112          // built-in script functions of this class          // built-in script functions of this class
113          if (name == "play_note") return &m_fnPlayNote;          if      (name == "play_note") return &m_fnPlayNote;
114            else if (name == "ignore_event") return &m_fnIgnoreEvent;
115            else if (name == "ignore_controller") return &m_fnIgnoreController;
116    
117          // built-in script functions of derived VM class          // built-in script functions of derived VM class
118          return ScriptVM::functionByName(name);          return ScriptVM::functionByName(name);

Legend:
Removed from v.2596  
changed lines
  Added in v.2598

  ViewVC Help
Powered by ViewVC