Skip to content

Commit

Permalink
Merge branch 'master' of github.com:rtbuf/rtbuf
Browse files Browse the repository at this point in the history
  • Loading branch information
thodg committed Mar 22, 2020
2 parents 7ea7037 + c7fd12f commit 40f88d1
Show file tree
Hide file tree
Showing 12 changed files with 104 additions and 63 deletions.
19 changes: 12 additions & 7 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,25 @@ else
AM_CFLAGS = -DNDEBUG -O2
endif

AM_CFLAGS += -std=c89 -pedantic -W -Wall -Werror
AM_CFLAGS += -std=c89 -W -Wall -Werror

lib_LTLIBRARIES += librtbuf.la
librtbuf_la_CFLAGS = ${LIBRTBUF_CFLAGS}
librtbuf_la_LDFLAGS = -no-undefined
librtbuf_la_LIBADD = ${LIBRTBUF_LIBS}
librtbuf_la_SOURCES = \
symbol.c \
rtbuf_lib.c \
rtbuf_type.c \
rtbuf_proc.c \
rtbuf_var.c \
rtbuf.c
include_HEADERS += \
symbol.h \
rtbuf_defs.h \
rtbuf_type.h \
rtbuf_lib.h \
rtbuf_proc.h \
rtbuf_type.h \
rtbuf_var.h \
rtbuf.h

Expand All @@ -50,13 +53,11 @@ rtbuf_gtk_SOURCES = \
rtbuf_gtk_resources.c \
rtbuf_gtk_rtbuf.c \
rtbuf_input_widget.c \
rtbuf_lib.c \
rtbuf_output_widget.c \
rtbuf_widget.c
include_HEADERS += \
rtbuf_gtk.h \
rtbuf_input_widget.h \
rtbuf_lib.h \
rtbuf_output_widget.h \
rtbuf_widget.h
rtbuf_gtk_UI = \
Expand All @@ -72,10 +73,7 @@ if ENABLE_RTBUF
bin_PROGRAMS += rtbuf
rtbuf_LDADD = ${RTBUF_LIBS} librtbuf.la
rtbuf_SOURCES = \
rtbuf_lib.c \
rtbuf_cli.c
include_HEADERS += \
rtbuf_lib.h

if ENABLE_CLI
rtbuf_SOURCES += \
Expand All @@ -94,6 +92,7 @@ CLEANFILES += rtbuf_music_type rtbuf_music_type.h

lib_LTLIBRARIES += librtbuf_music.la
librtbuf_music_la_LIBADD = ${MUSIC_LIBS} librtbuf.la
librtbuf_music_la_LDFLAGS = -no-undefined
librtbuf_music_la_SOURCES = \
rtbuf_music.c
include_HEADERS += \
Expand All @@ -110,6 +109,7 @@ CLEANFILES += rtbuf_signal_type rtbuf_signal_type.h
rtbuf_signal.lo: rtbuf_signal_type.h

lib_LTLIBRARIES += librtbuf_signal.la
librtbuf_signal_la_LDFLAGS = -no-undefined
librtbuf_signal_la_LIBADD = ${SIGNAL_LIBS} librtbuf_music.la librtbuf.la
librtbuf_signal_la_SOURCES = \
rtbuf_signal.c \
Expand Down Expand Up @@ -137,6 +137,7 @@ include_HEADERS += \
endif # ENABLE_SIGNAL

lib_LTLIBRARIES += librtbuf_dynamic.la
librtbuf_dynamic_la_LDFLAGS = -no-undefined
librtbuf_dynamic_la_LIBADD = -lm librtbuf_signal.la librtbuf.la
librtbuf_dynamic_la_SOURCES = \
rtbuf_dynamic.c \
Expand All @@ -152,6 +153,7 @@ CLEANFILES += rtbuf_synth_type rtbuf_synth_type.h
rtbuf_synth.lo: rtbuf_synth_type.h

