/[svn]/linuxsampler/trunk/src/engines/gig/Engine.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/gig/Engine.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1646 by persson, Sun Jan 20 15:04:51 2008 UTC revision 1700 by persson, Sun Feb 17 12:40:59 2008 UTC
# Line 1618  namespace LinuxSampler { namespace gig { Line 1618  namespace LinuxSampler { namespace gig {
1618      void Engine::ProcessControlChange(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itControlChangeEvent) {      void Engine::ProcessControlChange(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itControlChangeEvent) {
1619          dmsg(4,("Engine::ContinuousController cc=%d v=%d\n", itControlChangeEvent->Param.CC.Controller, itControlChangeEvent->Param.CC.Value));          dmsg(4,("Engine::ContinuousController cc=%d v=%d\n", itControlChangeEvent->Param.CC.Controller, itControlChangeEvent->Param.CC.Value));
1620    
1621            // handle the "control triggered" MIDI rule: a control change
1622            // event can trigger a new note on or note off event
1623            if (pEngineChannel->pInstrument) {
1624    
1625                ::gig::MidiRule* rule;
1626                for (int i = 0 ; (rule = pEngineChannel->pInstrument->GetMidiRule(i)) ; i++) {
1627    
1628                    if (::gig::MidiRuleCtrlTrigger* ctrlTrigger =
1629                        dynamic_cast< ::gig::MidiRuleCtrlTrigger*>(rule)) {
1630                        if (itControlChangeEvent->Param.CC.Controller ==
1631                            ctrlTrigger->ControllerNumber) {
1632    
1633                            uint8_t oldCCValue = pEngineChannel->ControllerTable[
1634                                itControlChangeEvent->Param.CC.Controller];
1635                            uint8_t newCCValue = itControlChangeEvent->Param.CC.Value;
1636    
1637                            for (int i = 0 ; i < ctrlTrigger->Triggers ; i++) {
1638                                ::gig::MidiRuleCtrlTrigger::trigger_t* pTrigger =
1639                                      &ctrlTrigger->pTriggers[i];
1640    
1641                                // check if the controller has passed the
1642                                // trigger point in the right direction
1643                                if ((pTrigger->Descending &&
1644                                     oldCCValue > pTrigger->TriggerPoint &&
1645                                     newCCValue <= pTrigger->TriggerPoint) ||
1646                                    (!pTrigger->Descending &&
1647                                     oldCCValue < pTrigger->TriggerPoint &&
1648                                     newCCValue >= pTrigger->TriggerPoint)) {
1649    
1650                                    RTList<Event>::Iterator itNewEvent = pGlobalEvents->allocAppend();
1651                                    if (itNewEvent) {
1652                                        *itNewEvent = *itControlChangeEvent;
1653                                        itNewEvent->Param.Note.Key = pTrigger->Key;
1654    
1655                                        if (pTrigger->NoteOff || pTrigger->Velocity == 0) {
1656                                            itNewEvent->Type = Event::type_note_off;
1657                                            itNewEvent->Param.Note.Velocity = 100;
1658    
1659                                            ProcessNoteOff(pEngineChannel, itNewEvent);
1660                                        } else {
1661                                            itNewEvent->Type = Event::type_note_on;
1662                                            //TODO: if Velocity is 255, the triggered velocity should
1663                                            // depend on how fast the controller is moving
1664                                            itNewEvent->Param.Note.Velocity =
1665                                                pTrigger->Velocity == 255 ? 100 :
1666                                                pTrigger->Velocity;
1667    
1668                                            ProcessNoteOn(pEngineChannel, itNewEvent);
1669                                        }
1670                                    }
1671                                    else dmsg(1,("Event pool emtpy!\n"));
1672                                }
1673                            }
1674                        }
1675                    }
1676                }
1677            }
1678    
1679          // update controller value in the engine channel's controller table          // update controller value in the engine channel's controller table
1680          pEngineChannel->ControllerTable[itControlChangeEvent->Param.CC.Controller] = itControlChangeEvent->Param.CC.Value;          pEngineChannel->ControllerTable[itControlChangeEvent->Param.CC.Controller] = itControlChangeEvent->Param.CC.Value;
1681    
# Line 1990  namespace LinuxSampler { namespace gig { Line 2048  namespace LinuxSampler { namespace gig {
2048      }      }
2049    
2050      String Engine::Version() {      String Engine::Version() {
2051          String s = "$Revision: 1.87 $";          String s = "$Revision: 1.88 $";
2052          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
2053      }      }
2054    

Legend:
Removed from v.1646  
changed lines
  Added in v.1700

  ViewVC Help
Powered by ViewVC