58 |
public: |
public: |
59 |
EventGenerator(uint SampleRate); |
EventGenerator(uint SampleRate); |
60 |
void UpdateFragmentTime(uint SamplesToProcess); |
void UpdateFragmentTime(uint SamplesToProcess); |
61 |
|
void SetSampleRate(uint SampleRate); |
62 |
Event CreateEvent(); |
Event CreateEvent(); |
63 |
Event CreateEvent(int32_t FragmentPos); |
Event CreateEvent(int32_t FragmentPos); |
64 |
|
|
167 |
type_note_pressure, ///< polyphonic key pressure (aftertouch) |
type_note_pressure, ///< polyphonic key pressure (aftertouch) |
168 |
type_play_note, ///< caused by a call to built-in instrument script function play_note() |
type_play_note, ///< caused by a call to built-in instrument script function play_note() |
169 |
type_stop_note, ///< caused by a call to built-in instrument script function note_off() |
type_stop_note, ///< caused by a call to built-in instrument script function note_off() |
170 |
|
type_kill_note, ///< caused by a call to built-in instrument script function fade_out() |
171 |
type_note_synth_param, ///< change a note's synthesis parameters (upon real-time instrument script function calls, i.e. change_vol(), change_tune(), change_pan(), etc.) |
type_note_synth_param, ///< change a note's synthesis parameters (upon real-time instrument script function calls, i.e. change_vol(), change_tune(), change_pan(), etc.) |
172 |
} Type; |
} Type; |
173 |
enum synth_param_t { |
enum synth_param_t { |
174 |
synth_param_volume, |
synth_param_volume, |
175 |
|
synth_param_volume_time, |
176 |
|
synth_param_volume_curve, |
177 |
synth_param_pitch, |
synth_param_pitch, |
178 |
|
synth_param_pitch_time, |
179 |
|
synth_param_pitch_curve, |
180 |
synth_param_pan, |
synth_param_pan, |
181 |
synth_param_cutoff, |
synth_param_cutoff, |
182 |
synth_param_resonance, |
synth_param_resonance, |
309 |
class VMEventHandler; |
class VMEventHandler; |
310 |
class VMExecContext; |
class VMExecContext; |
311 |
|
|
312 |
|
/** |
313 |
|
* Maximum amount of child script handler instances one script handler is |
314 |
|
* allowed to create by calling built-in script function fork(). |
315 |
|
*/ |
316 |
|
#define MAX_FORK_PER_SCRIPT_HANDLER 8 |
317 |
|
|
318 |
/** @brief Real-time instrument script event. |
/** @brief Real-time instrument script event. |
319 |
* |
* |
320 |
* Encapsulates one execution instance of a real-time instrument script for |
* Encapsulates one execution instance of a real-time instrument script for |
338 |
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. |
339 |
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()). |
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()). |
340 |
VMEventHandlerType_t handlerType; ///< Native representation of built-in script variable $NI_CALLBACK_TYPE, reflecting the script event type of this script event. |
VMEventHandlerType_t handlerType; ///< Native representation of built-in script variable $NI_CALLBACK_TYPE, reflecting the script event type of this script event. |
341 |
|
script_callback_id_t parentHandlerID; ///< Only in case this script handler instance was created by calling built-in script function fork(): callback ID of the parent event handler instance which created this child. For regular event handler instances which were not created by fork(), this variable reflects 0 (which is always considered an invalid handler ID). |
342 |
|
script_callback_id_t childHandlerID[MAX_FORK_PER_SCRIPT_HANDLER+1]; ///< In case built-in script function fork() was called by this script handler instance: A zero terminated ID list of all child event handler instances (note: children will not vanish from this list after they terminated). |
343 |
|
bool autoAbortByParent; ///< Only if this is a child event handler created by calling fork(): if this is true then this child will automatically aborted if the parent event handler terminates. |
344 |
|
int forkIndex; ///< Only for fork() calls: distinguishment feature which is 0 for parent, 1 for 1st child, 2 for 2nd child, etc. |
345 |
|
|
346 |
|
void forkTo(ScriptEvent* e, bool bAutoAbort) const; |
347 |
|
int countChildHandlers() const; |
348 |
|
void addChildHandlerID(script_callback_id_t childID); |
349 |
}; |
}; |
350 |
|
|
351 |
/** |
/** |
357 |
* interpreted by this method to be "now". |
* interpreted by this method to be "now". |
358 |
* |
* |
359 |
* The meaning of @a fragmentPosBase becomes more important the larger |
* The meaning of @a fragmentPosBase becomes more important the larger |
360 |
* the audio fragment size, and vice versa it bcomes less important the |
* the audio fragment size, and vice versa it becomes less important the |
361 |
* smaller the audio fragment size. |
* smaller the audio fragment size. |
362 |
* |
* |
363 |
* @param queue - destination scheduler queue |
* @param queue - destination scheduler queue |
367 |
*/ |
*/ |
368 |
template<typename T> |
template<typename T> |
369 |
void EventGenerator::scheduleAheadMicroSec(RTAVLTree<T>& queue, T& node, int32_t fragmentPosBase, uint64_t microseconds) { |
void EventGenerator::scheduleAheadMicroSec(RTAVLTree<T>& queue, T& node, int32_t fragmentPosBase, uint64_t microseconds) { |
370 |
node.scheduleTime = uiTotalSamplesProcessed + fragmentPosBase + float(uiSampleRate) * (float(microseconds) / 1000000.f); |
// round up (+1) if microseconds is not zero (i.e. because 44.1 kHz and |
371 |
|
// 1 us would yield in < 1 and thus would be offset == 0) |
372 |
|
const sched_time_t offset = |
373 |
|
(microseconds != 0LL) ? |
374 |
|
1.f + (float(uiSampleRate) * (float(microseconds) / 1000000.f)) |
375 |
|
: 0.f; |
376 |
|
node.scheduleTime = uiTotalSamplesProcessed + fragmentPosBase + offset; |
377 |
queue.insert(node); |
queue.insert(node); |
378 |
} |
} |
379 |
|
|