diff --git a/blooblib/blooblib.vcxproj b/blooblib/blooblib.vcxproj
index e5c36ac..15b2b49 100644
--- a/blooblib/blooblib.vcxproj
+++ b/blooblib/blooblib.vcxproj
@@ -19,7 +19,9 @@
+
+
@@ -31,19 +33,23 @@
+
+
+
+
diff --git a/blooblib/blooblib.vcxproj.filters b/blooblib/blooblib.vcxproj.filters
index c522456..87aede0 100644
--- a/blooblib/blooblib.vcxproj.filters
+++ b/blooblib/blooblib.vcxproj.filters
@@ -45,6 +45,12 @@
Source Files
+
+ Source Files
+
+
+ Source Files
+
@@ -89,6 +95,18 @@
Header Files
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
diff --git a/blooblib/gen_wave.py b/blooblib/gen_wave.py
new file mode 100644
index 0000000..1325964
--- /dev/null
+++ b/blooblib/gen_wave.py
@@ -0,0 +1,21 @@
+import math
+
+def sin(i):
+ return math.sin(i / 256.0 * math.pi * 2)
+
+def sqr(i):
+ if i < 128:
+ return -1.0
+ else:
+ return 1.0
+
+
+def to_str(i):
+ return hex(int(((i + 1.0)/2) * 65535) - 32768)
+
+def note_to_freq(i): #16ths of a tone starting at c0
+ return hex(round(2**(i/16.0/12)*16.3516))
+
+#print(", ".join(list(map(to_str, map(sqr, range(256))))))
+
+print(", ".join(list(map(note_to_freq, range(120*16)))))
\ No newline at end of file
diff --git a/blooblib/include/audio.h b/blooblib/include/audio.h
new file mode 100644
index 0000000..267f206
--- /dev/null
+++ b/blooblib/include/audio.h
@@ -0,0 +1,19 @@
+#pragma once
+
+#include
+
+using sample = int16_t;
+
+struct ma_device;
+
+extern sample lookup_sin[256], lookup_square[256];
+
+struct audio {
+ audio(int samplerate);
+ ~audio();
+
+ void callback(sample* output, int frames);
+private:
+ int _samplerate;
+ ma_device* _device;
+};
\ No newline at end of file
diff --git a/blooblib/include/bloob.h b/blooblib/include/bloob.h
index 0b61299..0583436 100644
--- a/blooblib/include/bloob.h
+++ b/blooblib/include/bloob.h
@@ -1,5 +1,6 @@
#pragma once
+#include "audio.h"
#include "font.h"
#include "game.h"
#include "image.h"
@@ -9,6 +10,7 @@
#include "resource.h"
#include "resource_manager.h"
#include "settings.h"
+#include "synth.h"
#include "tileset.h"
#include "util.h"
#include "vec2.h"
diff --git a/blooblib/include/game.h b/blooblib/include/game.h
index 86afa98..9e9f885 100644
--- a/blooblib/include/game.h
+++ b/blooblib/include/game.h
@@ -1,5 +1,6 @@
#pragma once
+#include "audio.h"
#include "image.h"
#include "settings.h"
#include "resource_manager.h"
@@ -24,6 +25,7 @@ private:
int _fps;
int _argc;
char** _argv;
+ audio* _audio;
};
template
diff --git a/blooblib/include/keys.h b/blooblib/include/keys.h
new file mode 100644
index 0000000..d06e742
--- /dev/null
+++ b/blooblib/include/keys.h
@@ -0,0 +1,12 @@
+#pragma once
+
+enum class key {
+ a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z,
+ n0, n1, n2, n3, n4, n5, n6, n7, n8, n9,
+ np0, np1, np2, np3, np4, np5, np6, np7, np8, np9,
+ np_mul, np_div, np_add, np_seperator, np_enter,
+ f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12,
+ backspace, tab, enter, lshift, ltrl, caps, esc, space,
+ end, home, insert, del, page_up, page_down, up, down, left, right,
+
+};
\ No newline at end of file
diff --git a/blooblib/include/synth.h b/blooblib/include/synth.h
new file mode 100644
index 0000000..6deb82a
--- /dev/null
+++ b/blooblib/include/synth.h
@@ -0,0 +1,13 @@
+#pragma once
+
+#include
+
+//notes are 16th steps, starting at C-0
+extern uint16_t lookup_note_to_freq[16*120];
+
+struct phase_accumulator {
+ phase_accumulator();
+ uint16_t acc;
+ uint16_t inc;
+ void tick();
+};
\ No newline at end of file
diff --git a/blooblib/src/audio.cpp b/blooblib/src/audio.cpp
new file mode 100644
index 0000000..98a39b2
--- /dev/null
+++ b/blooblib/src/audio.cpp
@@ -0,0 +1,68 @@
+#include "audio.h"
+
+#include
+#include
+#include
+
+#include "math_util.h"
+#include "synth.h"
+
+#define MA_ENABLE_ONLY_SPECIFIC_BACKENDS
+#define MA_ENABLE_WASAPI
+#define MA_NO_DECODING
+#define MA_NO_ENCODING
+#define MA_NO_WAV
+#define MA_NO_FLAC
+#define MA_NO_MP3
+#define MA_NO_RESOURCE_MANAGER
+#define MA_NO_NODE_GRAPH
+#define MA_NO_ENGINE
+#define MA_NO_GENERATION
+#define MINIAUDIO_IMPLEMENTATION
+#include "miniaudio.h"
+
+void static_callback(ma_device* device, void* output, void const* input, ma_uint32 frame_count) {
+ (reinterpret_cast