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

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

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

revision 717 by schoenebeck, Sun Jul 24 10:26:17 2005 UTC revision 718 by schoenebeck, Sun Jul 24 15:05:30 2005 UTC
# Line 66  namespace LinuxSampler { Line 66  namespace LinuxSampler {
66                  const unsigned int intLimit = (unsigned int) -1; // all 0xFFFF...                  const unsigned int intLimit = (unsigned int) -1; // all 0xFFFF...
67                  const float max = InternalDepth + ExtControlValue * ExtControlDepthCoeff;                  const float max = InternalDepth + ExtControlValue * ExtControlDepthCoeff;
68                  if (RANGE == range_unsigned) {                  if (RANGE == range_unsigned) {
69                      normalizer = max / (float) intLimit * 0.5f;                      normalizer = max / (float) intLimit;
70                  } else { // signed range                  } else { // signed range
71                      normalizer = max / (float) intLimit * 0.25f;                      normalizer = max / (float) intLimit * 4.0f;
72                      offset     = -max;                      offset     = -max;
73                  }                  }
74              }              }
# Line 82  namespace LinuxSampler { Line 82  namespace LinuxSampler {
82               * @param ExtControlDepth - defines how strong the external MIDI               * @param ExtControlDepth - defines how strong the external MIDI
83               *                          controller has influence on the               *                          controller has influence on the
84               *                          oscillator amplitude               *                          oscillator amplitude
85               * @param FlipPhase       - inverts the oscillator wave               * @param FlipPhase       - inverts the oscillator wave against
86                 *                          a horizontal axis
87               * @param SampleRate      - current sample rate of the engines               * @param SampleRate      - current sample rate of the engines
88               *                          audio output signal               *                          audio output signal
89               */               */
90              void trigger(float Frequency, start_level_t StartLevel, uint16_t InternalDepth, uint16_t ExtControlDepth, bool FlipPhase, unsigned int SampleRate) {              void trigger(float Frequency, start_level_t StartLevel, uint16_t InternalDepth, uint16_t ExtControlDepth, bool FlipPhase, unsigned int SampleRate) {
91                  this->InternalDepth        = (InternalDepth / 1200.0f) * Max;                  this->InternalDepth        = (InternalDepth / 1200.0f) * Max;
92                  this->ExtControlDepthCoeff = (((float) ExtControlDepth / 1200.0f) / 127.0f) * Max;                  this->ExtControlDepthCoeff = (((float) ExtControlDepth / 1200.0f) / 127.0f) * Max;
93                    if (RANGE == range_unsigned) {
94                        this->InternalDepth        *= 2.0f;
95                        this->ExtControlDepthCoeff *= 2.0f;
96                    }
97    
98                  const unsigned int intLimit = (unsigned int) -1; // all 0xFFFF...                  const unsigned int intLimit = (unsigned int) -1; // all 0xFFFF...
99                  const float r = Frequency / (float) SampleRate; // frequency alteration quotient                  const float r = Frequency / (float) SampleRate; // frequency alteration quotient
100                  c = (int) (intLimit * r);                  c = (int) (intLimit * r);
101    
102                  switch (StartLevel) {                  switch (StartLevel) {
103                      case start_level_max: {                      case start_level_max:
104                          c = -c; // wave should go down                          iLevel = (FlipPhase) ? 0 : intLimit >> 1;
                         if (RANGE == range_unsigned)  
                             iLevel = intLimit;  
                         else /* signed range */  
                             iLevel = intLimit >> 1;  
105                          break;                          break;
106                      }                      case start_level_mid:
                     case start_level_mid: {  
107                          if (FlipPhase) c = -c; // wave should go down                          if (FlipPhase) c = -c; // wave should go down
108                          if (RANGE == range_unsigned)                          iLevel = intLimit >> 2;
                             iLevel = intLimit >> 1;  
                         else /* signed range */  
                             iLevel = 0;  
109                          break;                          break;
110                      }                      case start_level_min:
111                      case start_level_min: {                          iLevel = (FlipPhase) ? intLimit >> 1 : 0;
                         if (RANGE == range_unsigned)  
                             iLevel = 0;  
                         else /* signed range */  
                             iLevel = -(intLimit >> 1);  
112                          break;                          break;
                     }  
113                  }                  }
114              }              }
115    

Legend:
Removed from v.717  
changed lines
  Added in v.718

  ViewVC Help
Powered by ViewVC