109 |
voice_steal_algo_oldestvoiceonkey, ///< Try to kill the oldest voice from same key where the new voice should be spawned. |
voice_steal_algo_oldestvoiceonkey, ///< Try to kill the oldest voice from same key where the new voice should be spawned. |
110 |
voice_steal_algo_oldestkey ///< Try to kill the oldest voice from the oldest active key. |
voice_steal_algo_oldestkey ///< Try to kill the oldest voice from the oldest active key. |
111 |
}; |
}; |
112 |
|
|
113 |
|
|
114 |
/** @brief MIDI key runtime informations |
/** @brief MIDI key runtime informations |
115 |
* |
* |
124 |
Pool<uint>::Iterator itSelf; ///< hack to allow fast deallocation of the key from the list of active keys |
Pool<uint>::Iterator itSelf; ///< hack to allow fast deallocation of the key from the list of active keys |
125 |
RTList<Event>* pEvents; ///< Key specific events (only Note-on, Note-off and sustain pedal currently) |
RTList<Event>* pEvents; ///< Key specific events (only Note-on, Note-off and sustain pedal currently) |
126 |
int VoiceTheftsQueued; ///< Amount of voices postponed due to shortage of voices. |
int VoiceTheftsQueued; ///< Amount of voices postponed due to shortage of voices. |
127 |
uint8_t RoundRobinIndex; ///< For the round robin dimension: current articulation for this key, will be incremented for each note on |
uint32_t* pRoundRobinIndex; ///< For the round robin dimension: current articulation for this key, will be incremented for each note on |
128 |
uint8_t Velocity; ///< Latest Note-on velocity for this key |
uint8_t Velocity; ///< Latest Note-on velocity for this key |
129 |
unsigned long NoteOnTime; ///< Time for latest Note-on event for this key |
unsigned long NoteOnTime; ///< Time for latest Note-on event for this key |
130 |
|
|
135 |
ReleaseTrigger = false; |
ReleaseTrigger = false; |
136 |
pEvents = NULL; |
pEvents = NULL; |
137 |
VoiceTheftsQueued = 0; |
VoiceTheftsQueued = 0; |
|
RoundRobinIndex = 0; |
|
138 |
} |
} |
139 |
|
|
140 |
void Reset() { |
void Reset() { |
182 |
bool SostenutoPedal; ///< true if sostenuto pedal is down |
bool SostenutoPedal; ///< true if sostenuto pedal is down |
183 |
int SostenutoKeys[128]; |
int SostenutoKeys[128]; |
184 |
int SostenutoKeyCount; |
int SostenutoKeyCount; |
185 |
|
uint32_t RoundRobinIndexes[128]; |
186 |
|
|
187 |
MidiKeyboardManager() { |
MidiKeyboardManager() { |
188 |
pMIDIKeyInfo = new MidiKey[128]; |
pMIDIKeyInfo = new MidiKey[128]; |
190 |
SoloMode = false; |
SoloMode = false; |
191 |
SustainPedal = false; |
SustainPedal = false; |
192 |
SostenutoPedal = false; |
SostenutoPedal = false; |
193 |
|
for (int i = 0 ; i < 128 ; i++) { |
194 |
|
RoundRobinIndexes[i] = 0; |
195 |
|
|
196 |
|
// by default use one counter for each key (the |
197 |
|
// gig engine will change this to one counter per |
198 |
|
// region) |
199 |
|
pMIDIKeyInfo[i].pRoundRobinIndex = &RoundRobinIndexes[i]; |
200 |
|
} |
201 |
} |
} |
202 |
|
|
203 |
virtual ~MidiKeyboardManager() { |
virtual ~MidiKeyboardManager() { |
288 |
// free the voice object |
// free the voice object |
289 |
pKey->pActiveVoices->free(itVoice); |
pKey->pActiveVoices->free(itVoice); |
290 |
|
|
291 |
// if no other voices left and member of a key group, remove from key group |
// if member of a key group and no other non-release-trigger |
292 |
if (pKey->pActiveVoices->isEmpty() && keygroup) { |
// voices left, remove from key group |
293 |
uint** ppKeyGroup = &ActiveKeyGroups[keygroup]; |
if (keygroup) { |
294 |
if (*ppKeyGroup == &*pKey->itSelf) *ppKeyGroup = NULL; // remove key from key group |
RTListVoiceIterator it = pKey->pActiveVoices->first(); |
295 |
|
RTListVoiceIterator end = pKey->pActiveVoices->end(); |
296 |
|
for (; it != end ; ++it) { |
297 |
|
if (it->Type != V::type_release_trigger) break; |
298 |
|
} |
299 |
|
if (it == end) { |
300 |
|
uint** ppKeyGroup = &ActiveKeyGroups[keygroup]; |
301 |
|
if (*ppKeyGroup == &*pKey->itSelf) *ppKeyGroup = NULL; // remove key from key group |
302 |
|
} |
303 |
} |
} |
304 |
} |
} |
305 |
else std::cerr << "Couldn't release voice! (!itVoice)\n" << std::flush; |
else std::cerr << "Couldn't release voice! (!itVoice)\n" << std::flush; |