/[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 2600 by schoenebeck, Sat Jun 7 00:16:03 2014 UTC
# Line 9  Line 9 
9    
10  #include "InstrumentScriptVM.h"  #include "InstrumentScriptVM.h"
11  #include "../AbstractEngineChannel.h"  #include "../AbstractEngineChannel.h"
12    #include "../../common/global_private.h"
13    
14  namespace LinuxSampler {  namespace LinuxSampler {
15    
     // circumvents a bug in GCC 4.x which causes a sizeof() expression applied  
     // on a class member to throw a compiler error, i.e. with GCC 4.4:  
     // "object missing in reference to 'LinuxSampler::AbstractEngineChannel::ControllerTable'")  
     // or with GCC 4.0:  
     // "invalid use of non-static data member 'LinuxSampler::AbstractEngineChannel::ControllerTable'"  
     #define _MEMBER_SIZEOF(T_Class, Member) sizeof(((T_Class*)NULL)->Member)  
   
16      InstrumentScriptVM::InstrumentScriptVM() :      InstrumentScriptVM::InstrumentScriptVM() :
17          m_event(NULL), m_fnPlayNote(this)          m_event(NULL), m_fnPlayNote(this), m_fnSetController(this),
18            m_fnIgnoreEvent(this), m_fnIgnoreController(this)
19      {      {
20          m_CC.size = _MEMBER_SIZEOF(AbstractEngineChannel, ControllerTable);          m_CC.size = _MEMBER_SIZEOF(AbstractEngineChannel, ControllerTable);
21          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);
22          m_EVENT_NOTE = DECLARE_VMINT(m_cause, class Event, Param.Note.Key);          m_EVENT_ID = DECLARE_VMINT(m_event, class ScriptEvent, id);
23          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);
24            m_EVENT_VELOCITY = DECLARE_VMINT(m_event, class ScriptEvent, cause.Param.Note.Velocity);
25      }      }
26    
27      VMExecStatus_t InstrumentScriptVM::exec(VMParserContext* parserCtx, ScriptEvent* event) {      VMExecStatus_t InstrumentScriptVM::exec(VMParserContext* parserCtx, ScriptEvent* event) {
# Line 33  namespace LinuxSampler { Line 29  namespace LinuxSampler {
29              static_cast<AbstractEngineChannel*>(event->cause.pEngineChannel);              static_cast<AbstractEngineChannel*>(event->cause.pEngineChannel);
30    
31          // prepare built-in script variables for script execution          // prepare built-in script variables for script execution
32          m_cause = &event->cause;          m_event = event;
33          m_CC.data = (int8_t*) &pEngineChannel->ControllerTable[0];          m_CC.data = (int8_t*) &pEngineChannel->ControllerTable[0];
34    
35          // 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 37  namespace LinuxSampler {
37          // 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
38          // script might access the new CC value          // script might access the new CC value
39          if (!event->executionSlices) {          if (!event->executionSlices) {
40              switch (m_cause->Type) {              switch (event->cause.Type) {
41                  case Event::type_control_change:                  case Event::type_control_change:
42                      pEngineChannel->ControllerTable[m_cause->Param.CC.Controller] =                      pEngineChannel->ControllerTable[event->cause.Param.CC.Controller] =
43                          m_cause->Param.CC.Value;                          event->cause.Param.CC.Value;
44                      break;                      break;
45                  case Event::type_channel_pressure:                  case Event::type_channel_pressure:
46                      pEngineChannel->ControllerTable[CTRL_TABLE_IDX_AFTERTOUCH] =                      pEngineChannel->ControllerTable[CTRL_TABLE_IDX_AFTERTOUCH] =
47                          m_cause->Param.ChannelPressure.Value;                          event->cause.Param.ChannelPressure.Value;
48                      break;                      break;
49                  case Event::type_pitchbend:                  case Event::type_pitchbend:
50                      pEngineChannel->ControllerTable[CTRL_TABLE_IDX_PITCHBEND] =                      pEngineChannel->ControllerTable[CTRL_TABLE_IDX_PITCHBEND] =
51                          m_cause->Param.Pitch.Pitch;                          event->cause.Param.Pitch.Pitch;
52                      break;                      break;
53              }              }
54          }          }
# Line 76  namespace LinuxSampler { Line 72  namespace LinuxSampler {
72    
73          // now add own built-in variables          // now add own built-in variables
74          m["$CC_NUM"] = &m_CC_NUM;          m["$CC_NUM"] = &m_CC_NUM;
75            m["$EVENT_ID"] = &m_EVENT_ID;
76          m["$EVENT_NOTE"] = &m_EVENT_NOTE;          m["$EVENT_NOTE"] = &m_EVENT_NOTE;
77          m["$EVENT_VELOCITY"] = &m_EVENT_VELOCITY;          m["$EVENT_VELOCITY"] = &m_EVENT_VELOCITY;
78  //         m["$POLY_AT_NUM"] = &m_POLY_AT_NUM;  //         m["$POLY_AT_NUM"] = &m_POLY_AT_NUM;
# Line 107  namespace LinuxSampler { Line 104  namespace LinuxSampler {
104    
105      VMFunction* InstrumentScriptVM::functionByName(const String& name) {      VMFunction* InstrumentScriptVM::functionByName(const String& name) {
106          // built-in script functions of this class          // built-in script functions of this class
107          if (name == "play_note") return &m_fnPlayNote;          if      (name == "play_note") return &m_fnPlayNote;
108            else if (name == "set_controller") return &m_fnSetController;
109            else if (name == "ignore_event") return &m_fnIgnoreEvent;
110            else if (name == "ignore_controller") return &m_fnIgnoreController;
111    
112          // built-in script functions of derived VM class          // built-in script functions of derived VM class
113          return ScriptVM::functionByName(name);          return ScriptVM::functionByName(name);

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

  ViewVC Help
Powered by ViewVC