From 0ea48752390228224e7f25575b096efc0aacd70b Mon Sep 17 00:00:00 2001 From: gramanas Date: Thu, 31 Aug 2023 01:06:56 +0300 Subject: Lets work on generators --- src/osc_digisaw.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/osc_digisaw.c (limited to 'src/osc_digisaw.c') 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); +} -- cgit v1.2.3