From c8cd7f9298de876f2046fddd2e322a63c421a505 Mon Sep 17 00:00:00 2001 From: gramanas Date: Fri, 7 Jul 2023 01:09:12 +0300 Subject: suppa --- src/osc_tri.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/osc_tri.c (limited to 'src/osc_tri.c') diff --git a/src/osc_tri.c b/src/osc_tri.c new file mode 100644 index 0000000..c4a56f5 --- /dev/null +++ b/src/osc_tri.c @@ -0,0 +1,30 @@ +#include "osc.h" + +osc_t OSC_tri = { + .name = "w_triangle", + .start = 0, + .end = 2, + .len = 2, +}; + +float +tri(int index) +{ + if (index == 0) return -1.0f; + else if (index == 1) return 1.0f; + else return 0.0f; +} + +float +osc_tri(float offset) +{ + return osc_interpolate(offset, + tri((int)offset), + tri(osc_next_index(&OSC_tri, offset))); +} + +float +osc_tri_next(float f, float offset) +{ + return osc_next_offset(&OSC_tri, f, offset); +} -- cgit v1.2.3