106 |
|
|
107 |
q.search(pChannel->pInstrument, cc); |
q.search(pChannel->pInstrument, cc); |
108 |
|
|
109 |
|
NoteIterator itNewNote; |
110 |
|
|
111 |
int i = 0; |
int i = 0; |
112 |
while (::sfz::Region* region = q.next()) { |
while (::sfz::Region* region = q.next()) { |
113 |
if (!RegionSuspended(region)) { |
if (!RegionSuspended(region)) { |
114 |
itControlChangeEvent->Param.Note.Key = 60; |
itControlChangeEvent->Param.Note.Key = 60; |
115 |
itControlChangeEvent->Param.Note.Velocity = 127; |
itControlChangeEvent->Param.Note.Velocity = 127; |
116 |
itControlChangeEvent->Param.Note.pRegion = region; |
itControlChangeEvent->Param.Note.pRegion = region; |
117 |
LaunchVoice(pChannel, itControlChangeEvent, i, false, false, true); |
if (!itNewNote) { |
118 |
|
const note_id_t noteID = LaunchNewNote(pEngineChannel, &*itControlChangeEvent); |
119 |
|
itNewNote = GetNotePool()->fromID(noteID); |
120 |
|
if (!itNewNote) { |
121 |
|
dmsg(1,("sfz::Engine: Note pool empty!\n")); |
122 |
|
return; |
123 |
|
} |
124 |
|
} |
125 |
|
VoiceIterator itNewVoice = |
126 |
|
LaunchVoice(pChannel, itControlChangeEvent, i, false, false, true); |
127 |
|
if (itNewVoice) |
128 |
|
itNewVoice.moveToEndOf(itNewNote->pActiveVoices); |
129 |
} |
} |
130 |
i++; |
i++; |
131 |
} |
} |
154 |
bool HandleKeyGroupConflicts |
bool HandleKeyGroupConflicts |
155 |
) { |
) { |
156 |
EngineChannel* pChannel = static_cast<EngineChannel*>(pEngineChannel); |
EngineChannel* pChannel = static_cast<EngineChannel*>(pEngineChannel); |
157 |
|
MidiKey* pKey = &pChannel->pMIDIKeyInfo[itNoteOnEvent->Param.Note.Key]; |
158 |
::sfz::Query q; |
::sfz::Query q; |
159 |
q.chan = itNoteOnEvent->Param.Note.Channel + 1; |
q.chan = itNoteOnEvent->Param.Note.Channel + 1; |
160 |
q.key = itNoteOnEvent->Param.Note.Key; |
q.key = itNoteOnEvent->Param.Note.Key; |
178 |
|
|
179 |
q.search(pChannel->pInstrument); |
q.search(pChannel->pInstrument); |
180 |
|
|
181 |
|
NoteIterator itNote = GetNotePool()->fromID(itNoteOnEvent->Param.Note.ID); |
182 |
|
if (!itNote) { |
183 |
|
dmsg(1,("sfz::Engine: No Note object for triggering new voices!\n")); |
184 |
|
return; |
185 |
|
} |
186 |
|
|
187 |
int i = 0; |
int i = 0; |
188 |
while (::sfz::Region* region = q.next()) { |
while (::sfz::Region* region = q.next()) { |
189 |
if (!RegionSuspended(region)) { |
if (!RegionSuspended(region)) { |
190 |
itNoteOnEvent->Param.Note.pRegion = region; |
itNoteOnEvent->Param.Note.pRegion = region; |
191 |
LaunchVoice(pChannel, itNoteOnEvent, i, false, true, HandleKeyGroupConflicts); |
VoiceIterator itNewVoice = |
192 |
|
LaunchVoice(pChannel, itNoteOnEvent, i, false, true, HandleKeyGroupConflicts); |
193 |
|
if (itNewVoice) |
194 |
|
itNewVoice.moveToEndOf(itNote->pActiveVoices); |
195 |
} |
} |
196 |
i++; |
i++; |
197 |
} |
} |
225 |
|
|
226 |
q.search(pChannel->pInstrument); |
q.search(pChannel->pInstrument); |
227 |
|
|
228 |
|
NoteIterator itNote = GetNotePool()->fromID(itNoteOffEvent->Param.Note.ID); |
229 |
|
if (!itNote) { |
230 |
|
dmsg(1,("sfz::Engine: No Note object for triggering new release voices!\n")); |
231 |
|
return; |
232 |
|
} |
233 |
|
|
234 |
// now launch the required amount of voices |
// now launch the required amount of voices |
235 |
int i = 0; |
int i = 0; |
236 |
while (::sfz::Region* region = q.next()) { |
while (::sfz::Region* region = q.next()) { |
237 |
itNoteOffEvent->Param.Note.pRegion = region; |
itNoteOffEvent->Param.Note.pRegion = region; |
238 |
LaunchVoice(pChannel, itNoteOffEvent, i, true, false, true); //FIXME: for the moment we don't perform voice stealing for release triggered samples |
VoiceIterator itNewVoice = |
239 |
|
LaunchVoice(pChannel, itNoteOffEvent, i, true, false, true); //FIXME: for the moment we don't perform voice stealing for release triggered samples |
240 |
|
if (itNewVoice) |
241 |
|
itNewVoice.moveToEndOf(itNote->pActiveVoices); |
242 |
i++; |
i++; |
243 |
} |
} |
244 |
} |
} |
253 |
) { |
) { |
254 |
EngineChannel* pChannel = static_cast<EngineChannel*>(pEngineChannel); |
EngineChannel* pChannel = static_cast<EngineChannel*>(pEngineChannel); |
255 |
int key = itNoteOnEvent->Param.Note.Key; |
int key = itNoteOnEvent->Param.Note.Key; |
256 |
EngineChannel::MidiKey* pKey = &pChannel->pMIDIKeyInfo[key]; |
//EngineChannel::MidiKey* pKey = &pChannel->pMIDIKeyInfo[key]; |
257 |
::sfz::Region* pRgn = static_cast< ::sfz::Region*>(itNoteOnEvent->Param.Note.pRegion); |
::sfz::Region* pRgn = static_cast< ::sfz::Region*>(itNoteOnEvent->Param.Note.pRegion); |
258 |
|
|
259 |
Voice::type_t VoiceType = |
Voice::type_t VoiceType = |
271 |
if (!pRgn->GetSample(false) || !pRgn->GetSample()->GetTotalFrameCount()) return Pool<Voice>::Iterator(); |
if (!pRgn->GetSample(false) || !pRgn->GetSample()->GetTotalFrameCount()) return Pool<Voice>::Iterator(); |
272 |
|
|
273 |
// allocate a new voice for the key |
// allocate a new voice for the key |
274 |
itNewVoice = pKey->pActiveVoices->allocAppend(); |
itNewVoice = GetVoicePool()->allocAppend(); |
275 |
int res = InitNewVoice ( |
int res = InitNewVoice ( |
276 |
pChannel, pRgn, itNoteOnEvent, VoiceType, iLayer, |
pChannel, pRgn, itNoteOnEvent, VoiceType, iLayer, |
277 |
pRgn->off_by, ReleaseTriggerVoice, VoiceStealing, itNewVoice |
pRgn->off_by, ReleaseTriggerVoice, VoiceStealing, itNewVoice |