diff options
Diffstat (limited to 'src/osc_tri.c')
-rw-r--r-- | src/osc_tri.c | 30 |
1 files changed, 30 insertions, 0 deletions
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); +} |