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

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

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

revision 2596 by schoenebeck, Thu Jun 5 19:39:12 2014 UTC revision 2613 by schoenebeck, Tue Jun 10 15:17:01 2014 UTC
# Line 13  Line 13 
13  #include "../../common/global.h"  #include "../../common/global.h"
14  #include "../../scriptvm/ScriptVM.h"  #include "../../scriptvm/ScriptVM.h"
15  #include "Event.h"  #include "Event.h"
16    #include "../../common/Pool.h"
17  #include "InstrumentScriptVMFunctions.h"  #include "InstrumentScriptVMFunctions.h"
18    
19  namespace LinuxSampler {  namespace LinuxSampler {
20    
21        class AbstractEngineChannel;
22    
23        /** @brief Real-time instrument script VM representation.
24         *
25         * Holds the VM representation of all event handlers of the currently loaded
26         * script, ready to be executed by the sampler engine.
27         */
28        struct InstrumentScript {
29            VMParserContext*      parserContext; ///< VM represenation of the currently loaded script or NULL if not script was loaded. Note that it is also not NULL if parser errors occurred!
30            bool                  bHasValidScript; ///< True in case there is a valid script currently loaded, false if script processing shall be skipped.
31            VMEventHandler*       handlerInit; ///< VM representation of script's initilization callback or NULL if current script did not define such an init handler.
32            VMEventHandler*       handlerNote; ///< VM representation of script's MIDI note on callback or NULL if current script did not define such an event handler.
33            VMEventHandler*       handlerRelease; ///< VM representation of script's MIDI note off callback or NULL if current script did not define such an event handler.
34            VMEventHandler*       handlerController; ///< VM representation of script's MIDI controller callback or NULL if current script did not define such an event handler.
35            Pool<ScriptEvent>*    pEvents; ///< Pool of all available script execution instances. ScriptEvents available to be allocated from the Pool are currently unused / not executiong, whereas the ScriptEvents allocated on the list are currently suspended / have not finished execution yet.
36            AbstractEngineChannel* pEngineChannel;
37            String                code; ///< Source code of the instrument script. Used in case the sampler engine is changed, in that case a new ScriptVM object is created for the engine and VMParserContext object for this script needs to be recreated as well. Thus the script is then parsed again by passing the source code to recreate the parser context.
38    
39            InstrumentScript(AbstractEngineChannel* pEngineChannel) {
40                parserContext = NULL;
41                bHasValidScript = false;
42                handlerInit = NULL;
43                handlerNote = NULL;
44                handlerRelease = NULL;
45                handlerController = NULL;
46                pEvents = NULL;
47                this->pEngineChannel = pEngineChannel;
48            }
49    
50            ~InstrumentScript() {
51                resetAll();
52            }
53    
54            void load(const String& text);
55            void unload();
56            void resetAll();
57        };
58    
59      /** @brief Real-time instrument script virtual machine.      /** @brief Real-time instrument script virtual machine.
60       *       *
61       * Extends the core ScriptVM implementation with MIDI specific built-in       * Extends the core ScriptVM implementation with MIDI specific built-in
# Line 38  namespace LinuxSampler { Line 77  namespace LinuxSampler {
77      protected:      protected:
78          ScriptEvent* m_event; ///< The event currently executed by exec().          ScriptEvent* m_event; ///< The event currently executed by exec().
79    
         Event* m_cause;  
   
80          // buil-in script variables          // buil-in script variables
81          VMInt8Array m_CC;          VMInt8Array m_CC;
82          VMInt8RelPtr m_CC_NUM;          VMInt8RelPtr m_CC_NUM;
83            VMIntRelPtr  m_EVENT_ID;
84          VMInt8RelPtr m_EVENT_NOTE;          VMInt8RelPtr m_EVENT_NOTE;
85          VMInt8RelPtr m_EVENT_VELOCITY;          VMInt8RelPtr m_EVENT_VELOCITY;
86          //VMIntArray m_KEY_DOWN; //TODO: ...          VMInt8Array  m_KEY_DOWN;
87          //VMIntArray m_POLY_AT; //TODO: ...          //VMIntArray m_POLY_AT; //TODO: ...
88          //int m_POLY_AT_NUM; //TODO: ...          //int m_POLY_AT_NUM; //TODO: ...
89    
90          // buil-in script functions          // buil-in script functions
91          InstrumentScriptVMFunction_play_note m_fnPlayNote;          InstrumentScriptVMFunction_play_note m_fnPlayNote;
92            InstrumentScriptVMFunction_set_controller m_fnSetController;
93            InstrumentScriptVMFunction_ignore_event m_fnIgnoreEvent;
94            InstrumentScriptVMFunction_ignore_controller m_fnIgnoreController;
95    
96          friend class InstrumentScriptVMFunction_play_note;          friend class InstrumentScriptVMFunction_play_note;
97            friend class InstrumentScriptVMFunction_set_controller;
98            friend class InstrumentScriptVMFunction_ignore_event;
99            friend class InstrumentScriptVMFunction_ignore_controller;
100      };      };
101    
102  } // namespace LinuxSampler  } // namespace LinuxSampler

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

  ViewVC Help
Powered by ViewVC