summaryrefslogtreecommitdiff
path: root/sw/Core/Src/lfo.h
diff options
context:
space:
mode:
Diffstat (limited to 'sw/Core/Src/lfo.h')
-rwxr-xr-xsw/Core/Src/lfo.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/sw/Core/Src/lfo.h b/sw/Core/Src/lfo.h
new file mode 100755
index 0000000..74b4b12
--- /dev/null
+++ b/sw/Core/Src/lfo.h
@@ -0,0 +1,13 @@
+typedef struct lfo {
+ float r, i, a;
+} lfo;
+#define LFOINIT(f) {1.f,0.f,(f)+(f)}
+__STATIC_FORCEINLINE void lfo_setfreq(lfo *l, float f) {
+ l->a = f + f;
+}
+__STATIC_FORCEINLINE float lfo_next(lfo *l) {
+ l->r -= l->a * l->i;
+ l->i += l->a * l->r;
+ return l->r;
+}
+