/[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 2220 by iliev, Thu Jul 28 15:47:51 2011 UTC revision 2221 by iliev, Thu Jul 28 17:17:42 2011 UTC
# Line 22  Line 22 
22    
23  #include "SfzSignalUnitRack.h"  #include "SfzSignalUnitRack.h"
24  #include "Voice.h"  #include "Voice.h"
25    #include <SF.h>
26    
27  namespace LinuxSampler { namespace sfz {  namespace LinuxSampler { namespace sfz {
28            
# Line 94  namespace LinuxSampler { namespace sfz { Line 95  namespace LinuxSampler { namespace sfz {
95          uiDelayTrigger = pLfoInfo->delay * GetSampleRate();          uiDelayTrigger = pLfoInfo->delay * GetSampleRate();
96      }      }
97            
98        void LFOv1Unit::Trigger() {
99            LFOUnit::Trigger();
100            
101            lfo.trigger (
102                pLfoInfo->freq,
103                start_level_mid,
104                1, 0, false, GetSampleRate()
105            );
106            lfo.update(0);
107        }
108        
109      void LFOv2Unit::Trigger() {      void LFOv2Unit::Trigger() {
110          LFOUnit::Trigger();          LFOUnit::Trigger();
111                    
# Line 104  namespace LinuxSampler { namespace sfz { Line 116  namespace LinuxSampler { namespace sfz {
116          );          );
117          lfo.update(0);          lfo.update(0);
118      }      }
119        
120        void AmpLFOUnit::Trigger() {
121            ::sfz::Region* const pRegion = pVoice->pRegion;
122            pLfoInfo->delay = pRegion->amplfo_delay;
123            pLfoInfo->freq = pRegion->amplfo_freq;
124            pLfoInfo->volume = pRegion->amplfo_depth;
125            
126            LFOv1Unit::Trigger();
127        }
128        
129        void PitchLFOUnit::Trigger() {
130            ::sfz::Region* const pRegion = pVoice->pRegion;
131            pLfoInfo->delay = pRegion->pitchlfo_delay;
132            pLfoInfo->freq = pRegion->pitchlfo_freq;
133            pLfoInfo->pitch = pRegion->pitchlfo_depth;
134            
135            LFOv1Unit::Trigger();
136        }
137        
138        void FilLFOUnit::Trigger() {
139            ::sfz::Region* const pRegion = pVoice->pRegion;
140            pLfoInfo->delay = pRegion->fillfo_delay;
141            pLfoInfo->freq = pRegion->fillfo_freq;
142            pLfoInfo->cutoff = pRegion->fillfo_depth;
143            
144            LFOv1Unit::Trigger();
145        }
146    
147    
148      EndpointUnit::EndpointUnit(SfzSignalUnitRack* rack): EndpointSignalUnit(rack) {      EndpointUnit::EndpointUnit(SfzSignalUnitRack* rack): EndpointSignalUnit(rack) {
# Line 138  namespace LinuxSampler { namespace sfz { Line 177  namespace LinuxSampler { namespace sfz {
177              vol += eg->GetLevel() * (eg->pEGInfo->amplitude / 100.0f);              vol += eg->GetLevel() * (eg->pEGInfo->amplitude / 100.0f);
178          }          }
179                    
180            AmpLFOUnit* u = &(GetRack()->suAmpLFO);
181            vol *= u->Active() ? ::sf2::ToRatio((u->GetLevel() * u->pLfoInfo->volume) * 10.0) : 1;
182            
183          return vol;          return vol;
184      }      }
185            
186      float EndpointUnit::GetFilterCutoff() {      float EndpointUnit::GetFilterCutoff() {
187          float val = 1;          float val;
188            
189            FilLFOUnit* u = &(GetRack()->suFilLFO);
190            val = u->Active() ? RTMath::CentsToFreqRatioUnlimited(u->GetLevel() * u->pLfoInfo->cutoff) : 1;
191                    
192          for (int i = 0; i < GetRack()->filLFOs.size(); i++) {          for (int i = 0; i < GetRack()->filLFOs.size(); i++) {
193              LFOv2Unit* lfo = GetRack()->filLFOs[i];              LFOv2Unit* lfo = GetRack()->filLFOs[i];
# Line 156  namespace LinuxSampler { namespace sfz { Line 201  namespace LinuxSampler { namespace sfz {
201      }      }
202            
203      float EndpointUnit::GetPitch() {      float EndpointUnit::GetPitch() {
204            double p;
205          EGv1Unit* u = &(GetRack()->suPitchEG);          EGv1Unit* u = &(GetRack()->suPitchEG);
206          double pitchEg = u->Active() ? RTMath::CentsToFreqRatioUnlimited(u->GetLevel() * u->depth) : 1;          p = u->Active() ? RTMath::CentsToFreqRatioUnlimited(u->GetLevel() * u->depth) : 1;
207          return pitchEg;          
208            PitchLFOUnit* u2 = &(GetRack()->suPitchLFO);
209            p *= u2->Active() ? RTMath::CentsToFreqRatioUnlimited(u2->GetLevel() * u2->pLfoInfo->pitch) : 1;
210            
211            return p;
212      }      }
213            
214      float EndpointUnit::GetResonance() {      float EndpointUnit::GetResonance() {
# Line 194  namespace LinuxSampler { namespace sfz { Line 244  namespace LinuxSampler { namespace sfz {
244      SfzSignalUnitRack::SfzSignalUnitRack(Voice* voice)      SfzSignalUnitRack::SfzSignalUnitRack(Voice* voice)
245          : SignalUnitRack(MaxUnitCount), pVoice(voice), suEndpoint(this), suVolEG(this), suPitchEG(this),          : SignalUnitRack(MaxUnitCount), pVoice(voice), suEndpoint(this), suVolEG(this), suPitchEG(this),
246          EGs(maxEgCount), volEGs(maxEgCount), pitchEGs(maxEgCount),          EGs(maxEgCount), volEGs(maxEgCount), pitchEGs(maxEgCount),
247            suAmpLFO(this), suPitchLFO(this), suFilLFO(this),
248          LFOs(maxLfoCount), filLFOs(maxLfoCount), resLFOs(maxLfoCount), panLFOs(maxLfoCount)          LFOs(maxLfoCount), filLFOs(maxLfoCount), resLFOs(maxLfoCount), panLFOs(maxLfoCount)
249      {      {
250          suEndpoint.pVoice = suVolEG.pVoice = suPitchEG.pVoice = voice;          suEndpoint.pVoice = suVolEG.pVoice = suPitchEG.pVoice = voice;
251            suAmpLFO.pVoice = suPitchLFO.pVoice = suFilLFO.pVoice = voice;
252                    
253          for (int i = 0; i < EGs.capacity(); i++) {          for (int i = 0; i < EGs.capacity(); i++) {
254              EGs[i] = new EGv2Unit(this);              EGs[i] = new EGv2Unit(this);
# Line 281  namespace LinuxSampler { namespace sfz { Line 333  namespace LinuxSampler { namespace sfz {
333                    
334          Units.add(&suVolEG);          Units.add(&suVolEG);
335          Units.add(&suPitchEG);          Units.add(&suPitchEG);
336            Units.add(&suPitchLFO);
337            Units.add(&suAmpLFO);
338            Units.add(&suFilLFO);
339                    
340          for (int i = 0; i < EGs.size(); i++) {          for (int i = 0; i < EGs.size(); i++) {
341              Units.add(EGs[i]);              Units.add(EGs[i]);

Legend:
Removed from v.2220  
changed lines
  Added in v.2221

  ViewVC Help
Powered by ViewVC