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

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

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

revision 2086 by persson, Sun Apr 25 12:51:30 2010 UTC revision 2106 by persson, Sun Jul 4 12:50:51 2010 UTC
# Line 41  namespace LinuxSampler { namespace sfz { Line 41  namespace LinuxSampler { namespace sfz {
41      ) {      ) {
42          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));
43    
44          EngineChannel* pChannel = dynamic_cast<EngineChannel*>(pEngineChannel);          EngineChannel* pChannel = static_cast<EngineChannel*>(pEngineChannel);
45          // handle the "control triggered" MIDI rule: a control change          // handle the "control triggered" MIDI rule: a control change
46          // event can trigger a new note on or note off event          // event can trigger a new note on or note off event
47          if (pChannel->pInstrument) {          if (pChannel->pInstrument) {
# Line 72  namespace LinuxSampler { namespace sfz { Line 72  namespace LinuxSampler { namespace sfz {
72          bool                         HandleKeyGroupConflicts          bool                         HandleKeyGroupConflicts
73      ) {      ) {
74          EngineChannel* pChannel = static_cast<EngineChannel*>(pEngineChannel);          EngineChannel* pChannel = static_cast<EngineChannel*>(pEngineChannel);
75            ::sfz::Query q;
76          uint8_t  chan     = pChannel->MidiChannel();          q.chan        = pChannel->MidiChannel();
77          int      key      = itNoteOnEvent->Param.Note.Key;          q.key         = itNoteOnEvent->Param.Note.Key;
78          uint8_t  vel      = itNoteOnEvent->Param.Note.Velocity;          q.vel         = itNoteOnEvent->Param.Note.Velocity;
79          int      bend     = pChannel->Pitch;          q.bend        = pChannel->Pitch;
80          uint8_t  chanaft  = pChannel->ControllerTable[128];          q.bpm         = 0;
81          uint8_t* cc       = pChannel->ControllerTable;          q.chanaft     = pChannel->ControllerTable[128];
82          ::sfz::trigger_t trig = TRIGGER_ATTACK |          q.polyaft     = 0;
83                ((pChannel->LastKey != -1 &&          q.prog        = 0;
84                  pChannel->PressedKeys[pChannel->LastKey] &&          q.rand        = Random();
85                  pChannel->LastKey != key) ?          q.cc          = pChannel->ControllerTable;
86                 TRIGGER_LEGATO : TRIGGER_FIRST);          q.timer       = 0;
87            q.sw          = pChannel->PressedKeys;
88          pChannel->regionsTemp = pChannel->pInstrument->GetRegionsOnKey (          q.last_sw_key = pChannel->LastKeySwitch;
89              chan, key, vel, bend, 0, chanaft, 0, 0, Random(), trig, cc,          q.prev_sw_key = pChannel->LastKey;
90              0.0f, pChannel->PressedKeys, pChannel->LastKeySwitch, pChannel->LastKey          q.trig        = TRIGGER_ATTACK |
91          );              ((pChannel->LastKey != -1 &&
92                  pChannel->PressedKeys[pChannel->LastKey] &&
93          for (int i = 0; i < pChannel->regionsTemp.size(); i++) {                pChannel->LastKey != q.key) ?
94              if (!RegionSuspended(pChannel->regionsTemp[i])) {               TRIGGER_LEGATO : TRIGGER_FIRST);
95    
96            q.search(pChannel->pInstrument);
97    
98            int i = 0;
99            while (::sfz::Region* region = q.next()) {
100                if (!RegionSuspended(region)) {
101                    itNoteOnEvent->Param.Note.pRegion = region;
102                  LaunchVoice(pChannel, itNoteOnEvent, i, false, true, HandleKeyGroupConflicts);                  LaunchVoice(pChannel, itNoteOnEvent, i, false, true, HandleKeyGroupConflicts);
103              }              }
104                i++;
105          }          }
106      }      }
107    
# Line 102  namespace LinuxSampler { namespace sfz { Line 110  namespace LinuxSampler { namespace sfz {
110          RTList<Event>::Iterator&      itNoteOffEvent          RTList<Event>::Iterator&      itNoteOffEvent
111      ) {      ) {
112          EngineChannel* pChannel = static_cast<EngineChannel*>(pEngineChannel);          EngineChannel* pChannel = static_cast<EngineChannel*>(pEngineChannel);
113          uint8_t  chan     = pChannel->MidiChannel();          ::sfz::Query q;
114          int      key      = itNoteOffEvent->Param.Note.Key;          q.chan        = pChannel->MidiChannel();
115            q.key         = itNoteOffEvent->Param.Note.Key;
116    
117          // MIDI note-on velocity is used instead of note-off velocity          // MIDI note-on velocity is used instead of note-off velocity
118          uint8_t  vel      = pChannel->pMIDIKeyInfo[key].Velocity;          q.vel         = pChannel->pMIDIKeyInfo[q.key].Velocity;
119          itNoteOffEvent->Param.Note.Velocity = vel;          itNoteOffEvent->Param.Note.Velocity = q.vel;
120    
121          int      bend     = pChannel->Pitch;          q.bend        = pChannel->Pitch;
122          uint8_t  chanaft  = pChannel->ControllerTable[128];          q.bpm         = 0;
123          uint8_t* cc       = pChannel->ControllerTable;          q.chanaft     = pChannel->ControllerTable[128];
124          ::sfz::trigger_t trig = TRIGGER_RELEASE;          q.polyaft     = 0;
125            q.prog        = 0;
126          pChannel->regionsTemp = pChannel->pInstrument->GetRegionsOnKey (          q.rand        = Random();
127              chan, key, vel, bend, 0, chanaft, 0, 0, Random(), trig, cc,          q.cc          = pChannel->ControllerTable;
128              0.0f, pChannel->PressedKeys, pChannel->LastKeySwitch, pChannel->LastKey          q.timer       = 0;
129          );          q.sw          = pChannel->PressedKeys;
130            q.last_sw_key = pChannel->LastKeySwitch;
131            q.prev_sw_key = pChannel->LastKey;
132            q.trig        = TRIGGER_RELEASE;
133    
134            q.search(pChannel->pInstrument);
135    
136          // now launch the required amount of voices          // now launch the required amount of voices
137          for (int i = 0; i < pChannel->regionsTemp.size(); i++) {          int i = 0;
138            while (::sfz::Region* region = q.next()) {
139                itNoteOffEvent->Param.Note.pRegion = region;
140              LaunchVoice(pChannel, itNoteOffEvent, i, true, false, false); //FIXME: for the moment we don't perform voice stealing for release triggered samples              LaunchVoice(pChannel, itNoteOffEvent, i, true, false, false); //FIXME: for the moment we don't perform voice stealing for release triggered samples
141                i++;
142          }          }
143      }      }
144    
# Line 139  namespace LinuxSampler { namespace sfz { Line 156  namespace LinuxSampler { namespace sfz {
156          Voice::type_t VoiceType = (ReleaseTriggerVoice) ? Voice::type_release_trigger : (!iLayer) ? Voice::type_release_trigger_required : Voice::type_normal;          Voice::type_t VoiceType = (ReleaseTriggerVoice) ? Voice::type_release_trigger : (!iLayer) ? Voice::type_release_trigger_required : Voice::type_normal;
157    
158          Pool<Voice>::Iterator itNewVoice;          Pool<Voice>::Iterator itNewVoice;
159          ::sfz::Region* pRgn = pChannel->regionsTemp[iLayer];          ::sfz::Region* pRgn = static_cast< ::sfz::Region*>(itNoteOnEvent->Param.Note.pRegion);
160    
161          // no need to process if sample is silent          // no need to process if sample is silent
162          if (!pRgn->GetSample() || !pRgn->GetSample()->GetTotalFrameCount()) return Pool<Voice>::Iterator();          if (!pRgn->GetSample() || !pRgn->GetSample()->GetTotalFrameCount()) return Pool<Voice>::Iterator();
# Line 174  namespace LinuxSampler { namespace sfz { Line 191  namespace LinuxSampler { namespace sfz {
191      }      }
192    
193      String Engine::Version() {      String Engine::Version() {
194          String s = "$Revision: 1.7 $";          String s = "$Revision: 1.9 $";
195          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
196      }      }
197    

Legend:
Removed from v.2086  
changed lines
  Added in v.2106

  ViewVC Help
Powered by ViewVC