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

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

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

revision 3117 by schoenebeck, Mon Oct 31 00:05:00 2016 UTC revision 3118 by schoenebeck, Fri Apr 21 13:33:03 2017 UTC
# Line 58  namespace LinuxSampler { Line 58  namespace LinuxSampler {
58               *               *
59               * @param ExtControlValue - new external controller value               * @param ExtControlValue - new external controller value
60               */               */
61              inline void update(const uint16_t& ExtControlValue) {              inline void updateByMIDICtrlValue(const uint16_t& ExtControlValue) {
62                    this->ExtControlValue = ExtControlValue;
63    
64                  //const unsigned int intLimit = (unsigned int) -1; // all 0xFFFF...                  //const unsigned int intLimit = (unsigned int) -1; // all 0xFFFF...
65                  const float max = this->InternalDepth + ExtControlValue * this->ExtControlDepthCoeff;                  const float max = (this->InternalDepth + ExtControlValue * this->ExtControlDepthCoeff) * this->ScriptDepthFactor;
66                  if (RANGE == range_unsigned) {                  if (RANGE == range_unsigned) {
67                      normalizer = max / 2.0f;                      normalizer = max / 2.0f;
68                  } else { // signed range                  } else { // signed range
# Line 82  namespace LinuxSampler { Line 84  namespace LinuxSampler {
84               *                          audio output signal               *                          audio output signal
85               */               */
86              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) {
87                    this->Frequency            = Frequency;
88                  this->InternalDepth        = (InternalDepth / 1200.0f) * this->Max;                  this->InternalDepth        = (InternalDepth / 1200.0f) * this->Max;
89                  this->ExtControlDepthCoeff = (((float) ExtControlDepth / 1200.0f) / 127.0f) * this->Max;                  this->ExtControlDepthCoeff = (((float) ExtControlDepth / 1200.0f) / 127.0f) * this->Max;
90                    this->ScriptFrequencyFactor = this->ScriptDepthFactor = 1.f; // reset for new voice
91    
92                  const unsigned int intLimit = (unsigned int) -1; // all 0xFFFF...                  const unsigned int intLimit = (unsigned int) -1; // all 0xFFFF...
93                  const float r = Frequency / (float) SampleRate; // frequency alteration quotient                  const float freq = Frequency * this->ScriptFrequencyFactor;
94                    const float r = freq / (float) SampleRate; // frequency alteration quotient
95                  c = (int) (intLimit * r);                  c = (int) (intLimit * r);
96                  c2 = (2.0f * M_PI) / (float) intLimit;                  c2 = (2.0f * M_PI) / (float) intLimit;
97    
# Line 105  namespace LinuxSampler { Line 110  namespace LinuxSampler {
110              }              }
111                            
112              void setFrequency(float Frequency, unsigned int SampleRate) {              void setFrequency(float Frequency, unsigned int SampleRate) {
113                    this->Frequency = Frequency;
114                    const float freq = Frequency * this->ScriptFrequencyFactor;
115                  const unsigned int intLimit = (unsigned int) -1; // all 0xFFFF...                  const unsigned int intLimit = (unsigned int) -1; // all 0xFFFF...
116                  float r = Frequency / (float) SampleRate; // frequency alteration quotient                  float r = freq / (float) SampleRate; // frequency alteration quotient
117                  c = (int) (intLimit * r);                  c = (int) (intLimit * r);
118              }              }
119    
120                void setScriptDepthFactor(float factor) {
121                    this->ScriptDepthFactor = factor;
122                    updateByMIDICtrlValue(this->ExtControlValue);
123                }
124    
125                void setScriptFrequencyFactor(float factor, unsigned int SampleRate) {
126                    this->ScriptFrequencyFactor = factor;
127                    setFrequency(this->Frequency, SampleRate);
128                }
129    
130          protected:          protected:
131              unsigned int uiLevel;              unsigned int uiLevel;
132              int   c;              int   c;

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

  ViewVC Help
Powered by ViewVC