1 |
/* |
/* |
2 |
* Copyright (c) 2016 - 2017 Christian Schoenebeck |
* Copyright (c) 2016 - 2019 Christian Schoenebeck |
3 |
* |
* |
4 |
* http://www.linuxsampler.org |
* http://www.linuxsampler.org |
5 |
* |
* |
17 |
|
|
18 |
// built-in variable $ENGINE_UPTIME |
// built-in variable $ENGINE_UPTIME |
19 |
|
|
20 |
int InstrumentScriptVMDynVar_ENGINE_UPTIME::evalInt() { |
vmint InstrumentScriptVMDynVar_ENGINE_UPTIME::evalInt() { |
21 |
|
|
22 |
AbstractEngineChannel* pEngineChannel = |
AbstractEngineChannel* pEngineChannel = |
23 |
static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel); |
static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel); |
26 |
static_cast<AbstractEngine*>(pEngineChannel->GetEngine()); |
static_cast<AbstractEngine*>(pEngineChannel->GetEngine()); |
27 |
|
|
28 |
// engine's official playback time in milliseconds (offline bounce safe) |
// engine's official playback time in milliseconds (offline bounce safe) |
29 |
return int( double(pEngine->FrameTime + m_vm->m_event->cause.FragmentPos()) / |
return vmint( double(pEngine->FrameTime + m_vm->m_event->cause.FragmentPos()) / |
30 |
double(pEngine->SampleRate) * 1000.0 ); |
double(pEngine->SampleRate) * 1000.0 ); |
31 |
} |
} |
32 |
|
|
33 |
// built-in variable $NI_CALLBACK_ID |
// built-in variable $NI_CALLBACK_ID |
34 |
|
|
35 |
int InstrumentScriptVMDynVar_NI_CALLBACK_ID::evalInt() { |
vmint InstrumentScriptVMDynVar_NI_CALLBACK_ID::evalInt() { |
36 |
|
|
37 |
AbstractEngineChannel* pEngineChannel = |
AbstractEngineChannel* pEngineChannel = |
38 |
static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel); |
static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel); |
51 |
return const_cast<VMIntArrayExpr*>( dynamic_cast<const VMIntArrayExpr*>(this) ); |
return const_cast<VMIntArrayExpr*>( dynamic_cast<const VMIntArrayExpr*>(this) ); |
52 |
} |
} |
53 |
|
|
54 |
int InstrumentScriptVMDynVar_NKSP_CALLBACK_CHILD_ID::arraySize() const { |
vmint InstrumentScriptVMDynVar_NKSP_CALLBACK_CHILD_ID::arraySize() const { |
55 |
return m_vm->m_event->countChildHandlers(); |
return m_vm->m_event->countChildHandlers(); |
56 |
} |
} |
57 |
|
|
58 |
int InstrumentScriptVMDynVar_NKSP_CALLBACK_CHILD_ID::evalIntElement(uint i) { |
vmint InstrumentScriptVMDynVar_NKSP_CALLBACK_CHILD_ID::evalIntElement(vmuint i) { |
59 |
if (i >= arraySize()) return 0; |
if (i >= arraySize()) return 0; |
60 |
return m_vm->m_event->childHandlerID[i]; |
return m_vm->m_event->childHandlerID[i]; |
61 |
} |
} |
78 |
return const_cast<VMIntArrayExpr*>( dynamic_cast<const VMIntArrayExpr*>(this) ); |
return const_cast<VMIntArrayExpr*>( dynamic_cast<const VMIntArrayExpr*>(this) ); |
79 |
} |
} |
80 |
|
|
81 |
int InstrumentScriptVMDynVar_ALL_EVENTS::arraySize() const { |
vmint InstrumentScriptVMDynVar_ALL_EVENTS::arraySize() const { |
82 |
return m_numIDs; |
return m_numIDs; |
83 |
} |
} |
84 |
|
|
85 |
int InstrumentScriptVMDynVar_ALL_EVENTS::evalIntElement(uint i) { |
vmint InstrumentScriptVMDynVar_ALL_EVENTS::evalIntElement(vmuint i) { |
86 |
if (i >= m_numIDs) return 0; |
if (i >= m_numIDs) return 0; |
87 |
return m_ids[i]; |
return m_ids[i]; |
88 |
} |
} |
95 |
m_numIDs = pEngineChannel->AllNoteIDs(&m_ids[0], GLOBAL_MAX_NOTES); |
m_numIDs = pEngineChannel->AllNoteIDs(&m_ids[0], GLOBAL_MAX_NOTES); |
96 |
|
|
97 |
// translate sampler engine internal note IDs to public script id scope |
// translate sampler engine internal note IDs to public script id scope |
98 |
for (uint i = 0; i < m_numIDs; ++i) |
for (vmuint i = 0; i < m_numIDs; ++i) |
99 |
m_ids[i] = ScriptID::fromNoteID(m_ids[i]); |
m_ids[i] = ScriptID::fromNoteID(m_ids[i]); |
100 |
} |
} |
101 |
|
|