lib_LTLIBRARIES += librtbuf_synth.la
librtbuf_synth_la_LDFLAGS = -no-undefined
librtbuf_synth_la_LIBADD = librtbuf_signal.la librtbuf_music.la librtbuf.la
librtbuf_synth_la_SOURCES = \
rtbuf_music_type.h \
Expand All @@ -172,6 +174,7 @@ CLEANFILES += rtbuf_sndio_type rtbuf_sndio_type.h
rtbuf_sndio.lo: rtbuf_sndio_type.h

lib_LTLIBRARIES += librtbuf_sndio.la
librtbuf_sndio_la_LDFLAGS = -no-undefined
librtbuf_sndio_la_LIBADD = ${SNDIO_LIBS} librtbuf_signal.la librtbuf.la
librtbuf_sndio_la_SOURCES = \
rtbuf_sndio.c \
Expand All @@ -192,6 +195,7 @@ CLEANFILES += rtbuf_portaudio_type rtbuf_portaudio_type.h
rtbuf_portaudio.lo: rtbuf_portaudio_type.h

lib_LTLIBRARIES += librtbuf_portaudio.la
librtbuf_portaudio_la_LDFLAGS = -no-undefined
librtbuf_portaudio_la_LIBADD = ${PORTAUDIO_LIBS} librtbuf_signal.la librtbuf.la
librtbuf_portaudio_la_SOURCES = \
rtbuf_portaudio.c \
Expand All @@ -206,6 +210,7 @@ endif # ENABLE_PORTAUDIO
if ENABLE_GLFW3
lib_LTLIBRARIES += librtbuf_glfw3.la
librtbuf_glfw3_la_CPPFLAGS = ${GLFW3_CFLAGS}
librtbuf_glfw3_la_LDFLAGS = -no-undefined
librtbuf_glfw3_la_LIBADD = ${GLFW3_LIBS} librtbuf_music.la librtbuf_signal.la librtbuf.la
librtbuf_glfw3_la_SOURCES = \
rtbuf_glfw3.c \
Expand Down
2 changes: 2 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ AM_CONDITIONAL([ENABLE_CLI], [test x"$enable_cli" = x"true"])
AC_SUBST([LIBRTBUF_CFLAGS])
AC_SUBST([LIBRTBUF_LIBS])

AC_CHECK_LIB(m, log2, [AC_DEFINE([HAVE_LOG2],[1],[Define to 1 if your system has 'log2'.])])

PKG_CHECK_MODULES([GTK3], [gtk+-3.0],
[enable_gtk3=true],
[enable_gtk3=false])
Expand Down
6 changes: 6 additions & 0 deletions rtbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -538,3 +538,9 @@ double clamp (double inf, double x, double sup)
{
return max(inf, min(x, sup));
}

int rtbuf_err (const char *msg)
{
fprintf(stderr, "%s\n", msg);
return -1;
}
6 changes: 0 additions & 6 deletions rtbuf_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,3 @@ int main (int argc, char *argv[])
rtbuf_cli_args(argc, argv);
return repl();
}

extern int rtbuf_err (const char *msg)
{
fprintf(stderr, "%s\n", msg);
return -1;
}
2 changes: 2 additions & 0 deletions rtbuf_glfw3_keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include "rtbuf_music_type.h"
#include "rtbuf_glfw3.h"

float ceilf (float x);

#define RTBUF_GLFW3_KEYBOARD_WIDTH 512
#define RTBUF_GLFW3_KEYBOARD_HEIGHT 256

Expand Down
67 changes: 38 additions & 29 deletions rtbuf_gtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ GtkWindow *modular = NULL;
GtkLayout *modular_layout = NULL;
GtkMenu *library_menu = NULL;

GtkTargetList *modular_layout_target_list;
#define MODULAR_LAYOUT_TARGETS 2
GtkTargetEntry modular_layout_target_entry[MODULAR_LAYOUT_TARGETS] = {
{"RtbufWidget", GTK_TARGET_SAME_APP, TARGET_RTBUF},
{"RtbufOutputWidget", GTK_TARGET_SAME_APP, TARGET_RTBUF_OUTPUT}
};
GtkWidget *drag_widget = NULL;
gint drag_x = 0;
gint drag_y = 0;

