summaryrefslogtreecommitdiff
path: root/mix.c
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2021-07-11 18:45:38 +0800
committerJSDurand <mmemmew@gmail.com>2021-07-11 18:45:38 +0800
commit6c358a842baaf6d211a5c8c1717d815e7813ed96 (patch)
treec78122d49e75a540a4f6054b224a90738b554606 /mix.c
First commit
Now I have a kind of piano like instrument. A violin-like instrument is being constructed.
Diffstat (limited to 'mix.c')
-rw-r--r--mix.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/mix.c b/mix.c
new file mode 100644
index 0000000..ae1c1ab
--- /dev/null
+++ b/mix.c
@@ -0,0 +1,22 @@
+#include "mix.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+/* Mix different sounds together. For now this is just a simple
+ averaging function. But more sophostigated mixing techniques such
+ as filters and reverbs might get includede in the future. */
+
+U_ATTR
+Pulse
+mix_sound(Wave w, LENT n)
+{
+ Pulse result = 0.0f;;
+
+ for (LENT i = 0; i < n;)
+ result += *(w+i++);
+
+ result /= (float) n;
+
+ return result;
+}
+