Added LFO Sawtooth

feature/AudioEffectAnalogChorus
Steve Lascos 5 years ago
parent d954f0aced
commit 362d0928d2
  1. 5
      src/LibBasicFunctions.h
  2. 11
      src/common/LowFrequencyOscillator.cpp

@ -477,8 +477,9 @@ private:
const T TWO_PI_F = 2.0 * 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899; ///< 2*PI
const T PI_DIV2_F = 0.5 * 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899; ///< PI/2
const T THREE_PI_DIV2_F = 1.5 * 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899; ///< 3*PI/2
const float TRIANGE_POS_SLOPE = 2.0f/PI_F;
const float TRIANGE_NEG_SLOPE = -2.0f/PI_F;
const T TRIANGE_POS_SLOPE = 2.0f/PI_F;
const T TRIANGE_NEG_SLOPE = -2.0f/PI_F;
const T SAWTOOTH_SLOPE = -1.0f/PI_F;
};
} // BALibrary

@ -116,13 +116,20 @@ T *LowFrequencyOscillatorVector<T>::getNextVector()
for (auto i=0; i<AUDIO_BLOCK_SAMPLES; i++) {
if (m_phaseVec[i] < PI_F) {
// y = (-2/pi)*x + 1.0
m_outputVec[i] = TRIANGE_NEG_SLOPE * m_phaseVec[i] + 1.0f;
m_outputVec[i] = (TRIANGE_NEG_SLOPE * m_phaseVec[i]) + 1.0f;
} else {
// y = (2/pi)*x -1.0
m_outputVec[i] = TRIANGE_POS_SLOPE * (m_phaseVec[i]-PI_F) - 1.0f;
m_outputVec[i] = (TRIANGE_POS_SLOPE * (m_phaseVec[i]-PI_F)) - 1.0f;
}
}
break;
case Waveform::SAWTOOTH :
// A sawtooth is made up of a single equation of the form y=mx+b
// where m = -pi + 1.0
for (auto i=0; i<AUDIO_BLOCK_SAMPLES; i++) {
m_outputVec[i] = (SAWTOOTH_SLOPE * m_phaseVec[i]) + 1.0f;
}
break;
case Waveform::RANDOM :
break;
default :

Loading…
Cancel
Save