Code: Select all
double value = 0.0;
switch (mWave) {
case SINE:
{
value = sin(mPhase);
break;
}
case SQUARE:
{
if (mPhase <= mPI) {
value = 1.0;
}
else {
value = -1.0;
}
break;
}
case SAW_UP:
{
value = (2.0 * mPhase / mTwoPI) - 1.0;
break;
}
case SAW_DOWN:
{
value = 1.0 - (2.0 * mPhase / mTwoPI);
break;
}
case TRIANGLE:
{
value = (2.0 * mPhase / mTwoPI) - 1.0;
value = 2.0 * (0.5 - fabs(value));
break;
}
}
mPhase += mPhaseIncrement;
while (mPhase >= mTwoPI) {
mPhase -= mTwoPI;
}
But, is it so bad used as LFO oscillator that will modulate a parameter? Did you make alias-free LFO generators? And why you should do it?
Just learning