summaryrefslogtreecommitdiffstats
path: root/src/osc_digisaw.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/osc_digisaw.c')
-rw-r--r--src/osc_digisaw.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/osc_digisaw.c b/src/osc_digisaw.c
new file mode 100644
index 0000000..b71a9e3
--- /dev/null
+++ b/src/osc_digisaw.c
@@ -0,0 +1,45 @@
+#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);
+}