92 |
}; |
}; |
93 |
|
|
94 |
/** |
/** |
95 |
|
* Unique numeric ID of an event which can be used to retrieve access to |
96 |
|
* the actual @c Event object. Once the event associated with a certain ID |
97 |
|
* was released (back to its event pool), this numeric ID becomes invalid |
98 |
|
* and Pool< Event >::fromID() will detect this circumstance and will |
99 |
|
* return an invalid Iterator, and thus will prevent you from misusing an |
100 |
|
* event which no longer "exists". |
101 |
|
* |
102 |
|
* Note that an @c Event object usually just "exists" for exactly on audio |
103 |
|
* fragment cycle: that is it exists right from the beginning of the audio |
104 |
|
* fragment cycle where it was caused (i.e. where its MIDI data was |
105 |
|
* received by the respective engine channel) and will disappear |
106 |
|
* automatically at the end of that audio fragment cycle. |
107 |
|
*/ |
108 |
|
typedef pool_element_id_t event_id_t; |
109 |
|
|
110 |
|
/** |
111 |
|
* Unique numeric ID of a note which can be used to retrieve access to the |
112 |
|
* actual @c Note object. Once the note associated with a certain ID was |
113 |
|
* released (back to its note pool), this numeric ID becomes invalid and |
114 |
|
* Pool< Note >::fromID() will detect this circumstance and will return |
115 |
|
* an invalid Iterator, and thus will prevent you from misusing a note |
116 |
|
* which no longer is "alive". |
117 |
|
* |
118 |
|
* A @c Note object exists right when the respective MIDI note-on event |
119 |
|
* was received by the respective engine channel, and remains existent |
120 |
|
* until the caused note and all its voices were finally freed (which might |
121 |
|
* even be long time after the respective note-off event was received, |
122 |
|
* depending on the duration of the voice's release stages etc.). |
123 |
|
*/ |
124 |
|
typedef pool_element_id_t note_id_t; |
125 |
|
|
126 |
|
/** |
127 |
* Events are usually caused by a MIDI source or an internal modulation |
* Events are usually caused by a MIDI source or an internal modulation |
128 |
* 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 |
129 |
* EventGenerator! |
* EventGenerator! |
152 |
uint8_t Velocity; ///< Trigger or release velocity of note-on / note-off event. |
uint8_t Velocity; ///< Trigger or release velocity of note-on / note-off event. |
153 |
int8_t Layer; ///< Layer index (usually only used if a note-on event has to be postponed, e.g. due to shortage of free voices). |
int8_t Layer; ///< Layer index (usually only used if a note-on event has to be postponed, e.g. due to shortage of free voices). |
154 |
int8_t ReleaseTrigger; ///< If new voice should be a release triggered voice (actually boolean field and usually only used if a note-on event has to be postponed, e.g. due to shortage of free voices). |
int8_t ReleaseTrigger; ///< If new voice should be a release triggered voice (actually boolean field and usually only used if a note-on event has to be postponed, e.g. due to shortage of free voices). |
155 |
|
note_id_t ID; ///< Unique numeric ID of the @c Note object associated with this note (on) event. |
156 |
|
note_id_t ParentNoteID; ///< If not zero: Unique numeric ID of the parent @c Note object that shall become parent of resulting new Note object of this Event. So this is used to associate a new note with a previous note, i.e. to release the new note once the parent note was released. |
157 |
void* pRegion; ///< Engine specific pointer to instrument region |
void* pRegion; ///< Engine specific pointer to instrument region |
158 |
} Note; |
} Note; |
159 |
/// Control change event specifics |
/// Control change event specifics |
184 |
uint8_t Value; ///< New pressure value for note. |
uint8_t Value; ///< New pressure value for note. |
185 |
} NotePressure; |
} NotePressure; |
186 |
} Param; |
} Param; |
|
/// Sampler format specific informations and variables. |
|
|
union { |
|
|
/// Gigasampler/GigaStudio format specifics. |
|
|
struct _Gig { |
|
|
uint8_t DimMask; ///< May be used to override the Dimension zone to be selected for a new voice: each 1 bit means that respective bit shall be overridden by taking the respective bit from DimBits instead. |
|
|
uint8_t DimBits; ///< Used only in conjunction with DimMask: Dimension bits that shall be selected. |
|
|
} Gig; |
|
|
} Format; |
|
187 |
EngineChannel* pEngineChannel; ///< Pointer to the EngineChannel where this event occured on, NULL means Engine global event (e.g. SysEx message). |
EngineChannel* pEngineChannel; ///< Pointer to the EngineChannel where this event occured on, NULL means Engine global event (e.g. SysEx message). |
188 |
MidiInputPort* pMidiInputPort; ///< Pointer to the MIDI input port on which this event occured (NOTE: currently only for global events, that is SysEx messages) |
MidiInputPort* pMidiInputPort; ///< Pointer to the MIDI input port on which this event occured (NOTE: currently only for global events, that is SysEx messages) |
189 |
|
|
190 |
|
inline void Init() { |
191 |
|
Param.Note.ID = 0; |
192 |
|
Param.Note.ParentNoteID = 0; |
193 |
|
} |
194 |
inline int32_t FragmentPos() { |
inline int32_t FragmentPos() { |
195 |
if (iFragmentPos >= 0) return iFragmentPos; |
if (iFragmentPos >= 0) return iFragmentPos; |
196 |
iFragmentPos = pEventGenerator->ToFragmentPos(TimeStamp); |
iFragmentPos = pEventGenerator->ToFragmentPos(TimeStamp); |
200 |
inline void ResetFragmentPos() { |
inline void ResetFragmentPos() { |
201 |
iFragmentPos = -1; |
iFragmentPos = -1; |
202 |
} |
} |
203 |
|
inline void CopyTimeFrom(const Event& other) { |
204 |
|
TimeStamp = other.TimeStamp; |
205 |
|
iFragmentPos = other.iFragmentPos; |
206 |
|
} |
207 |
protected: |
protected: |
208 |
typedef EventGenerator::time_stamp_t time_stamp_t; |
typedef EventGenerator::time_stamp_t time_stamp_t; |
209 |
Event(EventGenerator* pGenerator, EventGenerator::time_stamp_t Time); |
Event(EventGenerator* pGenerator, EventGenerator::time_stamp_t Time); |
263 |
*/ |
*/ |
264 |
class ScriptEvent : public SchedulerNode { |
class ScriptEvent : public SchedulerNode { |
265 |
public: |
public: |
266 |
Event cause; ///< Original external event that triggered this script event (i.e. MIDI note on event, MIDI CC event, etc.). |
Event cause; ///< Copy of original external @c Event that triggered this script event (i.e. MIDI note on event, MIDI CC event, etc.). |
267 |
int id; ///< Unique ID of the external event that triggered this script event. |
pool_element_id_t id; ///< Native representation of built-in script variable $EVENT_ID. For scripts' "note" event handler this will reflect the unique ID of the @c Note object, for all other event handlers the unique ID of the original external @c Event object that triggered this script event. |
268 |
VMEventHandler** handlers; ///< The script's event handlers (callbacks) to be processed (NULL terminated list). |
VMEventHandler** handlers; ///< The script's event handlers (callbacks) to be processed (NULL terminated list). |
269 |
VMExecContext* execCtx; ///< Script's current execution state (polyphonic variables and execution stack). |
VMExecContext* execCtx; ///< Script's current execution state (polyphonic variables and execution stack). |
270 |
int currentHandler; ///< Current index in 'handlers' list above. |
int currentHandler; ///< Current index in 'handlers' list above. |
274 |
/** |
/** |
275 |
* Insert given @a node into the supplied timing @a queue with a scheduled |
* Insert given @a node into the supplied timing @a queue with a scheduled |
276 |
* timing position given by @a fragmentPosBase and @a microseconds, where |
* timing position given by @a fragmentPosBase and @a microseconds, where |
277 |
* @a microseconds reflects the amount microseconds in future from "now" |
* @a microseconds reflects the amount of microseconds in future from "now" |
278 |
* where the node shall be scheduled, and @a fragmentPos identifies the |
* where the node shall be scheduled, and @a fragmentPos identifies the |
279 |
* sample point within the current audio fragment cycle which shall be |
* sample point within the current audio fragment cycle which shall be |
280 |
* interpreted by this method to be "now". |
* interpreted by this method to be "now". |