/[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 2100 by persson, Sun Apr 25 12:51:30 2010 UTC revision 2101 by persson, Sun May 30 11:40:31 2010 UTC
# 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(*pChannel->pInstrument);
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            int i = 0;
97            while (::sfz::Region* region = q.next()) {
98                if (!RegionSuspended(region)) {
99                    itNoteOnEvent->Param.Note.pRegion = region;
100                  LaunchVoice(pChannel, itNoteOnEvent, i, false, true, HandleKeyGroupConflicts);                  LaunchVoice(pChannel, itNoteOnEvent, i, false, true, HandleKeyGroupConflicts);
101              }              }
102                i++;
103          }          }
104      }      }
105    
# Line 102  namespace LinuxSampler { namespace sfz { Line 108  namespace LinuxSampler { namespace sfz {
108          RTList<Event>::Iterator&      itNoteOffEvent          RTList<Event>::Iterator&      itNoteOffEvent
109      ) {      ) {
110          EngineChannel* pChannel = static_cast<EngineChannel*>(pEngineChannel);          EngineChannel* pChannel = static_cast<EngineChannel*>(pEngineChannel);
111          uint8_t  chan     = pChannel->MidiChannel();          ::sfz::Query q(*pChannel->pInstrument);
112          int      key      = itNoteOffEvent->Param.Note.Key;          q.chan        = pChannel->MidiChannel();
113            q.key         = itNoteOffEvent->Param.Note.Key;
114    
115          // MIDI note-on velocity is used instead of note-off velocity          // MIDI note-on velocity is used instead of note-off velocity
116          uint8_t  vel      = pChannel->pMIDIKeyInfo[key].Velocity;          q.vel         = pChannel->pMIDIKeyInfo[q.key].Velocity;
117          itNoteOffEvent->Param.Note.Velocity = vel;          itNoteOffEvent->Param.Note.Velocity = q.vel;
118    
119          int      bend     = pChannel->Pitch;          q.bend        = pChannel->Pitch;
120          uint8_t  chanaft  = pChannel->ControllerTable[128];          q.bpm         = 0;
121          uint8_t* cc       = pChannel->ControllerTable;          q.chanaft     = pChannel->ControllerTable[128];
122          ::sfz::trigger_t trig = TRIGGER_RELEASE;          q.polyaft     = 0;
123            q.prog        = 0;
124          pChannel->regionsTemp = pChannel->pInstrument->GetRegionsOnKey (          q.rand        = Random();
125              chan, key, vel, bend, 0, chanaft, 0, 0, Random(), trig, cc,          q.cc          = pChannel->ControllerTable;
126              0.0f, pChannel->PressedKeys, pChannel->LastKeySwitch, pChannel->LastKey          q.timer       = 0;
127          );          q.sw          = pChannel->PressedKeys;
128            q.last_sw_key = pChannel->LastKeySwitch;
129            q.prev_sw_key = pChannel->LastKey;
130            q.trig        = TRIGGER_RELEASE;
131    
132          // now launch the required amount of voices          // now launch the required amount of voices
133          for (int i = 0; i < pChannel->regionsTemp.size(); i++) {          int i = 0;
134            while (::sfz::Region* region = q.next()) {
135                itNoteOffEvent->Param.Note.pRegion = region;
136              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
137                i++;
138          }          }
139      }      }
140    
# Line 139  namespace LinuxSampler { namespace sfz { Line 152  namespace LinuxSampler { namespace sfz {
152          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;
153    
154          Pool<Voice>::Iterator itNewVoice;          Pool<Voice>::Iterator itNewVoice;
155          ::sfz::Region* pRgn = pChannel->regionsTemp[iLayer];          ::sfz::Region* pRgn = static_cast< ::sfz::Region*>(itNoteOnEvent->Param.Note.pRegion);
156    
157          // no need to process if sample is silent          // no need to process if sample is silent
158          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 187  namespace LinuxSampler { namespace sfz {
187      }      }
188    
189      String Engine::Version() {      String Engine::Version() {
190          String s = "$Revision: 1.7 $";          String s = "$Revision: 1.8 $";
191          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
192      }      }
193    

Legend:
Removed from v.2100  
changed lines
  Added in v.2101

  ViewVC Help
Powered by ViewVC