aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/audio.hpp28
-rw-r--r--lib/ui.hpp36
2 files changed, 64 insertions, 0 deletions
diff --git a/lib/audio.hpp b/lib/audio.hpp
new file mode 100644
index 0000000..3502714
--- /dev/null
+++ b/lib/audio.hpp
@@ -0,0 +1,28 @@
+#ifndef AUDIO_HPP
+#define AUDIO_HPP
+
+#include <portaudio.h>
+
+#define FRAMES_PER_BUFFER 256
+
+class AudioData {
+ public:
+ AudioData();
+ void set_device_num(int device_num);
+ int get_channel_cnt();
+ float* get_channels();
+
+ void start_stream();
+ void close_stream();
+
+ private:
+ PaStream* stream;
+ int device_num;
+ int channel_cnt;
+ float* channels;
+
+ static int patestCallback(const void* inputBuffer, void* outputBuffer, unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags statusFlags,
+ void* userData);
+};
+
+#endif
diff --git a/lib/ui.hpp b/lib/ui.hpp
new file mode 100644
index 0000000..c656058
--- /dev/null
+++ b/lib/ui.hpp
@@ -0,0 +1,36 @@
+#ifndef UI_HPP
+#define UI_HPP
+
+#include <gtk/gtk.h>
+#include <cairo/cairo.h>
+#include "audio.hpp"
+#include <bits/stdc++.h>
+
+using namespace std;
+
+class GTKUI {
+ public:
+ GTKUI(int argc, char* argv[]);
+ static void draw(cairo_t* cr, GtkWidget* drawing_area, gpointer user_data);
+ static void draw_cb(GtkDrawingArea* drawing_area, cairo_t* cr, int width, int height, gpointer user_data);
+ static void select_device(GtkWidget* widget, gpointer user_data);
+ static void refresh(GtkWidget* widget, gpointer user_data);
+ static void close_window(GtkWidget* widget, gpointer user_data);
+ static gboolean drawCallback(GtkWidget* widget, GdkFrameClock* frame_clock, gpointer user_data);
+ static void activate(GtkApplication* app, gpointer user_data);
+
+ private:
+ GtkApplication* app;
+
+ GtkWidget* window;
+ GtkWidget* grid;
+ GtkWidget* refresh_button;
+ GtkWidget* quit_button;
+ vector<GtkWidget*> buttons;
+ GtkWidget* drawing_area;
+
+ int status;
+ AudioData* audiodata;
+};
+
+#endif