29 |
#include "../../common/RTAVLTree.h" |
#include "../../common/RTAVLTree.h" |
30 |
#include "../../common/Pool.h" |
#include "../../common/Pool.h" |
31 |
#include "../EngineChannel.h" |
#include "../EngineChannel.h" |
32 |
|
#include "../../scriptvm/common.h" |
33 |
|
|
34 |
namespace LinuxSampler { |
namespace LinuxSampler { |
35 |
|
|
68 |
RTList<ScriptEvent>::Iterator popNextScheduledScriptEvent(RTAVLTree<ScriptEvent>& queue, Pool<ScriptEvent>& pool, sched_time_t end); |
RTList<ScriptEvent>::Iterator popNextScheduledScriptEvent(RTAVLTree<ScriptEvent>& queue, Pool<ScriptEvent>& pool, sched_time_t end); |
69 |
|
|
70 |
/** |
/** |
71 |
|
* Returns the scheduler time for the first sample point of the |
72 |
|
* current audio fragment cycle. |
73 |
|
*/ |
74 |
|
sched_time_t schedTimeAtCurrentFragmentStart() const { |
75 |
|
return uiTotalSamplesProcessed; |
76 |
|
} |
77 |
|
|
78 |
|
/** |
79 |
* Returns the scheduler time for the first sample point of the next |
* Returns the scheduler time for the first sample point of the next |
80 |
* audio fragment cycle. |
* audio fragment cycle. |
81 |
*/ |
*/ |
133 |
typedef pool_element_id_t note_id_t; |
typedef pool_element_id_t note_id_t; |
134 |
|
|
135 |
/** |
/** |
136 |
|
* Unique numeric ID of a script callback ID instance which can be used to |
137 |
|
* retrieve access to the actual @c ScriptEvent object. Once the script |
138 |
|
* callback instance associated with a certain ID stopped its execution |
139 |
|
* (that is completely stopped, not just suspended) then this numeric ID |
140 |
|
* becomes invalid and Pool< ScriptEvent >::fromID() will detect this |
141 |
|
* circumstance and will return an invalid Iterator, and thus will prevent |
142 |
|
* you from misusing a script callback instance which no longer "exists". |
143 |
|
*/ |
144 |
|
typedef pool_element_id_t script_callback_id_t; |
145 |
|
|
146 |
|
/** |
147 |
* Events are usually caused by a MIDI source or an internal modulation |
* Events are usually caused by a MIDI source or an internal modulation |
148 |
* controller like LFO or EG. An event should only be created by an |
* controller like LFO or EG. An event should only be created by an |
149 |
* EventGenerator! |
* EventGenerator! |
244 |
TimeStamp = other.TimeStamp; |
TimeStamp = other.TimeStamp; |
245 |
iFragmentPos = other.iFragmentPos; |
iFragmentPos = other.iFragmentPos; |
246 |
} |
} |
247 |
|
inline sched_time_t SchedTime() { |
248 |
|
return pEventGenerator->schedTimeAtCurrentFragmentStart() + FragmentPos(); |
249 |
|
} |
250 |
protected: |
protected: |
251 |
typedef EventGenerator::time_stamp_t time_stamp_t; |
typedef EventGenerator::time_stamp_t time_stamp_t; |
252 |
Event(EventGenerator* pGenerator, EventGenerator::time_stamp_t Time); |
Event(EventGenerator* pGenerator, EventGenerator::time_stamp_t Time); |
265 |
*/ |
*/ |
266 |
class SchedulerNode : public RTAVLNode { |
class SchedulerNode : public RTAVLNode { |
267 |
public: |
public: |
268 |
|
using RTAVLNode::reset; // make reset() method public |
269 |
|
|
270 |
sched_time_t scheduleTime; ///< Time ahead in future (in sample points) when this object shall be processed. This value is compared with EventGenerator's uiTotalSamplesProcessed member variable. |
sched_time_t scheduleTime; ///< Time ahead in future (in sample points) when this object shall be processed. This value is compared with EventGenerator's uiTotalSamplesProcessed member variable. |
271 |
|
|
272 |
/// Required operator implementation for RTAVLTree class. |
/// Required operator implementation for RTAVLTree class. |
278 |
inline bool operator<(const SchedulerNode& other) const { |
inline bool operator<(const SchedulerNode& other) const { |
279 |
return this->scheduleTime < other.scheduleTime; |
return this->scheduleTime < other.scheduleTime; |
280 |
} |
} |
281 |
|
|
282 |
|
/// This is actually just for code readability. |
283 |
|
inline RTAVLTreeBase* currentSchedulerQueue() const { return rtavlTree(); } |
284 |
}; |
}; |
285 |
|
|
286 |
/** |
/** |
317 |
VMExecContext* execCtx; ///< Script's current execution state (polyphonic variables and execution stack). |
VMExecContext* execCtx; ///< Script's current execution state (polyphonic variables and execution stack). |
318 |
int currentHandler; ///< Current index in 'handlers' list above. |
int currentHandler; ///< Current index in 'handlers' list above. |
319 |
int executionSlices; ///< Amount of times this script event has been executed by the ScriptVM runner class. |
int executionSlices; ///< Amount of times this script event has been executed by the ScriptVM runner class. |
320 |
|
bool ignoreAllWaitCalls; ///< If true: calling any built-in wait*() script function should be ignored (this variable may be set with the 2nd argument of built-in script function stop_wait()). |
321 |
|
VMEventHandlerType_t handlerType; ///< Native representation of built-in script variable $NI_CALLBACK_TYPE, reflecting the script event type of this script event. |
322 |
}; |
}; |
323 |
|
|
324 |
/** |
/** |