diff options
author | gramanas <anastasis.gramm2@gmail.com> | 2023-08-31 01:06:56 +0300 |
---|---|---|
committer | gramanas <anastasis.gramm2@gmail.com> | 2023-08-31 01:07:16 +0300 |
commit | 0ea48752390228224e7f25575b096efc0aacd70b (patch) | |
tree | 62756ecadab1459dc02fa19e42c3cbe81deb63e2 /src/osc_digisaw.c | |
parent | 42479d2ed8fcbad5fb3ffb52553dad05a329590f (diff) | |
download | synth-project-0ea48752390228224e7f25575b096efc0aacd70b.tar.gz synth-project-0ea48752390228224e7f25575b096efc0aacd70b.tar.bz2 synth-project-0ea48752390228224e7f25575b096efc0aacd70b.zip |
Lets work on generators
Diffstat (limited to 'src/osc_digisaw.c')
-rw-r--r-- | src/osc_digisaw.c | 45 |
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); +} |