summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Johnson <[email protected]>2025-03-18 10:21:45 -0400
committerSamuel Johnson <[email protected]>2025-03-18 10:21:45 -0400
commit3fac4d38c1f8a7fa9b58f47cc9a5e0689c8bb29d (patch)
treed1c7c67354783447bf4087a2c4db06d865ead3fd
But it was a beginning
-rw-r--r--.gitignore4
-rw-r--r--.gitmodules3
-rw-r--r--CMakeLists.txt21
-rw-r--r--mmband/adsr.c3
-rw-r--r--mmband/api/adsr.h17
-rw-r--r--mmband/api/filter.h0
-rw-r--r--mmband/api/instrument.h38
-rw-r--r--mmband/audio_player.c4
-rw-r--r--mmband/instrument.c4
-rw-r--r--mmband/waves/none.c0
-rw-r--r--mmband/waves/saw.c0
-rw-r--r--mmband/waves/sine.c0
-rw-r--r--mmband/waves/square.c0
-rw-r--r--mmband/waves/triangle.c0
-rw-r--r--mmband/waves/waveform.h12
m---------vendor/portaudio0
16 files changed, 106 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..321d3c9
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+.cache/
+build/
+
+*.swp
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..f84692f
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "vendor/portaudio"]
+ path = vendor/portaudio
+ url = https://github.com/PortAudio/portaudio
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..b476823
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,21 @@
+cmake_minimum_required(VERSION 3.12)
+project(mmband VERSION 0.1)
+
+set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
+
+add_library(${PROJECT_NAME} SHARED
+ ${PROJECT_NAME}/audio_player.c
+ ${PROJECT_NAME}/instrument.c
+)
+
+target_include_directories(${PROJECT_NAME} PUBLIC .)
+set_target_properties(${PROECT_NAME} PROPERTIES
+ C_STANDARD 99
+ C_STANDARD_REQUIRED ON
+ C_EXTENSIONS OFF
+ COMPILE_WARNING_AS_ERROR ON
+)
+
+add_subdirectory(vendor/portaudio)
+
+target_link_libraries(${PROJECT_NAME} portaudio)
diff --git a/mmband/adsr.c b/mmband/adsr.c
new file mode 100644
index 0000000..c50a5c1
--- /dev/null
+++ b/mmband/adsr.c
@@ -0,0 +1,3 @@
+#include <mmband/api/adsr.h>
+
+
diff --git a/mmband/api/adsr.h b/mmband/api/adsr.h
new file mode 100644
index 0000000..899d1fe
--- /dev/null
+++ b/mmband/api/adsr.h
@@ -0,0 +1,17 @@
+#ifndef MMBAND_ADSR_H
+#define MMBAND_ADSR_H
+
+typedef struct adsr *adsr_ref;
+
+adsr_ref adsr_new (float sample_rate);
+void adsr_free (adsr_ref adsr);
+
+void adsr_set_attack (adsr_ref adsr, float attack_rate);
+void adsr_set_decay (adsr_ref adsr, float decay_rate);
+void adsr_set_sustain (adsr_ref adsr, float sustain_level);
+void adsr_set_release (adsr_ref adsr, float release_rate);
+
+void adsr_set_asc_ratio (adsr_ref adsr, float ratio);
+void adsr_set_desc_ratio (adsr_ref adsr, float ratio);
+
+#endif
diff --git a/mmband/api/filter.h b/mmband/api/filter.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/mmband/api/filter.h
diff --git a/mmband/api/instrument.h b/mmband/api/instrument.h
new file mode 100644
index 0000000..3fd07da
--- /dev/null
+++ b/mmband/api/instrument.h
@@ -0,0 +1,38 @@
+#ifndef MMBAND_INSTRUMENT_H
+#define MMBAND_INSTRUMENT_H
+
+enum filter_type {
+ FILTER_NONE = 0,
+ FILTER_LOWPASS,
+ FILTER_HIGHPASS,
+ FILTER_NOTCH,
+ FILTER_LOWSHELF,
+ FILTER_HIGHSHELF
+};
+
+enum osc_type {
+ OSC_NONE = 0,
+ OSC_SINE,
+ OSC_SQUARE,
+ OSC_TRIANGLE,
+ OSC_SAW
+};
+
+// INSTRUMENT CREATION, TWEAKS
+typedef struct instrument *instrument_ref;
+
+instrument_ref new_instrument ();
+void free_instrument (instrument_ref instrument);
+// int set_algorithm (instrument_ref instrument, enum algorithm alg);
+int ins_set_osc (instrument_ref instrument, enum osc_type osc);
+void ins_set_sample_rate (instrument_ref instrument, int sample_rate);
+
+// OUTPUT CREATION, TWEAKS
+struct audio_out {
+ float left_phase;
+ float right_phase;
+};
+
+struct audio_out instrument_tick (instrument_ref instrument);
+
+#endif
diff --git a/mmband/audio_player.c b/mmband/audio_player.c
new file mode 100644
index 0000000..3b257a4
--- /dev/null
+++ b/mmband/audio_player.c
@@ -0,0 +1,4 @@
+// dummy function for initial commit
+int add (int a, int b) {
+ return a + b;
+}
diff --git a/mmband/instrument.c b/mmband/instrument.c
new file mode 100644
index 0000000..96a8952
--- /dev/null
+++ b/mmband/instrument.c
@@ -0,0 +1,4 @@
+#include <mmband/api/instrument.h>
+#include <mmband/api/adsr.h>
+
+struct instrument { };
diff --git a/mmband/waves/none.c b/mmband/waves/none.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/mmband/waves/none.c
diff --git a/mmband/waves/saw.c b/mmband/waves/saw.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/mmband/waves/saw.c
diff --git a/mmband/waves/sine.c b/mmband/waves/sine.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/mmband/waves/sine.c
diff --git a/mmband/waves/square.c b/mmband/waves/square.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/mmband/waves/square.c
diff --git a/mmband/waves/triangle.c b/mmband/waves/triangle.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/mmband/waves/triangle.c
diff --git a/mmband/waves/waveform.h b/mmband/waves/waveform.h
new file mode 100644
index 0000000..df18e36
--- /dev/null
+++ b/mmband/waves/waveform.h
@@ -0,0 +1,12 @@
+#ifndef MMBAND_WAVEFORM_H
+#define MMBAND_WAVEFORM_H
+
+typedef float wave_function (float);
+
+wave_function none;
+wave_function sine;
+wave_function square;
+wave_function triangle;
+wave_function saw;
+
+#endif
diff --git a/vendor/portaudio b/vendor/portaudio
new file mode 160000
+Subproject 147dd722548358763a8b649b3e4b41dfffbcfbb