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

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

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

revision 2948 by schoenebeck, Fri Jul 15 15:29:04 2016 UTC revision 3073 by schoenebeck, Thu Jan 5 16:04:00 2017 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (c) 2016 Christian Schoenebeck   * Copyright (c) 2016 - 2017 Christian Schoenebeck
3   *   *
4   * http://www.linuxsampler.org   * http://www.linuxsampler.org
5   *   *
# Line 11  Line 11 
11  #include "InstrumentScriptVMDynVars.h"  #include "InstrumentScriptVMDynVars.h"
12  #include "InstrumentScriptVM.h"  #include "InstrumentScriptVM.h"
13  #include "../AbstractEngineChannel.h"  #include "../AbstractEngineChannel.h"
14    #include "../EngineBase.h"
15    
16  namespace LinuxSampler {  namespace LinuxSampler {
17    
18        // built-in variable $ENGINE_UPTIME
19    
20      int InstrumentScriptVMDynVar_ENGINE_UPTIME::evalInt() {      int InstrumentScriptVMDynVar_ENGINE_UPTIME::evalInt() {
21    
22          AbstractEngineChannel* pEngineChannel =          AbstractEngineChannel* pEngineChannel =
# Line 27  namespace LinuxSampler { Line 30  namespace LinuxSampler {
30                      double(pEngine->SampleRate) * 1000.0 );                      double(pEngine->SampleRate) * 1000.0 );
31      }      }
32    
33        // built-in variable $NI_CALLBACK_ID
34    
35      int InstrumentScriptVMDynVar_NI_CALLBACK_ID::evalInt() {      int InstrumentScriptVMDynVar_NI_CALLBACK_ID::evalInt() {
36    
37          AbstractEngineChannel* pEngineChannel =          AbstractEngineChannel* pEngineChannel =
# Line 35  namespace LinuxSampler { Line 40  namespace LinuxSampler {
40          return pEngineChannel->GetScriptCallbackID(m_vm->m_event);          return pEngineChannel->GetScriptCallbackID(m_vm->m_event);
41      }      }
42    
43        // built-in variable %ALL_EVENTS
44    
45        InstrumentScriptVMDynVar_ALL_EVENTS::InstrumentScriptVMDynVar_ALL_EVENTS(InstrumentScriptVM* parent)
46            : m_vm(parent), m_ids(NULL), m_numIDs(0)
47        {
48            m_ids = new note_id_t[GLOBAL_MAX_NOTES];
49            memset(&m_ids[0], 0, GLOBAL_MAX_NOTES * sizeof(note_id_t));
50        }
51    
52        InstrumentScriptVMDynVar_ALL_EVENTS::~InstrumentScriptVMDynVar_ALL_EVENTS() {
53            if (m_ids) delete[] m_ids;
54        }
55    
56        VMIntArrayExpr* InstrumentScriptVMDynVar_ALL_EVENTS::asIntArray() const {
57            const_cast<InstrumentScriptVMDynVar_ALL_EVENTS*>(this)->updateNoteIDs();
58            return const_cast<VMIntArrayExpr*>( dynamic_cast<const VMIntArrayExpr*>(this) );
59        }
60    
61        int InstrumentScriptVMDynVar_ALL_EVENTS::arraySize() const {
62            return m_numIDs;
63        }
64    
65        int InstrumentScriptVMDynVar_ALL_EVENTS::evalIntElement(uint i) {
66            if (i >= m_numIDs) return 0;
67            return m_ids[i];
68        }
69    
70        void InstrumentScriptVMDynVar_ALL_EVENTS::updateNoteIDs() {
71    
72            AbstractEngineChannel* pEngineChannel =
73                static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel);
74    
75            m_numIDs = pEngineChannel->AllNoteIDs(&m_ids[0], GLOBAL_MAX_NOTES);
76    
77            // translate sampler engine internal note IDs to public script id scope
78            for (uint i = 0; i < m_numIDs; ++i)
79                m_ids[i] = ScriptID::fromNoteID(m_ids[i]);
80        }
81    
82  } // namespace LinuxSampler  } // namespace LinuxSampler

Legend:
Removed from v.2948  
changed lines
  Added in v.3073

  ViewVC Help
Powered by ViewVC