diff options
author | gramanas <anastasis.gramm2@gmail.com> | 2023-07-07 01:09:12 +0300 |
---|---|---|
committer | gramanas <anastasis.gramm2@gmail.com> | 2023-07-07 01:09:12 +0300 |
commit | c8cd7f9298de876f2046fddd2e322a63c421a505 (patch) | |
tree | 1b764fed928592f8f3465e9ef28552b451efad8a /src/osc_tri.c | |
parent | f170fb058a07175e6e753f2a6d20283dc7200a88 (diff) | |
download | synth-project-c8cd7f9298de876f2046fddd2e322a63c421a505.tar.gz synth-project-c8cd7f9298de876f2046fddd2e322a63c421a505.tar.bz2 synth-project-c8cd7f9298de876f2046fddd2e322a63c421a505.zip |
suppa
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); +} |