479 |
* @param Velocity - MIDI velocity value of the triggered key |
* @param Velocity - MIDI velocity value of the triggered key |
480 |
*/ |
*/ |
481 |
void Engine::SendNoteOn(uint8_t Key, uint8_t Velocity) { |
void Engine::SendNoteOn(uint8_t Key, uint8_t Velocity) { |
482 |
Event event = pEventGenerator->CreateEvent(); |
Event event = pEventGenerator->CreateEvent(); |
483 |
event.Type = Event::type_note_on; |
event.Type = Event::type_note_on; |
484 |
event.Key = Key; |
event.Param.Note.Key = Key; |
485 |
event.Velocity = Velocity; |
event.Param.Note.Velocity = Velocity; |
486 |
if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event); |
if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event); |
487 |
else dmsg(1,("Engine: Input event queue full!")); |
else dmsg(1,("Engine: Input event queue full!")); |
488 |
} |
} |
495 |
* @param Velocity - MIDI release velocity value of the released key |
* @param Velocity - MIDI release velocity value of the released key |
496 |
*/ |
*/ |
497 |
void Engine::SendNoteOff(uint8_t Key, uint8_t Velocity) { |
void Engine::SendNoteOff(uint8_t Key, uint8_t Velocity) { |
498 |
Event event = pEventGenerator->CreateEvent(); |
Event event = pEventGenerator->CreateEvent(); |
499 |
event.Type = Event::type_note_off; |
event.Type = Event::type_note_off; |
500 |
event.Key = Key; |
event.Param.Note.Key = Key; |
501 |
event.Velocity = Velocity; |
event.Param.Note.Velocity = Velocity; |
502 |
if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event); |
if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event); |
503 |
else dmsg(1,("Engine: Input event queue full!")); |
else dmsg(1,("Engine: Input event queue full!")); |
504 |
} |
} |
510 |
* @param Pitch - MIDI pitch value (-8192 ... +8191) |
* @param Pitch - MIDI pitch value (-8192 ... +8191) |
511 |
*/ |
*/ |
512 |
void Engine::SendPitchbend(int Pitch) { |
void Engine::SendPitchbend(int Pitch) { |
513 |
Event event = pEventGenerator->CreateEvent(); |
Event event = pEventGenerator->CreateEvent(); |
514 |
event.Type = Event::type_pitchbend; |
event.Type = Event::type_pitchbend; |
515 |
event.Pitch = Pitch; |
event.Param.Pitch.Pitch = Pitch; |
516 |
if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event); |
if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event); |
517 |
else dmsg(1,("Engine: Input event queue full!")); |
else dmsg(1,("Engine: Input event queue full!")); |
518 |
} |
} |
525 |
* @param Value - value of the control change |
* @param Value - value of the control change |
526 |
*/ |
*/ |
527 |
void Engine::SendControlChange(uint8_t Controller, uint8_t Value) { |
void Engine::SendControlChange(uint8_t Controller, uint8_t Value) { |
528 |
Event event = pEventGenerator->CreateEvent(); |
Event event = pEventGenerator->CreateEvent(); |
529 |
event.Type = Event::type_control_change; |
event.Type = Event::type_control_change; |
530 |
event.Controller = Controller; |
event.Param.CC.Controller = Controller; |
531 |
event.Value = Value; |
event.Param.CC.Value = Value; |
532 |
if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event); |
if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event); |
533 |
else dmsg(1,("Engine: Input event queue full!")); |
else dmsg(1,("Engine: Input event queue full!")); |
534 |
} |
} |
541 |
* @param Size - lenght of sysex data (in bytes) |
* @param Size - lenght of sysex data (in bytes) |
542 |
*/ |
*/ |
543 |
void Engine::SendSysex(void* pData, uint Size) { |
void Engine::SendSysex(void* pData, uint Size) { |
544 |
Event event = pEventGenerator->CreateEvent(); |
Event event = pEventGenerator->CreateEvent(); |
545 |
event.Type = Event::type_sysex; |
event.Type = Event::type_sysex; |
546 |
event.Size = Size; |
event.Param.Sysex.Size = Size; |
547 |
if (pEventQueue->write_space() > 0) { |
if (pEventQueue->write_space() > 0) { |
548 |
if (pSysexBuffer->write_space() >= Size) { |
if (pSysexBuffer->write_space() >= Size) { |
549 |
// copy sysex data to input buffer |
// copy sysex data to input buffer |
570 |
* @param pNoteOnEvent - key, velocity and time stamp of the event |
* @param pNoteOnEvent - key, velocity and time stamp of the event |
571 |
*/ |
*/ |
572 |
void Engine::ProcessNoteOn(Event* pNoteOnEvent) { |
void Engine::ProcessNoteOn(Event* pNoteOnEvent) { |
573 |
midi_key_info_t* pKey = &pMIDIKeyInfo[pNoteOnEvent->Key]; |
midi_key_info_t* pKey = &pMIDIKeyInfo[pNoteOnEvent->Param.Note.Key]; |
574 |
|
|
575 |
pKey->KeyPressed = true; // the MIDI key was now pressed down |
pKey->KeyPressed = true; // the MIDI key was now pressed down |
576 |
|
|
600 |
* @param pNoteOffEvent - key, velocity and time stamp of the event |
* @param pNoteOffEvent - key, velocity and time stamp of the event |
601 |
*/ |
*/ |
602 |
void Engine::ProcessNoteOff(Event* pNoteOffEvent) { |
void Engine::ProcessNoteOff(Event* pNoteOffEvent) { |
603 |
midi_key_info_t* pKey = &pMIDIKeyInfo[pNoteOffEvent->Key]; |
midi_key_info_t* pKey = &pMIDIKeyInfo[pNoteOffEvent->Param.Note.Key]; |
604 |
|
|
605 |
pKey->KeyPressed = false; // the MIDI key was now released |
pKey->KeyPressed = false; // the MIDI key was now released |
606 |
|
|
626 |
* @param pPitchbendEvent - absolute pitch value and time stamp of the event |
* @param pPitchbendEvent - absolute pitch value and time stamp of the event |
627 |
*/ |
*/ |
628 |
void Engine::ProcessPitchbend(Event* pPitchbendEvent) { |
void Engine::ProcessPitchbend(Event* pPitchbendEvent) { |
629 |
this->Pitch = pPitchbendEvent->Pitch; // store current pitch value |
this->Pitch = pPitchbendEvent->Param.Pitch.Pitch; // store current pitch value |
630 |
pEvents->move(pPitchbendEvent, pSynthesisEvents[Event::destination_vco]); |
pEvents->move(pPitchbendEvent, pSynthesisEvents[Event::destination_vco]); |
631 |
} |
} |
632 |
|
|
642 |
* (optional, default = false) |
* (optional, default = false) |
643 |
*/ |
*/ |
644 |
void Engine::LaunchVoice(Event* pNoteOnEvent, int iLayer, bool ReleaseTriggerVoice) { |
void Engine::LaunchVoice(Event* pNoteOnEvent, int iLayer, bool ReleaseTriggerVoice) { |
645 |
midi_key_info_t* pKey = &pMIDIKeyInfo[pNoteOnEvent->Key]; |
midi_key_info_t* pKey = &pMIDIKeyInfo[pNoteOnEvent->Param.Note.Key]; |
646 |
|
|
647 |
// allocate a new voice for the key |
// allocate a new voice for the key |
648 |
Voice* pNewVoice = pKey->pActiveVoices->alloc(); |
Voice* pNewVoice = pKey->pActiveVoices->alloc(); |
671 |
if (!pKey->Active) { // mark as active key |
if (!pKey->Active) { // mark as active key |
672 |
pKey->Active = true; |
pKey->Active = true; |
673 |
pKey->pSelf = pActiveKeys->alloc(); |
pKey->pSelf = pActiveKeys->alloc(); |
674 |
*pKey->pSelf = pNoteOnEvent->Key; |
*pKey->pSelf = pNoteOnEvent->Param.Note.Key; |
675 |
} |
} |
676 |
if (pNewVoice->KeyGroup) { |
if (pNewVoice->KeyGroup) { |
677 |
*ppKeyGroup = pKey->pSelf; // put key as the (new) active key to its key group |
*ppKeyGroup = pKey->pSelf; // put key as the (new) active key to its key group |
721 |
* @param pControlChangeEvent - controller, value and time stamp of the event |
* @param pControlChangeEvent - controller, value and time stamp of the event |
722 |
*/ |
*/ |
723 |
void Engine::ProcessControlChange(Event* pControlChangeEvent) { |
void Engine::ProcessControlChange(Event* pControlChangeEvent) { |
724 |
dmsg(4,("Engine::ContinuousController cc=%d v=%d\n", pControlChangeEvent->Controller, pControlChangeEvent->Value)); |
dmsg(4,("Engine::ContinuousController cc=%d v=%d\n", pControlChangeEvent->Param.CC.Controller, pControlChangeEvent->Param.CC.Value)); |
725 |
|
|
726 |
switch (pControlChangeEvent->Controller) { |
switch (pControlChangeEvent->Param.CC.Controller) { |
727 |
case 64: { |
case 64: { |
728 |
if (pControlChangeEvent->Value >= 64 && !SustainPedal) { |
if (pControlChangeEvent->Param.CC.Value >= 64 && !SustainPedal) { |
729 |
dmsg(4,("PEDAL DOWN\n")); |
dmsg(4,("PEDAL DOWN\n")); |
730 |
SustainPedal = true; |
SustainPedal = true; |
731 |
|
|
745 |
} |
} |
746 |
} |
} |
747 |
} |
} |
748 |
if (pControlChangeEvent->Value < 64 && SustainPedal) { |
if (pControlChangeEvent->Param.CC.Value < 64 && SustainPedal) { |
749 |
dmsg(4,("PEDAL UP\n")); |
dmsg(4,("PEDAL UP\n")); |
750 |
SustainPedal = false; |
SustainPedal = false; |
751 |
|
|
770 |
} |
} |
771 |
|
|
772 |
// update controller value in the engine's controller table |
// update controller value in the engine's controller table |
773 |
ControllerTable[pControlChangeEvent->Controller] = pControlChangeEvent->Value; |
ControllerTable[pControlChangeEvent->Param.CC.Controller] = pControlChangeEvent->Param.CC.Value; |
774 |
|
|
775 |
// move event from the unsorted event list to the control change event list |
// move event from the unsorted event list to the control change event list |
776 |
pEvents->move(pControlChangeEvent, pCCEvents); |
pEvents->move(pControlChangeEvent, pCCEvents); |
829 |
} |
} |
830 |
|
|
831 |
free_sysex_data: // finally free sysex data |
free_sysex_data: // finally free sysex data |
832 |
pSysexBuffer->increment_read_ptr(pSysexEvent->Size); |
pSysexBuffer->increment_read_ptr(pSysexEvent->Param.Sysex.Size); |
833 |
} |
} |
834 |
|
|
835 |
/** |
/** |
963 |
} |
} |
964 |
|
|
965 |
String Engine::Version() { |
String Engine::Version() { |
966 |
String s = "$Revision: 1.12 $"; |
String s = "$Revision: 1.13 $"; |
967 |
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 |
968 |
} |
} |
969 |
|
|