527 |
pEvents->move(pNoteOnEvent, pKey->pEvents); // move event to the key's own event list |
pEvents->move(pNoteOnEvent, pKey->pEvents); // move event to the key's own event list |
528 |
} |
} |
529 |
|
|
530 |
// allocate a new voice for the key |
// allocate and trigger a new voice for the key |
531 |
Voice* pNewVoice = pKey->pActiveVoices->alloc(); |
LaunchVoice(pNoteOnEvent); |
|
if (pNewVoice) { |
|
|
// launch the new voice |
|
|
if (pNewVoice->Trigger(pNoteOnEvent, this->Pitch, this->pInstrument) < 0) { |
|
|
dmsg(1,("Triggering new voice failed!\n")); |
|
|
pKey->pActiveVoices->free(pNewVoice); |
|
|
} |
|
|
else if (!pKey->Active) { // mark as active key |
|
|
pKey->Active = true; |
|
|
pKey->pSelf = pActiveKeys->alloc(); |
|
|
*pKey->pSelf = pNoteOnEvent->Key; |
|
|
} |
|
|
} |
|
|
else std::cerr << "No free voice!" << std::endl << std::flush; |
|
532 |
} |
} |
533 |
|
|
534 |
/** |
/** |
563 |
} |
} |
564 |
|
|
565 |
/** |
/** |
566 |
|
* Allocates and triggers a new voice. This method will usually be |
567 |
|
* called by the ProcessNoteOn() method and by the voices itself |
568 |
|
* (e.g. to spawn further voices on the same key for layered sounds). |
569 |
|
* |
570 |
|
* @param pNoteOnEvent - key, velocity and time stamp of the event |
571 |
|
* @param iLayer - layer index for the new voice (optional - only |
572 |
|
* in case of layered sounds of course) |
573 |
|
*/ |
574 |
|
void Engine::LaunchVoice(Event* pNoteOnEvent, int iLayer) { |
575 |
|
midi_key_info_t* pKey = &pMIDIKeyInfo[pNoteOnEvent->Key]; |
576 |
|
|
577 |
|
// allocate a new voice for the key |
578 |
|
Voice* pNewVoice = pKey->pActiveVoices->alloc(); |
579 |
|
if (pNewVoice) { |
580 |
|
// launch the new voice |
581 |
|
if (pNewVoice->Trigger(pNoteOnEvent, this->Pitch, this->pInstrument, iLayer) < 0) { |
582 |
|
dmsg(1,("Triggering new voice failed!\n")); |
583 |
|
pKey->pActiveVoices->free(pNewVoice); |
584 |
|
} |
585 |
|
else if (!pKey->Active) { // mark as active key |
586 |
|
pKey->Active = true; |
587 |
|
pKey->pSelf = pActiveKeys->alloc(); |
588 |
|
*pKey->pSelf = pNoteOnEvent->Key; |
589 |
|
} |
590 |
|
} |
591 |
|
else std::cerr << "No free voice!" << std::endl << std::flush; |
592 |
|
} |
593 |
|
|
594 |
|
/** |
595 |
* Immediately kills the voice given with pVoice (no matter if sustain is |
* Immediately kills the voice given with pVoice (no matter if sustain is |
596 |
* pressed or not) and removes it from the MIDI key's list of active voice. |
* pressed or not) and removes it from the MIDI key's list of active voice. |
597 |
* This method will e.g. be called if a voice went inactive by itself. |
* This method will e.g. be called if a voice went inactive by itself. |
784 |
} |
} |
785 |
|
|
786 |
String Engine::Version() { |
String Engine::Version() { |
787 |
String s = "$Revision: 1.8 $"; |
String s = "$Revision: 1.9 $"; |
788 |
return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword |
return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword |
789 |
} |
} |
790 |
|
|