Expand Down Expand Up @@ -197,8 +192,10 @@ void rtbuf_gtk_modular_draw_connection (s_rtbuf_gtk_connection *c,
allocation.height / 2,
&x2, &y2);
}
else
gtk_widget_get_pointer(GTK_WIDGET(modular_layout), &x2, &y2);
else {
x2 = drag_x;
y2 = drag_y;
};
cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 1.0);
rtbuf_gtk_modular_draw_arrow(cr, x1, y1, x2, y2);
cairo_stroke(cr);
Expand Down Expand Up @@ -233,8 +230,10 @@ gboolean rtbuf_gtk_modular_button_press (GtkWidget *widget,
event->type == GDK_BUTTON_PRESS) {
GdkEventButton *eb = (GdkEventButton*) event;
if (eb->button == 3) {
GdkWindow *window =
gtk_widget_get_window(GTK_WIDGET(modular_layout));
printf("rtbuf-gtk modular popup\n");
gdk_window_get_device_position(eb->window, eb->device,
gdk_window_get_device_position(window, eb->device,
&rtbuf_x, &rtbuf_y, NULL);
gtk_menu_popup_at_pointer(library_menu, event);
return TRUE;
Expand All @@ -243,24 +242,38 @@ gboolean rtbuf_gtk_modular_button_press (GtkWidget *widget,
return FALSE;
}

gboolean rtbuf_gtk_modular_drag_motion (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
gpointer data)
gboolean rtbuf_gtk_modular_motion (GtkWidget *widget,
GdkEventMotion *event,
gpointer data)
{
(void) widget;
(void) time;
(void) data;
GtkWidget *drag_widget = gtk_drag_get_source_widget(context);
printf("rtbuf-gtk modular drag motion %i %i\n", x, y);
if (IS_RTBUF_WIDGET(drag_widget)) {
gtk_layout_move(modular_layout, drag_widget, x - drag_x, y - drag_y);
if (drag_widget) {
if (!(event->state & GDK_BUTTON1_MASK)) {
printf("rtbuf-gtk modular drop\n");
drag_widget = NULL;
return TRUE;
}
else {
gint x = 0;
gint y = 0;
GdkWindow *window =
gtk_widget_get_window(GTK_WIDGET(modular_layout));
gdk_window_get_device_position(window, event->device,
&x, &y, NULL);
printf("rtbuf-gtk modular drag motion %i %i\n", x, y);
gtk_layout_move(modular_layout, drag_widget, x - drag_x,
y - drag_y);
return TRUE;
}
}
else if (IS_RTBUF_OUTPUT_WIDGET(drag_widget)) {
/*
else if (drag_connection) {
GdkWindow *window =
gtk_widget_get_window(GTK_WIDGET(modular_layout));
gdk_window_get_device_position(window, event->device,
&drag_x, &drag_y, NULL);
gtk_widget_queue_draw(GTK_WIDGET(modular_layout));
}
*/
return FALSE;
}

Expand All @@ -285,12 +298,8 @@ void rtbuf_gtk_modular ()

rtbuf_gtk_library_menu();

modular_layout_target_list = gtk_target_list_new(modular_layout_target_entry,
MODULAR_LAYOUT_TARGETS);
gtk_drag_dest_set(GTK_WIDGET(modular_layout), 0, modular_layout_target_entry,
MODULAR_LAYOUT_TARGETS, GDK_ACTION_DEFAULT);
g_signal_connect(modular_layout, "drag-motion",
G_CALLBACK(rtbuf_gtk_modular_drag_motion), NULL);
g_signal_connect(modular_layout, "motion-notify-event",
G_CALLBACK(rtbuf_gtk_modular_motion), NULL);
}

int rtbuf_gtk_builder ()
Expand Down
5 changes: 3 additions & 2 deletions rtbuf_gtk.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ s_rtbuf_gtk_connection *modular_connections;

GtkTargetList *rtbuf_move_target_list;

gint drag_x;
gint drag_y;
GtkWidget *drag_widget;
gint drag_x;
gint drag_y;

gboolean rtbuf_gtk_rtbuf_button_press (GtkWidget *widget,
GdkEvent *event,
Expand Down
18 changes: 1 addition & 17 deletions rtbuf_gtk_rtbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,30 +77,14 @@ void rtbuf_gtk_rtbuf_menu (RtbufWidget *widget, GdkEvent *event)
gtk_menu_popup_at_pointer(menu, event);
}

void rtbuf_gtk_rtbuf_drag_begin (GtkWidget *widget,
GdkDragContext *context,
gpointer data)
{
(void) data;
(void) context;
printf("rtbuf-gtk rtbuf drag begin\n");
}

void rtbuf_gtk_rtbuf_drag (RtbufWidget *widget,
GdkEventButton *event)
{
GtkWidget *gtk_widget = GTK_WIDGET(widget);
printf("rtbuf-gtk rtbuf drag\n");
g_signal_connect(G_OBJECT(widget), "drag-begin",
G_CALLBACK (rtbuf_gtk_rtbuf_drag_begin), NULL);
gdk_window_get_device_position(event->window, event->device,
&drag_x, &drag_y, NULL);
gtk_drag_begin_with_coordinates(GTK_WIDGET(widget),
rtbuf_move_target_list,
GDK_ACTION_DEFAULT,
event->button,
(GdkEvent*) event,
-1, -1);
drag_widget = gtk_widget;
}

gboolean rtbuf_gtk_rtbuf_button_press (GtkWidget *widget,
Expand Down
31 changes: 29 additions & 2 deletions rtbuf_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,30 @@ void rtbuf_lib_load_path (s_rtbuf_lib *lib, const char *name)
}
}

void rtbuf_lib_load_path_dll (s_rtbuf_lib *lib, const char *name)
{
char **path = g_rtbuf_lib_path;
lib->lib = 0;
while (*path && !lib->lib) {
const char *in = *path++;
lib->path = &g_string[g_string_n];
while (*in)
g_string[g_string_n++] = *in++;
in = "msys-rtbuf_";
while (*in)
g_string[g_string_n++] = *in++;
in = name;
while (*in)
g_string[g_string_n++] = *in++;
in = "-0.dll";
while (*in)
g_string[g_string_n++] = *in++;
g_string[g_string_n++] = 0;
printf("lib_load path \"%s\"\n", lib->path);
lib->lib = dlopen(lib->path, RTLD_LAZY);
}
}

int rtbuf_lib_proc_p (s_rtbuf_lib_proc *proc)
{
return proc->name || proc->f || proc->start || proc->stop;
Expand All @@ -169,8 +193,11 @@ s_rtbuf_lib * rtbuf_lib_load (const char *name)
return 0;
rtbuf_lib_load_path(lib, name);
if (!lib->lib) {
rtbuf_lib_delete(lib);
return 0;
rtbuf_lib_load_path_dll(lib, name);
if (!lib->lib) {
rtbuf_lib_delete(lib);
return 0;
}
}
ver = dlsym(lib->lib, "rtbuf_lib_ver");
/* printf("lib_load ver %lu\n", *ver); */
Expand Down
1 change: 1 addition & 0 deletions rtbuf_modular.ui
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@
<property name="visible">True</property>
<property name="app_paintable">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_STRUCTURE_MASK</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="width">8192</property>
Expand Down
3 changes: 3 additions & 0 deletions rtbuf_music.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#include "rtbuf.h"
#include "rtbuf_music.h"

extern double log2 (double);
extern double exp2 (double);

int g_rtbuf_music_init = 0;
double g_rtbuf_music_tune = 0.0;

Expand Down
7 changes: 7 additions & 0 deletions rtbuf_signal.h
Original file line number Diff line number Diff line change
Expand Up @@ -456,4 +456,11 @@ int rtbuf_signal_square_start (s_rtbuf *rtb);

const double sqrt2_2;

#ifndef M_SQRT2
#define M_SQRT2 1.41421356237309504880
#endif
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif

#endif /* RTBUF_SIGNAL_H */

0 comments on commit 40f88d1

Please sign in to comment.