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

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

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

revision 2227 by iliev, Wed Aug 3 17:11:40 2011 UTC revision 3118 by schoenebeck, Fri Apr 21 13:33:03 2017 UTC
# Line 63  namespace LinuxSampler { Line 63  namespace LinuxSampler {
63               *               *
64               * @param ExtControlValue - new external controller value               * @param ExtControlValue - new external controller value
65               */               */
66              inline void update(const uint16_t& ExtControlValue) {              inline void updateByMIDICtrlValue(const uint16_t& ExtControlValue) {
67                    this->ExtControlValue = ExtControlValue;
68    
69                  const unsigned int intLimit = (unsigned int) -1; // all 0xFFFF...                  const unsigned int intLimit = (unsigned int) -1; // all 0xFFFF...
70                  const float max = this->InternalDepth + ExtControlValue * this->ExtControlDepthCoeff;                  const float max = (this->InternalDepth + ExtControlValue * this->ExtControlDepthCoeff) * this->ScriptDepthFactor;
71                  if (RANGE == range_unsigned) {                  if (RANGE == range_unsigned) {
72                      normalizer = max / (float) intLimit;                      normalizer = max / (float) intLimit;
73                  } else { // signed range                  } else { // signed range
# Line 88  namespace LinuxSampler { Line 90  namespace LinuxSampler {
90               *                          audio output signal               *                          audio output signal
91               */               */
92              virtual void trigger(float Frequency, start_level_t StartLevel, uint16_t InternalDepth, uint16_t ExtControlDepth, bool FlipPhase, unsigned int SampleRate) {              virtual void trigger(float Frequency, start_level_t StartLevel, uint16_t InternalDepth, uint16_t ExtControlDepth, bool FlipPhase, unsigned int SampleRate) {
93                    this->Frequency            = Frequency;
94                  this->InternalDepth        = (InternalDepth / 1200.0f) * this->Max;                  this->InternalDepth        = (InternalDepth / 1200.0f) * this->Max;
95                  this->ExtControlDepthCoeff = (((float) ExtControlDepth / 1200.0f) / 127.0f) * this->Max;                  this->ExtControlDepthCoeff = (((float) ExtControlDepth / 1200.0f) / 127.0f) * this->Max;
96                    this->ScriptFrequencyFactor = this->ScriptDepthFactor = 1.f; // reset for new voice
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 freq = Frequency * this->ScriptFrequencyFactor;
100                    const float r = freq / (float) SampleRate; // frequency alteration quotient
101                  c = (int) (intLimit * r);                  c = (int) (intLimit * r);
102    
103                  uiLevel = 0;                  uiLevel = 0;
# Line 111  namespace LinuxSampler { Line 116  namespace LinuxSampler {
116              }              }
117                            
118              void setFrequency(float Frequency, unsigned int SampleRate) {              void setFrequency(float Frequency, unsigned int SampleRate) {
119                    this->Frequency = Frequency;
120                    const float freq = Frequency * this->ScriptFrequencyFactor;
121                  const unsigned int intLimit = (unsigned int) -1; // all 0xFFFF...                  const unsigned int intLimit = (unsigned int) -1; // all 0xFFFF...
122                  float r = Frequency / (float) SampleRate; // frequency alteration quotient                  float r = freq / (float) SampleRate; // frequency alteration quotient
123                  c = (int) (intLimit * r);                  c = (int) (intLimit * r);
124              }              }
125    
126                void setScriptDepthFactor(float factor) {
127                    this->ScriptDepthFactor = factor;
128                    updateByMIDICtrlValue(this->ExtControlValue);
129                }
130    
131                void setScriptFrequencyFactor(float factor, unsigned int SampleRate) {
132                    this->ScriptFrequencyFactor = factor;
133                    setFrequency(this->Frequency, SampleRate);
134                }
135    
136          protected:          protected:
137              unsigned int uiLevel;              unsigned int uiLevel;
138              int   c;              int   c;

Legend:
Removed from v.2227  
changed lines
  Added in v.3118

  ViewVC Help
Powered by ViewVC