summaryrefslogtreecommitdiffstats
path: root/src/osc_sqr.c
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2023-09-14 23:49:54 +0300
committergramanas <anastasis.gramm2@gmail.com>2023-09-14 23:49:54 +0300
commita7c39399e3ec051f210d9e991fe0112d0f988817 (patch)
treefe22b9e8b13ec3053cecca006ffaa88912188776 /src/osc_sqr.c
parent51821bb2e9b67fc70486a4ee8dcbc88971adc3b6 (diff)
downloadsynth-project-a7c39399e3ec051f210d9e991fe0112d0f988817.tar.gz
synth-project-a7c39399e3ec051f210d9e991fe0112d0f988817.tar.bz2
synth-project-a7c39399e3ec051f210d9e991fe0112d0f988817.zip
Add sqr osc file
Diffstat (limited to 'src/osc_sqr.c')
-rw-r--r--src/osc_sqr.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/osc_sqr.c b/src/osc_sqr.c
new file mode 100644
index 0000000..9b68059
--- /dev/null
+++ b/src/osc_sqr.c
@@ -0,0 +1,20 @@
+#include "osc.h"
+
+osc_t OSC_sqr = {
+ .name = "f_sqr",
+ .len = 1,
+ .start = 0,
+ .end = 1,
+};
+
+float
+osc_sqr(float offset)
+{
+ return offset < 0.5 ? -1 : 1;
+}
+
+float
+osc_sqr_next(float f, float offset)
+{
+ return osc_next_offset(&OSC_sqr, f, offset);
+}