/[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 2611 by schoenebeck, Mon Jun 9 19:20:37 2014 UTC revision 2613 by schoenebeck, Tue Jun 10 15:17:01 2014 UTC
# Line 11  Line 11 
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    
# Line 32  namespace LinuxSampler { Line 33  namespace LinuxSampler {
33    
34          // hand back old script reference and VM execution contexts          // hand back old script reference and VM execution contexts
35          // (if not done already)          // (if not done already)
36          reset();          unload();
37    
38            code = text;
39    
40          AbstractInstrumentManager* pManager =          AbstractInstrumentManager* pManager =
41              dynamic_cast<AbstractInstrumentManager*>(pEngineChannel->pEngine->GetInstrumentManager());              dynamic_cast<AbstractInstrumentManager*>(pEngineChannel->pEngine->GetInstrumentManager());
# Line 84  namespace LinuxSampler { Line 87  namespace LinuxSampler {
87       * is used to share equivalent scripts among multiple sampler channels, and       * is used to share equivalent scripts among multiple sampler channels, and
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.
92         * Thus, the script can be parsed again afterwards.
93       */       */
94      void InstrumentScript::reset() {      void InstrumentScript::unload() {
95          if (parserContext)          if (parserContext)
96              dmsg(1,("Unloading current instrument script."));              dmsg(1,("Unloading current instrument script.\n"));
97    
98          // free allocated VM execution contexts          // free allocated VM execution contexts
99          if (pEvents) {          if (pEvents) {
# Line 119  namespace LinuxSampler { Line 125  namespace LinuxSampler {
125          bHasValidScript = false;          bHasValidScript = false;
126      }      }
127    
128        /**
129         * Same as unload(), but this one also empties the @c code member variable
130         * to an empty string.
131         */
132        void InstrumentScript::resetAll() {
133            unload();
134            code.clear();
135        }
136    
137      ///////////////////////////////////////////////////////////////////////      ///////////////////////////////////////////////////////////////////////
138      // class 'InstrumentScriptVM'      // class 'InstrumentScriptVM'
139    
# Line 131  namespace LinuxSampler { Line 146  namespace LinuxSampler {
146          m_EVENT_ID = DECLARE_VMINT(m_event, class ScriptEvent, id);          m_EVENT_ID = DECLARE_VMINT(m_event, class ScriptEvent, id);
147          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);
148          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);
149            m_KEY_DOWN.size = 128;
150      }      }
151    
152      VMExecStatus_t InstrumentScriptVM::exec(VMParserContext* parserCtx, ScriptEvent* event) {      VMExecStatus_t InstrumentScriptVM::exec(VMParserContext* parserCtx, ScriptEvent* event) {
# Line 140  namespace LinuxSampler { Line 156  namespace LinuxSampler {
156          // prepare built-in script variables for script execution          // prepare built-in script variables for script execution
157          m_event = event;          m_event = event;
158          m_CC.data = (int8_t*) &pEngineChannel->ControllerTable[0];          m_CC.data = (int8_t*) &pEngineChannel->ControllerTable[0];
159            m_KEY_DOWN.data = &pEngineChannel->GetMidiKeyboardManager()->KeyDown[0];
160    
161          // if script is in start condition, then do mandatory MIDI event          // if script is in start condition, then do mandatory MIDI event
162          // preprocessing tasks, which essentially means updating i.e. controller          // preprocessing tasks, which essentially means updating i.e. controller
# Line 195  namespace LinuxSampler { Line 212  namespace LinuxSampler {
212    
213          // now add own built-in variables          // now add own built-in variables
214          m["%CC"] = &m_CC;          m["%CC"] = &m_CC;
215          //m["%KEY_DOWN"] = &m_KEY_DOWN;          m["%KEY_DOWN"] = &m_KEY_DOWN;
216          //m["%POLY_AT"] = &m_POLY_AT;          //m["%POLY_AT"] = &m_POLY_AT;
217    
218          return m;          return m;

Legend:
Removed from v.2611  
changed lines
  Added in v.2613

  ViewVC Help
Powered by ViewVC