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

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

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

revision 2224 by iliev, Mon Aug 1 19:08:09 2011 UTC revision 2225 by iliev, Tue Aug 2 13:44:57 2011 UTC
# Line 129  namespace LinuxSampler { namespace sfz { Line 129  namespace LinuxSampler { namespace sfz {
129            
130      LFOv2Unit::LFOv2Unit(SfzSignalUnitRack* rack)      LFOv2Unit::LFOv2Unit(SfzSignalUnitRack* rack)
131          : LFOUnit(rack), lfos(8), lfo0(1200.0f), lfo1(1200.0f), lfo2(1200.0f),          : LFOUnit(rack), lfos(8), lfo0(1200.0f), lfo1(1200.0f), lfo2(1200.0f),
132            lfo3(1200.0f), lfo4(1200.0f), lfo5(1200.0f), lfo6(1200.0f), lfo7(1200.0f)            lfo3(1200.0f), lfo4(1200.0f), lfo5(1200.0f), lfo6(1200.0f), lfo7(1200.0f),
133              suPitchOnCC(rack)
134      {      {
135          lfos.add(&lfo0);          lfos.add(&lfo0);
136          lfos.add(&lfo1);          lfos.add(&lfo1);
# Line 153  namespace LinuxSampler { namespace sfz { Line 154  namespace LinuxSampler { namespace sfz {
154              1, 0, false, GetSampleRate()              1, 0, false, GetSampleRate()
155          );          );
156          pLFO->Update(0);          pLFO->Update(0);
157            
158            float phase = pLfoInfo->phase;
159            for (int i = 0; i < pLfoInfo->phase_oncc.size(); i++) {
160                int val = pVoice->GetControllerValue(pLfoInfo->phase_oncc[i].Controller);
161                phase += (val / 127.0f) * pLfoInfo->phase_oncc[i].Influence;
162            }
163            if (phase != 0) pLFO->SetPhase(phase);
164      }      }
165            
166      void AmpLFOUnit::Trigger() {      void AmpLFOUnit::Trigger() {
# Line 197  namespace LinuxSampler { namespace sfz { Line 205  namespace LinuxSampler { namespace sfz {
205               if (cc[i] != 0) AddCC(i, cc[i]);               if (cc[i] != 0) AddCC(i, cc[i]);
206           }           }
207       }       }
208        
209         void CCUnit::SetCCs(ArrayList< ::sfz::CC>& cc) {
210             RemoveAllCCs();
211             for (int i = 0; i < cc.size(); i++) {
212                 if (cc[i].Influence != 0) AddCC(cc[i].Controller, cc[i].Influence);
213             }
214         }
215    
216    
217      EndpointUnit::EndpointUnit(SfzSignalUnitRack* rack): EndpointSignalUnit(rack) {      EndpointUnit::EndpointUnit(SfzSignalUnitRack* rack): EndpointSignalUnit(rack) {
# Line 266  namespace LinuxSampler { namespace sfz { Line 281  namespace LinuxSampler { namespace sfz {
281          CCSignalUnit* u3 = &(GetRack()->suPitchLFO.suDepthCC);          CCSignalUnit* u3 = &(GetRack()->suPitchLFO.suDepthCC);
282          float f = u3->Active() ? u3->GetLevel() : 0;          float f = u3->Active() ? u3->GetLevel() : 0;
283          p *= u2->Active() ? RTMath::CentsToFreqRatioUnlimited(u2->GetLevel() * (u2->pLfoInfo->pitch + f)) : 1;          p *= u2->Active() ? RTMath::CentsToFreqRatioUnlimited(u2->GetLevel() * (u2->pLfoInfo->pitch + f)) : 1;
284            
285            for (int i = 0; i < GetRack()->pitchLFOs.size(); i++) {
286                LFOv2Unit* lfo = GetRack()->pitchLFOs[i];
287                if (!lfo->Active()) continue;
288                
289                float f = lfo->suPitchOnCC.Active() ? lfo->suPitchOnCC.GetLevel() : 0;
290                p *= RTMath::CentsToFreqRatioUnlimited(lfo->GetLevel() * (lfo->pLfoInfo->pitch + f));
291            }
292            
293          return p;          return p;
294      }      }
295            
# Line 303  namespace LinuxSampler { namespace sfz { Line 327  namespace LinuxSampler { namespace sfz {
327          : SignalUnitRack(MaxUnitCount), pVoice(voice), suEndpoint(this), suVolEG(this), suFilEG(this), suPitchEG(this),          : SignalUnitRack(MaxUnitCount), pVoice(voice), suEndpoint(this), suVolEG(this), suFilEG(this), suPitchEG(this),
328          EGs(maxEgCount), volEGs(maxEgCount), pitchEGs(maxEgCount),          EGs(maxEgCount), volEGs(maxEgCount), pitchEGs(maxEgCount),
329          suAmpLFO(this), suPitchLFO(this), suFilLFO(this),          suAmpLFO(this), suPitchLFO(this), suFilLFO(this),
330          LFOs(maxLfoCount), filLFOs(maxLfoCount), resLFOs(maxLfoCount), panLFOs(maxLfoCount)          LFOs(maxLfoCount), pitchLFOs(maxLfoCount), filLFOs(maxLfoCount), resLFOs(maxLfoCount), panLFOs(maxLfoCount)
331      {      {
332          suEndpoint.pVoice = suVolEG.pVoice = suFilEG.pVoice = suPitchEG.pVoice = voice;          suEndpoint.pVoice = suVolEG.pVoice = suFilEG.pVoice = suPitchEG.pVoice = voice;
333          suAmpLFO.pVoice = suPitchLFO.pVoice = suFilLFO.pVoice = voice;          suAmpLFO.pVoice = suPitchLFO.pVoice = suFilLFO.pVoice = voice;
# Line 317  namespace LinuxSampler { namespace sfz { Line 341  namespace LinuxSampler { namespace sfz {
341          for (int i = 0; i < LFOs.capacity(); i++) {          for (int i = 0; i < LFOs.capacity(); i++) {
342              LFOs[i] = new LFOv2Unit(this);              LFOs[i] = new LFOv2Unit(this);
343              LFOs[i]->pVoice = voice;              LFOs[i]->pVoice = voice;
344                LFOs[i]->suPitchOnCC.pVoice = voice;
345          }          }
346      }      }
347            
# Line 336  namespace LinuxSampler { namespace sfz { Line 361  namespace LinuxSampler { namespace sfz {
361          pitchEGs.clear();          pitchEGs.clear();
362                    
363          LFOs.clear();          LFOs.clear();
364            pitchLFOs.clear();
365          filLFOs.clear();          filLFOs.clear();
366          resLFOs.clear();          resLFOs.clear();
367          panLFOs.clear();          panLFOs.clear();
# Line 370  namespace LinuxSampler { namespace sfz { Line 396  namespace LinuxSampler { namespace sfz {
396                  LFOv2Unit lfo(this);                  LFOv2Unit lfo(this);
397                  lfo.pLfoInfo = &(pRegion->lfos[i]);                  lfo.pLfoInfo = &(pRegion->lfos[i]);
398                  LFOs.increment()->Copy(lfo);                  LFOs.increment()->Copy(lfo);
399                    LFOs[LFOs.size() - 1]->suPitchOnCC.SetCCs(pRegion->lfos[i].pitch_oncc);
400              } else { std::cerr << "Maximum number of LFOs reached!" << std::endl; break; }              } else { std::cerr << "Maximum number of LFOs reached!" << std::endl; break; }
401                            
402                if (pRegion->lfos[i].pitch != 0 || !pRegion->lfos[i].pitch_oncc.empty()) {
403                    if(pitchLFOs.size() < pitchLFOs.capacity()) pitchLFOs.add(LFOs[LFOs.size() - 1]);
404                    else std::cerr << "Maximum number of LFOs reached!" << std::endl;
405                }
406                
407              if (pRegion->lfos[i].cutoff != 0) {              if (pRegion->lfos[i].cutoff != 0) {
408                  if(filLFOs.size() < filLFOs.capacity()) filLFOs.add(LFOs[LFOs.size() - 1]);                  if(filLFOs.size() < filLFOs.capacity()) filLFOs.add(LFOs[LFOs.size() - 1]);
409                  else std::cerr << "Maximum number of LFOs reached!" << std::endl;                  else std::cerr << "Maximum number of LFOs reached!" << std::endl;
# Line 406  namespace LinuxSampler { namespace sfz { Line 438  namespace LinuxSampler { namespace sfz {
438                    
439          for (int i = 0; i < LFOs.size(); i++) {          for (int i = 0; i < LFOs.size(); i++) {
440              Units.add(LFOs[i]);              Units.add(LFOs[i]);
441                Units.add(&(LFOs[i]->suPitchOnCC));
442          }          }
443                    
444          Units.add(&suEndpoint);          Units.add(&suEndpoint);

Legend:
Removed from v.2224  
changed lines
  Added in v.2225

  ViewVC Help
Powered by ViewVC