summaryrefslogtreecommitdiffstats
path: root/src/osc_sin.c
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2023-07-07 01:09:12 +0300
committergramanas <anastasis.gramm2@gmail.com>2023-07-07 01:09:12 +0300
commitc8cd7f9298de876f2046fddd2e322a63c421a505 (patch)
tree1b764fed928592f8f3465e9ef28552b451efad8a /src/osc_sin.c
parentf170fb058a07175e6e753f2a6d20283dc7200a88 (diff)
downloadsynth-project-c8cd7f9298de876f2046fddd2e322a63c421a505.tar.gz
synth-project-c8cd7f9298de876f2046fddd2e322a63c421a505.tar.bz2
synth-project-c8cd7f9298de876f2046fddd2e322a63c421a505.zip
suppa
Diffstat (limited to 'src/osc_sin.c')
-rw-r--r--src/osc_sin.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/osc_sin.c b/src/osc_sin.c
new file mode 100644
index 0000000..66478d2
--- /dev/null
+++ b/src/osc_sin.c
@@ -0,0 +1,22 @@
+#include "osc.h"
+
+osc_t OSC_sin = {
+ .name = "f_sin",
+ .len = 20000,
+ .start = 0,
+ .end = 20000,
+};
+
+float
+osc_sin(float offset)
+{
+ return osc_interpolate(offset,
+ sin(2 * M_PI * (int)offset / OSC_sin.len),
+ sin(2 * M_PI * osc_next_index(&OSC_sin, offset) / OSC_sin.len));
+}
+
+float
+osc_sin_next(float f, float offset)
+{
+ return osc_next_offset(&OSC_sin, f, offset);
+}