/[svn]/linuxsampler/trunk/src/engines/common/LFO.h
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/common/LFO.h

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

revision 246 by schoenebeck, Sun Sep 19 14:12:55 2004 UTC revision 319 by schoenebeck, Mon Dec 13 00:46:42 2004 UTC
# Line 85  namespace LinuxSampler { Line 85  namespace LinuxSampler {
85               * @param Propagation - defines from which level the wave starts and which direction it grows with growing oscillator depth               * @param Propagation - defines from which level the wave starts and which direction it grows with growing oscillator depth
86               * @param pEventPool  - reference to an event pool which will be used to allocate Event objects               * @param pEventPool  - reference to an event pool which will be used to allocate Event objects
87               */               */
88              LFO(float Min, float Max, propagation_t Propagation, T_Manipulator* pManipulator, RTELMemoryPool<Event>* pEventPool) {              LFO(float Min, float Max, propagation_t Propagation, T_Manipulator* pManipulator, Pool<Event>* pEventPool) {
89                  this->Propagation   = Propagation;                  this->Propagation   = Propagation;
90                  this->pEvents       = new RTEList<Event>(pEventPool);                  this->pEvents       = new RTList<Event>(pEventPool);
91                  this->ExtController = 0;                  this->ExtController = 0;
92                  this->Min           = Min;                  this->Min           = Min;
93                  this->Max           = Max;                  this->Max           = Max;
# Line 104  namespace LinuxSampler { Line 104  namespace LinuxSampler {
104               *               *
105               * @param Samples - total number of sample points to be rendered in               * @param Samples - total number of sample points to be rendered in
106               *                  this audio fragment cycle by the audio engine               *                  this audio fragment cycle by the audio engine
107                 * @returns true if modulation is active (LFO depth <> 0.0)
108               */               */
109              void Process(uint Samples) {              bool Process(uint Samples) {
110                  Event* pCtrlEvent = pEvents->first();                  RTList<Event>::Iterator itCtrlEvent = pEvents->first();
111                  int iSample = TriggerDelay;                  int iSample = TriggerDelay;
112                    bool result;
113                  while (iSample < Samples) {                  while (iSample < Samples) {
114                      int process_break = Samples;                      int process_break = Samples;
115                      if (pCtrlEvent && pCtrlEvent->FragmentPos() <= process_break) process_break = pCtrlEvent->FragmentPos();                      if (itCtrlEvent && itCtrlEvent->FragmentPos() <= process_break) process_break = itCtrlEvent->FragmentPos();
116    
117                      if (Coeff > 0.0f) { // level going up                      if (Coeff > 0.0f) { // level going up
118                          while (iSample < process_break && Level <= CurrentMax) {                          while (iSample < process_break && Level <= CurrentMax) {
# Line 122  namespace LinuxSampler { Line 124  namespace LinuxSampler {
124                              Coeff = -Coeff; // invert direction                              Coeff = -Coeff; // invert direction
125                              Level += 2.0f * Coeff;                              Level += 2.0f * Coeff;
126                          }                          }
127                            result = true; // modulation active
128                      }                      }
129                      else if (Coeff < 0.0f) { // level going down                      else if (Coeff < 0.0f) { // level going down
130                          while (iSample < process_break && Level >= CurrentMin) {                          while (iSample < process_break && Level >= CurrentMin) {
# Line 133  namespace LinuxSampler { Line 136  namespace LinuxSampler {
136                              Coeff = -Coeff; // invert direction                              Coeff = -Coeff; // invert direction
137                              Level += 2.0f * Coeff;                              Level += 2.0f * Coeff;
138                          }                          }
139                            result = true; // modulation active
140                      }                      }
141                      else { // no modulation at all (Coeff = 0.0)                      else { // no modulation at all (Coeff = 0.0)
142                          switch (Propagation) {                          switch (Propagation) {
# Line 150  namespace LinuxSampler { Line 154  namespace LinuxSampler {
154                              pManipulator->ApplyLevel(Level, iSample);                              pManipulator->ApplyLevel(Level, iSample);
155                              iSample++;                              iSample++;
156                          }                          }
157                            result = false; // modulation inactive
158                      }                      }
159    
160                      if (pCtrlEvent) {                      if (itCtrlEvent) {
161                          RecalculateCoeff(pCtrlEvent->Param.CC.Value);                          RecalculateCoeff(itCtrlEvent->Param.CC.Value);
162                          pCtrlEvent = pEvents->next();                          ++itCtrlEvent;
163                      }                      }
164                  }                  }
165                  TriggerDelay = 0;                  TriggerDelay = 0;
166                  pEvents->clear();                  pEvents->clear();
167                    return result;
168              }              }
169    
170              /**              /**
# Line 223  namespace LinuxSampler { Line 229  namespace LinuxSampler {
229               *               *
230               * @param pEvent - control change event of external controller               * @param pEvent - control change event of external controller
231               */               */
232              inline void SendEvent(Event* pEvent) {              inline void SendEvent(Pool<Event>::Iterator itEvent) {
233                  if (ExtController && pEvent->FragmentPos() >= this->TriggerDelay) pEvents->alloc_assign(*pEvent);                  if (ExtController && itEvent->FragmentPos() >= this->TriggerDelay && !pEvents->poolIsEmpty()) *pEvents->allocAppend() = *itEvent;
234              }              }
235    
236              /**              /**
# Line 235  namespace LinuxSampler { Line 241  namespace LinuxSampler {
241              }              }
242    
243          protected:          protected:
244              RTEList<Event>* pEvents;              RTList<Event>*  pEvents;
245              propagation_t   Propagation;              propagation_t   Propagation;
246              int             TriggerDelay;              int             TriggerDelay;
247              float           Min;              float           Min;

Legend:
Removed from v.246  
changed lines
  Added in v.319

  ViewVC Help
Powered by ViewVC