summaryrefslogblamecommitdiffstats
path: root/src/osc_digisaw.c
blob: b71a9e311fda837284bdb0059a3b8cdb9bb00c68 (plain) (tree)












































                                                                        
#include "osc.h"

osc_t OSC_digisaw = MAKE_OSC("f_digisaw", 21, WAVE);

OSC_COMMON(digisaw)

static float
digisaw(int index)
{
  if (index == 0) return -1.0f;
  else if (index == 1) return -0.9f;
  else if (index == 2) return -0.8f;
  else if (index == 3) return -0.7f;
  else if (index == 4) return -0.6f;
  else if (index == 5) return -0.5f;
  else if (index == 6) return -0.4f;
  else if (index == 7) return -0.3f;
  else if (index == 8) return -0.2f;
  else if (index == 9) return -0.1f;
  else if (index == 10) return 0.0f;
  else if (index == 11) return 0.1f;
  else if (index == 12) return 0.2f;
  else if (index == 13) return 0.3f;
  else if (index == 14) return 0.4f;
  else if (index == 15) return 0.5f;
  else if (index == 16) return 0.6f;
  else if (index == 17) return 0.7f;
  else if (index == 18) return 0.8f;
  else if (index == 19) return 0.9f;
  else if (index == 20) return 1.0f;
}

float
osc_digisaw(float offset)
{
  return osc_interpolate(offset,
                         digisaw((int)offset),
                         digisaw(osc_next_index(&OSC_digisaw, offset)));
}

float
osc_digisaw_next(float f, float offset)
{
  return osc_next_offset(&OSC_digisaw, f, offset);
}