diff --git a/.gitignore b/.gitignore
index 9fd7da1..f210797 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,27 +1,27 @@
-/.deps/
-/.libs/
+.deps/
+.libs/
/autom4te.cache/
/build/
/build-aux/
-/Makefile
+Makefile
/config.h
/config.log
/config.status
/configure
/libtool
-/rtbuf
-/rtbuf-gtk
-/rtbuf_gtk_resources.c
-/rtbuf_music_type
-/rtbuf_music_type.h
-/rtbuf_portaudio_type
-/rtbuf_portaudio_type.h
-/rtbuf_signal_type
-/rtbuf_signal_type.h
-/rtbuf_sndio_type
-/rtbuf_sndio_type.h
-/rtbuf_synth_type
-/rtbuf_synth_type.h
+/cli/rtbuf
+/gtk/rtbuf-gtk
+/gtk/rtbuf_gtk_resources.c
+/lib/music_type
+/lib/include/rtbuf/music_type.h
+/lib/portaudio_type
+/lib/include/rtbuf/portaudio_type.h
+/lib/signal_type
+/lib/include/rtbuf/signal_type.h
+/lib/sndio_type
+/lib/include/rtbuf/sndio_type.h
+/lib/synth_type
+/lib/include/rtbuf/synth_type.h
/stamp-*
*.la
*.lo
diff --git a/Makefile.am b/Makefile.am
index bf7c71b..2ae2a68 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,241 +1,5 @@
-ACLOCAL_AMFLAGS = -I build-aux/m4
-bin_PROGRAMS =
-CLEANFILES =
-include_HEADERS =
-lib_LTLIBRARIES =
-
-if DEBUG
-AM_CFLAGS = -DDEBUG -O0 -ggdb
-else
-AM_CFLAGS = -DNDEBUG -O2
-endif
-
-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_lib.h \
- rtbuf_proc.h \
- rtbuf_type.h \
- rtbuf_var.h \
- rtbuf.h
-
-if ENABLE_LIBDATA
-librtbuf_la_SOURCES += \
- data.c
-include_HEADERS += \
- data.h
-endif
-
-if ENABLE_GTK3
-bin_PROGRAMS += rtbuf-gtk
-rtbuf_gtk_CFLAGS = ${GTK3_CFLAGS}
-rtbuf_gtk_LDADD = ${GTK3_LIBS} librtbuf.la
-rtbuf_gtk_SOURCES = \
- rtbuf_gtk.c \
- rtbuf_gtk_connection.c \
- rtbuf_gtk_input.c \
- rtbuf_gtk_output.c \
- rtbuf_gtk_resources.c \
- rtbuf_gtk_rtbuf.c \
- rtbuf_input_widget.c \
- rtbuf_output_widget.c \
- rtbuf_widget.c
-include_HEADERS += \
- rtbuf_gtk.h \
- rtbuf_input_widget.h \
- rtbuf_output_widget.h \
- rtbuf_widget.h
-rtbuf_gtk_UI = \
- rtbuf_input_widget.ui \
- rtbuf_modular.ui \
- rtbuf_output_widget.ui \
- rtbuf_widget.ui
-rtbuf_gtk_resources.c: rtbuf_gtk.gresource.xml ${rtbuf_gtk_UI}
- glib-compile-resources rtbuf_gtk.gresource.xml --target=rtbuf_gtk_resources.c --generate-source
-CLEANFILES += rtbuf_gtk_resources.c
-endif # ENABLE_GTK3
-
-if ENABLE_RTBUF
-bin_PROGRAMS += rtbuf
-rtbuf_LDADD = librtbuf.la ${RTBUF_LIBS}
-rtbuf_SOURCES = \
- rtbuf_cli.c
-
-if ENABLE_CLI
-rtbuf_SOURCES += \
- cli.c
-include_HEADERS += \
- cli.h
-endif # ENABLE_CLI
-endif # ENABLE_RTBUF
-
-if ENABLE_MUSIC
-rtbuf_music_type: rtbuf_music_type.c rtbuf_music.h
- ${CC} ${CFLAGS} ${CPPFLAGS} -o rtbuf_music_type rtbuf_music_type.c
-rtbuf_music_type.h: rtbuf_music_type
- ./rtbuf_music_type > rtbuf_music_type.h
-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 += \
- rtbuf_music.h \
- rtbuf_music_type.h
-endif # ENABLE_MUSIC
-
-if ENABLE_SIGNAL
-rtbuf_signal_type: rtbuf_signal_type.c rtbuf_signal.h
- ${CC} ${CFLAGS} ${CPPFLAGS} -o rtbuf_signal_type rtbuf_signal_type.c
-rtbuf_signal_type.h: rtbuf_signal_type
- ./rtbuf_signal_type > rtbuf_signal_type.h
-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 \
- rtbuf_signal_bandpass2.c \
- rtbuf_signal_delay.c \
- rtbuf_signal_equalizer10.c \
- rtbuf_signal_flanger.c \
- rtbuf_signal_hipass.c \
- rtbuf_signal_hipass2.c \
- rtbuf_signal_hipass3.c \
- rtbuf_signal_hipass4.c \
- rtbuf_signal_hipass5.c \
- rtbuf_signal_lowpass.c \
- rtbuf_signal_lowpass2.c \
- rtbuf_signal_lowpass3.c \
- rtbuf_signal_lowpass4.c \
- rtbuf_signal_lowpass5.c \
- rtbuf_signal_sawtooth.c \
- rtbuf_signal_sinus.c \
- rtbuf_signal_square.c \
- rtbuf_signal_type.h
-include_HEADERS += \
- rtbuf_signal.h \
- rtbuf_signal_type.h
-
-rtbuf_reverb_type: rtbuf_reverb_type.c rtbuf_reverb.h
- ${CC} ${CFLAGS} ${CPPFLAGS} -o rtbuf_reverb_type rtbuf_reverb_type.c
-rtbuf_reverb_type.h: rtbuf_reverb_type
- ./rtbuf_reverb_type > rtbuf_reverb_type.h
-CLEANFILES += rtbuf_reverb_type rtbuf_reverb_type.h
-rtbuf_reverb.lo: rtbuf_reverb_type.h
-
-lib_LTLIBRARIES += librtbuf_reverb.la
-librtbuf_reverb_la_LDFLAGS = -no-undefined
-librtbuf_reverb_la_LIBADD = librtbuf_signal.la
-librtbuf_reverb_la_SOURCES = \
- rtbuf_reverb.c \
- rtbuf_reverb_fdn4.c
-include_HEADERS += \
- rtbuf_reverb.h \
- rtbuf_reverb_type.h
-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 \
- rtbuf_dynamic_limiter.c
-include_HEADERS += \
- rtbuf_dynamic.h
-
-rtbuf_synth_type: rtbuf_synth_type.c rtbuf_synth.h rtbuf_music_type.h rtbuf_signal_type.h
- ${CC} ${CFLAGS} ${CPPFLAGS} -o rtbuf_synth_type rtbuf_synth_type.c
-rtbuf_synth_type.h: rtbuf_synth_type
- ./rtbuf_synth_type > rtbuf_synth_type.h
-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 \
- rtbuf_signal_type.h \
- rtbuf_synth.c \
- rtbuf_synth_adsr.c \
- rtbuf_synth_synth.c
-include_HEADERS += \
- rtbuf_synth.h \
- rtbuf_synth_type.h
-
-if ENABLE_SNDIO
-rtbuf_sndio_type: rtbuf_sndio_type.c rtbuf_sndio.h
- ${CC} ${CFLAGS} ${CPPFLAGS} -o rtbuf_sndio_type rtbuf_sndio_type.c
-rtbuf_sndio_type.h: rtbuf_sndio_type
- ./rtbuf_sndio_type > rtbuf_sndio_type.h
-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 \
- rtbuf_sndio_input.c \
- rtbuf_sndio_output.c \
- rtbuf_sndio_type.h
-include_HEADERS += \
- rtbuf_sndio.h \
- rtbuf_sndio_type.h
-endif # ENABLE_SNDIO
-
-if ENABLE_PORTAUDIO
-rtbuf_portaudio_type: rtbuf_portaudio_type.c rtbuf_portaudio.h
- ${CC} ${CFLAGS} ${CPPFLAGS} -o rtbuf_portaudio_type rtbuf_portaudio_type.c
-rtbuf_portaudio_type.h: rtbuf_portaudio_type
- ./rtbuf_portaudio_type > rtbuf_portaudio_type.h
-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 \
- rtbuf_portaudio_input.c \
- rtbuf_portaudio_output.c \
- rtbuf_portaudio_type.h
-include_HEADERS += \
- rtbuf_portaudio.h \
- rtbuf_portaudio_type.h
-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 \
- rtbuf_glfw3_keyboard.c \
- rtbuf_glfw3_oscilloscope.c
-include_HEADERS += \
- rtbuf_glfw3.h
-endif # ENABLE_GLFW3
+SUBDIRS = librtbuf cli gtk lib
if ENABLE_NSIS
rtbuf-${PACKAGE_VERSION}_setup.exe: .libs/rtbuf.exe .libs/rtbuf-gtk.exe
diff --git a/cli.c b/cli.c
deleted file mode 100644
index e098940..0000000
--- a/cli.c
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <readline/readline.h>
-#include <readline/history.h>
-
-char * readline (const char *prompt);
-
-#include "cli.h"
-
-void cli_init (s_cli *cli)
-{
- if (isatty(0)) {
- cli->prompt = "> ";
- using_history();
- }
- else
- cli->prompt = 0;
- cli->functions = 0;
-}
-
-void cli_prompt (s_cli *cli, const char *prompt)
-{
- if (isatty(0))
- cli->prompt = prompt;
- else
- cli->prompt = 0;
-}
-
-void cli_functions (s_cli *cli, const s_cli_function *functions)
-{
- cli->functions = functions;
-}
-
-int cli_scan (s_cli *cli)
-{
- unsigned i = 0;
- char *line = cli->line;
- char *arg = cli->arg;
- const char **argv = cli->argv;
- cli->argc = 0;
- *argv = arg;
- while (1) {
- *arg = ((++i == CLI_SIZE) ? 0 : *line);
- if (*arg == 0) {
- if (*argv != arg) {
- argv++;
- cli->argc++;
- }
- *argv = 0;
- return cli->argc;
- }
- else if (*arg == ' ') {
- *arg = 0;
- if (*argv != arg) {
- argv++;
- cli->argc++;
- }
- *argv = arg + 1;
- }
- arg++;
- line++;
- }
-}
-
-void trim_newline (char *str)
-{
- unsigned int i = 0;
- while (str[i])
- i++;
- if (i > 0 && str[i - 1] == '\n')
- str[i - 1] = 0;
-}
-
-int cli_read_file_line (s_cli *cli, FILE *fp)
-{
- if (fgets(cli->line, CLI_SIZE, fp)) {
- trim_newline(cli->line);
- fputs(cli->prompt, stdout);
- puts(cli->line);
- return 0;
- }
- return -1;
-}
-
-int cli_readline (s_cli *cli)
-{
- if (cli->prompt) {
- char *line = readline(cli->prompt);
- if (line == 0)
- return -1;
- strncpy(cli->line, line, CLI_SIZE - 1);
- cli->line[CLI_SIZE - 1] = 0;
- free(line);
- if (*cli->line)
- add_history(cli->line);
- return 0;
- }
- return cli_read_file_line(cli, stdin);
-}
-
-int cli_read_file (s_cli *cli, FILE *fp)
-{
- cli->argc = -1;
- cli->f = 0;
- if (cli_read_file_line(cli, fp))
- return -1;
- cli_scan(cli);
- if (0 < cli->argc)
- cli->f = cli_find_function(cli, cli->argv[0], cli->argc - 1);
- return cli->argc;
-}
-
-int cli_read (s_cli *cli)
-{
- cli->argc = -1;
- cli->f = 0;
- if (cli_readline(cli))
- return -1;
- cli_scan(cli);
- if (0 < cli->argc)
- cli->f = cli_find_function(cli, cli->argv[0], cli->argc - 1);
- return cli->argc;
-}
-
-f_cli cli_find_function (s_cli *cli, const char *name, int arity)
-{
- const s_cli_function *function = cli->functions;
- if (function == 0)
- return 0;
- while (1) {
- if (function->name == 0)
- return 0;
- if (strcmp(function->name, name) == 0 &&
- (function->arity < 0 || arity < 0 || function->arity == arity))
- return function->f;
- function++;
- }
-}
-
-int cli_eval (s_cli *cli)
-{
- if (0 < cli->argc) {
- if (cli->f)
- return cli->f(cli->argc - 1, cli->argv);
- fprintf(stderr, "rtbuf: function not found: %s\n", cli->argv[0]);
- }
- return -1;
-}
diff --git a/cli.h b/cli.h
deleted file mode 100644
index 0125d75..0000000
--- a/cli.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-#ifndef CLI_H
-#define CLI_H
-
-#include <stdio.h>
-#include "form.h"
-
-#define CLI_SIZE 1000
-
-typedef struct cli s_cli;
-typedef struct cli_function s_cli_function;
-typedef int (* f_cli) (int argc, const char *argv[]);
-
-struct cli
-{
- const char *prompt;
- const s_cli_function *functions;
- char line[CLI_SIZE];
- char arg[CLI_SIZE];
- int argc;
- const char *argv[500];
- f_cli f;
-};
-
-void cli_init (s_cli *cli);
-void cli_prompt (s_cli *cli, const char *prompt);
-
-struct cli_function {
- const char *name;
- int arity; /* negative arity means variable arity */
- f_cli f;
-};
-
-void cli_functions (s_cli *cli, const s_cli_function *functions);
-f_cli cli_find_function (s_cli *cli, const char *name, int arity);
-
-int cli_scan (s_cli *cli);
-int cli_read (s_cli *cli);
-int cli_read_file (s_cli *cli, FILE *fp);
-int cli_eval (s_cli *cli);
-
-#endif /* CLI_H */
diff --git a/cli/Makefile.am b/cli/Makefile.am
new file mode 100644
index 0000000..071286f
--- /dev/null
+++ b/cli/Makefile.am
@@ -0,0 +1,5 @@
+bin_PROGRAMS = rtbuf
+rtbuf_LDADD = ../librtbuf/.libs/librtbuf.la ${RTBUF_LIBS}
+rtbuf_SOURCES = \
+ cli.c \
+ rtbuf_cli.c
diff --git a/cli/cli.c b/cli/cli.c
new file mode 100644
index 0000000..e098940
--- /dev/null
+++ b/cli/cli.c
@@ -0,0 +1,166 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <readline/readline.h>
+#include <readline/history.h>
+
+char * readline (const char *prompt);
+
+#include "cli.h"
+
+void cli_init (s_cli *cli)
+{
+ if (isatty(0)) {
+ cli->prompt = "> ";
+ using_history();
+ }
+ else
+ cli->prompt = 0;
+ cli->functions = 0;
+}
+
+void cli_prompt (s_cli *cli, const char *prompt)
+{
+ if (isatty(0))
+ cli->prompt = prompt;
+ else
+ cli->prompt = 0;
+}
+
+void cli_functions (s_cli *cli, const s_cli_function *functions)
+{
+ cli->functions = functions;
+}
+
+int cli_scan (s_cli *cli)
+{
+ unsigned i = 0;
+ char *line = cli->line;
+ char *arg = cli->arg;
+ const char **argv = cli->argv;
+ cli->argc = 0;
+ *argv = arg;
+ while (1) {
+ *arg = ((++i == CLI_SIZE) ? 0 : *line);
+ if (*arg == 0) {
+ if (*argv != arg) {
+ argv++;
+ cli->argc++;
+ }
+ *argv = 0;
+ return cli->argc;
+ }
+ else if (*arg == ' ') {
+ *arg = 0;
+ if (*argv != arg) {
+ argv++;
+ cli->argc++;
+ }
+ *argv = arg + 1;
+ }
+ arg++;
+ line++;
+ }
+}
+
+void trim_newline (char *str)
+{
+ unsigned int i = 0;
+ while (str[i])
+ i++;
+ if (i > 0 && str[i - 1] == '\n')
+ str[i - 1] = 0;
+}
+
+int cli_read_file_line (s_cli *cli, FILE *fp)
+{
+ if (fgets(cli->line, CLI_SIZE, fp)) {
+ trim_newline(cli->line);
+ fputs(cli->prompt, stdout);
+ puts(cli->line);
+ return 0;
+ }
+ return -1;
+}
+
+int cli_readline (s_cli *cli)
+{
+ if (cli->prompt) {
+ char *line = readline(cli->prompt);
+ if (line == 0)
+ return -1;
+ strncpy(cli->line, line, CLI_SIZE - 1);
+ cli->line[CLI_SIZE - 1] = 0;
+ free(line);
+ if (*cli->line)
+ add_history(cli->line);
+ return 0;
+ }
+ return cli_read_file_line(cli, stdin);
+}
+
+int cli_read_file (s_cli *cli, FILE *fp)
+{
+ cli->argc = -1;
+ cli->f = 0;
+ if (cli_read_file_line(cli, fp))
+ return -1;
+ cli_scan(cli);
+ if (0 < cli->argc)
+ cli->f = cli_find_function(cli, cli->argv[0], cli->argc - 1);
+ return cli->argc;
+}
+
+int cli_read (s_cli *cli)
+{
+ cli->argc = -1;
+ cli->f = 0;
+ if (cli_readline(cli))
+ return -1;
+ cli_scan(cli);
+ if (0 < cli->argc)
+ cli->f = cli_find_function(cli, cli->argv[0], cli->argc - 1);
+ return cli->argc;
+}
+
+f_cli cli_find_function (s_cli *cli, const char *name, int arity)
+{
+ const s_cli_function *function = cli->functions;
+ if (function == 0)
+ return 0;
+ while (1) {
+ if (function->name == 0)
+ return 0;
+ if (strcmp(function->name, name) == 0 &&
+ (function->arity < 0 || arity < 0 || function->arity == arity))
+ return function->f;
+ function++;
+ }
+}
+
+int cli_eval (s_cli *cli)
+{
+ if (0 < cli->argc) {
+ if (cli->f)
+ return cli->f(cli->argc - 1, cli->argv);
+ fprintf(stderr, "rtbuf: function not found: %s\n", cli->argv[0]);
+ }
+ return -1;
+}
diff --git a/cli/cli.h b/cli/cli.h
new file mode 100644
index 0000000..0125d75
--- /dev/null
+++ b/cli/cli.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifndef CLI_H
+#define CLI_H
+
+#include <stdio.h>
+#include "form.h"
+
+#define CLI_SIZE 1000
+
+typedef struct cli s_cli;
+typedef struct cli_function s_cli_function;
+typedef int (* f_cli) (int argc, const char *argv[]);
+
+struct cli
+{
+ const char *prompt;
+ const s_cli_function *functions;
+ char line[CLI_SIZE];
+ char arg[CLI_SIZE];
+ int argc;
+ const char *argv[500];
+ f_cli f;
+};
+
+void cli_init (s_cli *cli);
+void cli_prompt (s_cli *cli, const char *prompt);
+
+struct cli_function {
+ const char *name;
+ int arity; /* negative arity means variable arity */
+ f_cli f;
+};
+
+void cli_functions (s_cli *cli, const s_cli_function *functions);
+f_cli cli_find_function (s_cli *cli, const char *name, int arity);
+
+int cli_scan (s_cli *cli);
+int cli_read (s_cli *cli);
+int cli_read_file (s_cli *cli, FILE *fp);
+int cli_eval (s_cli *cli);
+
+#endif /* CLI_H */
diff --git a/cli/rtbuf_cli.c b/cli/rtbuf_cli.c
new file mode 100644
index 0000000..48ac274
--- /dev/null
+++ b/cli/rtbuf_cli.c
@@ -0,0 +1,383 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <assert.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include "cli.h"
+#include <rtbuf/symbol.h>
+#include <rtbuf/rtbuf.h>
+#include <rtbuf/lib.h>
+#include <rtbuf/var.h>
+
+s_cli g_cli;
+pthread_t g_rtbuf_cli_thread = 0;
+
+int rtbuf_cli_libs (int argc, const char *argv[])
+{
+ unsigned int i = 0;
+ unsigned int n = g_rtbuf_lib_alloc.n - g_rtbuf_lib_alloc.free_n;
+ assert(argc == 0);
+ (void) argv;
+ printf("Listing %i libraries :\n", n);
+ while (i < g_rtbuf_lib_alloc.n && n > 0) {
+ if (g_rtbuf_lib[i].path[0]) {
+ rtbuf_lib_print(&g_rtbuf_lib[i]);
+ n--;
+ }
+ i++;
+ }
+ return 0;
+}
+
+int rtbuf_cli_lib (int argc, const char *argv[])
+{
+ int i;
+ if (argc != 1)
+ return rtbuf_err("usage: lib LIBRARY");
+ i = rtbuf_lib_find(argv[1]);
+ if (0 <= i && i < RTBUF_LIB_MAX) {
+ rtbuf_lib_print_long(i);
+ return 0;
+ }
+ return rtbuf_err("library not found");
+}
+
+int rtbuf_cli_load (int argc, const char *argv[])
+{
+ s_rtbuf_lib *lib;
+ assert(argc == 1);
+ lib = rtbuf_lib_load(argv[1]);
+ if (!lib) {
+ printf("load failed\n");
+ return -1;
+ }
+ rtbuf_lib_print(lib);
+ return 0;
+}
+
+int rtbuf_cli_buffers (int argc, const char *argv[])
+{
+ unsigned int i = 0;
+ unsigned int n = g_rtbuf_alloc.n;
+ assert(argc == 0);
+ (void) argv;
+ printf("Listing %i buffers :\n", n);
+ while (i < RTBUF_MAX && n > 0) {
+ if (g_rtbuf[i].data) {
+ rtbuf_print_long(i);
+ printf("\n");
+ n--;
+ }
+ i++;
+ }
+ return 0;
+}
+
+int rtbuf_cli_buffer (int argc, const char *argv[])
+{
+ int i;
+ if (argc != 1)
+ return rtbuf_err("usage: buffer N");
+ if ((i = rtbuf_find(argv[1])) < 0)
+ return rtbuf_err("buffer not found");
+ rtbuf_print_long(i);
+ return 0;
+}
+
+int rtbuf_cli_new (int argc, const char *argv[])
+{
+ int rl;
+ int rf;
+ int rtb;
+ if (argc != 2)
+ return rtbuf_err("usage: new LIBRARY PROCEDURE");
+ if ((rl = rtbuf_lib_find(argv[1])) < 0)
+ return rtbuf_err("library not found");
+ if ((rf = rtbuf_lib_find_proc(&g_rtbuf_lib[rl], argv[2])) < 0)
+ return rtbuf_err("procedure not found");
+ if ((rtb = rtbuf_new(g_rtbuf_lib[rl].proc[rf])) < 0)
+ return rtbuf_err("buffer not created");
+ rtbuf_print(rtb);
+ printf("\n");
+ return 0;
+}
+
+
+int rtbuf_cli_set (int argc, const char *argv[])
+{
+ s_rtbuf_var *v;
+ if (argc < 4 || argv[2][0] != '=' || argv[2][1])
+ return rtbuf_err("usage: set VAR = TYPE ARG [...]");
+ if (strncmp("new", argv[3], 4) == 0) {
+ int rl;
+ int rf;
+ int rtb;
+ if (argc != 5)
+ return rtbuf_err("usage: set VAR = new LIB PROC");
+ if ((rl = rtbuf_lib_find(argv[4])) < 0)
+ return rtbuf_err("library not found");
+ if ((rf = rtbuf_lib_find_proc(&g_rtbuf_lib[rl], argv[5])) < 0)
+ return rtbuf_err("procedure not found");
+ if ((rtb = rtbuf_new(g_rtbuf_lib[rl].proc[rf])) < 0)
+ return rtbuf_err("buffer not created");
+ v = rtbuf_var_rtbuf_set(argv[1], rtb);
+ assert(v);
+ rtbuf_var_print(v);
+ printf("\n");
+ return 0;
+ }
+ else if (strncmp("buffer", argv[3], 7) == 0) {
+ int rtb;
+ if (argc != 4)
+ return rtbuf_err("usage: set VAR = buffer N");
+ if ((rtb = rtbuf_find(argv[4])) < 0)
+ return rtbuf_err("buffer not found");
+ v = rtbuf_var_rtbuf_set(argv[1], rtb);
+ assert(v);
+ rtbuf_var_print(v);
+ return 0;
+ }
+ return rtbuf_err("unknown type for set");
+}
+
+int rtbuf_cli_delete (int argc, const char *argv[])
+{
+ int i;
+ if (argc != 1)
+ return rtbuf_err("usage: delete N");
+ i = rtbuf_find(argv[1]);
+ if (i < 0)
+ return rtbuf_err("buffer not found\n");
+ rtbuf_delete(&g_rtbuf[i]);
+ rtbuf_print(i);
+ printf("\n");
+ return 0;
+}
+
+int rtbuf_cli_bind (int argc, const char *argv[])
+{
+ int src;
+ int out;
+ int dest;
+ int in;
+ if (argc != 4)
+ return rtbuf_err("usage: bind SOURCE OUT DEST IN");
+ if ((src = rtbuf_find(argv[1])) < 0)
+ return rtbuf_err("source buffer not found");
+ if ((out = rtbuf_out_find(&g_rtbuf[src], argv[2])) < 0)
+ return rtbuf_err("output not found");
+ if ((dest = rtbuf_find(argv[3])) < 0)
+ return rtbuf_err("destination buffer not found");
+ if ((in = rtbuf_in_find(&g_rtbuf[dest], argv[4])) < 0)
+ return rtbuf_err("input not found");
+ rtbuf_bind(src, out, &g_rtbuf[dest], in);
+ rtbuf_print_long(dest);
+ return 0;
+}
+
+int rtbuf_cli_unbind (int argc, const char *argv[])
+{
+ int rtb;
+ if (argc < 1 || argc > 2)
+ return rtbuf_err("usage: unbind BUFFER [INPUT]");
+ if ((rtb = rtbuf_find(argv[1])) < 0)
+ return rtbuf_err("buffer not found");
+ if (argc == 2) {
+ int in = atoi(argv[2]);
+ if (in < 0 || (unsigned int) in >= g_rtbuf[rtb].proc->in_n)
+ return rtbuf_err("input not found");
+ rtbuf_in_unbind(&g_rtbuf[rtb], in);
+ }
+ else
+ rtbuf_unbind_all(&g_rtbuf[rtb]);
+ rtbuf_print_long(rtb);
+ return 0;
+}
+
+void * rtbuf_cli_thread_proc (void *arg)
+{
+ (void) arg;
+ printf("rtbuf thread: start\n");
+ if (!rtbuf_start())
+ g_rtbuf_run = 1;
+ while (g_rtbuf_run) {
+ if (rtbuf_run())
+ g_rtbuf_run = 0;
+ }
+ printf("rtbuf thread: stop\n");
+ rtbuf_stop();
+ return 0;
+}
+
+int rtbuf_cli_start (int argc, const char *argv[])
+{
+ (void) argv;
+ if (argc != 0)
+ return rtbuf_err("usage: start");
+ if (!g_rtbuf_run && g_rtbuf_cli_thread) {
+ if (pthread_join(g_rtbuf_cli_thread, 0))
+ return rtbuf_err("pthread_join failed");
+ g_rtbuf_cli_thread = 0;
+ }
+ if (!g_rtbuf_cli_thread) {
+ if (pthread_create(&g_rtbuf_cli_thread, 0, &rtbuf_cli_thread_proc,
+ 0))
+ return rtbuf_err("pthread_create failed");
+ }
+ return 0;
+}
+
+int rtbuf_cli_stop (int argc, const char *argv[])
+{
+ (void) argv;
+ if (argc != 0)
+ return rtbuf_err("usage: stop");
+ if (g_rtbuf_run)
+ g_rtbuf_run = 0;
+ if (g_rtbuf_cli_thread) {
+ if (pthread_join(g_rtbuf_cli_thread, 0))
+ return rtbuf_err("pthread_join failed");
+ g_rtbuf_cli_thread = 0;
+ }
+ return 0;
+}
+
+int rtbuf_cli_help (int argc, const char *argv[])
+{
+ (void) argc;
+ (void) argv;
+ printf("Available commands :\n"
+ " libs List loaded libraries.\n"
+ " lib N Show library N.\n"
+ " load PATH Load library at PATH.\n"
+ " buffers List buffers.\n"
+ " buffer N Show buffer N.\n"
+ " set VAR = buffer N Set variable.\n");
+ printf(" new LIB PROC Instanciate library procedure.\n"
+ " set VAR = new LIB PROC Set variable.\n"
+ " delete BUFFER Unlink and delete RTBUF.\n"
+ " bind SOURCE OUT DEST IN Bind SOURCE OUT to DEST IN.\n"
+ " unbind BUFFER IN Unbind BUFFER IN.\n"
+ " help Show this help message.\n"
+ " exit Quit RTBUF.\n");
+ return 0;
+}
+
+int rtbuf_cli_exit (int argc, const char *argv[])
+{
+ (void) argc;
+ (void) argv;
+ rtbuf_cli_stop(0, 0);
+ close(0);
+ exit(0);
+ return 0;
+}
+
+s_cli_function rtbuf_cli_functions[] = {
+ { "libs", 0, rtbuf_cli_libs },
+ { "lib", 1, rtbuf_cli_lib },
+ { "load", 1, rtbuf_cli_load },
+ { "buffers", 0, rtbuf_cli_buffers },
+ { "buffer", 1, rtbuf_cli_buffer },
+ { "new", 2, rtbuf_cli_new },
+ { "delete", 1, rtbuf_cli_delete },
+ { "bind", 4, rtbuf_cli_bind },
+ { "unbind", 1, rtbuf_cli_unbind },
+ { "unbind", 2, rtbuf_cli_unbind },
+ { "set", -1, rtbuf_cli_set },
+ { "start", 0, rtbuf_cli_start },
+ { "stop", 0, rtbuf_cli_stop },
+ { "h", 0, rtbuf_cli_help },
+ { "help", 0, rtbuf_cli_help },
+ { "exit", 0, rtbuf_cli_exit },
+ { 0, 0, 0 }
+};
+
+void debug_read (int argc, const char **argv, f_cli f)
+{
+ union {
+ f_cli f;
+ void *p;
+ } fp;
+ if (argc < 1)
+ return;
+ printf("CLI READ %i %s(", argc, *argv);
+ argv++;
+ argc--;
+ fp.f = f;
+ while (1) {
+ if (argc < 1) {
+ printf("); %p\n", fp.p);
+ return;
+ }
+ printf("%s", *argv);
+ if (argc > 1)
+ printf(", ");
+ argv++;
+ argc--;
+ }
+}
+
+void repl_init ()
+{
+ cli_init(&g_cli);
+ cli_prompt(&g_cli, "rtbuf> ");
+ cli_functions(&g_cli, rtbuf_cli_functions);
+}
+
+int load (const char *path)
+{
+ FILE *fp = fopen(path, "r");
+ if (!fp)
+ return -1;
+ printf("; Loading %s\n", path);
+ while (cli_read_file(&g_cli, fp) >= 0)
+ cli_eval(&g_cli);
+ fclose(fp);
+ return 0;
+}
+
+int repl ()
+{
+ while (cli_read(&g_cli) >= 0) {
+ /* debug_read(cli.argc, cli.argv, cli.f); */
+ cli_eval(&g_cli);
+ }
+ return 0;
+}
+
+void rtbuf_cli_args (int argc, char *argv[])
+{
+ while (--argc) {
+ char *arg = *++argv;
+ printf("loading script %s\n", arg);
+ load(arg);
+ }
+}
+
+int main (int argc, char *argv[])
+{
+ symbols_init();
+ librtbuf_init();
+ assert(g_rtbuf);
+ repl_init();
+ rtbuf_cli_args(argc, argv);
+ return repl();
+}
diff --git a/configure.ac b/configure.ac
index a6b8d6e..7520ff4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@ AC_PREREQ([2.59])
AC_INIT([rtbuf], [0.2.3], [kmx.io], [rtbuf], [http://kmx.io/])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([build-aux/m4])
-AC_CONFIG_SRCDIR([rtbuf.c])
+AC_CONFIG_SRCDIR([librtbuf/rtbuf.c])
AC_CONFIG_HEADERS([config.h:config.h.in])
AM_INIT_AUTOMAKE
@@ -28,28 +28,13 @@ if test -d /usr/lib; then
LDFLAGS="$LDFLAGS -L/usr/lib"
fi
+CPPFLAGS="-I${PWD}/librtbuf/include -I${PWD}/lib/include $CPPFLAGS"
+CFLAGS="$CFLAGS -std=c89 -W -Wall -Werror"
+
AC_CHECK_FUNC([strlcpy], [echo using system strlcpy],
AC_SEARCH_LIBS([strlcpy], [bsd],
[LIBRTBUF_CFLAGS="-I/usr/include/bsd -DLIBBSD_OVERLAY"
LIBRTBUF_LIBS="$LIBRTBUF_LIBS -lbsd"]))
-
-enable_libdata=true
-AC_SEARCH_LIBS([libdata_init], [data],
- [LIBRTBUF_LIBS="$LIBRTBUF_LIBS -ldata"
- enable_libdata=false],
- [if test x"$with_external_libdata" = x"true"; then
- AC_MSG_ERROR([missing libdata for rtbuf])
- fi])
-AM_CONDITIONAL([ENABLE_LIBDATA], [test x"$enable_libdata" = x"true"])
-
-enable_cli=true
-AC_SEARCH_LIBS([cli_init], [cli],
- [RTBUF_LIBS="$RTBUF_LIBS -lcli"
- enable_cli=false],
- [if test x"$with_external_libcli" = x"true"; then
- AC_MSG_ERROR([missing libcli for rtbuf])
- fi])
-AM_CONDITIONAL([ENABLE_CLI], [test x"$enable_cli" = x"true"])
AC_SUBST([LIBRTBUF_CFLAGS])
AC_SUBST([LIBRTBUF_LIBS])
@@ -86,23 +71,12 @@ AC_CHECK_LIB([termcap], [tputs],
AM_CONDITIONAL([ENABLE_RTBUF], [test x"$enable_rtbuf" = x"true"])
AC_SUBST([RTBUF_LIBS])
-enable_music=true
-AM_CONDITIONAL([ENABLE_MUSIC], [test x"$enable_music" = x"true"])
MUSIC_LIBS="-lm"
AC_SUBST([MUSIC_LIBS])
-enable_signal=true
-AC_ARG_ENABLE(signal,
- AS_HELP_STRING([--enable-signal],
- [enable building librtbuf_signal, default: yes]),
- [case "${enableval}" in
- no) enable_signal=false ;;
- esac])
SIGNAL_LIBS="-lm"
AC_SUBST([SIGNAL_LIBS])
-AM_CONDITIONAL([ENABLE_SIGNAL], [test x"$enable_signal" = x"true"])
-enable_sndio=false
SNDIO_LIBS=
AC_SEARCH_LIBS([sio_open], [sndio],
[enable_sndio=true
@@ -142,6 +116,11 @@ AC_CHECK_PROG([enable_nsis], [makensis], [true], [false])
AM_CONDITIONAL([ENABLE_NSIS], [test x"$enable_nsis" = x"true"])
AC_CONFIG_FILES([Makefile])
+AC_CONFIG_FILES([cli/Makefile])
+AC_CONFIG_FILES([gtk/Makefile])
+AC_CONFIG_FILES([lib/Makefile])
+AC_CONFIG_FILES([lib/signal/Makefile])
+AC_CONFIG_FILES([librtbuf/Makefile])
AC_OUTPUT
echo "Building status :"
diff --git a/data.c b/data.c
deleted file mode 100644
index f2e3e52..0000000
--- a/data.c
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <assert.h>
-#include <stdlib.h>
-#include <strings.h>
-#include "data.h"
-
-s_data_type g_data_alloc_type = {
- sizeof(s_data_alloc) * 8,
- DATA_TYPE_BITS
-};
-s_data_alloc g_data_alloc;
-
-s_data_type g_data_type_type = {
- sizeof(u_data_type) * 8,
- DATA_TYPE_BITS
-};
-s_data_alloc *g_data_type_alloc = 0;
-
-int libdata_init ()
-{
- data_alloc_init(&g_data_alloc, &g_data_alloc_type,
- DATA_ALLOC_MAX, 0, (f_data_clean*) data_alloc_clean);
- return 0;
-}
-
-void data_alloc_init (s_data_alloc *da, s_data_type *t,
- unsigned int max, f_data_init *init,
- f_data_clean *clean)
-{
- assert(da);
- assert(t);
- da->t = t;
- da->max = max;
- da->mem = calloc(max, (t->bits + 7) / 8);
- da->n = 0;
- da->free = calloc(max, sizeof(unsigned int));
- da->free_n = 0;
- da->init = init;
- da->clean = clean;
-}
-
-void data_alloc_clean (s_data_alloc *da)
-{
- assert(da);
- bzero(da->mem, da->max * ((da->t->bits + 7) / 8));
- bzero(da->free, da->max * sizeof(unsigned int));
- free(da->mem);
- free(da->free);
-}
-
-static inline
-void * data_new_at (s_data_alloc *da, unsigned int i)
-{
- unsigned int octets = (da->t->bits + 7) / 8;
- unsigned int offset = i * octets;
- void *m = da->mem + offset;
- bzero(m, octets);
- if (da->init)
- da->init(m);
- return m;
-}
-
-void * data_new (s_data_alloc *da)
-{
- assert(da);
- if (da->free_n) {
- unsigned int i = da->free[--da->free_n];
- da->free[da->free_n] = 0;
- return data_new_at(da, i);
- }
- if (da->n < da->max) {
- unsigned int i = da->n++;
- return data_new_at(da, i);
- }
- return 0;
-}
-
-int data_new_i (s_data_alloc *da)
-{
- assert(da);
- if (da->free_n) {
- unsigned int i = da->free[--da->free_n];
- da->free[da->free_n] = 0;
- data_new_at(da, i);
- return i;
- }
- if (da->n < da->max) {
- unsigned int i = da->n++;
- data_new_at(da, i);
- return i;
- }
- return -1;
-}
-
-void data_delete (s_data_alloc *da, void *data)
-{
- unsigned int octets;
- unsigned int i;
- assert(da);
- assert(da->t);
- octets = ((da->t->bits + 7) / 8);
- assert(da->mem <= data);
- assert(data < da->mem + da->max * octets);
- if (da->clean)
- da->clean(data);
- bzero(data, octets);
- i = (data - da->mem) / octets;
- da->free[da->free_n++] = i;
-}
-
-s_data_alloc * data_alloc_new (s_data_type *t, unsigned int max,
- f_data_init *init, f_data_clean *clean)
-{
- s_data_alloc *da = data_new(&g_data_alloc);
- assert(da);
- data_alloc_init(da, t, max, init, clean);
- return da;
-}
-
-void data_alloc_delete (s_data_alloc *da)
-{
- assert(da);
- data_delete(&g_data_alloc, da);
-}
-
-u_data_type * data_type_new (unsigned int bits, unsigned int type)
-{
- u_data_type *t;
- if (!g_data_type_alloc)
- g_data_type_alloc = data_alloc_new(&g_data_type_type, DATA_TYPE_MAX,
- 0, 0);
- assert(g_data_type_alloc);
- t = data_new(g_data_type_alloc);
- assert(t);
- t->t.bits = bits;
- t->t.type = type;
- return t;
-}
-
-void data_type_delete (s_data_type *t)
-{
- assert(g_data_type_alloc);
- data_delete(g_data_type_alloc, t);
-}
diff --git a/data.h b/data.h
deleted file mode 100644
index 8e61f96..0000000
--- a/data.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-#ifndef DATA_H
-#define DATA_H
-
-typedef enum {
- DATA_TYPE_BITS,
- DATA_TYPE_VECTOR,
- DATA_TYPE_INTEGER,
- DATA_TYPE_FLOAT,
- DATA_TYPE_STRUCT
-} e_data_type;
-
-#define DATA_TYPE_SIGNED 1
-#define DATA_TYPE_BIG_ENDIAN 2
-
-typedef struct data_type {
- unsigned int bits;
- unsigned int type;
-} s_data_type;
-
-typedef struct data_type_vector {
- s_data_type t;
- s_data_type *element_type;
- unsigned int nmemb;
-} s_data_type_vector;
-
-typedef struct data_type_integer {
- s_data_type t;
- unsigned int flags;
-} s_data_type_integer;
-
-typedef struct data_type_float {
- s_data_type t;
-} s_data_type_float;
-
-typedef struct data_type_struct {
- s_data_type t;
- s_data_type *first;
- struct data_type_struct *rest;
-} s_data_type_struct;
-
-typedef union data_type_ {
- s_data_type t;
- s_data_type_vector t_vector;
- s_data_type_integer t_integer;
- s_data_type_float t_float;
- s_data_type_struct t_struct;
-} u_data_type;
-
-#define DATA_TYPE_MAX 1024
-
-u_data_type * data_type_new (unsigned int bits, unsigned int type);
-void data_type_delete (s_data_type *t);
-
-typedef void f_data_init (void *data);
-typedef void f_data_clean (void *data);
-
-typedef struct data_alloc {
- s_data_type *t;
- unsigned int max;
- void *mem;
- unsigned int n;
- unsigned int *free;
- unsigned int free_n;
- f_data_init *init;
- f_data_clean *clean;
-} s_data_alloc;
-
-#define DATA_ALLOC_MAX 1024
-
-void * data_new (s_data_alloc *da);
-int data_new_i (s_data_alloc *da);
-void data_delete (s_data_alloc *da, void *data);
-
-void data_alloc_init (s_data_alloc *da, s_data_type *t,
- unsigned int max, f_data_init *init,
- f_data_clean *clean);
-void data_alloc_clean (s_data_alloc *da);
-s_data_alloc * data_alloc_new (s_data_type *t,
- unsigned int max, f_data_init *init,
- f_data_clean *clean);
-void data_alloc_delete (s_data_alloc *da);
-
-int libdata_init ();
-
-#endif
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
new file mode 100644
index 0000000..13226b8
--- /dev/null
+++ b/gtk/Makefile.am
@@ -0,0 +1,31 @@
+bin_PROGRAMS = rtbuf-gtk
+rtbuf_gtk_CFLAGS = ${GTK3_CFLAGS}
+rtbuf_gtk_LDADD = ${GTK3_LIBS} ../librtbuf/.libs/librtbuf.la
+rtbuf_gtk_SOURCES = \
+ rtbuf_gtk.c \
+ rtbuf_gtk_connection.c \
+ rtbuf_gtk_input.c \
+ rtbuf_gtk_output.c \
+ rtbuf_gtk_resources.c \
+ rtbuf_gtk_rtbuf.c \
+ rtbuf_input_widget.c \
+ rtbuf_output_widget.c \
+ rtbuf_widget.c
+
+rtbuf_includedir = $(includedir)/rtbuf
+rtbuf_include_HEADERS = \
+ rtbuf_gtk.h \
+ rtbuf_input_widget.h \
+ rtbuf_output_widget.h \
+ rtbuf_widget.h
+
+rtbuf_gtk_UI = \
+ rtbuf_input_widget.ui \
+ rtbuf_modular.ui \
+ rtbuf_output_widget.ui \
+ rtbuf_widget.ui
+rtbuf_gtk_resources.c: rtbuf_gtk.gresource.xml ${rtbuf_gtk_UI}
+ glib-compile-resources rtbuf_gtk.gresource.xml --target=rtbuf_gtk_resources.c --generate-source
+
+CLEANFILES = \
+ rtbuf_gtk_resources.c
diff --git a/gtk/rtbuf_gtk.c b/gtk/rtbuf_gtk.c
new file mode 100644
index 0000000..125599c
--- /dev/null
+++ b/gtk/rtbuf_gtk.c
@@ -0,0 +1,400 @@
+/*
+ * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <assert.h>
+#include <gtk/gtk.h>
+#include <stdio.h>
+#include <rtbuf/rtbuf.h>
+#include "rtbuf_gtk.h"
+#include "rtbuf_input_widget.h"
+#include <rtbuf/lib.h>
+#include <rtbuf/var.h>
+#include "rtbuf_widget.h"
+
+unsigned int g_next_id = 0;
+
+GtkBuilder *builder = NULL;
+
+GtkWindow *modular = NULL;
+s_rtbuf_gtk_connection *modular_connections = NULL;
+GtkLayout *modular_layout = NULL;
+
+GtkMenu *library_menu = NULL;
+
+gint rtbuf_x = 100;
+gint rtbuf_y = 100;
+
+s_rtbuf_gtk_connection *drag_connection = NULL;
+GtkWidget *drag_widget = NULL;
+gint drag_x = 0;
+gint drag_y = 0;
+
+void rtbuf_gtk_drag_connection_end (RtbufInputWidget *input_widget)
+{
+ if (drag_connection) {
+ if (input_widget) {
+ s_rtbuf_gtk_connection *dc = drag_connection;
+ printf("rtbuf-gtk drag connection connected to input\n");
+ drag_connection = NULL;
+ if (!rtbuf_gtk_connection_find(modular_connections,
+ dc->output_widget, input_widget)) {
+ s_rtbuf *src = rtbuf_output_widget_get_rtbuf(dc->output_widget);
+ unsigned int out = rtbuf_output_widget_get_out(dc->output_widget);
+ s_rtbuf *dest = rtbuf_input_widget_get_rtbuf(input_widget);
+ unsigned int in = rtbuf_input_widget_get_in(input_widget);
+ unsigned int src_i = src - g_rtbuf;
+ rtbuf_bind(src_i, out, dest, in);
+ dc->input_widget = input_widget;
+ }
+ else
+ rtbuf_gtk_connection_remove_one(&modular_connections, dc);
+ gtk_widget_queue_draw(GTK_WIDGET(modular_layout));
+ }
+ else {
+ printf("rtbuf-gtk drag connection abort\n");
+ rtbuf_gtk_connection_remove_one(&modular_connections,
+ drag_connection);
+ drag_connection = NULL;
+ gtk_widget_queue_draw(GTK_WIDGET(modular_layout));
+ }
+ }
+}
+
+gboolean rtbuf_gtk_input_button_press (RtbufInputWidget *widget,
+ GdkEvent *event)
+{
+ printf("rtbuf-gtk input button press\n");
+ (void) widget;
+ (void) event;
+ if (drag_connection) {
+ rtbuf_gtk_drag_connection_end(widget);
+ return TRUE;
+ }
+ return TRUE;
+}
+
+RtbufWidget * rtbuf_gtk_modular_layout_new (s_rtbuf *rtbuf,
+ const gint x, const gint y)
+{
+ RtbufWidget *widget;
+ GtkWidget *event_box;
+ char label[1024];
+ assert(rtbuf);
+ assert(rtbuf >= g_rtbuf && (rtbuf - g_rtbuf) < RTBUF_MAX);
+ printf("rtbuf-gtk modular layout new\n");
+ assert(rtbuf->proc);
+ assert(rtbuf->proc->name);
+ snprintf(label, sizeof(label), "%s%02d",
+ rtbuf->proc->name,
+ g_next_id++);
+ rtbuf_var_rtbuf_set(label, rtbuf - g_rtbuf);
+ widget = rtbuf_widget_new(rtbuf, label);
+ gtk_layout_put(modular_layout, GTK_WIDGET(widget), x, y);
+ event_box = rtbuf_widget_get_event_box(widget);
+ g_signal_connect_swapped(G_OBJECT(event_box), "button-press-event",
+ G_CALLBACK(rtbuf_gtk_rtbuf_button_press),
+ widget);
+ rtbuf_widget_connect_inputs
+ (widget, "button-press-event",
+ G_CALLBACK(rtbuf_gtk_input_button_press));
+ rtbuf_widget_connect_input_checks
+ (widget, "button-press-event",
+ G_CALLBACK(rtbuf_gtk_input_button_press));
+ rtbuf_widget_connect_output_checks
+ (widget, "button-press-event",
+ G_CALLBACK(rtbuf_gtk_output_check_button_press));
+ return widget;
+}
+
+RtbufWidget * rtbuf_gtk_new (gchar *library, gchar *proc,
+ const gint x, const gint y)
+{
+ int i;
+ s_rtbuf_lib *rl = 0;
+ s_rtbuf_proc *rp = 0;
+ s_rtbuf *rtb = 0;
+ printf("rtbuf-gtk new %s %s\n", library, proc);
+ i = rtbuf_lib_find(library);
+ if (i < 0) {
+ printf("load %s\n", library);
+ if (!(rl = rtbuf_lib_load(library))) {
+ fprintf(stderr, "rtbuf-gtk: load failed: '%s'\n", library);
+ return NULL;
+ }
+ rtbuf_lib_print(rl);
+ }
+ else {
+ assert(i < RTBUF_LIB_MAX);
+ rl = &g_rtbuf_lib[i];
+ }
+ i = rtbuf_lib_find_proc(rl, proc);
+ if (i < 0) {
+ fprintf(stderr, "rtbuf-gtk new: not found %s %s\n", library, proc);
+ return NULL;
+ }
+ rp = rl->proc[i];
+ assert(g_rtbuf);
+ i = rtbuf_new(rp);
+ if (i < 0) {
+ fprintf(stderr, "rtbuf-gtk new rtbuf_new failed: %s %s\n", library, proc);
+ return NULL;
+ }
+ rtb = &g_rtbuf[i];
+ return rtbuf_gtk_modular_layout_new(rtb, x, y);
+}
+
+void rtbuf_gtk_library_menu_activate (GtkMenuItem *menuitem,
+ gpointer data)
+{
+ gchar *proc;
+ gchar *library = (gchar*) data;
+ g_object_get(menuitem, "label", &proc, NULL);
+ rtbuf_gtk_new(library, proc, rtbuf_x, rtbuf_y);
+ rtbuf_x = 100;
+ rtbuf_y = 100;
+ g_free(proc);
+}
+
+void rtbuf_gtk_library_menu_library_item (GtkWidget *menuitem, gpointer data)
+{
+ gchar *library = (gchar*) data;
+ g_signal_connect(menuitem, "activate", G_CALLBACK(rtbuf_gtk_library_menu_activate), library);
+}
+
+void rtbuf_gtk_library_menu_library (GtkWidget *menuitem, gpointer data)
+{
+ GtkContainer *submenu;
+ gchar *library;
+ (void) data;
+ g_object_get(menuitem,
+ "label", &library,
+ "submenu", &submenu,
+ NULL);
+ gtk_container_foreach(submenu,
+ rtbuf_gtk_library_menu_library_item,
+ library);
+ g_object_unref(G_OBJECT(submenu));
+}
+
+void rtbuf_gtk_library_menu ()
+{
+ library_menu = GTK_MENU(gtk_builder_get_object(builder, "library_menu"));
+ gtk_container_foreach(GTK_CONTAINER(library_menu),
+ rtbuf_gtk_library_menu_library,
+ NULL);
+}
+
+void rtbuf_gtk_modular_close (GtkWidget *widget,
+ gpointer data)
+{
+ (void) widget;
+ (void) data;
+ printf("rtbuf-gtk modular close\n");
+ gtk_main_quit();
+}
+
+void rtbuf_gtk_modular_draw_arrow (cairo_t *cr, int x1, int y1,
+ int x2, int y2)
+{
+ const int arrow_size = 4;
+ int mx = (x2 - x1) / 3;
+ if (mx < 0) {
+ mx = -mx;
+ mx += mx / 2;
+ }
+
+ cairo_move_to(cr, x1, y1);
+ cairo_curve_to(cr,
+ x1 + mx, y1,
+ x2 - mx - arrow_size, y2,
+ x2 - arrow_size, y2);
+ cairo_move_to (cr, x2, y2);
+ cairo_line_to (cr, x2 - arrow_size, y2);
+ cairo_move_to (cr, x2 - arrow_size, y2 - arrow_size);
+ cairo_line_to (cr, x2, y2);
+ cairo_line_to (cr, x2 - arrow_size, y2 + arrow_size);
+}
+
+void rtbuf_gtk_modular_draw_connection (s_rtbuf_gtk_connection *c,
+ cairo_t *cr)
+{
+ int x1, y1, x2, y2;
+ GtkWidget *out = GTK_WIDGET(c->output_widget);
+ GtkAllocation allocation;
+ gtk_widget_get_allocation(out, &allocation);
+ gtk_widget_translate_coordinates(out, GTK_WIDGET(modular_layout),
+ allocation.width,
+ allocation.height / 2,
+ &x1, &y1);
+ if (c->input_widget) {
+ GtkWidget *in = GTK_WIDGET(c->input_widget);
+ gtk_widget_get_allocation(in, &allocation);
+ gtk_widget_translate_coordinates(in, GTK_WIDGET(modular_layout),
+ 0,
+ allocation.height / 2,
+ &x2, &y2);
+ x2 -= 2;
+ }
+ 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);
+}
+
+gboolean rtbuf_gtk_modular_draw (GtkWidget *widget,
+ cairo_t *cr,
+ gpointer data)
+{
+ (void) data;
+ if ((GtkLayout*) widget == modular_layout) {
+ s_rtbuf_gtk_connection *c = modular_connections;
+ cairo_set_source_rgb(cr, 0.5, 0.5, 0.5);
+ cairo_paint(cr);
+ while (c) {
+ rtbuf_gtk_modular_draw_connection(c, cr);
+ c = c->next;
+ }
+ GTK_WIDGET_GET_CLASS(widget)->draw(widget, cr);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+gboolean rtbuf_gtk_modular_button_press (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer data)
+{
+ (void) widget;
+ (void) data;
+ if (widget == GTK_WIDGET(modular_layout) &&
+ event->type == GDK_BUTTON_PRESS) {
+ GdkEventButton *eb = (GdkEventButton*) event;
+ if (eb->button == 1) {
+ if (drag_connection) {
+ rtbuf_gtk_drag_connection_end(NULL);
+ return TRUE;
+ }
+ }
+ else 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(window, eb->device,
+ &rtbuf_x, &rtbuf_y, NULL);
+ gtk_menu_popup_at_pointer(library_menu, event);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+gboolean rtbuf_gtk_modular_motion (GtkWidget *widget,
+ GdkEventMotion *event,
+ gpointer data)
+{
+ (void) widget;
+ (void) data;
+ if (drag_widget) {
+ if (!(event->state & GDK_BUTTON1_MASK)) {
+ printf("rtbuf-gtk modular drop widget\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 (drag_connection) {
+ GdkWindow *window;
+ window = gtk_widget_get_window(GTK_WIDGET(modular_layout));
+ gdk_window_get_device_position(window, event->device,
+ &drag_x, &drag_y, NULL);
+ drag_connection->input_widget = NULL;
+ gtk_widget_queue_draw(GTK_WIDGET(modular_layout));
+ return TRUE;
+ }
+ return FALSE;
+}
+
+void rtbuf_gtk_modular ()
+{
+ GObject *button;
+
+ modular = GTK_WINDOW(gtk_builder_get_object(builder, "modular"));
+ g_signal_connect(modular, "destroy",
+ G_CALLBACK(rtbuf_gtk_modular_close), NULL);
+
+ button = gtk_builder_get_object(builder, "quit");
+ g_signal_connect(button, "activate",
+ G_CALLBACK(rtbuf_gtk_modular_close), NULL);
+
+ modular_layout = GTK_LAYOUT(gtk_builder_get_object(builder, "modular_layout"));
+ gtk_widget_add_events(GTK_WIDGET(modular_layout), GDK_BUTTON_PRESS_MASK);
+ g_signal_connect(modular_layout, "button-press-event",
+ G_CALLBACK(rtbuf_gtk_modular_button_press), NULL);
+ g_signal_connect(modular_layout, "draw",
+ G_CALLBACK(rtbuf_gtk_modular_draw), NULL);
+
+ rtbuf_gtk_library_menu();
+
+ g_signal_connect(modular_layout, "motion-notify-event",
+ G_CALLBACK(rtbuf_gtk_modular_motion), NULL);
+}
+
+int rtbuf_gtk_builder ()
+{
+ GError *error = NULL;
+ builder = gtk_builder_new ();
+ if (gtk_builder_add_from_resource(builder, "/rtbuf/rtbuf_modular.ui", &error) == 0) {
+ g_printerr("Error loading resource /rtbuf/rtbuf_modular.ui: %s\n", error->message);
+ g_clear_error(&error);
+ return 1;
+ }
+ return 0;
+}
+
+int main (int argc, char *argv[])
+{
+ symbols_init();
+ librtbuf_init();
+ assert(g_rtbuf);
+ gtk_init(&argc, &argv);
+ rtbuf_gtk_connection_init();
+ rtbuf_gtk_output_init();
+ if (rtbuf_gtk_builder())
+ return 1;
+ rtbuf_gtk_modular();
+ gtk_main ();
+ return 0;
+}
+
+extern int rtbuf_err (const char *msg)
+{
+ fprintf(stderr, "rtbuf-gtk: %s\n", msg);
+ return -1;
+}
diff --git a/gtk/rtbuf_gtk.gresource.xml b/gtk/rtbuf_gtk.gresource.xml
new file mode 100644
index 0000000..59fdc3c
--- /dev/null
+++ b/gtk/rtbuf_gtk.gresource.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/rtbuf/">
+ <file preprocess="xml-stripblanks">rtbuf_input_widget.ui</file>
+ <file preprocess="xml-stripblanks">rtbuf_modular.ui</file>
+ <file preprocess="xml-stripblanks">rtbuf_output_widget.ui</file>
+ <file preprocess="xml-stripblanks">rtbuf_widget.ui</file>
+ </gresource>
+</gresources>
diff --git a/gtk/rtbuf_gtk.h b/gtk/rtbuf_gtk.h
new file mode 100644
index 0000000..564c3ba
--- /dev/null
+++ b/gtk/rtbuf_gtk.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifndef RTBUF_GTK_H
+#define RTBUF_GTK_H
+
+#include <gtk/gtk.h>
+#include "rtbuf_gtk_connection.h"
+#include "rtbuf_input_widget.h"
+#include "rtbuf_output_widget.h"
+#include "rtbuf_widget.h"
+
+enum dnd_targets {
+ TARGET_RTBUF,
+ TARGET_RTBUF_OUTPUT,
+ N_TARGETS
+};
+
+typedef struct signal_binding {
+ const char *signal;
+ GCallback callback;
+} s_signal_binding;
+
+extern GtkLayout *modular_layout;
+extern s_rtbuf_gtk_connection *modular_connections;
+
+extern GtkTargetList *rtbuf_move_target_list;
+
+extern GtkWidget *drag_widget;
+extern s_rtbuf_gtk_connection *drag_connection;
+extern gint drag_x;
+extern gint drag_y;
+
+void rtbuf_gtk_drag_connection_end (RtbufInputWidget *input_widget);
+
+gboolean rtbuf_gtk_rtbuf_button_press (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer data);
+
+gboolean rtbuf_gtk_input_check_button_press (RtbufInputWidget *widget,
+ GdkEvent *event);
+
+void rtbuf_gtk_output_init ();
+gboolean rtbuf_gtk_output_check_button_press (RtbufOutputWidget *widget,
+ GdkEvent *event);
+gboolean rtbuf_gtk_output_check_button_release (RtbufOutputWidget *widget,
+ GdkEvent *event);
+
+#endif /* RTBUF_GTK_H */
diff --git a/gtk/rtbuf_gtk_connection.c b/gtk/rtbuf_gtk_connection.c
new file mode 100644
index 0000000..900a12f
--- /dev/null
+++ b/gtk/rtbuf_gtk_connection.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <assert.h>
+#include <rtbuf/data.h>
+#include "rtbuf_gtk.h"
+
+s_data_type g_rtbuf_gtk_connection_type = {
+ sizeof(s_rtbuf_gtk_connection) * 8,
+ DATA_TYPE_BITS
+};
+s_data_alloc g_rtbuf_gtk_connection_alloc;
+
+void rtbuf_gtk_connection_init ()
+{
+ data_alloc_init(&g_rtbuf_gtk_connection_alloc,
+ &g_rtbuf_gtk_connection_type,
+ RTBUF_MAX * 10, NULL, NULL);
+}
+
+s_rtbuf_gtk_connection * rtbuf_gtk_connection_new ()
+{
+ s_rtbuf_gtk_connection *connection = data_new(&g_rtbuf_gtk_connection_alloc);
+ return connection;
+}
+
+void rtbuf_gtk_connection_delete (s_rtbuf_gtk_connection *connection)
+{
+ data_delete(&g_rtbuf_gtk_connection_alloc, connection);
+}
+
+void rtbuf_gtk_connection_push (s_rtbuf_gtk_connection **head,
+ s_rtbuf_gtk_connection *item)
+{
+ assert(!item->next);
+ item->next = *head;
+ *head = item;
+}
+
+int rtbuf_gtk_connection_remove_one (s_rtbuf_gtk_connection **head,
+ s_rtbuf_gtk_connection *item)
+{
+ s_rtbuf_gtk_connection **next = head;
+ while (*next && *next != item)
+ next = &(*next)->next;
+ if (*next == item) {
+ *next = item->next;
+ return 1;
+ }
+ return 0;
+}
+
+s_rtbuf_gtk_connection * rtbuf_gtk_connection_find
+(s_rtbuf_gtk_connection *c,
+ RtbufOutputWidget *output_widget,
+ RtbufInputWidget *input_widget)
+{
+ while (c && (c->output_widget != output_widget ||
+ c->input_widget != input_widget))
+ c = c->next;
+ return c;
+}
+
diff --git a/gtk/rtbuf_gtk_connection.h b/gtk/rtbuf_gtk_connection.h
new file mode 100644
index 0000000..eba2c4a
--- /dev/null
+++ b/gtk/rtbuf_gtk_connection.h
@@ -0,0 +1,28 @@
+#ifndef RTBUF_GTK_CONNECTION_H
+#define RTBUF_GTK_CONNECTION_H
+
+#include "rtbuf_input_widget.h"
+#include "rtbuf_output_widget.h"
+
+typedef struct rtbuf_gtk_connection s_rtbuf_gtk_connection;
+
+struct rtbuf_gtk_connection {
+ RtbufOutputWidget *output_widget;
+ RtbufInputWidget *input_widget;
+ s_rtbuf_gtk_connection *next;
+};
+
+void rtbuf_gtk_connection_init ();
+s_rtbuf_gtk_connection * rtbuf_gtk_connection_new ();
+void rtbuf_gtk_connection_delete (s_rtbuf_gtk_connection *connection);
+
+void rtbuf_gtk_connection_push (s_rtbuf_gtk_connection **head,
+ s_rtbuf_gtk_connection *item);
+int rtbuf_gtk_connection_remove_one (s_rtbuf_gtk_connection **head,
+ s_rtbuf_gtk_connection *item);
+s_rtbuf_gtk_connection * rtbuf_gtk_connection_find
+(s_rtbuf_gtk_connection *c,
+ RtbufOutputWidget *output_widget,
+ RtbufInputWidget *input_widget);
+
+#endif
diff --git a/gtk/rtbuf_gtk_input.c b/gtk/rtbuf_gtk_input.c
new file mode 100644
index 0000000..3bc4800
--- /dev/null
+++ b/gtk/rtbuf_gtk_input.c
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <assert.h>
+#include <gtk/gtk.h>
+#include <stdio.h>
+#include <rtbuf/rtbuf.h>
+#include "rtbuf_gtk.h"
+#include "rtbuf_input_widget.h"
+
+GtkTargetList *rtbuf_gtk_input_target_list;
+#define RTBUF_GTK_INPUT_TARGETS 1
+GtkTargetEntry rtbuf_gtk_input_target_entry[RTBUF_GTK_INPUT_TARGETS]
+= {
+ {"RtbufOutputWidget", GTK_TARGET_SAME_APP, TARGET_RTBUF_OUTPUT}
+};
+
+void rtbuf_gtk_input_init ()
+{
+ rtbuf_gtk_input_target_list =
+ gtk_target_list_new(rtbuf_gtk_input_target_entry,
+ RTBUF_GTK_INPUT_TARGETS);
+}
+
+void rtbuf_gtk_input_disconnect (RtbufInputWidget *widget)
+{
+ (void) widget;
+ printf("rtbuf-gtk input disconnect\n");
+}
+
+void rtbuf_gtk_input_menu (RtbufInputWidget *widget, GdkEvent *event)
+{
+ static GtkMenu *menu = 0;
+ static GtkWidget *disconnect;
+ static guint signal;
+ printf("rtbuf-gtk input menu\n");
+ if (!menu) {
+ signal = g_signal_lookup("activate", GTK_TYPE_MENU_ITEM);
+ assert(signal);
+ menu = GTK_MENU(gtk_menu_new());
+ disconnect = gtk_menu_item_new_with_label("Disconnect");
+ gtk_container_add(GTK_CONTAINER(menu), disconnect);
+ gtk_widget_show(disconnect);
+ }
+ g_signal_handlers_disconnect_matched(G_OBJECT(disconnect),
+ G_SIGNAL_MATCH_FUNC,
+ signal,
+ 0,
+ NULL,
+ G_CALLBACK(rtbuf_gtk_input_disconnect),
+ NULL);
+ g_signal_connect_swapped(G_OBJECT(disconnect), "activate",
+ G_CALLBACK(rtbuf_gtk_input_disconnect),
+ widget);
+ gtk_menu_popup_at_pointer(menu, event);
+}
+
+gboolean rtbuf_gtk_input_check_button_press (RtbufInputWidget *widget,
+ GdkEvent *event)
+{
+ printf("rtbuf-gtk input check button press\n");
+ if (event->type == GDK_BUTTON_PRESS) {
+ GdkEventButton *eb = (GdkEventButton*) event;
+ if (eb->button == 3) {
+ rtbuf_gtk_input_menu(widget, event);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
diff --git a/gtk/rtbuf_gtk_output.c b/gtk/rtbuf_gtk_output.c
new file mode 100644
index 0000000..cb6d9bf
--- /dev/null
+++ b/gtk/rtbuf_gtk_output.c
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <assert.h>
+#include <gtk/gtk.h>
+#include <stdio.h>
+#include <rtbuf/rtbuf.h>
+#include "rtbuf_gtk.h"
+#include "rtbuf_output_widget.h"
+
+GtkTargetList *rtbuf_gtk_output_target_list;
+#define RTBUF_GTK_OUTPUT_TARGETS 1
+GtkTargetEntry rtbuf_gtk_output_target_entry[RTBUF_GTK_OUTPUT_TARGETS]
+= {
+ {"RtbufOutputWidget", GTK_TARGET_SAME_APP, TARGET_RTBUF_OUTPUT}
+};
+
+void rtbuf_gtk_output_init ()
+{
+ rtbuf_gtk_output_target_list =
+ gtk_target_list_new(rtbuf_gtk_output_target_entry,
+ RTBUF_GTK_OUTPUT_TARGETS);
+}
+
+void rtbuf_gtk_output_disconnect (RtbufOutputWidget *widget)
+{
+ (void) widget;
+ printf("rtbuf-gtk output disconnect\n");
+}
+
+void rtbuf_gtk_output_menu (RtbufOutputWidget *widget, GdkEvent *event)
+{
+ static GtkMenu *menu = 0;
+ static GtkWidget *disconnect;
+ static guint signal;
+ printf("rtbuf-gtk output menu\n");
+ if (!menu) {
+ signal = g_signal_lookup("activate", GTK_TYPE_MENU_ITEM);
+ assert(signal);
+ menu = GTK_MENU(gtk_menu_new());
+ disconnect = gtk_menu_item_new_with_label("Disconnect");
+ gtk_container_add(GTK_CONTAINER(menu), disconnect);
+ gtk_widget_show(disconnect);
+ }
+ g_signal_handlers_disconnect_matched(G_OBJECT(disconnect),
+ G_SIGNAL_MATCH_FUNC,
+ signal,
+ 0,
+ NULL,
+ G_CALLBACK(rtbuf_gtk_output_disconnect),
+ NULL);
+ g_signal_connect_swapped(G_OBJECT(disconnect), "activate",
+ G_CALLBACK(rtbuf_gtk_output_disconnect),
+ widget);
+ gtk_menu_popup_at_pointer(menu, event);
+}
+
+void rtbuf_gtk_output_drag (RtbufOutputWidget *widget,
+ GdkEventButton *event)
+{
+ s_rtbuf_gtk_connection *connection;
+ (void) event;
+ printf("rtbuf-gtk output drag\n");
+ connection = rtbuf_gtk_connection_new();
+ if (!connection) {
+ rtbuf_err("failed to allocate rtbuf_gtk_connection");
+ return;
+ }
+ connection->output_widget = widget;
+ rtbuf_gtk_connection_push(&modular_connections, connection);
+ drag_connection = connection;
+}
+
+gboolean rtbuf_gtk_output_check_button_press (RtbufOutputWidget *widget,
+ GdkEvent *event)
+{
+ printf("rtbuf-gtk output check button press\n");
+ if (event->type == GDK_BUTTON_PRESS) {
+ GdkEventButton *eb = (GdkEventButton*) event;
+ if (eb->button == 1) {
+ rtbuf_gtk_output_drag(widget, eb);
+ return TRUE;
+ }
+ else if (eb->button == 3) {
+ rtbuf_gtk_output_menu(widget, event);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
diff --git a/gtk/rtbuf_gtk_rtbuf.c b/gtk/rtbuf_gtk_rtbuf.c
new file mode 100644
index 0000000..832219a
--- /dev/null
+++ b/gtk/rtbuf_gtk_rtbuf.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <assert.h>
+#include <gtk/gtk.h>
+#include <stdio.h>
+#include <rtbuf/rtbuf.h>
+#include "rtbuf_gtk.h"
+#include "rtbuf_widget.h"
+
+void rtbuf_gtk_rtbuf_rename (RtbufWidget *widget)
+{
+ (void) widget;
+ printf("rtbuf-gtk rtbuf rename\n");
+}
+
+void rtbuf_gtk_rtbuf_delete (RtbufWidget *widget)
+{
+ s_rtbuf *rtbuf = rtbuf_widget_get_rtbuf(widget);
+ printf("rtbuf-gtk rtbuf delete\n");
+ gtk_container_remove(GTK_CONTAINER(modular_layout),
+ GTK_WIDGET(widget));
+ rtbuf_delete(rtbuf);
+}
+
+void rtbuf_gtk_rtbuf_menu (RtbufWidget *widget, GdkEvent *event)
+{
+ static GtkMenu *menu = 0;
+ static GtkWidget *rename;
+ static GtkWidget *delete;
+ static guint signal;
+ printf("rtbuf-gtk rtbuf menu\n");
+ if (!menu) {
+ signal = g_signal_lookup("activate", GTK_TYPE_MENU_ITEM);
+ assert(signal);
+ menu = GTK_MENU(gtk_menu_new());
+ rename = gtk_menu_item_new_with_label("Rename...");
+ gtk_container_add(GTK_CONTAINER(menu), rename);
+ gtk_widget_show(rename);
+ delete = gtk_menu_item_new_with_label("Delete");
+ gtk_container_add(GTK_CONTAINER(menu), delete);
+ gtk_widget_show(delete);
+ }
+ g_signal_handlers_disconnect_matched(G_OBJECT(rename),
+ G_SIGNAL_MATCH_FUNC,
+ signal,
+ 0,
+ NULL,
+ G_CALLBACK(rtbuf_gtk_rtbuf_rename),
+ NULL);
+ g_signal_connect_swapped(G_OBJECT(rename), "activate",
+ G_CALLBACK(rtbuf_gtk_rtbuf_rename),
+ widget);
+ g_signal_handlers_disconnect_matched(G_OBJECT(delete),
+ G_SIGNAL_MATCH_FUNC,
+ signal,
+ 0,
+ NULL,
+ G_CALLBACK(rtbuf_gtk_rtbuf_delete),
+ NULL);
+ g_signal_connect_swapped(G_OBJECT(delete), "activate",
+ G_CALLBACK(rtbuf_gtk_rtbuf_delete),
+ widget);
+ gtk_menu_popup_at_pointer(menu, event);
+}
+
+void rtbuf_gtk_rtbuf_drag (RtbufWidget *widget,
+ GdkEventButton *event)
+{
+ GtkWidget *gtk_widget = GTK_WIDGET(widget);
+ printf("rtbuf-gtk rtbuf drag\n");
+ gdk_window_get_device_position(event->window, event->device,
+ &drag_x, &drag_y, NULL);
+ drag_widget = gtk_widget;
+}
+
+gboolean rtbuf_gtk_rtbuf_button_press (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer data)
+{
+ RtbufWidget *rtbuf_widget = RTBUF_WIDGET(widget);
+ (void) data;
+ printf("rtbuf-gtk rtbuf button press\n");
+ if (event->type == GDK_BUTTON_PRESS) {
+ GdkEventButton *eb = (GdkEventButton*) event;
+ if (eb->button == 1) {
+ rtbuf_gtk_rtbuf_drag(rtbuf_widget, eb);
+ return TRUE;
+ }
+ else if (eb->button == 3) {
+ rtbuf_gtk_rtbuf_menu(rtbuf_widget, event);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
diff --git a/gtk/rtbuf_input_widget.c b/gtk/rtbuf_input_widget.c
new file mode 100644
index 0000000..853ca92
--- /dev/null
+++ b/gtk/rtbuf_input_widget.c
@@ -0,0 +1,228 @@
+/*
+ * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <assert.h>
+#include <gtk/gtk.h>
+#include "rtbuf_gtk.h"
+#include "rtbuf_input_widget.h"
+#include <rtbuf/rtbuf.h>
+
+struct _RtbufInputWidgetPrivate {
+ s_rtbuf *rtbuf;
+ int in;
+ GtkWidget *check;
+ GtkWidget *label;
+ GtkWidget *value;
+ GtkWidget *min;
+ GtkWidget *slider;
+ GtkWidget *max;
+};
+
+enum {
+ PROP_0,
+ PROP_RTBUF,
+ PROP_IN,
+ LAST_PROP
+};
+
+static GParamSpec *rtbuf_input_widget_props[LAST_PROP];
+
+static void rtbuf_input_widget_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void rtbuf_input_widget_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void rtbuf_input_widget_finalize (GObject *object);
+
+G_DEFINE_TYPE_WITH_PRIVATE (RtbufInputWidget, rtbuf_input_widget, GTK_TYPE_BOX)
+
+static void
+rtbuf_input_widget_class_init (RtbufInputWidgetClass *klass)
+{
+ GObjectClass *gobject_class = (GObjectClass*) klass;
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
+ printf("rtbuf_input_widget class init\n");
+ gobject_class->finalize = rtbuf_input_widget_finalize;
+ gobject_class->set_property = rtbuf_input_widget_set_property;
+ gobject_class->get_property = rtbuf_input_widget_get_property;
+ rtbuf_input_widget_props[PROP_RTBUF] =
+ g_param_spec_pointer("rtbuf",
+ "Rtbuf",
+ "Pointer to a s_rtbuf",
+ G_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
+ rtbuf_input_widget_props[PROP_IN] =
+ g_param_spec_int("in",
+ "Input",
+ "rtbuf input index",
+ -1, /* min */
+ RTBUF_PROC_IN_MAX, /* max */
+ -1, /* default */
+ G_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
+ g_object_class_install_properties(gobject_class, LAST_PROP, rtbuf_input_widget_props);
+ gtk_widget_class_set_template_from_resource(widget_class,
+ "/rtbuf/rtbuf_input_widget.ui");
+ gtk_widget_class_bind_template_child_private(widget_class,
+ RtbufInputWidget, check);
+ gtk_widget_class_bind_template_child_private(widget_class,
+ RtbufInputWidget, label);
+ gtk_widget_class_bind_template_child_private(widget_class,
+ RtbufInputWidget, value);
+ gtk_widget_class_bind_template_child_private(widget_class,
+ RtbufInputWidget, min);
+ gtk_widget_class_bind_template_child_private(widget_class,
+ RtbufInputWidget, slider);
+ gtk_widget_class_bind_template_child_private(widget_class,
+ RtbufInputWidget, max);
+}
+
+static void
+rtbuf_input_widget_init (RtbufInputWidget *widget)
+{
+ printf("rtbuf_input_widget init\n");
+ gtk_widget_init_template(GTK_WIDGET(widget));
+}
+
+static void
+rtbuf_input_widget_set_property (GObject *object, guint prop_id,
+ const GValue *value, GParamSpec *pspec)
+{
+ RtbufInputWidget *widget = RTBUF_INPUT_WIDGET(object);
+ RtbufInputWidgetPrivate *priv =
+ rtbuf_input_widget_get_instance_private(widget);
+ switch (prop_id) {
+ case PROP_RTBUF:
+ priv->rtbuf = g_value_get_pointer(value);
+ rtbuf_input_widget_update(widget);
+ break;
+ case PROP_IN:
+ priv->in = g_value_get_int(value);
+ rtbuf_input_widget_update(widget);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+rtbuf_input_widget_get_property (GObject *object, guint prop_id,
+ GValue *value, GParamSpec *pspec)
+{
+ RtbufInputWidget *widget = RTBUF_INPUT_WIDGET(object);
+ RtbufInputWidgetPrivate *priv =
+ rtbuf_input_widget_get_instance_private(widget);
+ switch (prop_id) {
+ case PROP_RTBUF:
+ g_value_set_pointer(value, priv->rtbuf);
+ break;
+ case PROP_IN:
+ g_value_set_int(value, priv->in);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+rtbuf_input_widget_finalize (GObject *object)
+{
+ RtbufInputWidget *widget = RTBUF_INPUT_WIDGET(object);
+ RtbufInputWidgetPrivate *priv =
+ rtbuf_input_widget_get_instance_private(widget);
+ g_clear_object(&priv->check);
+ g_clear_object(&priv->label);
+ g_clear_object(&priv->value);
+ g_clear_object(&priv->min);
+ g_clear_object(&priv->slider);
+ g_clear_object(&priv->max);
+ G_OBJECT_CLASS(rtbuf_input_widget_parent_class)->finalize(object);
+}
+
+RtbufInputWidget *
+rtbuf_input_widget_new (s_rtbuf *rtbuf, unsigned int in)
+{
+ return (RtbufInputWidget*) g_object_new(RTBUF_INPUT_WIDGET_TYPE,
+ "rtbuf", rtbuf,
+ "in", in,
+ NULL);
+}
+
+s_rtbuf *
+rtbuf_input_widget_get_rtbuf (RtbufInputWidget *widget)
+{
+ RtbufInputWidgetPrivate *priv =
+ rtbuf_input_widget_get_instance_private(widget);
+ if (priv)
+ return priv->rtbuf;
+ return NULL;
+}
+
+unsigned int
+rtbuf_input_widget_get_in (RtbufInputWidget *widget)
+{
+ RtbufInputWidgetPrivate *priv =
+ rtbuf_input_widget_get_instance_private(widget);
+ if (priv)
+ return priv->in;
+ return 0;
+}
+
+GtkWidget *
+rtbuf_input_widget_get_check (RtbufInputWidget *widget)
+{
+ RtbufInputWidgetPrivate *priv =
+ rtbuf_input_widget_get_instance_private(widget);
+ if (priv)
+ return priv->check;
+ return NULL;
+}
+
+void
+rtbuf_input_widget_update (RtbufInputWidget *widget)
+{
+ const RtbufInputWidgetPrivate *priv =
+ rtbuf_input_widget_get_instance_private(widget);
+ if (priv && priv->rtbuf && priv->in >= 0) {
+ const s_rtbuf_proc *proc = priv->rtbuf->proc;
+ const char *label;
+ assert((long long) priv->in < (long long) proc->in_n);
+ label = proc->in[priv->in].name;
+ gtk_label_set_text(GTK_LABEL(priv->label), label);
+ }
+}
+
+void rtbuf_input_widget_connect (GtkWidget *widget,
+ gpointer data)
+{
+ s_signal_binding *sb = (s_signal_binding*) data;
+ g_signal_connect(G_OBJECT(widget), sb->signal,
+ sb->callback, NULL);
+}
+
+void rtbuf_input_widget_connect_check (GtkWidget *input,
+ gpointer data)
+{
+ RtbufInputWidget *widget = RTBUF_INPUT_WIDGET(input);
+ RtbufInputWidgetPrivate *priv =
+ rtbuf_input_widget_get_instance_private(widget);
+ s_signal_binding *sb = (s_signal_binding*) data;
+ g_signal_connect_swapped(G_OBJECT(priv->check), sb->signal,
+ sb->callback, widget);
+}
diff --git a/gtk/rtbuf_input_widget.h b/gtk/rtbuf_input_widget.h
new file mode 100644
index 0000000..c4342ad
--- /dev/null
+++ b/gtk/rtbuf_input_widget.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef RTBUF_INPUT_WIDGET_H
+#define RTBUF_INPUT_WIDGET_H
+
+#include <rtbuf/rtbuf.h>
+
+#define RTBUF_INPUT_WIDGET_TYPE \
+ (rtbuf_input_widget_get_type())
+
+#define RTBUF_INPUT_WIDGET(object) \
+ (G_TYPE_CHECK_INSTANCE_CAST((object), RTBUF_INPUT_WIDGET_TYPE, \
+ RtbufInputWidget))
+
+#define RTBUF_INPUT_WIDGET_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), RTBUF_INPUT_WIDGET_TYPE, \
+ RtbufInputWidgetClass))
+
+#define IS_RTBUF_INPUT_WIDGET(object) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((object), RTBUF_INPUT_WIDGET_TYPE))
+
+#define IS_RTBUF_INPUT_WIDGET_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), RTBUF_INPUT_WIDGET_TYPE))
+
+#define RTBUF_INPUT_WIDGET_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS((obj), RTBUF_INPUT_WIDGET_TYPE, \
+ RtbufInputWidgetClass))
+
+typedef struct _RtbufInputWidget RtbufInputWidget;
+typedef struct _RtbufInputWidgetClass RtbufInputWidgetClass;
+typedef struct _RtbufInputWidgetPrivate RtbufInputWidgetPrivate;
+
+struct _RtbufInputWidget {
+ GtkBox box;
+};
+
+struct _RtbufInputWidgetClass {
+ GtkBoxClass parent_class;
+};
+
+GType rtbuf_input_widget_get_type (void) G_GNUC_CONST;
+RtbufInputWidget * rtbuf_input_widget_new (s_rtbuf *rtbuf,
+ unsigned int in);
+s_rtbuf * rtbuf_input_widget_get_rtbuf (RtbufInputWidget *widget);
+unsigned int rtbuf_input_widget_get_in (RtbufInputWidget *widget);
+GtkWidget * rtbuf_input_widget_get_check (RtbufInputWidget *widget);
+void rtbuf_input_widget_update (RtbufInputWidget *widget);
+void rtbuf_input_widget_connect (GtkWidget *input,
+ gpointer data);
+void rtbuf_input_widget_connect_check (GtkWidget *input,
+ gpointer data);
+
+#endif
diff --git a/gtk/rtbuf_input_widget.ui b/gtk/rtbuf_input_widget.ui
new file mode 100644
index 0000000..450a8a3
--- /dev/null
+++ b/gtk/rtbuf_input_widget.ui
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.2 -->
+<interface>
+ <requires lib="gtk+" version="3.20"/>
+ <template class="RtbufInputWidget" parent="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_BUTTON_MOTION_MASK | GDK_STRUCTURE_MASK</property>
+ <child>
+ <object class="GtkCheckButton" id="check">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_BUTTON_MOTION_MASK | GDK_STRUCTURE_MASK</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_BUTTON_MOTION_MASK | GDK_STRUCTURE_MASK</property>
+ <property name="label" translatable="yes">input</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="value">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">0.5</property>
+ <property name="width_chars">9</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="min">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="has_frame">False</property>
+ <property name="width_chars">9</property>
+ <property name="text" translatable="yes">0.0</property>
+ <property name="caps_lock_warning">False</property>
+ <property name="input_purpose">number</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScale" id="slider">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="round_digits">1</property>
+ <property name="digits">3</property>
+ <property name="draw_value">False</property>
+ <property name="value_pos">left</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="max">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="has_frame">False</property>
+ <property name="width_chars">9</property>
+ <property name="text" translatable="yes">1.0</property>
+ <property name="input_purpose">number</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">5</property>
+ </packing>
+ </child>
+ </template>
+</interface>
diff --git a/gtk/rtbuf_modular.ui b/gtk/rtbuf_modular.ui
new file mode 100644
index 0000000..58ccab7
--- /dev/null
+++ b/gtk/rtbuf_modular.ui
@@ -0,0 +1,247 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<interface>
+ <requires lib="gtk+" version="3.20"/>
+ <object class="GtkWindow" id="modular">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child type="titlebar">
+ <placeholder/>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkMenuBar">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkMenuItem">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">_File</property>
+ <property name="use_underline">True</property>
+ <child type="submenu">
+ <object class="GtkMenu">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkImageMenuItem">
+ <property name="label">gtk-new</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImageMenuItem">
+ <property name="label">gtk-open</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImageMenuItem">
+ <property name="label">gtk-save</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImageMenuItem">
+ <property name="label">gtk-save-as</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkSeparatorMenuItem">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImageMenuItem" id="quit">
+ <property name="label">gtk-quit</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">_Edit</property>
+ <property name="use_underline">True</property>
+ <child type="submenu">
+ <object class="GtkMenu">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkImageMenuItem">
+ <property name="label">gtk-cut</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImageMenuItem">
+ <property name="label">gtk-copy</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImageMenuItem">
+ <property name="label">gtk-paste</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImageMenuItem">
+ <property name="label">gtk-delete</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">_Library</property>
+ <property name="use_underline">True</property>
+ <child type="submenu">
+ <object class="GtkMenu" id="library_menu">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkMenuItem">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label">signal</property>
+ <child type="submenu">
+ <object class="GtkMenu">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkMenuItem">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label">sinus</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">_View</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">_Help</property>
+ <property name="use_underline">True</property>
+ <child type="submenu">
+ <object class="GtkMenu">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkImageMenuItem">
+ <property name="label">gtk-about</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToolbar">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkLayout" id="modular_layout">
+ <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>
+ <property name="height">8192</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/gtk/rtbuf_output_widget.c b/gtk/rtbuf_output_widget.c
new file mode 100644
index 0000000..fb3cdb9
--- /dev/null
+++ b/gtk/rtbuf_output_widget.c
@@ -0,0 +1,205 @@
+/*
+ * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <assert.h>
+#include <gtk/gtk.h>
+#include "rtbuf_gtk.h"
+#include "rtbuf_output_widget.h"
+#include <rtbuf/rtbuf.h>
+
+struct _RtbufOutputWidgetPrivate {
+ s_rtbuf *rtbuf;
+ int out;
+ GtkWidget *check;
+ GtkWidget *label;
+};
+
+enum {
+ PROP_0,
+ PROP_RTBUF,
+ PROP_OUT,
+ LAST_PROP
+};
+
+static GParamSpec *rtbuf_output_widget_props[LAST_PROP];
+
+static void rtbuf_output_widget_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void rtbuf_output_widget_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void rtbuf_output_widget_finalize (GObject *object);
+
+G_DEFINE_TYPE_WITH_PRIVATE (RtbufOutputWidget, rtbuf_output_widget, GTK_TYPE_BOX)
+
+static void
+rtbuf_output_widget_class_init (RtbufOutputWidgetClass *klass)
+{
+ GObjectClass *gobject_class = (GObjectClass*) klass;
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
+ printf("rtbuf_output_widget class init\n");
+ gobject_class->finalize = rtbuf_output_widget_finalize;
+ gobject_class->set_property = rtbuf_output_widget_set_property;
+ gobject_class->get_property = rtbuf_output_widget_get_property;
+ rtbuf_output_widget_props[PROP_RTBUF] =
+ g_param_spec_pointer("rtbuf",
+ "Rtbuf",
+ "Pointer to a s_rtbuf",
+ G_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
+ rtbuf_output_widget_props[PROP_OUT] =
+ g_param_spec_int("out",
+ "Output",
+ "rtbuf output index",
+ -1, /* min */
+ RTBUF_PROC_OUT_MAX, /* max */
+ -1, /* default */
+ G_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
+ g_object_class_install_properties(gobject_class, LAST_PROP, rtbuf_output_widget_props);
+ gtk_widget_class_set_template_from_resource(widget_class,
+ "/rtbuf/rtbuf_output_widget.ui");
+ gtk_widget_class_bind_template_child_private(widget_class,
+ RtbufOutputWidget, check);
+ gtk_widget_class_bind_template_child_private(widget_class,
+ RtbufOutputWidget, label);
+}
+
+static void
+rtbuf_output_widget_init (RtbufOutputWidget *widget)
+{
+ printf("rtbuf_output_widget init\n");
+ gtk_widget_init_template(GTK_WIDGET(widget));
+}
+
+static void
+rtbuf_output_widget_set_property (GObject *object, guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ RtbufOutputWidget *widget = RTBUF_OUTPUT_WIDGET(object);
+ RtbufOutputWidgetPrivate *priv =
+ rtbuf_output_widget_get_instance_private(widget);
+ switch (prop_id) {
+ case PROP_RTBUF:
+ priv->rtbuf = g_value_get_pointer(value);
+ rtbuf_output_widget_update(widget);
+ break;
+ case PROP_OUT:
+ priv->out = g_value_get_int(value);
+ rtbuf_output_widget_update(widget);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+rtbuf_output_widget_get_property (GObject *object, guint prop_id,
+ GValue *value, GParamSpec *pspec)
+{
+ RtbufOutputWidget *widget = RTBUF_OUTPUT_WIDGET(object);
+ RtbufOutputWidgetPrivate *priv =
+ rtbuf_output_widget_get_instance_private(widget);
+ switch (prop_id) {
+ case PROP_RTBUF:
+ g_value_set_pointer(value, priv->rtbuf);
+ break;
+ case PROP_OUT:
+ g_value_set_int(value, priv->out);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+rtbuf_output_widget_finalize (GObject *object)
+{
+ RtbufOutputWidget *widget = RTBUF_OUTPUT_WIDGET(object);
+ RtbufOutputWidgetPrivate *priv =
+ rtbuf_output_widget_get_instance_private(widget);
+ g_clear_object(&priv->check);
+ g_clear_object(&priv->label);
+ G_OBJECT_CLASS(rtbuf_output_widget_parent_class)->finalize(object);
+}
+
+RtbufOutputWidget *
+rtbuf_output_widget_new (s_rtbuf *rtbuf, unsigned int out)
+{
+ return (RtbufOutputWidget*) g_object_new(RTBUF_OUTPUT_WIDGET_TYPE,
+ "rtbuf", rtbuf,
+ "out", out,
+ NULL);
+}
+
+s_rtbuf *
+rtbuf_output_widget_get_rtbuf (RtbufOutputWidget *widget)
+{
+ RtbufOutputWidgetPrivate *priv =
+ rtbuf_output_widget_get_instance_private(widget);
+ if (priv)
+ return priv->rtbuf;
+ return NULL;
+}
+
+unsigned int
+rtbuf_output_widget_get_out (RtbufOutputWidget *widget)
+{
+ RtbufOutputWidgetPrivate *priv =
+ rtbuf_output_widget_get_instance_private(widget);
+ if (priv)
+ return priv->out;
+ return 0;
+}
+
+GtkWidget *
+rtbuf_output_widget_get_check (RtbufOutputWidget *widget)
+{
+ RtbufOutputWidgetPrivate *priv =
+ rtbuf_output_widget_get_instance_private(widget);
+ if (priv)
+ return priv->check;
+ return NULL;
+}
+
+void
+rtbuf_output_widget_update (RtbufOutputWidget *widget)
+{
+ const RtbufOutputWidgetPrivate *priv =
+ rtbuf_output_widget_get_instance_private(widget);
+ if (priv && priv->rtbuf && priv->out >= 0) {
+ const s_rtbuf_proc *proc = priv->rtbuf->proc;
+ const char *label;
+ assert((long long) priv->out < (long long) proc->out_n);
+ label = proc->out[priv->out].name;
+ gtk_label_set_text(GTK_LABEL(priv->label), label);
+ }
+}
+
+void rtbuf_output_widget_connect_check (GtkWidget *output,
+ gpointer data)
+{
+ RtbufOutputWidget *widget = RTBUF_OUTPUT_WIDGET(output);
+ RtbufOutputWidgetPrivate *priv =
+ rtbuf_output_widget_get_instance_private(widget);
+ s_signal_binding *sb = (s_signal_binding*) data;
+ g_signal_connect_swapped(G_OBJECT(priv->check), sb->signal,
+ sb->callback, widget);
+}
diff --git a/gtk/rtbuf_output_widget.h b/gtk/rtbuf_output_widget.h
new file mode 100644
index 0000000..0eb46d0
--- /dev/null
+++ b/gtk/rtbuf_output_widget.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef RTBUF_OUTPUT_WIDGET_H
+#define RTBUF_OUTPUT_WIDGET_H
+
+#include <rtbuf/rtbuf.h>
+
+#define RTBUF_OUTPUT_WIDGET_TYPE \
+ (rtbuf_output_widget_get_type())
+
+#define RTBUF_OUTPUT_WIDGET(object) \
+ (G_TYPE_CHECK_INSTANCE_CAST((object), RTBUF_OUTPUT_WIDGET_TYPE, \
+ RtbufOutputWidget))
+
+#define RTBUF_OUTPUT_WIDGET_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), RTBUF_OUTPUT_WIDGET_TYPE, \
+ RtbufOutputWidgetClass))
+
+#define IS_RTBUF_OUTPUT_WIDGET(object) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((object), RTBUF_OUTPUT_WIDGET_TYPE))
+
+#define IS_RTBUF_OUTPUT_WIDGET_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), RTBUF_OUTPUT_WIDGET_TYPE))
+
+#define RTBUF_OUTPUT_WIDGET_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS((obj), RTBUF_OUTPUT_WIDGET_TYPE, \
+ RtbufOutputWidgetClass))
+
+typedef struct _RtbufOutputWidget RtbufOutputWidget;
+typedef struct _RtbufOutputWidgetClass RtbufOutputWidgetClass;
+typedef struct _RtbufOutputWidgetPrivate RtbufOutputWidgetPrivate;
+
+struct _RtbufOutputWidget {
+ GtkBox box;
+};
+
+struct _RtbufOutputWidgetClass {
+ GtkBoxClass parent_class;
+};
+
+GType rtbuf_output_widget_get_type (void) G_GNUC_CONST;
+RtbufOutputWidget * rtbuf_output_widget_new (s_rtbuf *rtbuf,
+ unsigned int out);
+s_rtbuf * rtbuf_output_widget_get_rtbuf (RtbufOutputWidget *widget);
+unsigned int rtbuf_output_widget_get_out (RtbufOutputWidget *widget);
+GtkWidget * rtbuf_output_widget_get_check (RtbufOutputWidget *widget);
+void rtbuf_output_widget_update (RtbufOutputWidget *widget);
+void rtbuf_output_widget_connect_check (GtkWidget *output,
+ gpointer data);
+
+#endif
diff --git a/gtk/rtbuf_output_widget.ui b/gtk/rtbuf_output_widget.ui
new file mode 100644
index 0000000..fc3a250
--- /dev/null
+++ b/gtk/rtbuf_output_widget.ui
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.2 -->
+<interface>
+ <requires lib="gtk+" version="3.20"/>
+ <template class="RtbufOutputWidget" parent="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkCheckButton" id="check">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">output</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </template>
+</interface>
diff --git a/gtk/rtbuf_widget.c b/gtk/rtbuf_widget.c
new file mode 100644
index 0000000..c950f96
--- /dev/null
+++ b/gtk/rtbuf_widget.c
@@ -0,0 +1,286 @@
+/*
+ * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <assert.h>
+#include <gtk/gtk.h>
+#include "rtbuf_gtk.h"
+#include "rtbuf_input_widget.h"
+#include "rtbuf_output_widget.h"
+#include "rtbuf_widget.h"
+#include <rtbuf/rtbuf.h>
+
+struct _RtbufWidgetPrivate {
+ s_rtbuf *rtbuf;
+ GtkWidget *event_box;
+ GtkWidget *label;
+ GtkWidget *inputs;
+ GtkWidget *outputs;
+};
+
+enum {
+ PROP_0,
+ PROP_RTBUF,
+ PROP_LABEL,
+ LAST_PROP
+};
+
+static GParamSpec *rtbuf_widget_props[LAST_PROP];
+
+static void rtbuf_widget_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void rtbuf_widget_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void rtbuf_widget_finalize (GObject *object);
+static gboolean rtbuf_widget_draw (GtkWidget *widget, cairo_t *cr,
+ gpointer data);
+
+G_DEFINE_TYPE_WITH_PRIVATE (RtbufWidget, rtbuf_widget, GTK_TYPE_BOX)
+
+static void
+rtbuf_widget_class_init (RtbufWidgetClass *klass)
+{
+ GObjectClass *gobject_class = (GObjectClass*) klass;
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
+ printf("rtbuf_widget class init\n");
+ gobject_class->finalize = rtbuf_widget_finalize;
+ gobject_class->set_property = rtbuf_widget_set_property;
+ gobject_class->get_property = rtbuf_widget_get_property;
+ rtbuf_widget_props[PROP_LABEL] =
+ g_param_spec_string("label",
+ "Label",
+ "Text of the frame's label",
+ NULL,
+ G_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
+ rtbuf_widget_props[PROP_RTBUF] =
+ g_param_spec_pointer("rtbuf",
+ "Rtbuf",
+ "Pointer to a s_rtbuf",
+ G_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
+ g_object_class_install_properties(gobject_class, LAST_PROP, rtbuf_widget_props);
+ gtk_widget_class_set_template_from_resource(widget_class,
+ "/rtbuf/rtbuf_widget.ui");
+ gtk_widget_class_bind_template_child_private(widget_class,
+ RtbufWidget, event_box);
+ gtk_widget_class_bind_template_child_private(widget_class,
+ RtbufWidget, label);
+ gtk_widget_class_bind_template_child_private(widget_class,
+ RtbufWidget, inputs);
+ gtk_widget_class_bind_template_child_private(widget_class,
+ RtbufWidget, outputs);
+}
+
+static void
+rtbuf_widget_init (RtbufWidget *widget)
+{
+ RtbufWidgetPrivate *priv;
+ printf("rtbuf_widget init\n");
+ priv = rtbuf_widget_get_instance_private(widget);
+ gtk_widget_init_template(GTK_WIDGET(widget));
+ g_signal_connect(G_OBJECT(widget), "draw",
+ G_CALLBACK(rtbuf_widget_draw), priv);
+}
+
+static void
+rtbuf_widget_set_property (GObject *object, guint prop_id,
+ const GValue *value, GParamSpec *pspec)
+{
+ RtbufWidget *widget = RTBUF_WIDGET(object);
+ switch (prop_id) {
+ case PROP_LABEL:
+ rtbuf_widget_set_label(widget, g_value_get_string(value));
+ break;
+ case PROP_RTBUF:
+ rtbuf_widget_set_rtbuf(widget, g_value_get_pointer(value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+rtbuf_widget_get_property (GObject *object, guint prop_id,
+ GValue *value, GParamSpec *pspec)
+{
+ RtbufWidget *widget = RTBUF_WIDGET(object);
+ RtbufWidgetPrivate *priv = rtbuf_widget_get_instance_private(widget);
+ switch (prop_id) {
+ case PROP_LABEL:
+ g_value_set_string(value, rtbuf_widget_get_label(widget));
+ break;
+ case PROP_RTBUF:
+ g_value_set_pointer(value, priv->rtbuf);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+rtbuf_widget_finalize (GObject *object)
+{
+ RtbufWidget *widget = RTBUF_WIDGET(object);
+ RtbufWidgetPrivate *priv = rtbuf_widget_get_instance_private(widget);
+ g_clear_object(&priv->label);
+ g_clear_object(&priv->inputs);
+ g_clear_object(&priv->outputs);
+ G_OBJECT_CLASS(rtbuf_widget_parent_class)->finalize(object);
+}
+
+static gboolean
+rtbuf_widget_draw (GtkWidget *widget, cairo_t *cr, gpointer data)
+{
+ GtkAllocation alloc;
+ gtk_widget_get_allocation(widget, &alloc);
+ cairo_new_path(cr);
+ cairo_rectangle(cr, 0, 0, alloc.width, alloc.height);
+ cairo_set_source_rgb(cr, 1.0, 1.0, 0.7);
+ cairo_fill(cr);
+ (void) data;
+ return FALSE;
+}
+
+RtbufWidget *
+rtbuf_widget_new (s_rtbuf *rtb, const gchar *label)
+{
+ return (RtbufWidget*) g_object_new(RTBUF_WIDGET_TYPE,
+ "label", label,
+ "rtbuf", rtb,
+ NULL);
+}
+
+void gtk_container_clear_widget (GtkWidget *widget,
+ gpointer data)
+{
+ GtkContainer *container = (GtkContainer*) data;
+ gtk_container_remove(container, widget);
+}
+
+void gtk_container_clear (GtkContainer *container)
+{
+ gtk_container_foreach(container,
+ gtk_container_clear_widget,
+ container);
+}
+
+void rtbuf_widget_set_rtbuf (RtbufWidget *widget, s_rtbuf *rtbuf)
+{
+
+ RtbufWidgetPrivate *priv = rtbuf_widget_get_instance_private(widget);
+ GtkContainer *inputs;
+ GtkContainer *outputs;
+ s_rtbuf_proc *proc;
+ unsigned int i;
+ printf("rtbuf_widget set rtbuf\n");
+ priv->rtbuf = rtbuf;
+ proc = rtbuf->proc;
+ inputs = GTK_CONTAINER(priv->inputs);
+ outputs = GTK_CONTAINER(priv->outputs);
+ gtk_container_clear(inputs);
+ for (i = 0; i < proc->in_n; i++) {
+ RtbufInputWidget *input_widget =
+ rtbuf_input_widget_new(priv->rtbuf, i);
+ gtk_container_add(inputs, GTK_WIDGET(input_widget));
+ }
+ gtk_container_clear(outputs);
+ for (i = 0; i < proc->out_n; i++) {
+ RtbufOutputWidget *output_widget =
+ rtbuf_output_widget_new(priv->rtbuf, i);
+ gtk_container_add(outputs, GTK_WIDGET(output_widget));
+ }
+}
+
+void rtbuf_widget_set_label (RtbufWidget *widget,
+ const gchar *label)
+{
+ g_return_if_fail(IS_RTBUF_WIDGET(widget));
+ if (label) {
+ RtbufWidgetPrivate *priv = rtbuf_widget_get_instance_private(widget);
+ if (GTK_IS_LABEL(priv->label))
+ gtk_label_set_text(GTK_LABEL(priv->label), label);
+ }
+}
+
+const gchar *
+rtbuf_widget_get_label (RtbufWidget *widget)
+{
+ RtbufWidgetPrivate *priv =
+ rtbuf_widget_get_instance_private(widget);
+ if (priv && priv->label)
+ return gtk_label_get_text(GTK_LABEL(priv->label));
+ return NULL;
+}
+
+GtkWidget *
+rtbuf_widget_get_event_box (RtbufWidget *widget)
+{
+ RtbufWidgetPrivate *priv =
+ rtbuf_widget_get_instance_private(widget);
+ if (priv)
+ return priv->event_box;
+ return NULL;
+}
+
+s_rtbuf *
+rtbuf_widget_get_rtbuf (RtbufWidget *widget)
+{
+ RtbufWidgetPrivate *priv =
+ rtbuf_widget_get_instance_private(widget);
+ if (priv)
+ return priv->rtbuf;
+ return NULL;
+}
+
+void rtbuf_widget_connect_inputs (RtbufWidget *widget,
+ const char *signal,
+ GCallback callback)
+{
+ RtbufWidgetPrivate *priv =
+ rtbuf_widget_get_instance_private(widget);
+ s_signal_binding sb = { signal, callback };
+ gtk_container_foreach(GTK_CONTAINER(priv->inputs),
+ rtbuf_input_widget_connect,
+ &sb);
+}
+
+void rtbuf_widget_connect_input_checks (RtbufWidget *widget,
+ const char *signal,
+ GCallback callback)
+{
+ RtbufWidgetPrivate *priv =
+ rtbuf_widget_get_instance_private(widget);
+ s_signal_binding sb = { signal, callback };
+ gtk_container_foreach(GTK_CONTAINER(priv->inputs),
+ rtbuf_input_widget_connect_check,
+ &sb);
+}
+
+void rtbuf_widget_connect_output_checks (RtbufWidget *widget,
+ const char *signal,
+ GCallback callback)
+{
+ RtbufWidgetPrivate *priv =
+ rtbuf_widget_get_instance_private(widget);
+ s_signal_binding sb = { signal, callback };
+ gtk_container_foreach(GTK_CONTAINER(priv->outputs),
+ rtbuf_output_widget_connect_check,
+ &sb);
+}
diff --git a/gtk/rtbuf_widget.h b/gtk/rtbuf_widget.h
new file mode 100644
index 0000000..1bfa5fa
--- /dev/null
+++ b/gtk/rtbuf_widget.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef RTBUF_WIDGET_H
+#define RTBUF_WIDGET_H
+
+#include <rtbuf/rtbuf.h>
+
+#define RTBUF_WIDGET_TYPE \
+ (rtbuf_widget_get_type())
+
+#define RTBUF_WIDGET(object) \
+ (G_TYPE_CHECK_INSTANCE_CAST((object), RTBUF_WIDGET_TYPE, \
+ RtbufWidget))
+
+#define RTBUF_WIDGET_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), RTBUF_WIDGET_TYPE, \
+ RtbufWidgetClass))
+
+#define IS_RTBUF_WIDGET(object) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((object), RTBUF_WIDGET_TYPE))
+
+#define IS_RTBUF_WIDGET_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), RTBUF_WIDGET_TYPE))
+
+#define RTBUF_WIDGET_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS((obj), RTBUF_WIDGET_TYPE, \
+ RtbufWidgetClass))
+
+typedef struct _RtbufWidget RtbufWidget;
+typedef struct _RtbufWidgetClass RtbufWidgetClass;
+typedef struct _RtbufWidgetPrivate RtbufWidgetPrivate;
+
+struct _RtbufWidget {
+ GtkBox box;
+};
+
+struct _RtbufWidgetClass {
+ GtkBoxClass parent_class;
+};
+
+GType rtbuf_widget_get_type (void) G_GNUC_CONST;
+RtbufWidget * rtbuf_widget_new (s_rtbuf *rtbuf, const gchar *label);
+void rtbuf_widget_set_rtbuf (RtbufWidget *widget,
+ s_rtbuf *rtbuf);
+void rtbuf_widget_set_label (RtbufWidget *widget,
+ const gchar *label);
+const gchar * rtbuf_widget_get_label (RtbufWidget *widget);
+GtkWidget * rtbuf_widget_get_event_box (RtbufWidget *widget);
+s_rtbuf * rtbuf_widget_get_rtbuf (RtbufWidget *widget);
+void rtbuf_widget_connect_inputs (RtbufWidget *widget,
+ const char *signal,
+ GCallback callback);
+void rtbuf_widget_connect_input_checks (RtbufWidget *widget,
+ const char *signal,
+ GCallback callback);
+void rtbuf_widget_connect_output_checks (RtbufWidget *widget,
+ const char *signal,
+ GCallback callback);
+
+#endif
diff --git a/gtk/rtbuf_widget.ui b/gtk/rtbuf_widget.ui
new file mode 100644
index 0000000..d9ce4b3
--- /dev/null
+++ b/gtk/rtbuf_widget.ui
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<interface>
+ <requires lib="gtk+" version="3.20"/>
+ <template class="RtbufWidget" parent="GtkBox">
+ <property name="visible">True</property>
+ <property name="app_paintable">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkEventBox" id="event_box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel" id="label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">rtbuf</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="inputs">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="outputs">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </template>
+</interface>
diff --git a/hadamard.h b/hadamard.h
deleted file mode 100644
index 62c4209..0000000
--- a/hadamard.h
+++ /dev/null
@@ -1,99 +0,0 @@
-#ifndef HADAMARD_H
-#define HADAMARD_H
-
-#define HADAMARD_1 1
-
-#define HADAMARD_2_0_0 HADAMARD_1
-#define HADAMARD_2_0_1 HADAMARD_1
-#define HADAMARD_2_1_0 HADAMARD_1
-#define HADAMARD_2_1_1 -HADAMARD_1
-
-#define HADAMARD_4_0_0 HADAMARD_2_0_0
-#define HADAMARD_4_0_1 HADAMARD_2_0_1
-#define HADAMARD_4_1_0 HADAMARD_2_1_0
-#define HADAMARD_4_1_1 HADAMARD_2_1_1
-
-#define HADAMARD_4_0_2 HADAMARD_2_0_0
-#define HADAMARD_4_0_3 HADAMARD_2_0_1
-#define HADAMARD_4_1_2 HADAMARD_2_1_0
-#define HADAMARD_4_1_3 HADAMARD_2_1_1
-
-#define HADAMARD_4_2_0 HADAMARD_2_0_0
-#define HADAMARD_4_2_1 HADAMARD_2_0_1
-#define HADAMARD_4_3_0 HADAMARD_2_1_0
-#define HADAMARD_4_3_1 HADAMARD_2_1_1
-
-#define HADAMARD_4_2_2 -HADAMARD_2_0_0
-#define HADAMARD_4_2_3 -HADAMARD_2_0_1
-#define HADAMARD_4_3_2 -HADAMARD_2_1_0
-#define HADAMARD_4_3_3 -HADAMARD_2_1_1
-
-#define HADAMARD_8_0_0 HADAMARD_4_0_0
-#define HADAMARD_8_0_1 HADAMARD_4_0_1
-#define HADAMARD_8_0_2 HADAMARD_4_0_2
-#define HADAMARD_8_0_3 HADAMARD_4_0_3
-#define HADAMARD_8_1_0 HADAMARD_4_1_0
-#define HADAMARD_8_1_1 HADAMARD_4_1_1
-#define HADAMARD_8_1_2 HADAMARD_4_1_2
-#define HADAMARD_8_1_3 HADAMARD_4_1_3
-#define HADAMARD_8_2_0 HADAMARD_4_2_0
-#define HADAMARD_8_2_1 HADAMARD_4_2_1
-#define HADAMARD_8_2_2 HADAMARD_4_2_2
-#define HADAMARD_8_2_3 HADAMARD_4_2_3
-#define HADAMARD_8_3_0 HADAMARD_4_3_0
-#define HADAMARD_8_3_1 HADAMARD_4_3_1
-#define HADAMARD_8_3_2 HADAMARD_4_3_2
-#define HADAMARD_8_3_3 HADAMARD_4_3_3
-
-#define HADAMARD_8_0_4 HADAMARD_4_0_0
-#define HADAMARD_8_0_5 HADAMARD_4_0_1
-#define HADAMARD_8_0_6 HADAMARD_4_0_2
-#define HADAMARD_8_0_7 HADAMARD_4_0_3
-#define HADAMARD_8_1_4 HADAMARD_4_1_0
-#define HADAMARD_8_1_5 HADAMARD_4_1_1
-#define HADAMARD_8_1_6 HADAMARD_4_1_2
-#define HADAMARD_8_1_7 HADAMARD_4_1_3
-#define HADAMARD_8_2_4 HADAMARD_4_2_0
-#define HADAMARD_8_2_5 HADAMARD_4_2_1
-#define HADAMARD_8_2_6 HADAMARD_4_2_2
-#define HADAMARD_8_2_7 HADAMARD_4_2_3
-#define HADAMARD_8_3_4 HADAMARD_4_3_0
-#define HADAMARD_8_3_5 HADAMARD_4_3_1
-#define HADAMARD_8_3_6 HADAMARD_4_3_2
-#define HADAMARD_8_3_7 HADAMARD_4_3_3
-
-#define HADAMARD_8_4_0 HADAMARD_4_0_0
-#define HADAMARD_8_4_1 HADAMARD_4_0_1
-#define HADAMARD_8_4_2 HADAMARD_4_0_2
-#define HADAMARD_8_4_3 HADAMARD_4_0_3
-#define HADAMARD_8_5_0 HADAMARD_4_1_0
-#define HADAMARD_8_5_1 HADAMARD_4_1_1
-#define HADAMARD_8_5_2 HADAMARD_4_1_2
-#define HADAMARD_8_5_3 HADAMARD_4_1_3
-#define HADAMARD_8_6_0 HADAMARD_4_2_0
-#define HADAMARD_8_6_1 HADAMARD_4_2_1
-#define HADAMARD_8_6_2 HADAMARD_4_2_2
-#define HADAMARD_8_6_3 HADAMARD_4_2_3
-#define HADAMARD_8_7_0 HADAMARD_4_3_0
-#define HADAMARD_8_7_1 HADAMARD_4_3_1
-#define HADAMARD_8_7_2 HADAMARD_4_3_2
-#define HADAMARD_8_7_3 HADAMARD_4_3_3
-
-#define HADAMARD_8_4_4 -HADAMARD_4_0_0
-#define HADAMARD_8_4_5 -HADAMARD_4_0_1
-#define HADAMARD_8_4_6 -HADAMARD_4_0_2
-#define HADAMARD_8_4_7 -HADAMARD_4_0_3
-#define HADAMARD_8_5_4 -HADAMARD_4_1_0
-#define HADAMARD_8_5_5 -HADAMARD_4_1_1
-#define HADAMARD_8_5_6 -HADAMARD_4_1_2
-#define HADAMARD_8_5_7 -HADAMARD_4_1_3
-#define HADAMARD_8_6_4 -HADAMARD_4_2_0
-#define HADAMARD_8_6_5 -HADAMARD_4_2_1
-#define HADAMARD_8_6_6 -HADAMARD_4_2_2
-#define HADAMARD_8_6_7 -HADAMARD_4_2_3
-#define HADAMARD_8_7_4 -HADAMARD_4_3_0
-#define HADAMARD_8_7_5 -HADAMARD_4_3_1
-#define HADAMARD_8_7_6 -HADAMARD_4_3_2
-#define HADAMARD_8_7_7 -HADAMARD_4_3_3
-
-#endif
diff --git a/lib/Makefile.am b/lib/Makefile.am
new file mode 100644
index 0000000..c4eed8d
--- /dev/null
+++ b/lib/Makefile.am
@@ -0,0 +1,81 @@
+CLEANFILES =
+rtbuf_includedir = $(includedir)/rtbuf
+rtbuf_include_HEADERS =
+rtbuf_libdir = $(libdir)/rtbuf/
+rtbuf_lib_LTLIBRARIES =
+
+SUBDIRS = . signal # dynamic glfw3 portaudio reverb sndio synth
+
+# music
+
+music_type: music_type.c include/rtbuf/music.h
+ ${CC} ${CFLAGS} ${CPPFLAGS} -o music_type music_type.c
+include/rtbuf/music_type.h: music_type
+ ./music_type > include/rtbuf/music_type.h
+CLEANFILES += music_type include/rtbuf/music_type.h
+
+rtbuf_lib_LTLIBRARIES += music.la
+music_la_LIBADD = ${MUSIC_LIBS} ../librtbuf/.libs/librtbuf.la
+music_la_LDFLAGS = -no-undefined -module
+
+rtbuf_include_HEADERS += \
+ include/rtbuf/music.h \
+ include/rtbuf/music_type.h
+
+# portaudio
+
+if ENABLE_PORTAUDIO
+portaudio_type: portaudio_type.c include/rtbuf/portaudio.h
+ ${CC} ${CFLAGS} ${CPPFLAGS} -o portaudio_type portaudio_type.c
+include/rtbuf/portaudio_type.h: portaudio_type
+ ./portaudio_type > include/rtbuf/portaudio_type.h
+CLEANFILES += portaudio_type include/rtbuf/portaudio_type.h
+portaudio.lo: include/rtbuf/portaudio_type.h
+endif # ENABLE_PORTAUDIO
+
+
+# reverb
+
+reverb_type: reverb_type.c include/rtbuf/reverb.h
+ ${CC} ${CFLAGS} ${CPPFLAGS} -o reverb_type reverb_type.c
+include/rtbuf/reverb_type.h: reverb_type
+ ./reverb_type > include/rtbuf/reverb_type.h
+CLEANFILES += reverb_type include/rtbuf/reverb_type.h
+reverb.lo: include/rtbuf/reverb_type.h
+
+# signal
+
+signal_type: signal_type.c include/rtbuf/signal.h
+ ${CC} ${CFLAGS} ${CPPFLAGS} -o signal_type signal_type.c
+include/rtbuf/signal_type.h: signal_type
+ ./signal_type > include/rtbuf/signal_type.h
+CLEANFILES += signal_type include/rtbuf/signal_type.h
+signal.lo: include/rtbuf/signal_type.h
+
+rtbuf_lib_LTLIBRARIES += signal.la
+signal_la_LIBADD = ${SIGNAL_LIBS} ../librtbuf/.libs/librtbuf.la
+signal_la_LDFLAGS = -no-undefined -module
+
+rtbuf_include_HEADERS += \
+ include/rtbuf/signal.h \
+ include/rtbuf/signal_type.h
+
+# sndio
+
+if ENABLE_SNDIO
+sndio_type: sndio_type.c include/rtbuf/sndio.h
+ ${CC} ${CFLAGS} ${CPPFLAGS} -o sndio_type sndio_type.c
+include/rtbuf/sndio_type.h: sndio_type
+ ./sndio_type > include/rtbuf/sndio_type.h
+CLEANFILES += sndio_type include/rtbuf/sndio_type.h
+sndio.lo: include/rtbuf/sndio_type.h
+endif # ENABLE_SNDIO
+
+# synth
+
+synth_type: synth_type.c include/rtbuf/synth.h include/rtbuf/music_type.h include/rtbuf/signal_type.h
+ ${CC} ${CFLAGS} ${CPPFLAGS} -o synth_type synth_type.c
+include/rtbuf/synth_type.h: synth_type
+ ./synth_type > include/rtbuf/synth_type.h
+CLEANFILES += synth_type include/rtbuf/synth_type.h
+synth.lo: include/rtbuf/synth_type.h
diff --git a/lib/dynamic.c b/lib/dynamic.c
new file mode 100644
index 0000000..aa986b1
--- /dev/null
+++ b/lib/dynamic.c
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "rtbuf.h"
+#include "rtbuf_lib.h"
+#include "rtbuf_signal.h"
+#include "rtbuf_signal_type.h"
+#include "rtbuf_dynamic.h"
+
+s_rtbuf_lib_proc_in g_rtbuf_dynamic_limiter_in[] = {
+ { "signal" , RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
+ { "gain" , RTBUF_SIGNAL_TYPE, 1.0, 0.0, 1.0 },
+ { "treshold", RTBUF_SIGNAL_TYPE, 0.9, 0.0, 1.0 },
+ { "attack" , RTBUF_SIGNAL_TYPE, 0.1, 0.0, 1.0 },
+ { "release" , RTBUF_SIGNAL_TYPE, 1.0, 0.0, 1.0 },
+ { 0, 0, 0.0, 0.0, 0.0 } };
+
+s_rtbuf_lib_proc_out g_rtbuf_dynamic_limiter_out[] = {
+ { "signal", RTBUF_SIGNAL_TYPE },
+ { "ratio" , RTBUF_SIGNAL_SAMPLE_TYPE },
+ { 0, 0 } };
+
+const char *rtbuf_lib_name = "dynamic";
+unsigned long rtbuf_lib_ver = RTBUF_LIB_VER;
+s_rtbuf_lib_proc rtbuf_lib_proc[] = {
+ { "limiter", rtbuf_dynamic_limiter, rtbuf_dynamic_limiter_start, 0,
+ g_rtbuf_dynamic_limiter_in, g_rtbuf_dynamic_limiter_out },
+ { 0, 0, 0, 0, 0, 0 } };
diff --git a/lib/dynamic/limiter.c b/lib/dynamic/limiter.c
new file mode 100644
index 0000000..82c5943
--- /dev/null
+++ b/lib/dynamic/limiter.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2019 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ * Copyright 2019 Judy Najnudel
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <math.h>
+#include "rtbuf.h"
+#include "rtbuf_dynamic.h"
+
+int rtbuf_dynamic_limiter (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_fun in_;
+ s_rtbuf_signal_fun g_;
+ s_rtbuf_signal_fun t_;
+ s_rtbuf_signal_fun a_;
+ s_rtbuf_signal_fun r_;
+ s_rtbuf_dynamic_limiter_data *data;
+ unsigned int i = 0;
+ assert(rtb);
+ assert(rtb->proc);
+ assert(rtb->data);
+ rtbuf_signal_fun(rtb, RTBUF_DYNAMIC_LIMITER_IN_SIGNAL , &in_);
+ rtbuf_signal_fun(rtb, RTBUF_DYNAMIC_LIMITER_IN_GAIN , &g_);
+ rtbuf_signal_fun(rtb, RTBUF_DYNAMIC_LIMITER_IN_TRESHOLD, &t_);
+ rtbuf_signal_fun(rtb, RTBUF_DYNAMIC_LIMITER_IN_ATTACK , &a_);
+ rtbuf_signal_fun(rtb, RTBUF_DYNAMIC_LIMITER_IN_RELEASE , &r_);
+ data = (s_rtbuf_dynamic_limiter_data*) rtb->data;
+ while (i < RTBUF_SIGNAL_SAMPLES) {
+ double in = in_.sample_fun(in_.signal, i);
+ double g = max(0.0, g_.sample_fun(g_.signal, i));
+ double t = max(0.0, t_.sample_fun(t_.signal, i));
+ double a = max(0.0, a_.sample_fun(a_.signal, i));
+ double r = max(0.0, r_.sample_fun(r_.signal, i));
+ double in_g = in * g;
+ double s = in_g * data->ratio;
+ if (s < t)
+ if (data->ratio < 1.0) {
+ data->ratio += 1.0 / (r * RTBUF_SIGNAL_SAMPLERATE);
+ if (data->ratio > 1.0)
+ data->ratio = 1.0;
+ }
+ if (s >= t) {
+ data->ratio -= 1.0 / (a * RTBUF_SIGNAL_SAMPLERATE);
+ if (data->ratio < 0.0)
+ data->ratio = 0;
+ }
+ data->signal[i] = in_g * data->ratio;
+ i++;
+ }
+ return 0;
+}
+
+int rtbuf_dynamic_limiter_start (s_rtbuf *rtb)
+{
+ s_rtbuf_dynamic_limiter_data *data;
+ assert(rtb);
+ assert(rtb->proc);
+ assert(rtb->data);
+ assert(rtb->proc->out_bytes == sizeof(*data));
+ data = (s_rtbuf_dynamic_limiter_data*) rtb->data;
+ data->signal[RTBUF_SIGNAL_SAMPLES - 1] = 0.0;
+ data->ratio = 1.0;
+ return 0;
+}
diff --git a/lib/glfw3/rtbuf_glfw3.c b/lib/glfw3/rtbuf_glfw3.c
new file mode 100644
index 0000000..6470431
--- /dev/null
+++ b/lib/glfw3/rtbuf_glfw3.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "rtbuf.h"
+#include "rtbuf_lib.h"
+#include "rtbuf_signal.h"
+#include "rtbuf_signal_type.h"
+#include "rtbuf_music.h"
+#include "rtbuf_music_type.h"
+#include "rtbuf_glfw3.h"
+
+s_rtbuf_lib_proc_out g_rtbuf_glfw3_keyboard_out[] = {
+ RTBUF_MUSIC_NOTES_OUT("note"),
+ { "window", "void*" },
+ { "octave", "unsigned int" },
+ { 0, 0 } };
+
+s_rtbuf_lib_proc_in g_rtbuf_glfw3_oscilloscope_in[] = {
+ { "black", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
+ { "red" , RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
+ { "green", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
+ { "blue" , RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
+ { 0, 0, 0.0, 0.0, 0.0 } };
+
+s_rtbuf_lib_proc_out g_rtbuf_glfw3_oscilloscope_out[] = {
+ { "window", "void*" },
+ { 0, 0 } };
+
+const char *rtbuf_lib_name = "glfw3";
+unsigned long rtbuf_lib_ver = RTBUF_LIB_VER;
+s_rtbuf_lib_proc rtbuf_lib_proc[] = {
+ { "keyboard", rtbuf_glfw3_keyboard, rtbuf_glfw3_keyboard_start,
+ rtbuf_glfw3_keyboard_stop, 0, g_rtbuf_glfw3_keyboard_out },
+ { "oscilloscope", rtbuf_glfw3_oscilloscope,
+ rtbuf_glfw3_oscilloscope_start, 0, g_rtbuf_glfw3_oscilloscope_in,
+ g_rtbuf_glfw3_oscilloscope_out },
+ { 0, 0, 0, 0, 0, 0 } };
+
+int rtbuf_lib_init (s_rtbuf_lib *lib)
+{
+ (void) lib;
+ rtbuf_music_init();
+ glfwInit();
+ return 0;
+}
diff --git a/lib/glfw3/rtbuf_glfw3.h b/lib/glfw3/rtbuf_glfw3.h
new file mode 100644
index 0000000..1d89890
--- /dev/null
+++ b/lib/glfw3/rtbuf_glfw3.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifndef RTBUF_GLFW3_H
+#define RTBUF_GLFW3_H
+
+#include <GLFW/glfw3.h>
+#include "rtbuf.h"
+#include "rtbuf_music.h"
+
+#pragma pack(push,1)
+typedef struct rtbuf_glfw3_keyboard_data {
+ s_rtbuf_music_notes notes;
+ GLFWwindow *window;
+ unsigned int octave;
+} s_rtbuf_glfw3_keyboard_data;
+#pragma pack(pop)
+
+int rtbuf_glfw3_keyboard (s_rtbuf *rtb);
+int rtbuf_glfw3_keyboard_start (s_rtbuf *rtb);
+int rtbuf_glfw3_keyboard_stop (s_rtbuf *rtb);
+
+enum {
+ RTBUF_GLFW3_OSCILLOSCOPE_IN_BLACK,
+ RTBUF_GLFW3_OSCILLOSCOPE_IN_RED,
+ RTBUF_GLFW3_OSCILLOSCOPE_IN_GREEN,
+ RTBUF_GLFW3_OSCILLOSCOPE_IN_BLUE,
+ RTBUF_GLFW3_OSCILLOSCOPE_INS
+};
+
+#pragma pack(push,1)
+typedef struct rtbuf_glfw3_oscilloscope_data {
+ GLFWwindow *window;
+} s_rtbuf_glfw3_oscilloscope_data;
+#pragma pack(pop)
+
+int rtbuf_glfw3_oscilloscope (s_rtbuf *rtb);
+int rtbuf_glfw3_oscilloscope_start (s_rtbuf *rtb);
+
+#endif
diff --git a/lib/glfw3/rtbuf_glfw3_keyboard.c b/lib/glfw3/rtbuf_glfw3_keyboard.c
new file mode 100644
index 0000000..80b88f2
--- /dev/null
+++ b/lib/glfw3/rtbuf_glfw3_keyboard.c
@@ -0,0 +1,281 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <math.h>
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include "rtbuf.h"
+#include "rtbuf_signal.h"
+#include "rtbuf_music.h"
+#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
+
+double scancode_frequency (int scancode, unsigned int octave)
+{
+ int note = -1;
+ double freq = 0.0;
+ printf("scancode %i\n", scancode);
+ switch (scancode) {
+ case 52: note = 0; break; /* C */
+ case 39: note = 1; break;
+ case 53: note = 2; break; /* D */
+ case 40: note = 3; break;
+ case 54: note = 4; break; /* E */
+ case 55: note = 5; break; /* F */
+ case 42: note = 6; break;
+ case 56: note = 7; break; /* G */
+ case 43: note = 8; break;
+ case 57: note = 9; break; /* A */
+ case 44: note = 10; break;
+ case 58: note = 11; break; /* B */
+ case 59: /* C */
+ case 24: note = 12; break;
+ case 46:
+ case 11: note = 13; break;
+ case 60: /* D */
+ case 25: note = 14; break;
+ case 47:
+ case 12: note = 15; break;
+ case 61: /* E */
+ case 26: note = 16; break;
+ case 27: note = 17; break; /* F */
+ case 14: note = 18; break;
+ case 28: note = 19; break; /* G */
+ case 15: note = 20; break;
+ case 29: note = 21; break; /* A */
+ case 16: note = 22; break;
+ case 30: note = 23; break; /* B */
+ case 31: note = 24; break; /* C */
+ case 18: note = 25; break;
+ case 32: note = 26; break; /* D */
+ case 19: note = 27; break;
+ case 33: note = 28; break; /* E */
+ case 34: note = 29; break; /* F */
+ case 21: note = 30; break;
+ case 35: note = 31; break; /* G */
+ }
+ if (note >= 0)
+ freq = rtbuf_music_note_frequency(octave, note);
+ return freq;
+}
+
+static int find_note (s_rtbuf_music_notes *notes, double freq)
+{
+ unsigned int i = 0;
+ unsigned int n = notes->note_n;
+ while (i < RTBUF_MUSIC_NOTE_MAX && n > 0) {
+ s_rtbuf_music_note *note = ¬es->note[i];
+ if (note->velocity > 0.0 && note->start >= 0.0 && note->stop < 0.0) {
+ if (freq == notes->note[i].freq)
+ return i;
+ n--;
+ }
+ i++;
+ }
+ return -1;
+}
+
+void rtbuf_glfw3_keyboard_key (GLFWwindow *w, int key,
+ int scancode, int action,
+ int mods)
+{
+ int i;
+ double freq;
+ s_rtbuf_music_note *note;
+ s_rtbuf *rtb = (s_rtbuf*) glfwGetWindowUserPointer(w);
+ s_rtbuf_glfw3_keyboard_data *data;
+ s_rtbuf_music_notes *notes;
+ data = (s_rtbuf_glfw3_keyboard_data*) rtb->data;
+ notes = &data->notes;
+ (void) key;
+ (void) mods;
+ switch (action) {
+ case GLFW_RELEASE:
+ freq = scancode_frequency(scancode, data->octave);
+ if ((i = find_note(notes, freq)) >= 0)
+ notes->note[i].stop = 0.0;
+ break;
+ case GLFW_PRESS:
+ freq = scancode_frequency(scancode, data->octave);
+ if ((i = rtbuf_music_notes_new(notes, 1.0)) < 0)
+ break;
+ note = ¬es->note[i];
+ note->freq = freq;
+ note->start = 0.0;
+ note->stop = -1.0;
+ break;
+ case GLFW_REPEAT:
+ break;
+ }
+}
+
+void rtbuf_glfw3_keyboard_size (GLFWwindow *w, int width,
+ int height)
+{
+ (void) w;
+ glViewport(0, 0, width, height);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(0.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+}
+
+static
+void rtbuf_glfw3_keyboard_draw_panel (float y1, float y2)
+{
+ glColor3f(0.5f, 0.5f, 0.5f);
+ glBegin(GL_QUAD_STRIP);
+ glVertex2f(0.0f, y1);
+ glVertex2f(0.0f, y2);
+ glVertex2f(1.0f, y1);
+ glVertex2f(1.0f, y2);
+ glEnd();
+}
+
+static
+void rtbuf_glfw3_keyboard_draw_white (unsigned int i, float n,
+ float y1, float y2)
+{
+ float x = (float) i / n;
+ glBegin(GL_LINE_STRIP);
+ glVertex2f(x, y1);
+ glVertex2f(x, y2);
+ i++;
+ x = (float) i / n;
+ glVertex2f(x, y2);
+ glVertex2f(x, y1);
+ glEnd();
+}
+
+static
+void rtbuf_glfw3_keyboard_draw_black (unsigned int i, float n,
+ float y1, float y2)
+{
+ float x1 = (i - 1.0f / 3.0f) / n;
+ float x2 = (i + 1.0f / 3.0f) / n;
+ glBegin(GL_QUAD_STRIP);
+ glVertex2f(x1, y1);
+ glVertex2f(x1, y2);
+ glVertex2f(x2, y1);
+ glVertex2f(x2, y2);
+ glEnd();
+}
+
+void rtbuf_glfw3_keyboard_draw (GLFWwindow *w)
+{
+ float y_buttons = 0.75f;
+ float y_black = 0.36f;
+ unsigned int notes = 32;
+ float n = ceilf((notes + 1) * 7 / 12);
+ unsigned int i = 0;
+ unsigned int j = 0;
+ glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
+ glClear(GL_COLOR_BUFFER_BIT);
+ rtbuf_glfw3_keyboard_draw_panel(1.0f, y_buttons);
+ glColor3f(0.0f, 0.0f, 0.0f);
+ while (i < notes) {
+ int k = i % 12;
+ if (k == 1 || k == 3 || k == 6 || k == 8 || k == 10)
+ rtbuf_glfw3_keyboard_draw_black(j, n, y_buttons, y_black);
+ else
+ rtbuf_glfw3_keyboard_draw_white(j++, n, y_buttons, 0.0f);
+ i++;
+ }
+ glfwSwapBuffers(w);
+}
+
+void rtbuf_glfw3_keyboard_close (GLFWwindow *window)
+{
+ s_rtbuf *rtb = (s_rtbuf*) glfwGetWindowUserPointer(window);
+ s_rtbuf_glfw3_keyboard_data* data = (s_rtbuf_glfw3_keyboard_data*)
+ rtb->data;
+ glfwDestroyWindow(window);
+ data->window = 0;
+}
+
+GLFWwindow * rtbuf_glfw3_keyboard_window (s_rtbuf *rtb)
+{
+ GLFWwindow *window = glfwCreateWindow(RTBUF_GLFW3_KEYBOARD_WIDTH,
+ RTBUF_GLFW3_KEYBOARD_HEIGHT,
+ "rtbuf_glfw3_keyboard",
+ NULL, NULL);
+ if (!window) {
+ rtbuf_err("glfw3_keyboard: glfwCreateWindow failed");
+ return 0;
+ }
+ glfwMakeContextCurrent(window);
+ glfwSetWindowUserPointer(window, rtb);
+ glfwSetKeyCallback(window, rtbuf_glfw3_keyboard_key);
+ glfwSetWindowCloseCallback(window, rtbuf_glfw3_keyboard_close);
+ glfwSetWindowSizeCallback(window, rtbuf_glfw3_keyboard_size);
+ glfwSetWindowRefreshCallback(window,
+ rtbuf_glfw3_keyboard_draw);
+ glfwShowWindow(window);
+ rtbuf_glfw3_keyboard_size(window, RTBUF_GLFW3_KEYBOARD_WIDTH,
+ RTBUF_GLFW3_KEYBOARD_HEIGHT);
+ return window;
+}
+
+int rtbuf_glfw3_keyboard_start (s_rtbuf *rtb)
+{
+ s_rtbuf_glfw3_keyboard_data *data;
+ assert(rtb->proc->out_bytes == sizeof(*data));
+ data = (s_rtbuf_glfw3_keyboard_data*) rtb->data;
+ if (!data->window &&
+ !(data->window = rtbuf_glfw3_keyboard_window(rtb)))
+ return -1;
+ data->octave = 3;
+ return 0;
+}
+
+int rtbuf_glfw3_keyboard_stop (s_rtbuf *rtb)
+{
+ s_rtbuf_glfw3_keyboard_data *data;
+ data = (s_rtbuf_glfw3_keyboard_data*) rtb->data;
+ rtbuf_music_notes_delete_all(&data->notes);
+ return 0;
+}
+
+int rtbuf_glfw3_keyboard (s_rtbuf *rtb)
+{
+ s_rtbuf_glfw3_keyboard_data *data;
+ unsigned int i = 0;
+ unsigned int n;
+ data = (s_rtbuf_glfw3_keyboard_data*) rtb->data;
+ if (!data->window)
+ return -1;
+ n = data->notes.note_n;
+ while (i < RTBUF_MUSIC_NOTE_MAX && n > 0) {
+ s_rtbuf_music_note *note = &data->notes.note[i];
+ if (note->velocity > 0.0) {
+ assert(note->start >= 0.0);
+ rtbuf_music_note_dt(note, RTBUF_SIGNAL_DT);
+ if (note->stop > RTBUF_MUSIC_RELEASE_MAX)
+ rtbuf_music_notes_delete(&data->notes, i);
+ n--;
+ }
+ i++;
+ }
+ glfwPollEvents();
+ return 0;
+}
diff --git a/lib/glfw3/rtbuf_glfw3_oscilloscope.c b/lib/glfw3/rtbuf_glfw3_oscilloscope.c
new file mode 100644
index 0000000..2be4650
--- /dev/null
+++ b/lib/glfw3/rtbuf_glfw3_oscilloscope.c
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "rtbuf.h"
+#include "rtbuf_signal.h"
+#include "rtbuf_glfw3.h"
+
+void rtbuf_glfw3_oscilloscope_size (GLFWwindow *w, int width,
+ int height)
+{
+ (void) w;
+ glViewport(0, 0, width, height);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(0.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+}
+
+void rtbuf_glfw3_oscilloscope_draw (GLFWwindow *window)
+{
+ s_rtbuf *rtb = (s_rtbuf*) glfwGetWindowUserPointer(window);
+ s_rtbuf_signal_fun in[4];
+ const float color[4][3] = { { 0.0f, 0.0f, 0.0f },
+ { 1.0f, 0.0f, 0.0f },
+ { 0.0f, 1.0f, 0.0f },
+ { 0.0f, 0.0f, 1.0f } };
+ unsigned int i = 0;
+ unsigned int j;
+ assert(rtb);
+ for (j = 0; j < 4; j++)
+ rtbuf_signal_fun(rtb, j, &in[j]);
+ glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
+ glClear(GL_COLOR_BUFFER_BIT);
+ for (j = 0; j < 4; j++) {
+ glColor3f(color[j][0], color[j][1], color[j][2]);
+ glBegin(GL_LINE_STRIP);
+ for (i = 0; i < RTBUF_SIGNAL_SAMPLES; i++) {
+ float x = (double) i / RTBUF_SIGNAL_SAMPLES;
+ float s = in[j].sample_fun(in[j].signal, i);
+ glVertex2f(x, s / 4.0f + 0.5f);
+ }
+ glEnd();
+ }
+ glfwSwapBuffers(window);
+}
+
+GLFWwindow * rtbuf_glfw3_oscilloscope_window (s_rtbuf *rtb)
+{
+ GLFWwindow *window = glfwCreateWindow(512, 512,
+ "rtbuf_glfw3_oscilloscope",
+ NULL, NULL);
+ if (!window) {
+ rtbuf_err("glfw3_oscilloscope: glfwCreateWindow failed");
+ return 0;
+ }
+ glfwMakeContextCurrent(window);
+ glfwSetWindowUserPointer(window, rtb);
+ glfwSetWindowSizeCallback(window, rtbuf_glfw3_oscilloscope_size);
+ glfwSetWindowRefreshCallback(window, rtbuf_glfw3_oscilloscope_draw);
+ glfwShowWindow(window);
+ return window;
+}
+
+int rtbuf_glfw3_oscilloscope_start (s_rtbuf *rtb)
+{
+ s_rtbuf_glfw3_oscilloscope_data *data;
+ assert(rtb->proc->out_bytes == sizeof(*data));
+ data = (s_rtbuf_glfw3_oscilloscope_data*) rtb->data;
+ if (!data->window &&
+ !(data->window = rtbuf_glfw3_oscilloscope_window(rtb)))
+ return -1;
+ return 0;
+}
+
+int rtbuf_glfw3_oscilloscope (s_rtbuf *rtb)
+{
+ s_rtbuf_glfw3_oscilloscope_data *data;
+ assert(rtb);
+ assert(rtb->data);
+ assert(rtb->proc);
+ data = (s_rtbuf_glfw3_oscilloscope_data*) rtb->data;
+ rtbuf_glfw3_oscilloscope_draw(data->window);
+ glfwPollEvents();
+ return 0;
+}
diff --git a/lib/glfw3/rtbuf_glfw3_type.c b/lib/glfw3/rtbuf_glfw3_type.c
new file mode 100644
index 0000000..bf8d3ef
--- /dev/null
+++ b/lib/glfw3/rtbuf_glfw3_type.c
@@ -0,0 +1,18 @@
+
+#include <stdio.h>
+#include "rtbuf.h"
+#include "rtbuf_glfw3.h"
+
+int main ()
+{
+ printf("/* file generated by rtbuf_glfw3_type */\n");
+ printf("#ifndef RTBUF_GLFW3_TYPE_H\n"
+ "#define RTBUF_GLFW3_TYPE_H\n"
+ "\n");
+ printf("#define RTBUF_GLFW3_SAMPLES_TYPE RTBUF_GLFW3_SAMPLE_TYPE"
+ " \"[%u]\"\n",
+ RTBUF_GLFW3_SAMPLES);
+ printf("\n"
+ "#endif\n");
+ return 0;
+}
diff --git a/lib/include/rtbuf/dynamic.h b/lib/include/rtbuf/dynamic.h
new file mode 100644
index 0000000..c821900
--- /dev/null
+++ b/lib/include/rtbuf/dynamic.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifndef RTBUF_DYNAMIC_H
+#define RTBUF_DYNAMIC_H
+
+#include <rtbuf/signal.h>
+
+enum {
+ RTBUF_DYNAMIC_LIMITER_IN_SIGNAL = 0,
+ RTBUF_DYNAMIC_LIMITER_IN_GAIN,
+ RTBUF_DYNAMIC_LIMITER_IN_TRESHOLD,
+ RTBUF_DYNAMIC_LIMITER_IN_ATTACK,
+ RTBUF_DYNAMIC_LIMITER_IN_RELEASE,
+ RTBUF_DYNAMIC_LIMITER_IN_N
+};
+
+typedef struct rtbuf_dynamic_limiter_data {
+ t_rtbuf_signal signal;
+ t_rtbuf_signal_sample ratio;
+} s_rtbuf_dynamic_limiter_data;
+
+int rtbuf_dynamic_limiter (s_rtbuf *rtb);
+int rtbuf_dynamic_limiter_start (s_rtbuf *rtb);
+
+#endif
diff --git a/lib/include/rtbuf/music.h b/lib/include/rtbuf/music.h
new file mode 100644
index 0000000..91604c3
--- /dev/null
+++ b/lib/include/rtbuf/music.h
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifndef RTBUF_MUSIC_H
+#define RTBUF_MUSIC_H
+
+#include <rtbuf/signal.h>
+
+#define RTBUF_MUSIC_TUNE_A 440.0
+#define RTBUF_MUSIC_BASE_OCTAVE 4
+
+#define RTBUF_MUSIC_RELEASE_MAX 1.0
+
+#define RTBUF_MUSIC_NOTE_SIZE RTBUF_SIGNAL_SAMPLE_SIZE
+#define RTBUF_MUSIC_NOTE_TYPE "music_note"
+
+#pragma pack(push,1)
+typedef struct rtbuf_music_note {
+ t_rtbuf_signal_sample velocity; /* between 0.0 and 1.0 */
+ t_rtbuf_signal_sample freq; /* above 0.0 */
+ t_rtbuf_signal_sample start; /* time since start */
+ t_rtbuf_signal_sample stop; /* time since stop, or -1.0 */
+} s_rtbuf_music_note;
+#pragma pack(pop)
+
+#define RTBUF_MUSIC_NOTE_IN(note) \
+ { note "velocity", RTBUF_SIGNAL_SAMPLE_TYPE, 1.0, 0.0, 1.0 }, \
+ { note "frequency", RTBUF_SIGNAL_SAMPLE_TYPE, 220.0, 0.0, \
+ RTBUF_SIGNAL_SAMPLERATE / 2.0 }, \
+ { note "start", RTBUF_SIGNAL_SAMPLE_TYPE, -1.0, -1.0, FLT_MAX }, \
+ { note "stop", RTBUF_SIGNAL_SAMPLE_TYPE, -1.0, -1.0, FLT_MAX }
+
+#define RTBUF_MUSIC_NOTE_IN_ENUM(note) \
+ note ## _VELOCITY , \
+ note ## _FREQUENCY, \
+ note ## _START , \
+ note ## _STOP
+
+enum {
+ RTBUF_MUSIC_NOTE_IN_VELOCITY = 0,
+ RTBUF_MUSIC_NOTE_IN_FREQUENCY,
+ RTBUF_MUSIC_NOTE_IN_START,
+ RTBUF_MUSIC_NOTE_IN_STOP,
+ RTBUF_MUSIC_NOTE_INS
+};
+
+#define RTBUF_MUSIC_NOTE_IN_VELOCITY(notes, i) \
+ (notes + 1 + RTBUF_MUSIC_NOTE_INS * i + \
+ RTBUF_MUSIC_NOTE_IN_VELOCITY)
+#define RTBUF_MUSIC_NOTE_IN_FREQUENCY(notes, i) \
+ (notes + 1 + RTBUF_MUSIC_NOTE_INS * i + \
+ RTBUF_MUSIC_NOTE_IN_FREQUENCY)
+#define RTBUF_MUSIC_NOTE_IN_START(notes, i) \
+ (notes + 1 + RTBUF_MUSIC_NOTE_INS * i + RTBUF_MUSIC_NOTE_IN_START)
+#define RTBUF_MUSIC_NOTE_IN_STOP(notes, i) \
+ (notes + 1 + RTBUF_MUSIC_NOTE_INS * i + RTBUF_MUSIC_NOTE_IN_STOP)
+
+#define RTBUF_MUSIC_NOTE_MAX 32
+
+#pragma pack(push,1)
+typedef struct rtbuf_music_notes {
+ unsigned int note_n;
+ s_rtbuf_music_note note[RTBUF_MUSIC_NOTE_MAX];
+} s_rtbuf_music_notes;
+#pragma pack(pop)
+
+#define RTBUF_MUSIC_NOTES_SIZE sizeof(unsigned int)
+#define RTBUF_MUSIC_NOTES_TYPE "music_notes"
+
+int rtbuf_music_init ();
+void rtbuf_music_notes_init (s_rtbuf_music_notes *notes);
+int rtbuf_music_notes_new (s_rtbuf_music_notes *notes, double velocity);
+void rtbuf_music_notes_delete (s_rtbuf_music_notes *notes,
+ unsigned int i);
+void rtbuf_music_notes_delete_all (s_rtbuf_music_notes *notes);
+void rtbuf_music_notes_dt (s_rtbuf_music_notes *notes, double dt);
+int rtbuf_music_note_p (s_rtbuf_music_note *note);
+void rtbuf_music_note_dt (s_rtbuf_music_note *note, double dt);
+
+s_rtbuf_music_notes * rtbuf_music_notes (s_rtbuf *rtb,
+ unsigned int in);
+
+t_rtbuf_signal_sample rtbuf_music_note_frequency (unsigned int octave,
+ unsigned int note);
+double rtbuf_music_frequency_note (double f);
+
+#endif
diff --git a/lib/include/rtbuf/reverb.h b/lib/include/rtbuf/reverb.h
new file mode 100644
index 0000000..7e7fad1
--- /dev/null
+++ b/lib/include/rtbuf/reverb.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifndef RTBUF_REVERB_H
+#define RTBUF_REVERB_H
+
+#include <assert.h>
+#include <rtbuf/rtbuf.h>
+#include <rtbuf/signal.h>
+
+/* Feedback delay network with fourth order Hadamard matrix */
+
+#define RTBUF_REVERB_FDN4_DELAY_SAMPLES_MAX \
+ RTBUF_SIGNAL_SAMPLERATE
+
+#pragma pack(push,1)
+typedef struct rtbuf_reverb_fdn4_data {
+ t_rtbuf_signal signal;
+ t_rtbuf_signal_sample d0[RTBUF_REVERB_FDN4_DELAY_SAMPLES_MAX];
+ t_rtbuf_signal_sample d1[RTBUF_REVERB_FDN4_DELAY_SAMPLES_MAX];
+ t_rtbuf_signal_sample d2[RTBUF_REVERB_FDN4_DELAY_SAMPLES_MAX];
+ t_rtbuf_signal_sample d3[RTBUF_REVERB_FDN4_DELAY_SAMPLES_MAX];
+ unsigned int pos;
+} s_rtbuf_reverb_fdn4_data;
+#pragma pack(pop)
+
+enum {
+ RTBUF_REVERB_FDN4_IN_SIGNAL = 0,
+ RTBUF_REVERB_FDN4_IN_TIME,
+ RTBUF_REVERB_FDN4_IN_DRY_LEVEL,
+ RTBUF_REVERB_FDN4_IN_WET_LEVEL,
+ RTBUF_REVERB_FDN4_INS
+};
+
+int rtbuf_reverb_fdn4 (s_rtbuf *rtb);
+int rtbuf_reverb_fdn4_start (s_rtbuf *rtb);
+
+#endif /* RTBUF_REVERB_H */
diff --git a/lib/include/rtbuf/signal.h b/lib/include/rtbuf/signal.h
new file mode 100644
index 0000000..08ce473
--- /dev/null
+++ b/lib/include/rtbuf/signal.h
@@ -0,0 +1,466 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifndef RTBUF_SIGNAL_H
+#define RTBUF_SIGNAL_H
+
+#include <assert.h>
+#include <rtbuf/rtbuf.h>
+
+typedef double t_rtbuf_signal_sample;
+#define RTBUF_SIGNAL_SAMPLE_SIZE sizeof(t_rtbuf_signal_sample)
+#define RTBUF_SIGNAL_SAMPLE_TYPE "double"
+
+#define RTBUF_SIGNAL_SAMPLES 1024
+#define RTBUF_SIGNAL_SAMPLERATE 48000
+#define RTBUF_SIGNAL_DT \
+ ((double) RTBUF_SIGNAL_SAMPLES / RTBUF_SIGNAL_SAMPLERATE)
+
+typedef t_rtbuf_signal_sample t_rtbuf_signal[RTBUF_SIGNAL_SAMPLES];
+
+#define RTBUF_SIGNAL_SIZE sizeof(t_rtbuf_signal)
+
+typedef t_rtbuf_signal_sample
+f_rtbuf_signal (const t_rtbuf_signal_sample *signal,
+ unsigned int sample);
+
+typedef struct rtbuf_signal_fun {
+ f_rtbuf_signal *sample_fun;
+ const t_rtbuf_signal_sample *signal;
+} s_rtbuf_signal_fun;
+
+void rtbuf_signal_zero (t_rtbuf_signal_sample *signal);
+t_rtbuf_signal_sample
+rtbuf_signal_sample (s_rtbuf *rtb,
+ unsigned int in,
+ t_rtbuf_signal_sample default_value);
+void rtbuf_signal_fun (s_rtbuf *rtb,
+ unsigned int in,
+ s_rtbuf_signal_fun *data);
+
+f_rtbuf_signal rtbuf_signal_sample_from_sample;
+f_rtbuf_signal rtbuf_signal_sample_from_signal;
+
+const double g_rtbuf_signal_sample_zero;
+const double g_rtbuf_signal_sample_half;
+const double g_rtbuf_signal_sample_one;
+const double g_rtbuf_signal_sample_2pi;
+const double g_rtbuf_signal_default_frequency;
+
+/* butterworth bandpass filter, second order */
+
+#pragma pack(push,1)
+typedef struct rtbuf_signal_bandpass2_data {
+ t_rtbuf_signal signal;
+ t_rtbuf_signal_sample x1;
+ t_rtbuf_signal_sample x2;
+ t_rtbuf_signal_sample x3;
+ t_rtbuf_signal_sample x4;
+ t_rtbuf_signal_sample y1;
+ t_rtbuf_signal_sample y2;
+ t_rtbuf_signal_sample y3;
+ t_rtbuf_signal_sample y4;
+} s_rtbuf_signal_bandpass2_data;
+#pragma pack(pop)
+
+enum {
+ RTBUF_SIGNAL_BANDPASS_IN_SIGNAL = 0,
+ RTBUF_SIGNAL_BANDPASS_IN_CUTOFF,
+ RTBUF_SIGNAL_BANDPASS_IN_QFACTOR,
+ RTBUF_SIGNAL_BANDPASS_INS
+};
+
+int rtbuf_signal_bandpass2 (s_rtbuf *rtb);
+int rtbuf_signal_bandpass2_start (s_rtbuf *rtb);
+
+/* delay */
+
+#define RTBUF_SIGNAL_DELAY_MAX 10
+#define RTBUF_SIGNAL_DELAY_SAMPLES_MAX (RTBUF_SIGNAL_DELAY_MAX * \
+ RTBUF_SIGNAL_SAMPLERATE)
+
+#pragma pack(push,1)
+typedef struct rtbuf_signal_delay_data {
+ t_rtbuf_signal signal;
+ t_rtbuf_signal_sample in[RTBUF_SIGNAL_DELAY_SAMPLES_MAX];
+ unsigned int pos;
+} s_rtbuf_signal_delay_data;
+#pragma pack(pop)
+
+enum {
+ RTBUF_SIGNAL_DELAY_IN_SIGNAL = 0,
+ RTBUF_SIGNAL_DELAY_IN_DELAY,
+ RTBUF_SIGNAL_DELAY_IN_FEEDBACK,
+ RTBUF_SIGNAL_DELAY_INS
+};
+
+int rtbuf_signal_delay (s_rtbuf *rtb);
+int rtbuf_signal_delay_start (s_rtbuf *rtb);
+
+/* butterworth second order 10 band equalizer */
+
+#pragma pack(push,1)
+typedef struct rtbuf_signal_equalizer10_data {
+ t_rtbuf_signal signal;
+ t_rtbuf_signal signal32;
+ t_rtbuf_signal signal64;
+ t_rtbuf_signal signal128;
+ t_rtbuf_signal signal256;
+ t_rtbuf_signal signal512;
+ t_rtbuf_signal signal1k;
+ t_rtbuf_signal signal2k;
+ t_rtbuf_signal signal4k;
+ t_rtbuf_signal signal8k;
+ t_rtbuf_signal signal16k;
+ t_rtbuf_signal_sample x1;
+ t_rtbuf_signal_sample x2;
+ t_rtbuf_signal_sample x3;
+ t_rtbuf_signal_sample x4;
+ t_rtbuf_signal_sample y0_1;
+ t_rtbuf_signal_sample y0_2;
+ t_rtbuf_signal_sample y0_3;
+ t_rtbuf_signal_sample y0_4;
+ t_rtbuf_signal_sample y1_1;
+ t_rtbuf_signal_sample y1_2;
+ t_rtbuf_signal_sample y1_3;
+ t_rtbuf_signal_sample y1_4;
+ t_rtbuf_signal_sample y2_1;
+ t_rtbuf_signal_sample y2_2;
+ t_rtbuf_signal_sample y2_3;
+ t_rtbuf_signal_sample y2_4;
+ t_rtbuf_signal_sample y3_1;
+ t_rtbuf_signal_sample y3_2;
+ t_rtbuf_signal_sample y3_3;
+ t_rtbuf_signal_sample y3_4;
+ t_rtbuf_signal_sample y4_1;
+ t_rtbuf_signal_sample y4_2;
+ t_rtbuf_signal_sample y4_3;
+ t_rtbuf_signal_sample y4_4;
+ t_rtbuf_signal_sample y5_1;
+ t_rtbuf_signal_sample y5_2;
+ t_rtbuf_signal_sample y5_3;
+ t_rtbuf_signal_sample y5_4;
+ t_rtbuf_signal_sample y6_1;
+ t_rtbuf_signal_sample y6_2;
+ t_rtbuf_signal_sample y6_3;
+ t_rtbuf_signal_sample y6_4;
+ t_rtbuf_signal_sample y7_1;
+ t_rtbuf_signal_sample y7_2;
+ t_rtbuf_signal_sample y7_3;
+ t_rtbuf_signal_sample y7_4;
+ t_rtbuf_signal_sample y8_1;
+ t_rtbuf_signal_sample y8_2;
+ t_rtbuf_signal_sample y8_3;
+ t_rtbuf_signal_sample y8_4;
+ t_rtbuf_signal_sample y9_1;
+ t_rtbuf_signal_sample y9_2;
+ t_rtbuf_signal_sample y9_3;
+ t_rtbuf_signal_sample y9_4;
+} s_rtbuf_signal_equalizer10_data;
+#pragma pack(pop)
+
+enum {
+ RTBUF_SIGNAL_EQUALIZER10_IN_SIGNAL = 0,
+ RTBUF_SIGNAL_EQUALIZER10_IN_AMP32,
+ RTBUF_SIGNAL_EQUALIZER10_IN_AMP64,
+ RTBUF_SIGNAL_EQUALIZER10_IN_AMP128,
+ RTBUF_SIGNAL_EQUALIZER10_IN_AMP256,
+ RTBUF_SIGNAL_EQUALIZER10_IN_AMP512,
+ RTBUF_SIGNAL_EQUALIZER10_IN_AMP1K,
+ RTBUF_SIGNAL_EQUALIZER10_IN_AMP2K,
+ RTBUF_SIGNAL_EQUALIZER10_IN_AMP4K,
+ RTBUF_SIGNAL_EQUALIZER10_IN_AMP8K,
+ RTBUF_SIGNAL_EQUALIZER10_IN_AMP16K,
+ RTBUF_SIGNAL_EQUALIZER10_INS
+};
+
+int rtbuf_signal_equalizer10 (s_rtbuf *rtb);
+int rtbuf_signal_equalizer10_start (s_rtbuf *rtb);
+
+/* flanger */
+
+#define RTBUF_SIGNAL_FLANGER_MAX 1
+#define RTBUF_SIGNAL_FLANGER_SAMPLES_MAX (RTBUF_SIGNAL_FLANGER_MAX * \
+ RTBUF_SIGNAL_SAMPLERATE)
+
+#pragma pack(push,1)
+typedef struct rtbuf_signal_flanger_data {
+ t_rtbuf_signal signal;
+ double phase;
+ t_rtbuf_signal_sample in[RTBUF_SIGNAL_FLANGER_SAMPLES_MAX];
+ unsigned int pos;
+ unsigned int ds;
+} s_rtbuf_signal_flanger_data;
+#pragma pack(pop)
+
+enum {
+ RTBUF_SIGNAL_FLANGER_IN_SIGNAL = 0,
+ RTBUF_SIGNAL_FLANGER_IN_FREQUENCY,
+ RTBUF_SIGNAL_FLANGER_IN_AMPLITUDE,
+ RTBUF_SIGNAL_FLANGER_IN_DELAY,
+ RTBUF_SIGNAL_FLANGER_IN_FEEDBACK,
+ RTBUF_SIGNAL_FLANGER_IN_N
+};
+
+int rtbuf_signal_flanger (s_rtbuf *rtb);
+int rtbuf_signal_flanger_start (s_rtbuf *rtb);
+
+/* butterworth hipass filter, first order */
+
+#pragma pack(push,1)
+typedef struct rtbuf_signal_hipass_data {
+ t_rtbuf_signal signal;
+ t_rtbuf_signal_sample x1;
+ t_rtbuf_signal_sample y1;
+} s_rtbuf_signal_hipass_data;
+#pragma pack(pop)
+
+enum {
+ RTBUF_SIGNAL_HIPASS_IN_SIGNAL = 0,
+ RTBUF_SIGNAL_HIPASS_IN_CUTOFF,
+ RTBUF_SIGNAL_HIPASS_INS
+};
+
+int rtbuf_signal_hipass (s_rtbuf *rtb);
+int rtbuf_signal_hipass_start (s_rtbuf *rtb);
+
+/* butterworth hipass filter, second order */
+
+#pragma pack(push,1)
+typedef struct rtbuf_signal_hipass2_data {
+ t_rtbuf_signal signal;
+ t_rtbuf_signal_sample x1;
+ t_rtbuf_signal_sample x2;
+ t_rtbuf_signal_sample y1;
+ t_rtbuf_signal_sample y2;
+} s_rtbuf_signal_hipass2_data;
+#pragma pack(pop)
+
+int rtbuf_signal_hipass2 (s_rtbuf *rtb);
+int rtbuf_signal_hipass2_start (s_rtbuf *rtb);
+
+/* butterworth hipass filter, third order */
+
+#pragma pack(push,1)
+typedef struct rtbuf_signal_hipass3_data {
+ t_rtbuf_signal signal;
+ t_rtbuf_signal_sample x1;
+ t_rtbuf_signal_sample x2;
+ t_rtbuf_signal_sample x3;
+ t_rtbuf_signal_sample y1;
+ t_rtbuf_signal_sample y2;
+ t_rtbuf_signal_sample y3;
+} s_rtbuf_signal_hipass3_data;
+#pragma pack(pop)
+
+int rtbuf_signal_hipass3 (s_rtbuf *rtb);
+int rtbuf_signal_hipass3_start (s_rtbuf *rtb);
+
+/* butterworth hipass filter, fourth order */
+
+#pragma pack(push,1)
+typedef struct rtbuf_signal_hipass4_data {
+ t_rtbuf_signal signal;
+ t_rtbuf_signal_sample x1;
+ t_rtbuf_signal_sample x2;
+ t_rtbuf_signal_sample x3;
+ t_rtbuf_signal_sample x4;
+ t_rtbuf_signal_sample y1;
+ t_rtbuf_signal_sample y2;
+ t_rtbuf_signal_sample y3;
+ t_rtbuf_signal_sample y4;
+} s_rtbuf_signal_hipass4_data;
+#pragma pack(pop)
+
+int rtbuf_signal_hipass4 (s_rtbuf *rtb);
+int rtbuf_signal_hipass4_start (s_rtbuf *rtb);
+
+/* butterworth hipass filter, fifth order */
+
+#pragma pack(push,1)
+typedef struct rtbuf_signal_hipass5_data {
+ t_rtbuf_signal signal;
+ t_rtbuf_signal_sample x1;
+ t_rtbuf_signal_sample x2;
+ t_rtbuf_signal_sample x3;
+ t_rtbuf_signal_sample x4;
+ t_rtbuf_signal_sample x5;
+ t_rtbuf_signal_sample y1;
+ t_rtbuf_signal_sample y2;
+ t_rtbuf_signal_sample y3;
+ t_rtbuf_signal_sample y4;
+ t_rtbuf_signal_sample y5;
+} s_rtbuf_signal_hipass5_data;
+#pragma pack(pop)
+
+int rtbuf_signal_hipass5 (s_rtbuf *rtb);
+int rtbuf_signal_hipass5_start (s_rtbuf *rtb);
+
+/* butterworth lowpass filter, first order */
+
+#pragma pack(push,1)
+typedef struct rtbuf_signal_lowpass_data {
+ t_rtbuf_signal signal;
+ t_rtbuf_signal_sample x1;
+ t_rtbuf_signal_sample y1;
+} s_rtbuf_signal_lowpass_data;
+#pragma pack(pop)
+
+enum {
+ RTBUF_SIGNAL_LOWPASS_IN_SIGNAL = 0,
+ RTBUF_SIGNAL_LOWPASS_IN_CUTOFF,
+ RTBUF_SIGNAL_LOWPASS_INS
+};
+
+int rtbuf_signal_lowpass (s_rtbuf *rtb);
+int rtbuf_signal_lowpass_start (s_rtbuf *rtb);
+
+/* butterworth lowpass filter, second order */
+
+#pragma pack(push,1)
+typedef struct rtbuf_signal_lowpass2_data {
+ t_rtbuf_signal signal;
+ t_rtbuf_signal_sample x1;
+ t_rtbuf_signal_sample x2;
+ t_rtbuf_signal_sample y1;
+ t_rtbuf_signal_sample y2;
+} s_rtbuf_signal_lowpass2_data;
+#pragma pack(pop)
+
+int rtbuf_signal_lowpass2 (s_rtbuf *rtb);
+int rtbuf_signal_lowpass2_start (s_rtbuf *rtb);
+
+/* butterworth lowpass filter, third order */
+
+#pragma pack(push,1)
+typedef struct rtbuf_signal_lowpass3_data {
+ t_rtbuf_signal signal;
+ t_rtbuf_signal_sample x1;
+ t_rtbuf_signal_sample x2;
+ t_rtbuf_signal_sample x3;
+ t_rtbuf_signal_sample y1;
+ t_rtbuf_signal_sample y2;
+ t_rtbuf_signal_sample y3;
+} s_rtbuf_signal_lowpass3_data;
+#pragma pack(pop)
+
+int rtbuf_signal_lowpass3 (s_rtbuf *rtb);
+int rtbuf_signal_lowpass3_start (s_rtbuf *rtb);
+
+/* butterworth lowpass filter, fourth order */
+
+#pragma pack(push,1)
+typedef struct rtbuf_signal_lowpass4_data {
+ t_rtbuf_signal signal;
+ t_rtbuf_signal_sample x1;
+ t_rtbuf_signal_sample x2;
+ t_rtbuf_signal_sample x3;
+ t_rtbuf_signal_sample x4;
+ t_rtbuf_signal_sample y1;
+ t_rtbuf_signal_sample y2;
+ t_rtbuf_signal_sample y3;
+ t_rtbuf_signal_sample y4;
+} s_rtbuf_signal_lowpass4_data;
+#pragma pack(pop)
+
+int rtbuf_signal_lowpass4 (s_rtbuf *rtb);
+int rtbuf_signal_lowpass4_start (s_rtbuf *rtb);
+
+/* butterworth lowpass filter, fifth order */
+
+#pragma pack(push,1)
+typedef struct rtbuf_signal_lowpass5_data {
+ t_rtbuf_signal signal;
+ t_rtbuf_signal_sample x1;
+ t_rtbuf_signal_sample x2;
+ t_rtbuf_signal_sample x3;
+ t_rtbuf_signal_sample x4;
+ t_rtbuf_signal_sample x5;
+ t_rtbuf_signal_sample y1;
+ t_rtbuf_signal_sample y2;
+ t_rtbuf_signal_sample y3;
+ t_rtbuf_signal_sample y4;
+ t_rtbuf_signal_sample y5;
+} s_rtbuf_signal_lowpass5_data;
+#pragma pack(pop)
+
+int rtbuf_signal_lowpass5 (s_rtbuf *rtb);
+int rtbuf_signal_lowpass5_start (s_rtbuf *rtb);
+
+/* sawtooth */
+
+#pragma pack(push,1)
+typedef struct rtbuf_signal_sawtooth_data {
+ t_rtbuf_signal signal;
+ double phase;
+} s_rtbuf_signal_sawtooth_data;
+#pragma pack(pop)
+
+enum {
+ RTBUF_SIGNAL_SAWTOOTH_IN_FREQUENCY = 0,
+ RTBUF_SIGNAL_SAWTOOTH_IN_AMPLITUDE,
+ RTBUF_SIGNAL_SAWTOOTH_IN_N
+};
+
+int rtbuf_signal_sawtooth (s_rtbuf *rtb);
+int rtbuf_signal_sawtooth_start (s_rtbuf *rtb);
+
+/* sinus */
+
+#pragma pack(push,1)
+typedef struct rtbuf_signal_sinus_data {
+ t_rtbuf_signal signal;
+ double phase;
+} s_rtbuf_signal_sinus_data;
+#pragma pack(pop)
+
+enum {
+ RTBUF_SIGNAL_SINUS_IN_FREQUENCY = 0,
+ RTBUF_SIGNAL_SINUS_IN_AMPLITUDE,
+ RTBUF_SIGNAL_SINUS_IN_N
+};
+
+int rtbuf_signal_sinus (s_rtbuf *rtb);
+int rtbuf_signal_sinus_start (s_rtbuf *rtb);
+
+/* square */
+
+enum {
+ RTBUF_SIGNAL_SQUARE_IN_FREQUENCY = 0,
+ RTBUF_SIGNAL_SQUARE_IN_AMPLITUDE,
+ RTBUF_SIGNAL_SQUARE_IN_PULSE,
+ RTBUF_SIGNAL_SQUARE_IN_N
+};
+
+#pragma pack(push,1)
+typedef struct rtbuf_signal_square_data {
+ t_rtbuf_signal signal;
+ double phase;
+} s_rtbuf_signal_square_data;
+#pragma pack(pop)
+
+int rtbuf_signal_square (s_rtbuf *rtb);
+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 */
diff --git a/lib/music.c b/lib/music.c
new file mode 100644
index 0000000..c1c9c56
--- /dev/null
+++ b/lib/music.c
@@ -0,0 +1,144 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <assert.h>
+#include <math.h>
+#include <stdio.h>
+#include <rtbuf/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;
+
+int rtbuf_music_init ()
+{
+ double tune_c;
+ if (g_rtbuf_music_init)
+ return 0;
+ rtbuf_type_define(RTBUF_MUSIC_NOTE_TYPE, RTBUF_MUSIC_NOTE_SIZE);
+ rtbuf_type_define(RTBUF_MUSIC_NOTES_TYPE, RTBUF_MUSIC_NOTES_SIZE);
+ tune_c = fmod(log2(RTBUF_MUSIC_TUNE_A) - 9.0 / 12.0, 1.0);
+ g_rtbuf_music_tune = RTBUF_MUSIC_BASE_OCTAVE + tune_c;
+ g_rtbuf_music_init = 1;
+ return 0;
+}
+
+double rtbuf_music_note_frequency (unsigned int octave,
+ unsigned int note)
+{
+ return exp2(octave + note / 12.0 + g_rtbuf_music_tune);
+}
+
+double rtbuf_music_frequency_note (double f)
+{
+ return log2(f) * 12.0 - g_rtbuf_music_tune;
+}
+
+int rtbuf_music_notes_new (s_rtbuf_music_notes *notes, double velocity)
+{
+ unsigned int i = 0;
+ assert(notes);
+ if (velocity == 0.0)
+ return rtbuf_err("music_notes_new: zero velocity");
+ if (notes->note_n >= RTBUF_MUSIC_NOTE_MAX)
+ return rtbuf_err("RTBUF_MUSIC_NOTE_MAX exhausted");
+ while (i < RTBUF_MUSIC_NOTE_MAX) {
+ if (notes->note[i].velocity == 0.0) {
+ notes->note[i].velocity = velocity;
+ notes->note_n++;
+ printf("music_notes_new %u\n", i);
+ return i;
+ }
+ i++;
+ }
+ return -1;
+}
+
+void rtbuf_music_notes_delete (s_rtbuf_music_notes *notes,
+ unsigned int i)
+{
+ s_rtbuf_music_note *note;
+ assert(notes);
+ assert(i < RTBUF_MUSIC_NOTE_MAX);
+ note = ¬es->note[i];
+ if (note->velocity > 0.0 && note->start >= 0.0) {
+ printf("music_notes_delete %u\n", i);
+ notes->note_n--;
+ }
+ note->velocity = 0.0;
+ note->freq = 0.0;
+ note->start = -1.0;
+ note->stop = -1.0;
+}
+
+void rtbuf_music_notes_delete_all (s_rtbuf_music_notes *notes)
+{
+ unsigned int i = 0;
+ while (i < RTBUF_MUSIC_NOTE_MAX && notes->note_n > 0) {
+ rtbuf_music_notes_delete(notes, i);
+ i++;
+ }
+}
+
+void rtbuf_music_note_dt (s_rtbuf_music_note *note, double dt)
+{
+ assert(note);
+ if (note->start >= 0.0) {
+ note->start += dt;
+ if (note->stop >= 0.0)
+ note->stop += dt;
+ }
+}
+
+void rtbuf_music_notes_dt (s_rtbuf_music_notes *notes, double dt)
+{
+ unsigned int i = 0;
+ if (notes) {
+ unsigned int n = notes->note_n;
+ while (i < RTBUF_MUSIC_NOTE_MAX && n > 0) {
+ if (notes->note[i].velocity > 0.0) {
+ rtbuf_music_note_dt(¬es->note[i], dt);
+ n--;
+ }
+ i++;
+ }
+ }
+}
+
+s_rtbuf_music_notes * rtbuf_music_notes (s_rtbuf *rtb,
+ unsigned int in)
+{
+ s_rtbuf_binding *v;
+ s_rtbuf *target;
+ unsigned int offset;
+ v = &rtb->in[in];
+ if (v->rtb < 0)
+ return 0;
+ assert(v->rtb < RTBUF_MAX);
+ target = &g_rtbuf[v->rtb];
+ assert(target->proc);
+ assert(v->out < target->proc->out_n);
+ offset = target->proc->out[v->out].offset;
+ return (s_rtbuf_music_notes*) ((char*) target->data + offset);
+}
+
+int rtbuf_music_note_p (s_rtbuf_music_note *note)
+{
+ return (note && note->velocity > 0.0);
+}
diff --git a/lib/music_type.c b/lib/music_type.c
new file mode 100644
index 0000000..3ed4246
--- /dev/null
+++ b/lib/music_type.c
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <rtbuf/rtbuf.h>
+#include <rtbuf/music.h>
+
+void notes_in ()
+{
+ unsigned int i = 0;
+ const char *st = "RTBUF_SIGNAL_SAMPLE_TYPE";
+ printf("\n"
+ "#define RTBUF_MUSIC_NOTES_IN(note) \\\n"
+ " { note \"s\" , RTBUF_MUSIC_NOTES_TYPE, 0.0, 0.0, 0.0 }"
+ ", \\\n");
+ while (i < RTBUF_MUSIC_NOTE_MAX) {
+ printf(" { note \"[%u].velocity\" , %s, 0.0, 0.0, 1.0 }, \\\n", i, st);
+ printf(" { note \"[%u].frequency\", %s, 0.0, 0.0, "
+ "RTBUF_SIGNAL_SAMPLERATE / 2.0 }, \\\n", i, st);
+ printf(" { note \"[%u].start\" , %s, -1.0, -1.0, FLT_MAX }, \\\n", i, st);
+ printf(" { note \"[%u].stop\" , %s, -1.0, -1.0, FLT_MAX }", i, st);
+ if (i < RTBUF_MUSIC_NOTE_MAX - 1)
+ printf(", \\");
+ printf("\n");
+ i++;
+ }
+ i = 0;
+ printf("\n"
+ "#define RTBUF_MUSIC_NOTES_IN_ENUM(note) \\\n"
+ " note ## S , \\\n");
+ while (i < RTBUF_MUSIC_NOTE_MAX) {
+ printf(" note ## _%u_VELOCITY , \\\n", i);
+ printf(" note ## _%u_FREQUENCY, \\\n", i);
+ printf(" note ## _%u_START , \\\n", i);
+ printf(" note ## _%u_STOP", i);
+ if (i < RTBUF_MUSIC_NOTE_MAX - 1)
+ printf(" , \\");
+ printf("\n");
+ i++;
+ }
+}
+
+void notes_out ()
+{
+ unsigned int i = 0;
+ const char *st = "RTBUF_SIGNAL_SAMPLE_TYPE";
+ printf("\n"
+ "#define RTBUF_MUSIC_NOTES_OUT(note) \\\n"
+ " { note \"s\" , RTBUF_MUSIC_NOTES_TYPE }"
+ ", \\\n");
+ while (i < RTBUF_MUSIC_NOTE_MAX) {
+ printf(" { note \"[%u].velocity\" , %s }, \\\n", i, st);
+ printf(" { note \"[%u].frequency\", %s }, \\\n", i, st);
+ printf(" { note \"[%u].start\" , %s }, \\\n", i, st);
+ printf(" { note \"[%u].stop\" , %s }", i, st);
+ if (i < RTBUF_MUSIC_NOTE_MAX - 1)
+ printf(", \\");
+ printf("\n");
+ i++;
+ }
+}
+
+int main ()
+{
+ printf("/* file generated by rtbuf_music_type */\n");
+ printf("#ifndef RTBUF_MUSIC_TYPE_H\n"
+ "#define RTBUF_MUSIC_TYPE_H\n");
+ notes_in();
+ notes_out();
+ printf("\n"
+ "#endif\n");
+ return 0;
+}
diff --git a/lib/portaudio/rtbuf_portaudio.c b/lib/portaudio/rtbuf_portaudio.c
new file mode 100644
index 0000000..338014b
--- /dev/null
+++ b/lib/portaudio/rtbuf_portaudio.c
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <portaudio.h>
+#include <stdio.h>
+#include <strings.h>
+#include "rtbuf.h"
+#include "rtbuf_lib.h"
+#include "rtbuf_signal.h"
+#include "rtbuf_signal_type.h"
+#include "rtbuf_portaudio.h"
+#include "rtbuf_portaudio_type.h"
+
+s_rtbuf_lib_proc_out g_rtbuf_portaudio_input_out[] = {
+ { "left", RTBUF_SIGNAL_TYPE },
+ { "right", RTBUF_SIGNAL_TYPE },
+ { "samples", RTBUF_PORTAUDIO_SAMPLES_TYPE },
+ { 0, 0 } };
+
+s_rtbuf_lib_proc_in g_rtbuf_portaudio_output_in[] = {
+ { "left", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
+ { "right", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
+ { 0, 0, 0.0, 0.0, 0.0 } };
+
+s_rtbuf_lib_proc_out g_rtbuf_portaudio_output_out[] = {
+ { "samples", RTBUF_PORTAUDIO_SAMPLES_TYPE },
+ { "reserved", RTBUF_PORTAUDIO_OUTPUT_RESERVED_TYPE },
+ { 0, 0 } };
+
+const char *rtbuf_lib_name = "portaudio";
+unsigned long rtbuf_lib_ver = RTBUF_LIB_VER;
+s_rtbuf_lib_proc rtbuf_lib_proc[] = {
+ { "input", rtbuf_portaudio_input, rtbuf_portaudio_input_start,
+ rtbuf_portaudio_input_stop, 0, g_rtbuf_portaudio_input_out },
+ { "output", rtbuf_portaudio_output, rtbuf_portaudio_output_start,
+ rtbuf_portaudio_output_stop, g_rtbuf_portaudio_output_in,
+ g_rtbuf_portaudio_output_out },
+ { 0, 0, 0, 0, 0, 0 } };
diff --git a/lib/portaudio/rtbuf_portaudio.h b/lib/portaudio/rtbuf_portaudio.h
new file mode 100644
index 0000000..13e044b
--- /dev/null
+++ b/lib/portaudio/rtbuf_portaudio.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifndef RTBUF_PORTAUDIO_H
+#define RTBUF_PORTAUDIO_H
+
+#include <portaudio.h>
+#include "rtbuf_signal.h"
+
+enum {
+ RTBUF_PORTAUDIO_LEFT = 0,
+ RTBUF_PORTAUDIO_RIGHT,
+ RTBUF_PORTAUDIO_CHANNELS
+};
+
+#define RTBUF_PORTAUDIO_SAMPLE_TYPE "short"
+#define RTBUF_PORTAUDIO_SAMPLES \
+ (RTBUF_PORTAUDIO_CHANNELS * RTBUF_SIGNAL_SAMPLES)
+
+typedef short t_rtbuf_portaudio_sample;
+typedef t_rtbuf_portaudio_sample t_rtbuf_portaudio_samples[RTBUF_PORTAUDIO_SAMPLES];
+
+typedef struct rtbuf_portaudio_input_data {
+ t_rtbuf_signal signal[RTBUF_PORTAUDIO_CHANNELS];
+ t_rtbuf_portaudio_samples samples;
+} s_rtbuf_portaudio_input_data;
+
+int rtbuf_portaudio_input (s_rtbuf *rtb);
+int rtbuf_portaudio_input_start (s_rtbuf *rtb);
+int rtbuf_portaudio_input_stop (s_rtbuf *rtb);
+
+typedef struct rtbuf_portaudio_output_reserved {
+ PaStream *stream;
+} s_rtbuf_portaudio_output_reserved;
+
+typedef struct rtbuf_portaudio_output_data {
+ t_rtbuf_portaudio_samples samples;
+ s_rtbuf_portaudio_output_reserved reserved;
+} s_rtbuf_portaudio_output_data;
+
+#define RTBUF_PORTAUDIO_OUTPUT_RESERVED_SIZE \
+ sizeof(s_rtbuf_portaudio_output_reserved)
+
+int rtbuf_portaudio_output (s_rtbuf *rtb);
+int rtbuf_portaudio_output_start (s_rtbuf *rtb);
+int rtbuf_portaudio_output_stop (s_rtbuf *rtb);
+
+#endif
diff --git a/lib/portaudio/rtbuf_portaudio_input.c b/lib/portaudio/rtbuf_portaudio_input.c
new file mode 100644
index 0000000..6ee5709
--- /dev/null
+++ b/lib/portaudio/rtbuf_portaudio_input.c
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <portaudio.h>
+#include <stdio.h>
+#include <strings.h>
+#include "rtbuf.h"
+#include "rtbuf_signal.h"
+#include "rtbuf_portaudio.h"
+
+int rtbuf_portaudio_input (s_rtbuf *rtb)
+{
+ /*
+ s_portaudio_input_data *data = (s_portaudio_input_data*) rtb->data;
+ */
+ (void) rtb;
+ return 0;
+}
+
+int rtbuf_portaudio_input_start (s_rtbuf *rtb)
+{
+ s_rtbuf_portaudio_input_data *data;
+ assert(rtb->proc->out_bytes == sizeof(*data));
+ data = (s_rtbuf_portaudio_input_data*) rtb->data;
+ return 0;
+}
+
+int rtbuf_portaudio_input_stop (s_rtbuf *rtb)
+{
+ (void) rtb;
+ return 0;
+}
diff --git a/lib/portaudio/rtbuf_portaudio_output.c b/lib/portaudio/rtbuf_portaudio_output.c
new file mode 100644
index 0000000..0d210b6
--- /dev/null
+++ b/lib/portaudio/rtbuf_portaudio_output.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <limits.h>
+#include <portaudio.h>
+#include <stdio.h>
+#include <strings.h>
+#include "rtbuf.h"
+#include "rtbuf_portaudio.h"
+
+int g_initialized = 0;
+
+int rtbuf_portaudio_output_start (s_rtbuf *rtb)
+{
+ s_rtbuf_portaudio_output_data *data;
+ PaError err;
+ assert(rtb->proc->out_bytes == sizeof(*data));
+ data = (s_rtbuf_portaudio_output_data*) rtb->data;
+ if (!g_initialized) {
+ if (Pa_Initialize() != paNoError)
+ return rtbuf_err("portaudio_output_start: Pa_Initialize() failed");
+ g_initialized = 1;
+ }
+ err = Pa_OpenDefaultStream(&data->reserved.stream, /* stream pointer */
+ 0, /* input channels */
+ RTBUF_PORTAUDIO_CHANNELS, /* output channels */
+ paInt16, /* sample format */
+ RTBUF_SIGNAL_SAMPLERATE, /* sample rate */
+ RTBUF_SIGNAL_SAMPLES, /* frames per buffer */
+ NULL, /* stream callback */
+ NULL); /* user data */
+ if (err != paNoError) {
+ rtbuf_err(Pa_GetErrorText(err));
+ return rtbuf_err("portaudio_output_start: Pa_OpenDefaultStream() failed");
+ }
+ err = Pa_StartStream(data->reserved.stream);
+ if (err != paNoError) {
+ rtbuf_err(Pa_GetErrorText(err));
+ return rtbuf_err("portaudio output start: Pa_StartStream() failed");
+ }
+ return 0;
+}
+
+int rtbuf_portaudio_output_stop (s_rtbuf *rtb)
+{
+ s_rtbuf_portaudio_output_data *data;
+ data = (s_rtbuf_portaudio_output_data*) rtb->data;
+ if (data->reserved.stream) {
+ Pa_StopStream(data->reserved.stream);
+ Pa_CloseStream(data->reserved.stream);
+ data->reserved.stream = 0;
+ }
+ return 0;
+}
+
+int rtbuf_portaudio_output (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_fun in[RTBUF_PORTAUDIO_CHANNELS];
+ s_rtbuf_portaudio_output_data *data;
+ short *sample;
+ unsigned int i = 0;
+ unsigned int j = 0;
+ PaError err;
+ assert(rtb);
+ assert(rtb->data);
+ assert(rtb->proc);
+ while (j < RTBUF_PORTAUDIO_CHANNELS) {
+ rtbuf_signal_fun(rtb, j, &in[j]);
+ j++;
+ }
+ data = (s_rtbuf_portaudio_output_data*) rtb->data;
+ sample = data->samples;
+ /* printf("portaudio_output"); */
+ while (i < RTBUF_SIGNAL_SAMPLES) {
+ j = 0;
+ while (j < RTBUF_PORTAUDIO_CHANNELS) {
+ double in_ = in[j].sample_fun(in[j].signal, i);
+ in_ = clamp(-1.0, in_, 1.0);
+ if (in_ < 0.0)
+ in_ *= -SHRT_MIN;
+ else
+ in_ *= SHRT_MAX;
+ *sample = (short) in_;
+ sample++;
+ j++;
+ }
+ i++;
+ }
+ err = Pa_WriteStream(data->reserved.stream, data->samples, RTBUF_SIGNAL_SAMPLES);
+ if (err != paNoError) {
+ rtbuf_err(Pa_GetErrorText(err));
+ rtbuf_err("portaudio output: Pa_WriteStream failed");
+ }
+ /* printf("\n"); */
+ return 0;
+}
diff --git a/lib/portaudio/rtbuf_portaudio_type.c b/lib/portaudio/rtbuf_portaudio_type.c
new file mode 100644
index 0000000..3bef91f
--- /dev/null
+++ b/lib/portaudio/rtbuf_portaudio_type.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include "rtbuf.h"
+#include "rtbuf_portaudio.h"
+
+int main ()
+{
+ printf("/* file generated by rtbuf_portaudio_type */\n");
+ printf("#ifndef RTBUF_PORTAUDIO_TYPE_H\n"
+ "#define RTBUF_PORTAUDIO_TYPE_H\n"
+ "\n");
+ printf("#define RTBUF_PORTAUDIO_SAMPLES_TYPE RTBUF_PORTAUDIO_SAMPLE_TYPE"
+ " \"[%u]\"\n",
+ RTBUF_PORTAUDIO_SAMPLES);
+ printf("#define RTBUF_PORTAUDIO_OUTPUT_RESERVED_TYPE"
+ " \"char[%u]\"\n",
+ (unsigned int) RTBUF_PORTAUDIO_OUTPUT_RESERVED_SIZE);
+ printf("\n"
+ "#endif\n");
+ return 0;
+}
diff --git a/lib/reverb.c b/lib/reverb.c
new file mode 100644
index 0000000..d6d41e6
--- /dev/null
+++ b/lib/reverb.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <math.h>
+#include <stdio.h>
+#include <strings.h>
+#include "rtbuf.h"
+#include "rtbuf_lib.h"
+#include "rtbuf_signal.h"
+#include "rtbuf_signal_type.h"
+#include "rtbuf_reverb.h"
+#include "rtbuf_reverb_type.h"
+
+s_rtbuf_lib_proc_in g_rtbuf_reverb_fdn4_in[] = {
+ { "signal", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
+ { "time", RTBUF_SIGNAL_TYPE, 1.0, 0.0, 100.0 },
+ { "dry_level", RTBUF_SIGNAL_TYPE, 0.8, 0.0, 1.0 },
+ { "wet_level", RTBUF_SIGNAL_TYPE, 0.2, 0.0, 1.0 },
+ { 0, 0, 0.0, 0.0, 0.0 } };
+
+s_rtbuf_lib_proc_out g_rtbuf_reverb_fdn4_out[] = {
+ { "signal", RTBUF_SIGNAL_TYPE },
+ { "d0", RTBUF_REVERB_FDN4_DELAY_TYPE },
+ { "d1", RTBUF_REVERB_FDN4_DELAY_TYPE },
+ { "d2", RTBUF_REVERB_FDN4_DELAY_TYPE },
+ { "d3", RTBUF_REVERB_FDN4_DELAY_TYPE },
+ { "pos", "unsigned int" },
+ { 0, 0 } };
+
+const char *rtbuf_lib_name = "reverb";
+unsigned long rtbuf_lib_ver = RTBUF_LIB_VER;
+s_rtbuf_lib_proc rtbuf_lib_proc[] = {
+ { "fdn4", rtbuf_reverb_fdn4, rtbuf_reverb_fdn4_start, 0,
+ g_rtbuf_reverb_fdn4_in, g_rtbuf_reverb_fdn4_out },
+ { 0, 0, 0, 0, 0, 0 } };
diff --git a/lib/reverb/fdn4.c b/lib/reverb/fdn4.c
new file mode 100644
index 0000000..79b786f
--- /dev/null
+++ b/lib/reverb/fdn4.c
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <math.h>
+#include <stdio.h>
+#include <strings.h>
+#include "hadamard.h"
+#include "rtbuf.h"
+#include "rtbuf_reverb.h"
+
+int rtbuf_reverb_fdn4_start (s_rtbuf *rtb)
+{
+ s_rtbuf_reverb_fdn4_data *data;
+ assert(rtb->proc->out_bytes == sizeof(*data));
+ data = (s_rtbuf_reverb_fdn4_data*) rtb->data;
+ bzero(data, sizeof(*data));
+ return 0;
+}
+
+int rtbuf_reverb_fdn4 (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_fun signal;
+ s_rtbuf_signal_fun time;
+ s_rtbuf_signal_fun dry_level;
+ s_rtbuf_signal_fun wet_level;
+ s_rtbuf_reverb_fdn4_data *data;
+ unsigned int i = 0;
+ rtbuf_signal_fun(rtb, RTBUF_REVERB_FDN4_IN_SIGNAL, &signal);
+ rtbuf_signal_fun(rtb, RTBUF_REVERB_FDN4_IN_TIME, &time);
+ rtbuf_signal_fun(rtb, RTBUF_REVERB_FDN4_IN_DRY_LEVEL, &dry_level);
+ rtbuf_signal_fun(rtb, RTBUF_REVERB_FDN4_IN_WET_LEVEL, &wet_level);
+ data = (s_rtbuf_reverb_fdn4_data*) rtb->data;
+ while (i < RTBUF_SIGNAL_SAMPLES) {
+ const double x = signal.sample_fun(signal.signal, i);
+ const double t = max(0.0, time.sample_fun(time.signal, i));
+ const double dl = dry_level.sample_fun(dry_level.signal, i);
+ const double wl = wet_level.sample_fun(wet_level.signal, i);
+ const double r = 0.0 * t;
+ data->signal[i] = dl * x + wl * r;
+ i++;
+ }
+ return 0;
+}
diff --git a/lib/reverb/hadamard.h b/lib/reverb/hadamard.h
new file mode 100644
index 0000000..62c4209
--- /dev/null
+++ b/lib/reverb/hadamard.h
@@ -0,0 +1,99 @@
+#ifndef HADAMARD_H
+#define HADAMARD_H
+
+#define HADAMARD_1 1
+
+#define HADAMARD_2_0_0 HADAMARD_1
+#define HADAMARD_2_0_1 HADAMARD_1
+#define HADAMARD_2_1_0 HADAMARD_1
+#define HADAMARD_2_1_1 -HADAMARD_1
+
+#define HADAMARD_4_0_0 HADAMARD_2_0_0
+#define HADAMARD_4_0_1 HADAMARD_2_0_1
+#define HADAMARD_4_1_0 HADAMARD_2_1_0
+#define HADAMARD_4_1_1 HADAMARD_2_1_1
+
+#define HADAMARD_4_0_2 HADAMARD_2_0_0
+#define HADAMARD_4_0_3 HADAMARD_2_0_1
+#define HADAMARD_4_1_2 HADAMARD_2_1_0
+#define HADAMARD_4_1_3 HADAMARD_2_1_1
+
+#define HADAMARD_4_2_0 HADAMARD_2_0_0
+#define HADAMARD_4_2_1 HADAMARD_2_0_1
+#define HADAMARD_4_3_0 HADAMARD_2_1_0
+#define HADAMARD_4_3_1 HADAMARD_2_1_1
+
+#define HADAMARD_4_2_2 -HADAMARD_2_0_0
+#define HADAMARD_4_2_3 -HADAMARD_2_0_1
+#define HADAMARD_4_3_2 -HADAMARD_2_1_0
+#define HADAMARD_4_3_3 -HADAMARD_2_1_1
+
+#define HADAMARD_8_0_0 HADAMARD_4_0_0
+#define HADAMARD_8_0_1 HADAMARD_4_0_1
+#define HADAMARD_8_0_2 HADAMARD_4_0_2
+#define HADAMARD_8_0_3 HADAMARD_4_0_3
+#define HADAMARD_8_1_0 HADAMARD_4_1_0
+#define HADAMARD_8_1_1 HADAMARD_4_1_1
+#define HADAMARD_8_1_2 HADAMARD_4_1_2
+#define HADAMARD_8_1_3 HADAMARD_4_1_3
+#define HADAMARD_8_2_0 HADAMARD_4_2_0
+#define HADAMARD_8_2_1 HADAMARD_4_2_1
+#define HADAMARD_8_2_2 HADAMARD_4_2_2
+#define HADAMARD_8_2_3 HADAMARD_4_2_3
+#define HADAMARD_8_3_0 HADAMARD_4_3_0
+#define HADAMARD_8_3_1 HADAMARD_4_3_1
+#define HADAMARD_8_3_2 HADAMARD_4_3_2
+#define HADAMARD_8_3_3 HADAMARD_4_3_3
+
+#define HADAMARD_8_0_4 HADAMARD_4_0_0
+#define HADAMARD_8_0_5 HADAMARD_4_0_1
+#define HADAMARD_8_0_6 HADAMARD_4_0_2
+#define HADAMARD_8_0_7 HADAMARD_4_0_3
+#define HADAMARD_8_1_4 HADAMARD_4_1_0
+#define HADAMARD_8_1_5 HADAMARD_4_1_1
+#define HADAMARD_8_1_6 HADAMARD_4_1_2
+#define HADAMARD_8_1_7 HADAMARD_4_1_3
+#define HADAMARD_8_2_4 HADAMARD_4_2_0
+#define HADAMARD_8_2_5 HADAMARD_4_2_1
+#define HADAMARD_8_2_6 HADAMARD_4_2_2
+#define HADAMARD_8_2_7 HADAMARD_4_2_3
+#define HADAMARD_8_3_4 HADAMARD_4_3_0
+#define HADAMARD_8_3_5 HADAMARD_4_3_1
+#define HADAMARD_8_3_6 HADAMARD_4_3_2
+#define HADAMARD_8_3_7 HADAMARD_4_3_3
+
+#define HADAMARD_8_4_0 HADAMARD_4_0_0
+#define HADAMARD_8_4_1 HADAMARD_4_0_1
+#define HADAMARD_8_4_2 HADAMARD_4_0_2
+#define HADAMARD_8_4_3 HADAMARD_4_0_3
+#define HADAMARD_8_5_0 HADAMARD_4_1_0
+#define HADAMARD_8_5_1 HADAMARD_4_1_1
+#define HADAMARD_8_5_2 HADAMARD_4_1_2
+#define HADAMARD_8_5_3 HADAMARD_4_1_3
+#define HADAMARD_8_6_0 HADAMARD_4_2_0
+#define HADAMARD_8_6_1 HADAMARD_4_2_1
+#define HADAMARD_8_6_2 HADAMARD_4_2_2
+#define HADAMARD_8_6_3 HADAMARD_4_2_3
+#define HADAMARD_8_7_0 HADAMARD_4_3_0
+#define HADAMARD_8_7_1 HADAMARD_4_3_1
+#define HADAMARD_8_7_2 HADAMARD_4_3_2
+#define HADAMARD_8_7_3 HADAMARD_4_3_3
+
+#define HADAMARD_8_4_4 -HADAMARD_4_0_0
+#define HADAMARD_8_4_5 -HADAMARD_4_0_1
+#define HADAMARD_8_4_6 -HADAMARD_4_0_2
+#define HADAMARD_8_4_7 -HADAMARD_4_0_3
+#define HADAMARD_8_5_4 -HADAMARD_4_1_0
+#define HADAMARD_8_5_5 -HADAMARD_4_1_1
+#define HADAMARD_8_5_6 -HADAMARD_4_1_2
+#define HADAMARD_8_5_7 -HADAMARD_4_1_3
+#define HADAMARD_8_6_4 -HADAMARD_4_2_0
+#define HADAMARD_8_6_5 -HADAMARD_4_2_1
+#define HADAMARD_8_6_6 -HADAMARD_4_2_2
+#define HADAMARD_8_6_7 -HADAMARD_4_2_3
+#define HADAMARD_8_7_4 -HADAMARD_4_3_0
+#define HADAMARD_8_7_5 -HADAMARD_4_3_1
+#define HADAMARD_8_7_6 -HADAMARD_4_3_2
+#define HADAMARD_8_7_7 -HADAMARD_4_3_3
+
+#endif
diff --git a/lib/reverb_type.c b/lib/reverb_type.c
new file mode 100644
index 0000000..56c7122
--- /dev/null
+++ b/lib/reverb_type.c
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include "rtbuf.h"
+#include "rtbuf_reverb.h"
+
+int main ()
+{
+ printf("/* file generated by rtbuf_reverb_type */\n");
+ printf("#ifndef RTBUF_REVERB_TYPE_H\n"
+ "#define RTBUF_REVERB_TYPE_H\n"
+ "\n");
+ printf("#define RTBUF_REVERB_FDN4_DELAY_TYPE"
+ " RTBUF_SIGNAL_SAMPLE_TYPE \"[%u]\"\n",
+ RTBUF_REVERB_FDN4_DELAY_SAMPLES_MAX);
+ printf("\n"
+ "#endif\n");
+ return 0;
+}
diff --git a/lib/signal.c b/lib/signal.c
new file mode 100644
index 0000000..96fd843
--- /dev/null
+++ b/lib/signal.c
@@ -0,0 +1,450 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <math.h>
+#include <stdio.h>
+#include <strings.h>
+#include <rtbuf/rtbuf.h>
+#include <rtbuf/lib.h>
+#include <rtbuf/signal.h>
+#include <rtbuf/signal_type.h>
+
+const double g_rtbuf_signal_sample_zero = 0.0;
+const double g_rtbuf_signal_sample_half = 0.5;
+const double g_rtbuf_signal_sample_one = 1.0;
+const double g_rtbuf_signal_default_frequency = 220.0;
+
+s_rtbuf_lib_proc_in g_rtbuf_signal_bandpass2_in[] = {
+ { "signal", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
+ { "cutoff", RTBUF_SIGNAL_TYPE, 400.0, 0.0, RTBUF_SIGNAL_SAMPLERATE / 2.0 },
+ { "qfactor", RTBUF_SIGNAL_TYPE, 1.0, 0.0, 1000.0 },
+ { 0, 0, 0.0, 0.0, 0.0 } };
+
+s_rtbuf_lib_proc_out g_rtbuf_signal_bandpass2_out[] = {
+ { "signal", RTBUF_SIGNAL_TYPE },
+ { "x1", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "x2", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "x3", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "x4", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y1", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y2", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y3", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y4", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { 0, 0 } };
+
+s_rtbuf_lib_proc_in g_rtbuf_signal_delay_in[] = {
+ { "signal", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
+ { "delay", RTBUF_SIGNAL_TYPE, 0.4, 0.0, RTBUF_SIGNAL_DELAY_MAX },
+ { "feedback", RTBUF_SIGNAL_TYPE, 0.5, 0.0, 1.0 },
+ { 0, 0, 0.0, 0.0, 0.0 } };
+
+s_rtbuf_lib_proc_out g_rtbuf_signal_delay_out[] = {
+ { "signal", RTBUF_SIGNAL_TYPE },
+ { "in", RTBUF_SIGNAL_DELAY_TYPE },
+ { "pos", "unsigned int" },
+ { 0, 0 } };
+
+s_rtbuf_lib_proc_in g_rtbuf_signal_equalizer10_in[] = {
+ { "signal", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
+ { "amp32", RTBUF_SIGNAL_TYPE, 1.0, 0.0, 2.0 },
+ { "amp64", RTBUF_SIGNAL_TYPE, 1.0, 0.0, 2.0 },
+ { "amp128", RTBUF_SIGNAL_TYPE, 1.0, 0.0, 2.0 },
+ { "amp256", RTBUF_SIGNAL_TYPE, 1.0, 0.0, 2.0 },
+ { "amp512", RTBUF_SIGNAL_TYPE, 1.0, 0.0, 2.0 },
+ { "amp1k", RTBUF_SIGNAL_TYPE, 1.0, 0.0, 2.0 },
+ { "amp2k", RTBUF_SIGNAL_TYPE, 1.0, 0.0, 2.0 },
+ { "amp4k", RTBUF_SIGNAL_TYPE, 1.0, 0.0, 2.0 },
+ { "amp8k", RTBUF_SIGNAL_TYPE, 1.0, 0.0, 2.0 },
+ { "amp16k", RTBUF_SIGNAL_TYPE, 1.0, 0.0, 2.0 },
+ { 0, 0, 0.0, 0.0, 0.0 } };
+
+s_rtbuf_lib_proc_out g_rtbuf_signal_equalizer10_out[] = {
+ { "signal", RTBUF_SIGNAL_TYPE },
+ { "signal32", RTBUF_SIGNAL_TYPE },
+ { "signal64", RTBUF_SIGNAL_TYPE },
+ { "signal128", RTBUF_SIGNAL_TYPE },
+ { "signal256", RTBUF_SIGNAL_TYPE },
+ { "signal512", RTBUF_SIGNAL_TYPE },
+ { "signal1k", RTBUF_SIGNAL_TYPE },
+ { "signal2k", RTBUF_SIGNAL_TYPE },
+ { "signal4k", RTBUF_SIGNAL_TYPE },
+ { "signal8k", RTBUF_SIGNAL_TYPE },
+ { "signal16k", RTBUF_SIGNAL_TYPE },
+ { "x1", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "x2", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "x3", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "x4", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y0_1", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y0_2", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y0_3", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y0_4", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y1_1", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y1_2", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y1_3", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y1_4", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y2_1", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y2_2", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y2_3", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y2_4", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y3_1", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y3_2", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y3_3", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y3_4", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y4_1", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y4_2", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y4_3", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y4_4", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y5_1", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y5_2", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y5_3", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y5_4", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y6_1", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y6_2", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y6_3", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y6_4", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y7_1", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y7_2", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y7_3", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y7_4", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y8_1", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y8_2", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y8_3", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y8_4", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y9_1", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y9_2", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y9_3", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y9_4", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { 0, 0 } };
+
+s_rtbuf_lib_proc_in g_rtbuf_signal_flanger_in[] = {
+ { "signal", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
+ { "frequency", RTBUF_SIGNAL_TYPE, 0.5, 0.0, RTBUF_SIGNAL_SAMPLERATE / 2.0 },
+ { "amplitude", RTBUF_SIGNAL_TYPE, 0.02, 0.0, 1.0 },
+ { "delay", RTBUF_SIGNAL_TYPE, 0.0001, 0.0, 1.0 },
+ { "feedback", RTBUF_SIGNAL_TYPE, 0.01, 0.0, 1.0 },
+ { 0, 0, 0.0, 0.0, 0.0 } };
+
+s_rtbuf_lib_proc_out g_rtbuf_signal_flanger_out[] = {
+ { "signal", RTBUF_SIGNAL_TYPE },
+ { "phase", "double" },
+ { "in", RTBUF_SIGNAL_FLANGER_TYPE },
+ { "pos", "unsigned int" },
+ { "ds", "unsigned int" },
+ { 0, 0 } };
+
+s_rtbuf_lib_proc_in g_rtbuf_signal_hipass_in[] = {
+ { "signal", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
+ { "cutoff", RTBUF_SIGNAL_TYPE, 8000.0, 0.0, RTBUF_SIGNAL_SAMPLERATE / 2.0 },
+ { 0, 0, 0.0, 0.0, 0.0 } };
+
+s_rtbuf_lib_proc_out g_rtbuf_signal_hipass_out[] = {
+ { "signal", RTBUF_SIGNAL_TYPE },
+ { "x", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { 0, 0 } };
+
+s_rtbuf_lib_proc_in g_rtbuf_signal_hipass2_in[] = {
+ { "signal", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
+ { "cutoff", RTBUF_SIGNAL_TYPE, 8000.0, 0.0, RTBUF_SIGNAL_SAMPLERATE / 2.0 },
+ { 0, 0, 0.0, 0.0, 0.0 } };
+
+s_rtbuf_lib_proc_out g_rtbuf_signal_hipass2_out[] = {
+ { "signal", RTBUF_SIGNAL_TYPE },
+ { "x1", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "x2", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y1", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y2", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { 0, 0 } };
+
+s_rtbuf_lib_proc_in g_rtbuf_signal_hipass3_in[] = {
+ { "signal", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
+ { "cutoff", RTBUF_SIGNAL_TYPE, 8000.0, 0.0, RTBUF_SIGNAL_SAMPLERATE / 2.0 },
+ { 0, 0, 0.0, 0.0, 0.0 } };
+
+s_rtbuf_lib_proc_out g_rtbuf_signal_hipass3_out[] = {
+ { "signal", RTBUF_SIGNAL_TYPE },
+ { "x1", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "x2", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "x3", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y1", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y2", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y3", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { 0, 0 } };
+
+s_rtbuf_lib_proc_in g_rtbuf_signal_hipass4_in[] = {
+ { "signal", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
+ { "cutoff", RTBUF_SIGNAL_TYPE, 8000.0, 0.0, RTBUF_SIGNAL_SAMPLERATE / 2.0 },
+ { 0, 0, 0.0, 0.0, 0.0 } };
+
+s_rtbuf_lib_proc_out g_rtbuf_signal_hipass4_out[] = {
+ { "signal", RTBUF_SIGNAL_TYPE },
+ { "x1", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "x2", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "x3", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "x4", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y1", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y2", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y3", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y4", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { 0, 0 } };
+
+s_rtbuf_lib_proc_in g_rtbuf_signal_hipass5_in[] = {
+ { "signal", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
+ { "cutoff", RTBUF_SIGNAL_TYPE, 400.0, 0.0, RTBUF_SIGNAL_SAMPLERATE / 2.0 },
+ { 0, 0, 0.0, 0.0, 0.0 } };
+
+s_rtbuf_lib_proc_out g_rtbuf_signal_hipass5_out[] = {
+ { "signal", RTBUF_SIGNAL_TYPE },
+ { "x1", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "x2", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "x3", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "x4", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "x5", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y1", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y2", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y3", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y4", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y5", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { 0, 0 } };
+
+s_rtbuf_lib_proc_in g_rtbuf_signal_lowpass_in[] = {
+ { "signal", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
+ { "cutoff", RTBUF_SIGNAL_TYPE, 400.0, 0.0, RTBUF_SIGNAL_SAMPLERATE / 2.0 },
+ { 0, 0, 0.0, 0.0, 0.0 } };
+
+s_rtbuf_lib_proc_out g_rtbuf_signal_lowpass_out[] = {
+ { "signal", RTBUF_SIGNAL_TYPE },
+ { "x", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { 0, 0 } };
+
+s_rtbuf_lib_proc_in g_rtbuf_signal_lowpass2_in[] = {
+ { "signal", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
+ { "cutoff", RTBUF_SIGNAL_TYPE, 400.0, 0.0, RTBUF_SIGNAL_SAMPLERATE / 2.0 },
+ { 0, 0, 0.0, 0.0, 0.0 } };
+
+s_rtbuf_lib_proc_out g_rtbuf_signal_lowpass2_out[] = {
+ { "signal", RTBUF_SIGNAL_TYPE },
+ { "x1", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "x2", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y1", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y2", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { 0, 0 } };
+
+s_rtbuf_lib_proc_in g_rtbuf_signal_lowpass3_in[] = {
+ { "signal", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
+ { "cutoff", RTBUF_SIGNAL_TYPE, 400.0, 0.0, RTBUF_SIGNAL_SAMPLERATE / 2.0 },
+ { 0, 0, 0.0, 0.0, 0.0 } };
+
+s_rtbuf_lib_proc_out g_rtbuf_signal_lowpass3_out[] = {
+ { "signal", RTBUF_SIGNAL_TYPE },
+ { "x1", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "x2", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "x3", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y1", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y2", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y3", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { 0, 0 } };
+
+s_rtbuf_lib_proc_in g_rtbuf_signal_lowpass4_in[] = {
+ { "signal", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
+ { "cutoff", RTBUF_SIGNAL_TYPE, 400.0, 0.0, RTBUF_SIGNAL_SAMPLERATE / 2.0 },
+ { 0, 0, 0.0, 0.0, 0.0 } };
+
+s_rtbuf_lib_proc_out g_rtbuf_signal_lowpass4_out[] = {
+ { "signal", RTBUF_SIGNAL_TYPE },
+ { "x1", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "x2", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "x3", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "x4", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y1", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y2", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y3", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y4", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { 0, 0 } };
+
+s_rtbuf_lib_proc_in g_rtbuf_signal_lowpass5_in[] = {
+ { "signal", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
+ { "cutoff", RTBUF_SIGNAL_TYPE, 400.0, 0.0, RTBUF_SIGNAL_SAMPLERATE / 2.0 },
+ { 0, 0, 0.0, 0.0, 0.0 } };
+
+s_rtbuf_lib_proc_out g_rtbuf_signal_lowpass5_out[] = {
+ { "signal", RTBUF_SIGNAL_TYPE },
+ { "x1", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "x2", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "x3", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "x4", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "x5", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y1", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y2", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y3", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y4", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { "y5", RTBUF_SIGNAL_SAMPLE_TYPE },
+ { 0, 0 } };
+
+s_rtbuf_lib_proc_in g_rtbuf_signal_sawtooth_in[] = {
+ { "frequency", RTBUF_SIGNAL_TYPE, 220.0, 0.0, RTBUF_SIGNAL_SAMPLERATE / 2.0 },
+ { "amplitude", RTBUF_SIGNAL_TYPE, 1.0, 0.0, 1.0 },
+ { 0, 0, 0.0, 0.0, 0.0 } };
+
+s_rtbuf_lib_proc_out g_rtbuf_signal_sawtooth_out[] = {
+ { "signal", RTBUF_SIGNAL_TYPE },
+ { "phase", "double" },
+ { 0, 0 } };
+
+s_rtbuf_lib_proc_in g_rtbuf_signal_sinus_in[] = {
+ { "frequency", RTBUF_SIGNAL_TYPE, 220.0, 0.0, RTBUF_SIGNAL_SAMPLERATE / 2.0 },
+ { "amplitude", RTBUF_SIGNAL_TYPE, 1.0, 0.0, 1.0 },
+ { 0, 0, 0.0, 0.0, 0.0 } };
+
+s_rtbuf_lib_proc_out g_rtbuf_signal_sinus_out[] = {
+ { "signal", RTBUF_SIGNAL_TYPE },
+ { "phase", "double" },
+ { 0, 0 } };
+
+s_rtbuf_lib_proc_in g_rtbuf_signal_square_in[] = {
+ { "frequency", RTBUF_SIGNAL_TYPE, 220.0, 0.0, RTBUF_SIGNAL_SAMPLERATE / 2.0 },
+ { "amplitude", RTBUF_SIGNAL_TYPE, 1.0, 0.0, 1.0 },
+ { "pulse", RTBUF_SIGNAL_TYPE, 0.5, 0.0, 1.0 },
+ { 0, 0, 0.0, 0.0, 0.0 } };
+
+s_rtbuf_lib_proc_out g_rtbuf_signal_square_out[] = {
+ { "signal", RTBUF_SIGNAL_TYPE },
+ { "phase", "double" },
+ { 0, 0 } };
+
+const char *rtbuf_lib_name = "signal";
+unsigned long rtbuf_lib_ver = RTBUF_LIB_VER;
+s_rtbuf_lib_proc rtbuf_lib_proc[] = {
+ { "bandpass2", rtbuf_signal_bandpass2, rtbuf_signal_bandpass2_start, 0,
+ g_rtbuf_signal_bandpass2_in, g_rtbuf_signal_bandpass2_out },
+ { "delay", rtbuf_signal_delay, rtbuf_signal_delay_start, 0,
+ g_rtbuf_signal_delay_in, g_rtbuf_signal_delay_out },
+ { "equalizer10", rtbuf_signal_equalizer10, rtbuf_signal_equalizer10_start, 0,
+ g_rtbuf_signal_equalizer10_in, g_rtbuf_signal_equalizer10_out },
+ { "flanger", rtbuf_signal_flanger, rtbuf_signal_flanger_start, 0,
+ g_rtbuf_signal_flanger_in, g_rtbuf_signal_flanger_out },
+ { "hipass", rtbuf_signal_hipass, rtbuf_signal_hipass_start, 0,
+ g_rtbuf_signal_hipass_in, g_rtbuf_signal_hipass_out },
+ { "hipass2", rtbuf_signal_hipass2, rtbuf_signal_hipass2_start, 0,
+ g_rtbuf_signal_hipass2_in, g_rtbuf_signal_hipass2_out },
+ { "hipass3", rtbuf_signal_hipass3, rtbuf_signal_hipass3_start, 0,
+ g_rtbuf_signal_hipass3_in, g_rtbuf_signal_hipass3_out },
+ { "hipass4", rtbuf_signal_hipass4, rtbuf_signal_hipass4_start, 0,
+ g_rtbuf_signal_hipass4_in, g_rtbuf_signal_hipass4_out },
+ { "hipass5", rtbuf_signal_hipass5, rtbuf_signal_hipass5_start, 0,
+ g_rtbuf_signal_hipass5_in, g_rtbuf_signal_hipass5_out },
+ { "lowpass", rtbuf_signal_lowpass, rtbuf_signal_lowpass_start, 0,
+ g_rtbuf_signal_lowpass_in, g_rtbuf_signal_lowpass_out },
+ { "lowpass2", rtbuf_signal_lowpass2, rtbuf_signal_lowpass2_start, 0,
+ g_rtbuf_signal_lowpass2_in, g_rtbuf_signal_lowpass2_out },
+ { "lowpass3", rtbuf_signal_lowpass3, rtbuf_signal_lowpass3_start, 0,
+ g_rtbuf_signal_lowpass3_in, g_rtbuf_signal_lowpass3_out },
+ { "lowpass4", rtbuf_signal_lowpass4, rtbuf_signal_lowpass4_start, 0,
+ g_rtbuf_signal_lowpass4_in, g_rtbuf_signal_lowpass4_out },
+ { "lowpass5", rtbuf_signal_lowpass5, rtbuf_signal_lowpass5_start, 0,
+ g_rtbuf_signal_lowpass5_in, g_rtbuf_signal_lowpass5_out },
+ { "sawtooth", rtbuf_signal_sawtooth, rtbuf_signal_sawtooth_start, 0,
+ g_rtbuf_signal_sawtooth_in, g_rtbuf_signal_sawtooth_out },
+ { "sinus", rtbuf_signal_sinus, rtbuf_signal_sinus_start, 0,
+ g_rtbuf_signal_sinus_in, g_rtbuf_signal_sinus_out },
+ { "square", rtbuf_signal_square, rtbuf_signal_square_start, 0,
+ g_rtbuf_signal_square_in, g_rtbuf_signal_square_out },
+ { 0, 0, 0, 0, 0, 0 } };
+
+void rtbuf_signal_zero (t_rtbuf_signal_sample *signal)
+{
+ assert(signal);
+ bzero(signal, sizeof(t_rtbuf_signal));
+}
+
+t_rtbuf_signal_sample
+rtbuf_signal_sample (s_rtbuf *rtb,
+ unsigned int in,
+ t_rtbuf_signal_sample default_value)
+{
+ s_rtbuf_binding *v;
+ assert(rtb);
+ assert(rtb->proc);
+ assert(in < rtb->proc->in_n);
+ v = &rtb->in[in];
+ if (v->rtb >= 0) {
+ s_rtbuf *src;
+ s_rtbuf_proc_out *out;
+ assert(v->rtb < RTBUF_MAX);
+ src = &g_rtbuf[v->rtb];
+ assert(src->data);
+ assert(src->proc);
+ assert(v->out < src->proc->out_n);
+ out = &src->proc->out[v->out];
+ assert(out->type);
+ if (out->type->t.bits >= sizeof(t_rtbuf_signal_sample) * 8) {
+ t_rtbuf_signal_sample *sample = (t_rtbuf_signal_sample*)
+ ((char*) src->data + out->offset);
+ return *sample;
+ }
+ }
+ return default_value;
+}
+
+double rtbuf_signal_sample_from_sample (const double *signal,
+ unsigned int i)
+{
+ (void) i;
+ assert(signal);
+ return *signal;
+}
+
+double rtbuf_signal_sample_from_signal (const double *signal,
+ unsigned int i)
+{
+ assert(signal);
+ assert(i < RTBUF_SIGNAL_SAMPLES);
+ return signal[i];
+}
+
+void rtbuf_signal_fun (s_rtbuf *rtb,
+ unsigned int in,
+ s_rtbuf_signal_fun *rsf)
+{
+ s_rtbuf_binding *v;
+ const double *default_value;
+ assert(rtb);
+ assert(rtb->proc);
+ assert(in < rtb->proc->in_n);
+ assert(rsf);
+ default_value = &rtb->proc->in[in].def;
+ rsf->signal = default_value;
+ rsf->sample_fun = rtbuf_signal_sample_from_sample;
+ v = &rtb->in[in];
+ if (v->rtb >= 0) {
+ s_rtbuf *dest;
+ s_rtbuf_proc_out *out;
+ assert(v->rtb < RTBUF_MAX);
+ dest = &g_rtbuf[v->rtb];
+ assert(dest->data);
+ assert(dest->proc);
+ assert(v->out < dest->proc->out_n);
+ out = &dest->proc->out[v->out];
+ assert(out->type);
+ if (out->type->t.bits >= sizeof(t_rtbuf_signal_sample) * 8)
+ rsf->signal = (double*)((char*) dest->data + out->offset);
+ if (out->type->t.bits >= sizeof(t_rtbuf_signal) * 8)
+ rsf->sample_fun = rtbuf_signal_sample_from_signal;
+ }
+}
+
+const double sqrt2_2 = M_SQRT2 * M_SQRT2;
diff --git a/lib/signal/Makefile.am b/lib/signal/Makefile.am
new file mode 100644
index 0000000..e7e950a
--- /dev/null
+++ b/lib/signal/Makefile.am
@@ -0,0 +1,73 @@
+CLEANFILES =
+rtbuf_includedir = $(includedir)/rtbuf/signal
+rtbuf_include_HEADERS =
+rtbuf_libdir = $(libdir)/rtbuf/signal
+rtbuf_lib_LTLIBRARIES =
+
+rtbuf_lib_LTLIBRARIES += bandpass2.la
+bandpass2_la_LDFLAGS = -no-undefined -module
+bandpass2_la_LIBADD = ${SIGNAL_LIBS}
+
+rtbuf_lib_LTLIBRARIES += delay.la
+delay_la_LDFLAGS = -no-undefined -module
+delay_la_LIBADD = ${SIGNAL_LIBS}
+
+rtbuf_lib_LTLIBRARIES += equalizer10.la
+equalizer10_la_LDFLAGS = -no-undefined -module
+equalizer10_la_LIBADD = ${SIGNAL_LIBS}
+
+rtbuf_lib_LTLIBRARIES += flanger.la
+flanger_la_LDFLAGS = -no-undefined -module
+flanger_la_LIBADD = ${SIGNAL_LIBS}
+
+rtbuf_lib_LTLIBRARIES += hipass.la
+hipass_la_LDFLAGS = -no-undefined -module
+hipass_la_LIBADD = ${SIGNAL_LIBS}
+
+rtbuf_lib_LTLIBRARIES += hipass2.la
+hipass2_la_LDFLAGS = -no-undefined -module
+hipass2_la_LIBADD = ${SIGNAL_LIBS}
+
+rtbuf_lib_LTLIBRARIES += hipass3.la
+hipass3_la_LDFLAGS = -no-undefined -module
+hipass3_la_LIBADD = ${SIGNAL_LIBS}
+
+rtbuf_lib_LTLIBRARIES += hipass4.la
+hipass4_la_LDFLAGS = -no-undefined -module
+hipass4_la_LIBADD = ${SIGNAL_LIBS}
+
+rtbuf_lib_LTLIBRARIES += hipass5.la
+hipass5_la_LDFLAGS = -no-undefined -module
+hipass5_la_LIBADD = ${SIGNAL_LIBS}
+
+rtbuf_lib_LTLIBRARIES += lowpass.la
+lowpass_la_LDFLAGS = -no-undefined -module
+lowpass_la_LIBADD = ${SIGNAL_LIBS}
+
+rtbuf_lib_LTLIBRARIES += lowpass2.la
+lowpass2_la_LDFLAGS = -no-undefined -module
+lowpass2_la_LIBADD = ${SIGNAL_LIBS}
+
+rtbuf_lib_LTLIBRARIES += lowpass3.la
+lowpass3_la_LDFLAGS = -no-undefined -module
+lowpass3_la_LIBADD = ${SIGNAL_LIBS}
+
+rtbuf_lib_LTLIBRARIES += lowpass4.la
+lowpass4_la_LDFLAGS = -no-undefined -module
+lowpass4_la_LIBADD = ${SIGNAL_LIBS}
+
+rtbuf_lib_LTLIBRARIES += lowpass5.la
+lowpass5_la_LDFLAGS = -no-undefined -module
+lowpass5_la_LIBADD = ${SIGNAL_LIBS}
+
+rtbuf_lib_LTLIBRARIES += sawtooth.la
+sawtooth_la_LDFLAGS = -no-undefined -module
+sawtooth_la_LIBADD = ${SIGNAL_LIBS}
+
+rtbuf_lib_LTLIBRARIES += sinus.la
+sinus_la_LDFLAGS = -no-undefined -module
+sinus_la_LIBADD = ${SIGNAL_LIBS}
+
+rtbuf_lib_LTLIBRARIES += square.la
+square_la_LDFLAGS = -no-undefined -module
+square_la_LIBADD = ${SIGNAL_LIBS}
diff --git a/lib/signal/bandpass2.c b/lib/signal/bandpass2.c
new file mode 100644
index 0000000..53ead13
--- /dev/null
+++ b/lib/signal/bandpass2.c
@@ -0,0 +1,132 @@
+/*
+ * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+/* Butterworth bandpass second order filter
+s: 2*f*(1-z)/(1+z) $
+B2: (q*(s/w+w/s))^2+sqrt(2)*(q*(s/w+w/s))+1 $
+H: 1/B2 $
+ratsimp(H);
+ 2 2 4 2 2 2 2 2
+(%o25) (4 f w z - 8 f w z + 4 f w )
+ 2 4 3/2 3 2 2 2 2 7/2 3 4 2 4
+/((q w - 2 f q w + (8 f q + 4 f ) w - 2 f q w + 16 f q ) z
+ 2 4 5/2 3 9/2 3 4 2 3
+ + (4 q w - 2 f q w + 2 f q w - 64 f q ) z
+ 2 4 2 2 2 2 4 2 2
+ + (6 q w + ((- 16 f q ) - 8 f ) w + 96 f q ) z
+ 2 4 5/2 3 9/2 3 4 2 2 4 3/2 3
+ + (4 q w + 2 f q w - 2 f q w - 64 f q ) z + q w + 2 f q w
+ 2 2 2 2 7/2 3 4 2
+ + (8 f q + 4 f ) w + 2 f q w + 16 f q )
+
+a: q2 w4 + sqrt(2)^3 f q w3 + (8 f2 q2 + 4 f2) w2 + sqrt(2)^7 f3 q w + 16 f4 q2;
+b: 4 q2 w4 + sqrt(2)^5 f q w3 - sqrt(2)^9 f3 q w - 64 f4 q2;
+c: 6 q2 w4 - 2 (8 f2 q2 + 4 f2) w2 + 96 f4 q2;
+d: 4 q2 w4 - sqrt(2)^5 f q w3 + sqrt(2)^9 f3 q w - 64 f4 q2;
+e: q2 w4 - sqrt(2)^3 f q w3 + (8 f2 q2 + 4 f2) w2 - sqrt(2)^7 f3 q w + 16 f4 q2;
+-----------------------------------------------------------------------------------
+a: q2 w4 + sqrt(2)^3 f q w3 + (2 q2 + 1) 4 f2 w2 + sqrt(2)^7 f3 q w + 16 f4 q2;
+b: 4 q2 w4 + sqrt(2)^5 f q w3 - sqrt(2)^9 f3 q w - 64 f4 q2;
+c: 6 q2 w4 - 2 (2 q2 + 1) 4 f2 w2 + 96 f4 q2;
+d: 4 q2 w4 - sqrt(2)^5 f q w3 + sqrt(2)^9 f3 q w - 64 f4 q2;
+e: q2 w4 - sqrt(2)^3 f q w3 + (2 q2 + 1) 4 f2 w2 - sqrt(2)^7 f3 q w + 16 f4 q2;
+-----------------------------------------------------------------------------------
+y: (4 f2 w2 (x4 - 2 x2 + x) - (b y1 + c y2 + d y3 + e y4)) / a;
+*/
+#include <math.h>
+#include <rtbuf/rtbuf.h>
+#include <rtbuf/signal.h>
+
+int rtbuf_signal_bandpass2_start (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_bandpass2_data *data;
+ assert(rtb->proc->out_bytes == sizeof(*data));
+ data = (s_rtbuf_signal_bandpass2_data*) rtb->data;
+ data->x1 = 0.0;
+ data->x2 = 0.0;
+ data->x3 = 0.0;
+ data->x4 = 0.0;
+ data->y1 = 0.0;
+ data->y2 = 0.0;
+ data->y3 = 0.0;
+ data->y4 = 0.0;
+ return 0;
+}
+
+int rtbuf_signal_bandpass2 (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_fun in;
+ s_rtbuf_signal_fun cutoff;
+ s_rtbuf_signal_fun qfactor;
+ s_rtbuf_signal_bandpass2_data *data;
+ unsigned int i = 0;
+ const double sqrt2_3 = sqrt2_2 * M_SQRT2;
+ const double sqrt2_5 = sqrt2_3 * sqrt2_2;
+ const double sqrt2_7 = sqrt2_5 * sqrt2_2;
+ const double sqrt2_9 = sqrt2_7 * sqrt2_2;
+ const double f = RTBUF_SIGNAL_SAMPLERATE;
+ const double f2 = f * f;
+ const double f3 = f2 * f;
+ const double f4 = f2 * f2;
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_BANDPASS_IN_SIGNAL, &in);
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_BANDPASS_IN_CUTOFF, &cutoff);
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_BANDPASS_IN_QFACTOR, &qfactor);
+ data = (s_rtbuf_signal_bandpass2_data*) rtb->data;
+ while (i < RTBUF_SIGNAL_SAMPLES) {
+ const double x = in.sample_fun(in.signal, i);
+ const double fc = cutoff.sample_fun(cutoff.signal, i);
+ const double q = qfactor.sample_fun(qfactor.signal, i);
+ const double q2 = q * q;
+ const double f4q2 = f4 * q2;
+ const double _16f4q2 = 16.0 * f4q2;
+ const double _64f4q2 = 64.0 * f4q2;
+ const double w = 2.0 * M_PI * fc;
+ const double f3qw = f3 * q * w;
+ const double sqrt2_7f3qw = sqrt2_7 * f3qw;
+ const double sqrt2_9f3qw = sqrt2_9 * f3qw;
+ const double w2 = w * w;
+ const double _4f2w2 = 4.0 * f2 * w2;
+ const double _2q2_1_4f2w2 = (2.0 * q2 + 1.0) * _4f2w2;
+ const double w3 = w2 * w;
+ const double fqw3 = f * q * w3;
+ const double sqrt2_3fqw3 = sqrt2_3 * fqw3;
+ const double sqrt2_5fqw3 = sqrt2_5 * fqw3;
+ const double w4 = w2 * w2;
+ const double q2w4 = q2 * w4;
+ const double _4q2w4 = 4.0 * q2w4;
+ const double a = q2w4 + sqrt2_3fqw3 + _2q2_1_4f2w2 + sqrt2_7f3qw + _16f4q2;
+ const double b = _4q2w4 + sqrt2_5fqw3 - sqrt2_9f3qw - _64f4q2;
+ const double c = 6.0 * q2w4 - 2.0 * _2q2_1_4f2w2 + 96.0 * f4q2;
+ const double d = _4q2w4 - sqrt2_5fqw3 + sqrt2_9f3qw - _64f4q2;
+ const double e = q2w4 - sqrt2_3fqw3 + _2q2_1_4f2w2 - sqrt2_7f3qw + _16f4q2;
+ data->signal[i] = (_4f2w2 * (x
+ - 2.0 * data->x2
+ + data->x4)
+ - (b * data->y1
+ + c * data->y2
+ + d * data->y3
+ + e * data->y4)) / a;
+ data->x4 = data->x3;
+ data->x3 = data->x2;
+ data->x2 = data->x1;
+ data->x1 = x;
+ data->y4 = data->y3;
+ data->y3 = data->y2;
+ data->y2 = data->y1;
+ data->y1 = data->signal[i];
+ i++;
+ }
+ return 0;
+}
diff --git a/lib/signal/delay.c b/lib/signal/delay.c
new file mode 100644
index 0000000..202af98
--- /dev/null
+++ b/lib/signal/delay.c
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <strings.h>
+#include <rtbuf/rtbuf.h>
+#include <rtbuf/signal.h>
+
+int rtbuf_signal_delay_start (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_delay_data *data;
+ assert(rtb->proc->out_bytes == sizeof(*data));
+ data = (s_rtbuf_signal_delay_data*) rtb->data;
+ bzero(data->in, sizeof(data->in));
+ data->pos = 0;
+ return 0;
+}
+
+int rtbuf_signal_delay (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_fun in;
+ s_rtbuf_signal_fun delay;
+ s_rtbuf_signal_fun feedback;
+ s_rtbuf_signal_delay_data *data;
+ unsigned int i = 0;
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_DELAY_IN_SIGNAL, &in);
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_DELAY_IN_DELAY, &delay);
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_DELAY_IN_DELAY, &feedback);
+ data = (s_rtbuf_signal_delay_data*) rtb->data;
+ while (i < RTBUF_SIGNAL_SAMPLES) {
+ double s = in.sample_fun(in.signal, i);
+ double d = min(max(0.0, delay.sample_fun(delay.signal, i)),
+ RTBUF_SIGNAL_DELAY_MAX);
+ double fb = min(max(0.0, feedback.sample_fun(feedback.signal, i)), 1.0);
+ unsigned int ds = d * RTBUF_SIGNAL_SAMPLERATE;
+ unsigned int p = (data->pos + RTBUF_SIGNAL_DELAY_SAMPLES_MAX - ds) %
+ RTBUF_SIGNAL_DELAY_SAMPLES_MAX;
+ data->signal[i] = data->in[p];
+ data->in[data->pos] = (1.0 - fb) * s + fb * data->in[p];
+ data->pos = (data->pos + 1) % RTBUF_SIGNAL_DELAY_SAMPLES_MAX;
+ i++;
+ }
+ return 0;
+}
diff --git a/lib/signal/equalizer10.c b/lib/signal/equalizer10.c
new file mode 100644
index 0000000..8aa54b8
--- /dev/null
+++ b/lib/signal/equalizer10.c
@@ -0,0 +1,303 @@
+/*
+ * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+/* Butterworth bandpass second order filter
+s: 2*f*(1-z)/(1+z) $
+B2: (q*(s/w+w/s))^2+sqrt(2)*(q*(s/w+w/s))+1 $
+H: 1/B2 $
+ratsimp(H);
+ 2 2 4 2 2 2 2 2
+(%o25) (4 f w z - 8 f w z + 4 f w )
+ 2 4 3/2 3 2 2 2 2 7/2 3 4 2 4
+/((q w - 2 f q w + (8 f q + 4 f ) w - 2 f q w + 16 f q ) z
+ 2 4 5/2 3 9/2 3 4 2 3
+ + (4 q w - 2 f q w + 2 f q w - 64 f q ) z
+ 2 4 2 2 2 2 4 2 2
+ + (6 q w + ((- 16 f q ) - 8 f ) w + 96 f q ) z
+ 2 4 5/2 3 9/2 3 4 2 2 4 3/2 3
+ + (4 q w + 2 f q w - 2 f q w - 64 f q ) z + q w + 2 f q w
+ 2 2 2 2 7/2 3 4 2
+ + (8 f q + 4 f ) w + 2 f q w + 16 f q )
+
+a: q2 w4 + sqrt(2)^3 f q w3 + (8 f2 q2 + 4 f2) w2 + sqrt(2)^7 f3 q w + 16 f4 q2;
+b: 4 q2 w4 + sqrt(2)^5 f q w3 - sqrt(2)^9 f3 q w - 64 f4 q2;
+c: 6 q2 w4 - 2 (8 f2 q2 + 4 f2) w2 + 96 f4 q2;
+d: 4 q2 w4 - sqrt(2)^5 f q w3 + sqrt(2)^9 f3 q w - 64 f4 q2;
+e: q2 w4 - sqrt(2)^3 f q w3 + (8 f2 q2 + 4 f2) w2 - sqrt(2)^7 f3 q w + 16 f4 q2;
+-----------------------------------------------------------------------------------
+a: q2 w4 + sqrt(2)^3 f q w3 + (2 q2 + 1) 4 f2 w2 + sqrt(2)^7 f3 q w + 16 f4 q2;
+b: 4 q2 w4 + sqrt(2)^5 f q w3 - sqrt(2)^9 f3 q w - 64 f4 q2;
+c: 6 q2 w4 - 2 (2 q2 + 1) 4 f2 w2 + 96 f4 q2;
+d: 4 q2 w4 - sqrt(2)^5 f q w3 + sqrt(2)^9 f3 q w - 64 f4 q2;
+e: q2 w4 - sqrt(2)^3 f q w3 + (2 q2 + 1) 4 f2 w2 - sqrt(2)^7 f3 q w + 16 f4 q2;
+-----------------------------------------------------------------------------------
+y: (4 f2 w2 (x4 - 2 x2 + x) - (b y1 + c y2 + d y3 + e y4)) / a;
+
+12db/octave
+fc: -3db
+3/12 = 1/4 octave = 3/4 et 5/4
+q: 2
+*/
+#include <math.h>
+#include <rtbuf/rtbuf.h>
+#include <rtbuf/signal.h>
+
+double sqrt2_3 = 0.0;
+double sqrt2_5;
+double sqrt2_7;
+double sqrt2_9;
+double f;
+double f2;
+double f3;
+double f4;
+
+int rtbuf_signal_equalizer10_start (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_equalizer10_data *data;
+ assert(rtb->proc->out_bytes == sizeof(*data));
+ data = (s_rtbuf_signal_equalizer10_data*) rtb->data;
+ data->x1 = 0.0;
+ data->x2 = 0.0;
+ data->x3 = 0.0;
+ data->x4 = 0.0;
+ data->y0_1 = 0.0;
+ data->y0_2 = 0.0;
+ data->y0_3 = 0.0;
+ data->y0_4 = 0.0;
+ data->y1_1 = 0.0;
+ data->y1_2 = 0.0;
+ data->y1_3 = 0.0;
+ data->y1_4 = 0.0;
+ data->y2_1 = 0.0;
+ data->y2_2 = 0.0;
+ data->y2_3 = 0.0;
+ data->y2_4 = 0.0;
+ data->y3_1 = 0.0;
+ data->y3_2 = 0.0;
+ data->y3_3 = 0.0;
+ data->y3_4 = 0.0;
+ data->y4_1 = 0.0;
+ data->y4_2 = 0.0;
+ data->y4_3 = 0.0;
+ data->y4_4 = 0.0;
+ data->y5_1 = 0.0;
+ data->y5_2 = 0.0;
+ data->y5_3 = 0.0;
+ data->y5_4 = 0.0;
+ data->y6_1 = 0.0;
+ data->y6_2 = 0.0;
+ data->y6_3 = 0.0;
+ data->y6_4 = 0.0;
+ data->y7_1 = 0.0;
+ data->y7_2 = 0.0;
+ data->y7_3 = 0.0;
+ data->y7_4 = 0.0;
+ data->y8_1 = 0.0;
+ data->y8_2 = 0.0;
+ data->y8_3 = 0.0;
+ data->y8_4 = 0.0;
+ data->y9_1 = 0.0;
+ data->y9_2 = 0.0;
+ data->y9_3 = 0.0;
+ data->y9_4 = 0.0;
+ sqrt2_3 = sqrt2_2 * M_SQRT2;
+ sqrt2_5 = sqrt2_3 * sqrt2_2;
+ sqrt2_7 = sqrt2_5 * sqrt2_2;
+ sqrt2_9 = sqrt2_7 * sqrt2_2;
+ f = RTBUF_SIGNAL_SAMPLERATE;
+ f2 = f * f;
+ f3 = f2 * f;
+ f4 = f2 * f2;
+ return 0;
+}
+
+double butterworth_bandpass2 (const double x, const double fc,
+ const double q, const double x2,
+ const double x4, const double y1,
+ const double y2, const double y3,
+ const double y4)
+{
+ const double q2 = q * q;
+ const double f4q2 = f4 * q2;
+ const double _16f4q2 = 16.0 * f4q2;
+ const double _64f4q2 = 64.0 * f4q2;
+ const double w = 2.0 * M_PI * fc;
+ const double f3qw = f3 * q * w;
+ const double sqrt2_7f3qw = sqrt2_7 * f3qw;
+ const double sqrt2_9f3qw = sqrt2_9 * f3qw;
+ const double w2 = w * w;
+ const double _4f2w2 = 4.0 * f2 * w2;
+ const double _2q2_1_4f2w2 = (2.0 * q2 + 1.0) * _4f2w2;
+ const double w3 = w2 * w;
+ const double fqw3 = f * q * w3;
+ const double sqrt2_3fqw3 = sqrt2_3 * fqw3;
+ const double sqrt2_5fqw3 = sqrt2_5 * fqw3;
+ const double w4 = w2 * w2;
+ const double q2w4 = q2 * w4;
+ const double _4q2w4 = 4.0 * q2w4;
+ const double a = q2w4 + sqrt2_3fqw3 + _2q2_1_4f2w2 + sqrt2_7f3qw + _16f4q2;
+ const double b = _4q2w4 + sqrt2_5fqw3 - sqrt2_9f3qw - _64f4q2;
+ const double c = 6.0 * q2w4 - 2.0 * _2q2_1_4f2w2 + 96.0 * f4q2;
+ const double d = _4q2w4 - sqrt2_5fqw3 + sqrt2_9f3qw - _64f4q2;
+ const double e = q2w4 - sqrt2_3fqw3 + _2q2_1_4f2w2 - sqrt2_7f3qw + _16f4q2;
+ const double y = (_4f2w2 * (x
+ - 2.0 * x2
+ + x4)
+ - (b * y1
+ + c * y2
+ + d * y3
+ + e * y4)) / a;
+ return y;
+}
+
+int rtbuf_signal_equalizer10 (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_fun in;
+ s_rtbuf_signal_fun amp32;
+ s_rtbuf_signal_fun amp64;
+ s_rtbuf_signal_fun amp128;
+ s_rtbuf_signal_fun amp256;
+ s_rtbuf_signal_fun amp512;
+ s_rtbuf_signal_fun amp1k;
+ s_rtbuf_signal_fun amp2k;
+ s_rtbuf_signal_fun amp4k;
+ s_rtbuf_signal_fun amp8k;
+ s_rtbuf_signal_fun amp16k;
+ s_rtbuf_signal_equalizer10_data *data;
+ unsigned int i = 0;
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_EQUALIZER10_IN_SIGNAL, &in);
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_EQUALIZER10_IN_AMP32, &32);
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_EQUALIZER10_IN_AMP64, &64);
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_EQUALIZER10_IN_AMP128, &128);
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_EQUALIZER10_IN_AMP256, &256);
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_EQUALIZER10_IN_AMP512, &512);
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_EQUALIZER10_IN_AMP1K, &1k);
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_EQUALIZER10_IN_AMP2K, &2k);
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_EQUALIZER10_IN_AMP4K, &4k);
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_EQUALIZER10_IN_AMP8K, &8k);
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_EQUALIZER10_IN_AMP16K, &16k);
+ data = (s_rtbuf_signal_equalizer10_data*) rtb->data;
+ while (i < RTBUF_SIGNAL_SAMPLES) {
+ const double x = in.sample_fun(in.signal, i);
+ const double a0 = amp32.sample_fun(amp32.signal, i);
+ const double a1 = amp32.sample_fun(amp64.signal, i);
+ const double a2 = amp32.sample_fun(amp128.signal, i);
+ const double a3 = amp32.sample_fun(amp256.signal, i);
+ const double a4 = amp32.sample_fun(amp512.signal, i);
+ const double a5 = amp32.sample_fun(amp1k.signal, i);
+ const double a6 = amp32.sample_fun(amp2k.signal, i);
+ const double a7 = amp32.sample_fun(amp4k.signal, i);
+ const double a8 = amp32.sample_fun(amp8k.signal, i);
+ const double a9 = amp32.sample_fun(amp16k.signal, i);
+ const double y0 = butterworth_bandpass2(x, 32.0, 2.0,
+ data->x2, data->x4,
+ data->y0_1, data->y0_2,
+ data->y0_3, data->y0_4);
+ const double y1 = butterworth_bandpass2(x, 64.0, 2.0,
+ data->x2, data->x4,
+ data->y1_1, data->y1_2,
+ data->y1_3, data->y1_4);
+ const double y2 = butterworth_bandpass2(x, 128.0, 2.0,
+ data->x2, data->x4,
+ data->y2_1, data->y2_2,
+ data->y2_3, data->y2_4);
+ const double y3 = butterworth_bandpass2(x, 256.0, 2.0,
+ data->x2, data->x4,
+ data->y3_1, data->y3_2,
+ data->y3_3, data->y3_4);
+ const double y4 = butterworth_bandpass2(x, 512.0, 2.0,
+ data->x2, data->x4,
+ data->y4_1, data->y4_2,
+ data->y4_3, data->y4_4);
+ const double y5 = butterworth_bandpass2(x, 1024.0, 2.0,
+ data->x2, data->x4,
+ data->y5_1, data->y5_2,
+ data->y5_3, data->y5_4);
+ const double y6 = butterworth_bandpass2(x, 2048.0, 2.0,
+ data->x2, data->x4,
+ data->y6_1, data->y6_2,
+ data->y6_3, data->y6_4);
+ const double y7 = butterworth_bandpass2(x, 4096.0, 2.0,
+ data->x2, data->x4,
+ data->y7_1, data->y7_2,
+ data->y7_3, data->y7_4);
+ const double y8 = butterworth_bandpass2(x, 8192.0, 2.0,
+ data->x2, data->x4,
+ data->y8_1, data->y8_2,
+ data->y8_3, data->y8_4);
+ const double y9 = butterworth_bandpass2(x, 16384.0, 2.0,
+ data->x2, data->x4,
+ data->y9_1, data->y9_2,
+ data->y9_3, data->y9_4);
+ data->signal[i] = (a0 * y0 + a1 * y1 + a2 * y2 + a3 * y3 + a4 * y4 +
+ a5 * y5 + a6 * y6 + a7 * y7 + a8 * y8 + a9 * y9);
+ data->signal32[i] = y0;
+ data->signal64[i] = y1;
+ data->signal128[i] = y2;
+ data->signal256[i] = y3;
+ data->signal512[i] = y4;
+ data->signal1k[i] = y5;
+ data->signal2k[i] = y6;
+ data->signal4k[i] = y7;
+ data->signal8k[i] = y8;
+ data->signal16k[i] = y9;
+ data->x4 = data->x3;
+ data->x3 = data->x2;
+ data->x2 = data->x1;
+ data->x1 = x;
+ data->y0_4 = data->y0_3;
+ data->y0_3 = data->y0_2;
+ data->y0_2 = data->y0_1;
+ data->y0_1 = y0;
+ data->y1_4 = data->y1_3;
+ data->y1_3 = data->y1_2;
+ data->y1_2 = data->y1_1;
+ data->y1_1 = y1;
+ data->y2_4 = data->y2_3;
+ data->y2_3 = data->y2_2;
+ data->y2_2 = data->y2_1;
+ data->y2_1 = y2;
+ data->y3_4 = data->y3_3;
+ data->y3_3 = data->y3_2;
+ data->y3_2 = data->y3_1;
+ data->y3_1 = y3;
+ data->y4_4 = data->y4_3;
+ data->y4_3 = data->y4_2;
+ data->y4_2 = data->y4_1;
+ data->y4_1 = y4;
+ data->y5_4 = data->y5_3;
+ data->y5_3 = data->y5_2;
+ data->y5_2 = data->y5_1;
+ data->y5_1 = y5;
+ data->y6_4 = data->y6_3;
+ data->y6_3 = data->y6_2;
+ data->y6_2 = data->y6_1;
+ data->y6_1 = y6;
+ data->y7_4 = data->y7_3;
+ data->y7_3 = data->y7_2;
+ data->y7_2 = data->y7_1;
+ data->y7_1 = y7;
+ data->y8_4 = data->y8_3;
+ data->y8_3 = data->y8_2;
+ data->y8_2 = data->y8_1;
+ data->y8_1 = y8;
+ data->y9_4 = data->y9_3;
+ data->y9_3 = data->y9_2;
+ data->y9_2 = data->y9_1;
+ data->y9_1 = y9;
+ i++;
+ }
+ return 0;
+}
diff --git a/lib/signal/flanger.c b/lib/signal/flanger.c
new file mode 100644
index 0000000..da103f4
--- /dev/null
+++ b/lib/signal/flanger.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2018,2020 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ * Copyright 2018 Judy Najnudel <judy.najnudel@gmail.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <math.h>
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <rtbuf/rtbuf.h>
+#include <rtbuf/signal.h>
+
+int rtbuf_signal_flanger_start (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_flanger_data *data;
+ assert(rtb->proc->out_bytes == sizeof(*data));
+ data = (s_rtbuf_signal_flanger_data*) rtb->data;
+ data->phase = 0;
+ bzero(data->in, sizeof(data->in));
+ data->pos = 0;
+ data->ds = 0;
+ return 0;
+}
+
+int rtbuf_signal_flanger (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_fun in;
+ s_rtbuf_signal_fun freq;
+ s_rtbuf_signal_fun amp;
+ s_rtbuf_signal_fun delay;
+ s_rtbuf_signal_fun feedback;
+ s_rtbuf_signal_flanger_data *data;
+ unsigned int i = 0;
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_FLANGER_IN_SIGNAL, &in);
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_FLANGER_IN_FREQUENCY, &freq);
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_FLANGER_IN_AMPLITUDE, &);
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_FLANGER_IN_DELAY, &delay);
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_FLANGER_IN_FEEDBACK, &feedback);
+ data = (s_rtbuf_signal_flanger_data*) rtb->data;
+ while (i < RTBUF_SIGNAL_SAMPLES) {
+ double s = in.sample_fun(in.signal, i);
+ double f = freq.sample_fun(freq.signal, i);
+ double a = amp.sample_fun(amp.signal, i);
+ double d = delay.sample_fun(delay.signal, i);
+ double delay;
+ double fb = feedback.sample_fun(feedback.signal, i);
+ unsigned int ds;
+ unsigned int pos;
+ f = max(0.0, f);
+ f /= (double) RTBUF_SIGNAL_SAMPLERATE;
+ data->phase = fmod(data->phase + 2.0 * M_PI * f, 2.0 * M_PI);
+ delay = a * (sin(data->phase) * 0.5 + 0.5) + d;
+ ds = max(0.0, min(delay * RTBUF_SIGNAL_SAMPLERATE,
+ RTBUF_SIGNAL_FLANGER_SAMPLES_MAX));
+ pos = (data->pos + RTBUF_SIGNAL_FLANGER_SAMPLES_MAX - ds) %
+ RTBUF_SIGNAL_FLANGER_SAMPLES_MAX;
+ data->signal[i] = (data->in[pos] + s) / 2.0;
+ data->in[data->pos++] = (1.0 - fb) * s + fb * data->in[pos];
+ data->pos %= RTBUF_SIGNAL_FLANGER_SAMPLES_MAX;
+ i++;
+ }
+ return 0;
+}
diff --git a/lib/signal/hipass.c b/lib/signal/hipass.c
new file mode 100644
index 0000000..2f2a3a3
--- /dev/null
+++ b/lib/signal/hipass.c
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <math.h>
+#include <rtbuf/rtbuf.h>
+#include <rtbuf/signal.h>
+
+int rtbuf_signal_hipass_start (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_hipass_data *data;
+ assert(rtb->proc->out_bytes == sizeof(*data));
+ data = (s_rtbuf_signal_hipass_data*) rtb->data;
+ data->x1 = 0;
+ data->y1 = 0;
+ return 0;
+}
+
+int rtbuf_signal_hipass (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_fun in;
+ s_rtbuf_signal_fun cutoff;
+ s_rtbuf_signal_hipass_data *data;
+ unsigned int i = 0;
+ double k = 2.0 * RTBUF_SIGNAL_SAMPLERATE;
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_HIPASS_IN_SIGNAL, &in);
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_HIPASS_IN_CUTOFF, &cutoff);
+ data = (s_rtbuf_signal_hipass_data*) rtb->data;
+ while (i < RTBUF_SIGNAL_SAMPLES) {
+ double x = in.sample_fun(in.signal, i);
+ double fc = cutoff.sample_fun(cutoff.signal, i);
+ double wc = 2.0 * M_PI * fc;
+ data->signal[i] = (k * (x - data->x1) + (k - wc) * data->y1) / (k + wc);
+ data->x1 = x;
+ data->y1 = data->signal[i];
+ i++;
+ }
+ return 0;
+}
diff --git a/lib/signal/hipass2.c b/lib/signal/hipass2.c
new file mode 100644
index 0000000..3ac072a
--- /dev/null
+++ b/lib/signal/hipass2.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <math.h>
+#include <rtbuf/rtbuf.h>
+#include <rtbuf/signal.h>
+
+int rtbuf_signal_hipass2_start (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_hipass2_data *data;
+ assert(rtb->proc->out_bytes == sizeof(*data));
+ data = (s_rtbuf_signal_hipass2_data*) rtb->data;
+ data->x1 = 0;
+ data->x2 = 0;
+ data->y1 = 0;
+ data->y2 = 0;
+ return 0;
+}
+
+int rtbuf_signal_hipass2 (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_fun in;
+ s_rtbuf_signal_fun cutoff;
+ s_rtbuf_signal_hipass2_data *data;
+ unsigned int i = 0;
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_HIPASS_IN_SIGNAL, &in);
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_HIPASS_IN_CUTOFF, &cutoff);
+ data = (s_rtbuf_signal_hipass2_data*) rtb->data;
+ while (i < RTBUF_SIGNAL_SAMPLES) {
+ double x = in.sample_fun(in.signal, i);
+ double fc = cutoff.sample_fun(cutoff.signal, i);
+ double wc = 2.0 * M_PI * fc;
+ double wc2 = wc * wc;
+ double _2fs = 2.0 * RTBUF_SIGNAL_SAMPLERATE;
+ double k = M_SQRT2 * _2fs * wc;
+ double _4fs2 = _2fs * _2fs;
+ data->signal[i] = (_4fs2 * (x
+ + data->x1 * -2.0
+ + data->x2)
+ + data->y1 * (2.0 * _4fs2 - 2.0 * wc2)
+ + data->y2 * (k - (_4fs2 + wc2)))
+ / (wc2 + k + _4fs2);
+ data->x2 = data->x1;
+ data->x1 = x;
+ data->y2 = data->y1;
+ data->y1 = data->signal[i];
+ i++;
+ }
+ return 0;
+}
diff --git a/lib/signal/hipass3.c b/lib/signal/hipass3.c
new file mode 100644
index 0000000..6bd2907
--- /dev/null
+++ b/lib/signal/hipass3.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ * Copyright 2020 Judy Najnudel
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+/*
+
+Polynomial for Butterworth third order high pass filter
+b: (w/s+1)*((w/s)^2+w/s+1) $
+
+Transfer function
+h: 1/b $
+
+Bilinear transform:
+s: 2*F*(1-z)/(1+z) $
+
+ratsimp(h);
+-(8 F³ z³ - 24 F³ z² + 24 F³ z - 8 F³)
+/((w³ - 4 F w² + 8 F² w - 8 F³) z³
+ + (3 w³ - 4 F w² - 8 F² w + 24 F³) z²
+ + (3 w³ + 4 F w² - 8 F² w - 24 F³) z
+ + w³ + 4 F w² + 8 F² w + 8 F³)
+
+a: w³ - 4 F w² + 8 F² w - 8 F³
+b: 3 w³ - 4 F w² - 8 F² w + 24 F³
+c: 3 w³ + 4 F w² - 8 F² w - 24 F³
+d: w³ + 4 F w² + 8 F² w + 8 F³
+
+y: (8 F³ ((x - x3) + 3 (x2 - x1)) - (a y3 + b y2 + c y1)) / d
+
+*/
+#include <math.h>
+#include <rtbuf/rtbuf.h>
+#include <rtbuf/signal.h>
+
+int rtbuf_signal_hipass3_start (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_hipass3_data *data;
+ assert(rtb->proc->out_bytes == sizeof(*data));
+ data = (s_rtbuf_signal_hipass3_data*) rtb->data;
+ data->x1 = 0.0;
+ data->x2 = 0.0;
+ data->x3 = 0.0;
+ data->y1 = 0.0;
+ data->y2 = 0.0;
+ data->y3 = 0.0;
+ return 0;
+}
+
+int rtbuf_signal_hipass3 (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_fun in;
+ s_rtbuf_signal_fun cutoff;
+ s_rtbuf_signal_hipass3_data *data;
+ unsigned int i = 0;
+ const double fs = RTBUF_SIGNAL_SAMPLERATE;
+ const double fs2 = fs * fs;
+ const double fs3 = fs2 * fs;
+ const double _8fs3 = 8.0 * fs3;
+ const double _24fs3 = 24.0 * fs3;
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_HIPASS_IN_SIGNAL, &in);
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_HIPASS_IN_CUTOFF, &cutoff);
+ data = (s_rtbuf_signal_hipass3_data*) rtb->data;
+ while (i < RTBUF_SIGNAL_SAMPLES) {
+ const double x = in.sample_fun(in.signal, i);
+ const double fc = cutoff.sample_fun(cutoff.signal, i);
+ const double wc = 2.0 * M_PI * fc;
+ const double wc2 = wc * wc;
+ const double wc3 = wc2 * wc;
+ const double _8fs2wc = 8.0 * fs2 * wc;
+ const double _4fswc2 = 4.0 * fs * wc2;
+ const double _3wc3 = 3.0 * wc3;
+ const double a = wc3 - _4fswc2 + _8fs2wc - _8fs3;
+ const double b = _3wc3 - _4fswc2 - _8fs2wc + _24fs3;
+ const double c = _3wc3 + _4fswc2 - _8fs2wc - _24fs3;
+ const double d = wc3 + _4fswc2 + _8fs2wc + _8fs3;
+ data->signal[i] = (_8fs3 * (x
+ + 3.0 * (data->x2
+ - data->x1)
+ - data->x3)
+ - (a * data->y3
+ + b * data->y2
+ + c * data-> y1)) / d;
+ data->x3 = data->x2;
+ data->x2 = data->x1;
+ data->x1 = x;
+ data->y3 = data->y2;
+ data->y2 = data->y1;
+ data->y1 = data->signal[i];
+ i++;
+ }
+ return 0;
+}
diff --git a/lib/signal/hipass4.c b/lib/signal/hipass4.c
new file mode 100644
index 0000000..6608258
--- /dev/null
+++ b/lib/signal/hipass4.c
@@ -0,0 +1,126 @@
+/*
+ * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+/* Butterworth hipass fourth order filter
+a: cos(5*%pi/8) $
+b: cos(7*%pi/8) $
+s: 2*F*(1-z)/(1+z) $
+B4:((w/s)^2-2*(w/s)*a+1)*((w/s)^2-2*w/s*b+1) $
+H: 1/B4 $
+ratsimp(H);
+ 4 4 4 3 4 2 4 4
+(16 F z - 64 F z + 96 F z - 64 F z + 16 F )
+ 4 3 2 2 2 3 3
+/((w + (4 F b + 4 F a) w + (16 F a b + 8 F ) w + (16 F b + 16 F a) w
+ 4 4 4 3 3 3
+ + 16 F ) z + (4 w + (8 F b + 8 F a) w + ((- 32 F b) - 32 F a) w
+ 4 3 4 2 2 2 4 2
+ - 64 F ) z + (6 w + ((- 32 F a b) - 16 F ) w + 96 F ) z
+ 4 3 3 3 4 4
+ + (4 w + ((- 8 F b) - 8 F a) w + (32 F b + 32 F a) w - 64 F ) z + w
+ 3 2 2 2
+ + ((- 4 F b) - 4 F a) w + (16 F a b + 8 F ) w
+ 3 3 4
+ + ((- 16 F b) - 16 F a) w + 16 F )
+
+a: w4 - 4 (a + b) F w3 + (16 a b + 8) f2 w2 - 16 (a + b) f3 w + 16 f4 $
+b: 4 w4 - 8 (a + b) F w3 + 32 (a + b) f3 w - 64 f4 $
+c: 6 w4 - (32 a b + 16) f2 w2 + 96 f4 $
+d: 4 w4 + 8 (a + b) F w3 - 32 (a + b) f3 w - 64 f4 $
+e: w4 + 4 (a + b) F w3 + (16 a b + 8) f2 w2 + 16 (a + b) f3 w + 16 f4 $
+
+y: f4 (16 x4 - 64 x3 + 96 x2 - 64 x1 + 16 x - (e y4 + d y3 + c y2 + b y1)) / a $
+y: f4 (16 (x4 + x) - 64 (x3 + x1) + 96 x2 - (e y4 + d y3 + c y2 + b y1)) / a $
+
+*/
+#include <math.h>
+#include <rtbuf/rtbuf.h>
+#include <rtbuf/signal.h>
+
+int rtbuf_signal_hipass4_start (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_hipass4_data *data;
+ assert(rtb->proc->out_bytes == sizeof(*data));
+ data = (s_rtbuf_signal_hipass4_data*) rtb->data;
+ data->x1 = 0.0;
+ data->x2 = 0.0;
+ data->x3 = 0.0;
+ data->x4 = 0.0;
+ data->y1 = 0.0;
+ data->y2 = 0.0;
+ data->y3 = 0.0;
+ data->y4 = 0.0;
+ return 0;
+}
+
+int rtbuf_signal_hipass4 (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_fun in;
+ s_rtbuf_signal_fun cutoff;
+ s_rtbuf_signal_hipass4_data *data;
+ unsigned int i = 0;
+ const double a = cos(5.0 * M_PI / 8.0);
+ const double b = cos(7.0 * M_PI / 8.0);
+ const double f = RTBUF_SIGNAL_SAMPLERATE;
+ const double _4a_bf = 4.0 * (a + b) * f;
+ const double f2 = f * f;
+ const double _16ab_8f2 = (16.0 * a * b + 8.0) * f2;
+ const double f3 = f2 * f;
+ const double _16a_bf3 = 16.0 * (a + b) * f3;
+ const double f4 = f2 * f2;
+ const double _16f4 = 16.0 * f4;
+ const double _64f4 = 64.0 * f4;
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_HIPASS_IN_SIGNAL, &in);
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_HIPASS_IN_CUTOFF, &cutoff);
+ data = (s_rtbuf_signal_hipass4_data*) rtb->data;
+ while (i < RTBUF_SIGNAL_SAMPLES) {
+ const double x = in.sample_fun(in.signal, i);
+ const double fc = cutoff.sample_fun(cutoff.signal, i);
+ const double w = 2.0 * M_PI * fc;
+ const double _16a_bf3w = _16a_bf3 * w;
+ const double _32a_bf3w = 2.0 * _16a_bf3w;
+ const double w2 = w * w;
+ const double _16ab_8f2w2 = _16ab_8f2 * w2;
+ const double _32ab_16f2w2 = 2 * _16ab_8f2w2;
+ const double w3 = w2 * w;
+ const double _4a_bfw3 = _4a_bf * w3;
+ const double _8a_bfw3 = 2.0 * _4a_bfw3;
+ const double w4 = w2 * w2;
+ const double _4w4 = 4.0 * w4;
+ const double a = w4 - _4a_bfw3 + _16ab_8f2w2 - _16a_bf3w + _16f4;
+ const double b = _4w4 - _8a_bfw3 + _32a_bf3w - _64f4;
+ const double c = 6.0 * w4 - _32ab_16f2w2 + 96.0 * f4;
+ const double d = _4w4 + _8a_bfw3 - _32a_bf3w - _64f4;
+ const double e = w4 + _4a_bfw3 + _16ab_8f2w2 + _16a_bf3w + _16f4;
+ data->signal[i] = (f4 * (16.0 * (x + data->x4)
+ - 64.0 * (data->x1 +
+ data->x3)
+ + 96.0 * data->x2)
+ - (e * data->y4
+ + d * data->y3
+ + c * data->y2
+ + b * data->y1)) / a;
+ data->x4 = data->x3;
+ data->x3 = data->x2;
+ data->x2 = data->x1;
+ data->x1 = x;
+ data->y4 = data->y3;
+ data->y3 = data->y2;
+ data->y2 = data->y1;
+ data->y1 = data->signal[i];
+ i++;
+ }
+ return 0;
+}
diff --git a/lib/signal/hipass5.c b/lib/signal/hipass5.c
new file mode 100644
index 0000000..1d1af99
--- /dev/null
+++ b/lib/signal/hipass5.c
@@ -0,0 +1,148 @@
+/*
+ * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+/* Butterworth hipass fifth order filter
+a: (sqrt(5)-1)/2 $
+b: (sqrt(5)+1)/2 $
+s: 2*F*(1-z)/(1+z) $
+B5:(w/s+1)*((w/s)^2+a*(w/s)+1)*((w/s)^2+b*w/s+1) $
+H: 1/B5 $
+ratsimp(H);
+ 5 5 5 4 5 3 5 2 5 5
+- (32 F z - 160 F z + 320 F z - 320 F z + 160 F z - 32 F )
+ 5 4 2 3
+/((w + ((- 2 sqrt(5)) - 2) F w + (4 sqrt(5) + 12) F w
+ 3 2 4 5 5
+ + ((- 8 sqrt(5)) - 24) F w + (16 sqrt(5) + 16) F w - 32 F ) z
+ 5 4 2 3
+ + (5 w + ((- 6 sqrt(5)) - 6) F w + (4 sqrt(5) + 12) F w
+ 3 2 4 5 4
+ + (8 sqrt(5) + 24) F w + ((- 48 sqrt(5)) - 48) F w + 160 F ) z
+ 5 4 2 3
+ + (10 w + ((- 4 sqrt(5)) - 4) F w + ((- 8 sqrt(5)) - 24) F w
+ 3 2 4 5 3
+ + (16 sqrt(5) + 48) F w + (32 sqrt(5) + 32) F w - 320 F ) z
+ 5 4 2 3
+ + (10 w + (4 sqrt(5) + 4) F w + ((- 8 sqrt(5)) - 24) F w
+ 3 2 4 5 2
+ + ((- 16 sqrt(5)) - 48) F w + (32 sqrt(5) + 32) F w + 320 F ) z
+ 5 4 2 3
+ + (5 w + (6 sqrt(5) + 6) F w + (4 sqrt(5) + 12) F w
+ 3 2 4 5
+ + ((- 8 sqrt(5)) - 24) F w + ((- 48 sqrt(5)) - 48) F w - 160 F ) z
+ 5 4 2 3
+ + w + (2 sqrt(5) + 2) F w + (4 sqrt(5) + 12) F w
+ 3 2 4 5
+ + (8 sqrt(5) + 24) F w + (16 sqrt(5) + 16) F w + 32 F )
+
+a: w5 + (r5 + 1)( 2)(f w4 + 8 f4 w) + (4 r5 + 12) (f2 w3 + 2 f3 w2) + 32 f5; z
+b: 5 w5 + (r5 + 1)( 6)(f w4 - 8 f4 w) + (4 r5 + 12) (f2 w3 - 2 f3 w2) - 160 f5; z1
+c: 10 w5 + (r5 + 1)( 4)(f w4 + 8 f4 w) + (4 r5 + 12)(-2)(f2 w3 + 2 f3 w2) + 320 f5; z2
+d: 10 w5 + (r5 + 1)(-4)(f w4 - 8 f4 w) + (4 r5 + 12)(-2)(f2 w3 - 2 f3 w2) - 320 f5; z3
+e: 5 w5 + (r5 + 1)(-6)(f w4 + 8 f4 w) + (4 r5 + 12) (f2 w3 + 2 f3 w2) + 160 f5; z4
+f: w5 + (r5 + 1)(-2)(f w4 - 8 f4 w) + (4 r5 + 12) (f2 w3 - 2 f3 w2) - 32 f5; z5
+
+y: (f5 (32 (x - x5) + 160 (x4 - x1) + 320 (x2 - x3)) - (b y1 + c y2 + d y3 + e y4 + f y5)) / a;
+
+*/
+#include <math.h>
+#include <rtbuf/rtbuf.h>
+#include <rtbuf/signal.h>
+
+int rtbuf_signal_hipass5_start (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_hipass5_data *data;
+ assert(rtb->proc->out_bytes == sizeof(*data));
+ data = (s_rtbuf_signal_hipass5_data*) rtb->data;
+ data->x1 = 0.0;
+ data->x2 = 0.0;
+ data->x3 = 0.0;
+ data->x4 = 0.0;
+ data->x5 = 0.0;
+ data->y1 = 0.0;
+ data->y2 = 0.0;
+ data->y3 = 0.0;
+ data->y4 = 0.0;
+ data->y5 = 0.0;
+ return 0;
+}
+
+int rtbuf_signal_hipass5 (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_fun in;
+ s_rtbuf_signal_fun cutoff;
+ s_rtbuf_signal_hipass5_data *data;
+ unsigned int i = 0;
+ const double r5_1 = sqrt(5.0) + 1.0;
+ const double _4r5_12 = 4.0 * sqrt(5.0) + 12.0;
+ const double f = RTBUF_SIGNAL_SAMPLERATE;
+ const double f2 = f * f;
+ const double f3 = f2 * f;
+ const double f4 = f2 * f2;
+ const double f5 = f2 * f3;
+ const double _32f5 = 32.0 * f5;
+ const double _160f5 = 160.0 * f5;
+ const double _320f5 = 320.0 * f5;
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_HIPASS_IN_SIGNAL, &in);
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_HIPASS_IN_CUTOFF, &cutoff);
+ data = (s_rtbuf_signal_hipass5_data*) rtb->data;
+ while (i < RTBUF_SIGNAL_SAMPLES) {
+ const double x = in.sample_fun(in.signal, i);
+ const double fc = cutoff.sample_fun(cutoff.signal, i);
+ const double w = 2.0 * M_PI * fc;
+ const double _8f4w = 8.0 * f4 * w;
+ const double w2 = w * w;
+ const double _2f3w2 = 2.0 * f3 * w2;
+ const double w3 = w2 * w;
+ const double f2w3 = f2 * w3;
+ const double f2w3p2f3w2 = f2w3 + _2f3w2;
+ const double f2w3m2f3w2 = f2w3 - _2f3w2;
+ const double w4 = w2 * w2;
+ const double fw4 = f * w4;
+ const double fw4p8f4w = (fw4 + _8f4w);
+ const double fw4m8f4w = (fw4 - _8f4w);
+ const double w5 = w2 * w3;
+ const double _5w5 = 5.0 * w5;
+ const double _10w5 = 10.0 * w5;
+ const double a = w5 + r5_1 * 2.0 * fw4p8f4w + _4r5_12 * f2w3p2f3w2 + _32f5;
+ const double b = _5w5 + r5_1 * 6.0 * fw4m8f4w + _4r5_12 * f2w3m2f3w2 - _160f5;
+ const double c = _10w5 + r5_1 * 4.0 * fw4p8f4w + _4r5_12 * -2.0 * f2w3p2f3w2 + _320f5;
+ const double d = _10w5 + r5_1 * -4.0 * fw4m8f4w + _4r5_12 * -2.0 * f2w3m2f3w2 - _320f5;
+ const double e = _5w5 + r5_1 * -6.0 * fw4p8f4w + _4r5_12 * f2w3p2f3w2 + _160f5;
+ const double f = w5 + r5_1 * -2.0 * fw4m8f4w + _4r5_12 * f2w3m2f3w2 - _32f5;
+ data->signal[i] = (f5 * (32.0 * (x - data->x5)
+ + 160.0 * (data->x4
+ - data->x1)
+ + 320.0 * (data->x2
+ - data->x3))
+ - (b * data->y1
+ + c * data->y2
+ + d * data->y3
+ + e * data->y4
+ + f * data->y5)) / a;
+ data->x5 = data->x4;
+ data->x4 = data->x3;
+ data->x3 = data->x2;
+ data->x2 = data->x1;
+ data->x1 = x;
+ data->y5 = data->y4;
+ data->y4 = data->y3;
+ data->y3 = data->y2;
+ data->y2 = data->y1;
+ data->y1 = data->signal[i];
+ i++;
+ }
+ return 0;
+}
diff --git a/lib/signal/lowpass.c b/lib/signal/lowpass.c
new file mode 100644
index 0000000..3f1ee54
--- /dev/null
+++ b/lib/signal/lowpass.c
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ * Copyright 2020 Judy Najnudel
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <math.h>
+#include <rtbuf/rtbuf.h>
+#include <rtbuf/signal.h>
+
+int rtbuf_signal_lowpass_start (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_lowpass_data *data;
+ assert(rtb->proc->out_bytes == sizeof(*data));
+ data = (s_rtbuf_signal_lowpass_data*) rtb->data;
+ data->x1 = 0;
+ data->y1 = 0;
+ return 0;
+}
+
+int rtbuf_signal_lowpass (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_fun in;
+ s_rtbuf_signal_fun cutoff;
+ s_rtbuf_signal_lowpass_data *data;
+ unsigned int i = 0;
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_LOWPASS_IN_SIGNAL, &in);
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_LOWPASS_IN_CUTOFF, &cutoff);
+ data = (s_rtbuf_signal_lowpass_data*) rtb->data;
+ while (i < RTBUF_SIGNAL_SAMPLES) {
+ double x = in.sample_fun(in.signal, i);
+ double fc = cutoff.sample_fun(cutoff.signal, i);
+ double k = RTBUF_SIGNAL_SAMPLERATE / (M_PI * fc);
+ data->signal[i] = (x + data->x1 + (k - 1.0) * data->y1) / (1.0 + k);
+ data->x1 = x;
+ data->y1 = data->signal[i];
+ i++;
+ }
+ return 0;
+}
diff --git a/lib/signal/lowpass2.c b/lib/signal/lowpass2.c
new file mode 100644
index 0000000..877fb35
--- /dev/null
+++ b/lib/signal/lowpass2.c
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+/* Butterworth lowpass second order filter
+
+B2: s^2+sqrt(2)*s+1 $
+H: 1/B2 $
+
+*/
+#include <math.h>
+#include <rtbuf/rtbuf.h>
+#include <rtbuf/signal.h>
+
+int rtbuf_signal_lowpass2_start (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_lowpass2_data *data;
+ assert(rtb->proc->out_bytes == sizeof(*data));
+ data = (s_rtbuf_signal_lowpass2_data*) rtb->data;
+ data->x1 = 0.0;
+ data->x2 = 0.0;
+ data->y1 = 0.0;
+ data->y2 = 0.0;
+ return 0;
+}
+
+int rtbuf_signal_lowpass2 (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_fun in;
+ s_rtbuf_signal_fun cutoff;
+ s_rtbuf_signal_lowpass2_data *data;
+ unsigned int i = 0;
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_LOWPASS_IN_SIGNAL, &in);
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_LOWPASS_IN_CUTOFF, &cutoff);
+ data = (s_rtbuf_signal_lowpass2_data*) rtb->data;
+ while (i < RTBUF_SIGNAL_SAMPLES) {
+ double x = in.sample_fun(in.signal, i);
+ double fc = cutoff.sample_fun(cutoff.signal, i);
+ double k = RTBUF_SIGNAL_SAMPLERATE / (M_PI * fc);
+ double k2 = k * k;
+ double k_sqrt2 = M_SQRT2 * k;
+ double z = 1.0 / (k2 + k_sqrt2 + 1);
+ data->signal[i] = z * (x
+ + data->x1 * 2.0
+ + data->x2
+ + data->y1 * 2.0 * (k2 - 1.0)
+ + data->y2 * (k_sqrt2 - (k2 + 1.0)));
+ data->x2 = data->x1;
+ data->x1 = x;
+ data->y2 = data->y1;
+ data->y1 = data->signal[i];
+ i++;
+ }
+ return 0;
+}
diff --git a/lib/signal/lowpass3.c b/lib/signal/lowpass3.c
new file mode 100644
index 0000000..1a37b21
--- /dev/null
+++ b/lib/signal/lowpass3.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ * Copyright 2020 Judy Najnudel
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <math.h>
+#include <rtbuf/rtbuf.h>
+#include <rtbuf/signal.h>
+
+int rtbuf_signal_lowpass3_start (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_lowpass3_data *data;
+ assert(rtb->proc->out_bytes == sizeof(*data));
+ data = (s_rtbuf_signal_lowpass3_data*) rtb->data;
+ data->x1 = 0.0;
+ data->x2 = 0.0;
+ data->x3 = 0.0;
+ data->y1 = 0.0;
+ data->y2 = 0.0;
+ data->y3 = 0.0;
+ return 0;
+}
+
+int rtbuf_signal_lowpass3 (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_fun in;
+ s_rtbuf_signal_fun cutoff;
+ s_rtbuf_signal_lowpass3_data *data;
+ unsigned int i = 0;
+ const double fs = RTBUF_SIGNAL_SAMPLERATE;
+ const double fs2 = fs * fs;
+ const double fs3 = fs2 * fs;
+ const double _8fs3 = 8.0 * fs3;
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_LOWPASS_IN_SIGNAL, &in);
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_LOWPASS_IN_CUTOFF, &cutoff);
+ data = (s_rtbuf_signal_lowpass3_data*) rtb->data;
+ while (i < RTBUF_SIGNAL_SAMPLES) {
+ const double x = in.sample_fun(in.signal, i);
+ const double fc = cutoff.sample_fun(cutoff.signal, i);
+ const double wc = 2.0 * M_PI * fc;
+ const double wc2 = wc * wc;
+ const double wc3 = wc2 * wc;
+ const double _4fs2wc = 4.0 * fs2 * wc;
+ const double _8fs2wc = 2.0 * _4fs2wc;
+ const double _4fswc2 = 4.0 * fs * wc2;
+ const double _3wc3 = 3.0 * wc3;
+ const double a = wc3 + _4fswc2 + _8fs2wc + _8fs3;
+ const double b = _8fs2wc + 24.0 * fs3 - (_3wc3 + _4fswc2);
+ const double c = _4fswc2 + _8fs2wc - (24.0 * fs3 + _3wc3);
+ const double d = _8fs3 + _4fswc2 - (wc3 + _8fs2wc);
+ data->signal[i] = (wc3 * (x
+ + 3.0 * (data->x1 +
+ data->x2)
+ + data->x3)
+ + b * data->y1
+ + c * data->y2
+ + d * data->y3) / a;
+ data->x3 = data->x2;
+ data->x2 = data->x1;
+ data->x1 = x;
+ data->y3 = data->y2;
+ data->y2 = data->y1;
+ data->y1 = data->signal[i];
+ i++;
+ }
+ return 0;
+}
diff --git a/lib/signal/lowpass4.c b/lib/signal/lowpass4.c
new file mode 100644
index 0000000..b98f362
--- /dev/null
+++ b/lib/signal/lowpass4.c
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+/* Butterworth lowpass fourth order filter
+a: cos(5*%pi/8) $
+b: cos(7*%pi/8) $
+s: 2*F*(1-z)/(1+z) $
+B4:((s/w)^2-2*(s/w)*a+1)*((s/w)^2-2*s/w*b+1) $
+H: 1/B4 $
+ratsimp(H);
+ 4 4 4 3 4 2 4 4
+(%o8) (w z + 4 w z + 6 w z + 4 w z + w )
+ 4 3 2 2 2 3 3
+/((w + (4 F b + 4 F a) w + (16 F a b + 8 F ) w + (16 F b + 16 F a) w
+ 4 4 4 3 3 3
+ + 16 F ) z + (4 w + (8 F b + 8 F a) w + ((- 32 F b) - 32 F a) w
+ 4 3 4 2 2 2 4 2
+ - 64 F ) z + (6 w + ((- 32 F a b) - 16 F ) w + 96 F ) z
+ 4 3 3 3 4 4
+ + (4 w + ((- 8 F b) - 8 F a) w + (32 F b + 32 F a) w - 64 F ) z + w
+ 3 2 2 2
+ + ((- 4 F b) - 4 F a) w + (16 F a b + 8 F ) w
+ 3 3 4
+ + ((- 16 F b) - 16 F a) w + 16 F )
+
+c: 16*F^4+( 16*b+16*a)*F^3*w+(16*a*b +8)*F^2*w^2+( 4*b+4*a)*F*w^3+ w^4 $
+d: -64*F^4+(-32*b-32*a)*F^3*w +( 8*b+8*a)*F*w^3+4*w^4 $
+e: 96*F^4 +(-32*a*b-16)*F^2*w^2 +6*w^4 $
+f: -64*F^4+( 32*b+32*a)*F^3*w +(-8*b-8*a)*F*w^3+4*w^4 $
+g: 16*F^4+(-16*b-16*a)*F^3*w+(16*a*b +8)*F^2*w^2+(-4*b-4*a)*F*w^3+ w^4 $
+
+c: 16*F^4 + 16*(a+b)*F^3*w + (16*a*b+8)*F^2*w^2 + 4*(a+b)*F*w^3 + w^4 $
+d: -(64*F^4 + 32*(a+b)*F^3*w) + 8*(a+b)*F*w^3 + 4*w^4 $
+e: 96*F^4 -2*(16*a*b+8)*F^2*w^2 + 6*w^4 $
+f: -64*F^4 + 32*(a+b)*F^3*w - 8*(a+b)*F*w^3 + 4*w^4 $
+g: 16*F^4 - 16*(a+b)*F^3*w + (16*a*b+8)*F^2*w^2 - 4*(a+b)*F*w^3 + w^4 $
+
+y: (w4*(x4+4*x3+6*x2+4*x1+x)-(c*y4+d*y3+e*y2+f*y1))/g $
+*/
+#include <math.h>
+#include <rtbuf/rtbuf.h>
+#include <rtbuf/signal.h>
+
+int rtbuf_signal_lowpass4_start (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_lowpass4_data *data;
+ assert(rtb->proc->out_bytes == sizeof(*data));
+ data = (s_rtbuf_signal_lowpass4_data*) rtb->data;
+ data->x1 = 0.0;
+ data->x2 = 0.0;
+ data->x3 = 0.0;
+ data->x4 = 0.0;
+ data->y1 = 0.0;
+ data->y2 = 0.0;
+ data->y3 = 0.0;
+ data->y4 = 0.0;
+ return 0;
+}
+
+int rtbuf_signal_lowpass4 (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_fun in;
+ s_rtbuf_signal_fun cutoff;
+ s_rtbuf_signal_lowpass4_data *data;
+ unsigned int i = 0;
+ const double a = cos(5.0 * M_PI / 8.0);
+ const double b = cos(7.0 * M_PI / 8.0);
+ const double f = RTBUF_SIGNAL_SAMPLERATE;
+ const double _4a_bf = 4.0 * (a + b) * f;
+ const double f2 = f * f;
+ const double _16ab_8f2 = (16.0 * a * b + 8.0) * f2;
+ const double f3 = f2 * f;
+ const double _16a_bf3 = 16.0 * (a + b) * f3;
+ const double f4 = f2 * f2;
+ const double _16f4 = 16.0 * f4;
+ const double _64f4 = 64.0 * f4;
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_LOWPASS_IN_SIGNAL, &in);
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_LOWPASS_IN_CUTOFF, &cutoff);
+ data = (s_rtbuf_signal_lowpass4_data*) rtb->data;
+ while (i < RTBUF_SIGNAL_SAMPLES) {
+ const double x = in.sample_fun(in.signal, i);
+ const double fc = cutoff.sample_fun(cutoff.signal, i);
+ const double w = 2.0 * M_PI * fc;
+ const double _16a_bf3w = _16a_bf3 * w;
+ const double _32a_bf3w = 2.0 * _16a_bf3w;
+ const double w2 = w * w;
+ const double _16ab_8f2w2 = _16ab_8f2 * w2;
+ const double w3 = w2 * w;
+ const double _4a_bfw3 = _4a_bf * w3;
+ const double _8a_bfw3 = 2.0 * _4a_bfw3;
+ const double w4 = w2 * w2;
+ const double _4w4 = 4.0 * w4;
+ const double c = _16f4 + _16a_bf3w + _16ab_8f2w2 + _4a_bfw3 + w4;
+ const double d = -(_64f4 + _32a_bf3w) + _8a_bfw3 + _4w4;
+ const double e = 96.0 * f4 - 2.0 * _16ab_8f2w2 + 6.0 * w4;
+ const double f = - _64f4 + _32a_bf3w - _8a_bfw3 + _4w4;
+ const double g = _16f4 - _16a_bf3w + _16ab_8f2w2 - _4a_bfw3 + w4;
+ data->signal[i] = (w4 * (x
+ + 4.0 * (data->x1 +
+ data->x3)
+ + 6.0 * data->x2
+ + data->x4)
+ - (c * data->y4
+ + d * data->y3
+ + e * data->y2
+ + f * data->y1)) / g;
+ data->x4 = data->x3;
+ data->x3 = data->x2;
+ data->x2 = data->x1;
+ data->x1 = x;
+ data->y4 = data->y3;
+ data->y3 = data->y2;
+ data->y2 = data->y1;
+ data->y1 = data->signal[i];
+ i++;
+ }
+ return 0;
+}
diff --git a/lib/signal/lowpass5.c b/lib/signal/lowpass5.c
new file mode 100644
index 0000000..570c4aa
--- /dev/null
+++ b/lib/signal/lowpass5.c
@@ -0,0 +1,147 @@
+/*
+ * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+/* Butterworth lowpass fifth order filter
+a: (sqrt(5)-1)/2 $
+b: (sqrt(5)+1)/2 $
+s: 2*F*(1-z)/(1+z) $
+B5:(s/w+1)*((s/w)^2+a*(s/w)+1)*((s/w)^2+b*s/w+1) $
+H: 1/B5 $
+ratsimp(H);
+ 5 5 5 4 5 3 5 2 5 5
+(w z + 5 w z + 10 w z + 10 w z + 5 w z + w )
+ 5 4 2 3
+/((w + ((- 2 sqrt(5)) - 2) F w + (4 sqrt(5) + 12) F w
+ 3 2 4 5 5
+ + ((- 8 sqrt(5)) - 24) F w + (16 sqrt(5) + 16) F w - 32 F ) z
+ 5 4 2 3
+ + (5 w + ((- 6 sqrt(5)) - 6) F w + (4 sqrt(5) + 12) F w
+ 3 2 4 5 4
+ + (8 sqrt(5) + 24) F w + ((- 48 sqrt(5)) - 48) F w + 160 F ) z
+ 5 4 2 3
+ + (10 w + ((- 4 sqrt(5)) - 4) F w + ((- 8 sqrt(5)) - 24) F w
+ 3 2 4 5 3
+ + (16 sqrt(5) + 48) F w + (32 sqrt(5) + 32) F w - 320 F ) z
+ 5 4 2 3
+ + (10 w + (4 sqrt(5) + 4) F w + ((- 8 sqrt(5)) - 24) F w
+ 3 2 4 5 2
+ + ((- 16 sqrt(5)) - 48) F w + (32 sqrt(5) + 32) F w + 320 F ) z
+ 5 4 2 3
+ + (5 w + (6 sqrt(5) + 6) F w + (4 sqrt(5) + 12) F w
+ 3 2 4 5
+ + ((- 8 sqrt(5)) - 24) F w + ((- 48 sqrt(5)) - 48) F w - 160 F ) z
+ 5 4 2 3
+ + w + (2 sqrt(5) + 2) F w + (4 sqrt(5) + 12) F w
+ 3 2 4 5
+ + (8 sqrt(5) + 24) F w + (16 sqrt(5) + 16) F w + 32 F )
+
+a: w5 + (r5 + 1)( 2)(f w4 + 8 f4 w) + (4 r5 + 12) (f2 w3 + 2 f3 w2) + 32 f5; z
+b: 5 w5 + (r5 + 1)( 6)(f w4 - 8 f4 w) + (4 r5 + 12) (f2 w3 - 2 f3 w2) - 160 f5; z1
+c: 10 w5 + (r5 + 1)( 4)(f w4 + 8 f4 w) + (4 r5 + 12)(-2)(f2 w3 + 2 f3 w2) + 320 f5; z2
+d: 10 w5 + (r5 + 1)(-4)(f w4 - 8 f4 w) + (4 r5 + 12)(-2)(f2 w3 - 2 f3 w2) - 320 f5; z3
+e: 5 w5 + (r5 + 1)(-6)(f w4 + 8 f4 w) + (4 r5 + 12) (f2 w3 + 2 f3 w2) + 160 f5; z4
+f: w5 + (r5 + 1)(-2)(f w4 - 8 f4 w) + (4 r5 + 12) (f2 w3 - 2 f3 w2) - 32 f5; z5
+
+*/
+#include <math.h>
+#include <rtbuf/rtbuf.h>
+#include <rtbuf/signal.h>
+
+int rtbuf_signal_lowpass5_start (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_lowpass5_data *data;
+ assert(rtb->proc->out_bytes == sizeof(*data));
+ data = (s_rtbuf_signal_lowpass5_data*) rtb->data;
+ data->x1 = 0.0;
+ data->x2 = 0.0;
+ data->x3 = 0.0;
+ data->x4 = 0.0;
+ data->x5 = 0.0;
+ data->y1 = 0.0;
+ data->y2 = 0.0;
+ data->y3 = 0.0;
+ data->y4 = 0.0;
+ data->y5 = 0.0;
+ return 0;
+}
+
+int rtbuf_signal_lowpass5 (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_fun in;
+ s_rtbuf_signal_fun cutoff;
+ s_rtbuf_signal_lowpass5_data *data;
+ unsigned int i = 0;
+ const double r5_1 = sqrt(5.0) + 1.0;
+ const double _4r5_12 = 4.0 * sqrt(5.0) + 12.0;
+ const double f = RTBUF_SIGNAL_SAMPLERATE;
+ const double f2 = f * f;
+ const double f3 = f2 * f;
+ const double f4 = f2 * f2;
+ const double f5 = f2 * f3;
+ const double _32f5 = 32.0 * f5;
+ const double _160f5 = 160.0 * f5;
+ const double _320f5 = 320.0 * f5;
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_LOWPASS_IN_SIGNAL, &in);
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_LOWPASS_IN_CUTOFF, &cutoff);
+ data = (s_rtbuf_signal_lowpass5_data*) rtb->data;
+ while (i < RTBUF_SIGNAL_SAMPLES) {
+ const double x = in.sample_fun(in.signal, i);
+ const double fc = cutoff.sample_fun(cutoff.signal, i);
+ const double w = 2.0 * M_PI * fc;
+ const double _8f4w = 8.0 * f4 * w;
+ const double w2 = w * w;
+ const double _2f3w2 = 2.0 * f3 * w2;
+ const double w3 = w2 * w;
+ const double f2w3 = f2 * w3;
+ const double f2w3p2f3w2 = f2w3 + _2f3w2;
+ const double f2w3m2f3w2 = f2w3 - _2f3w2;
+ const double w4 = w2 * w2;
+ const double fw4 = f * w4;
+ const double fw4p8f4w = (fw4 + _8f4w);
+ const double fw4m8f4w = (fw4 - _8f4w);
+ const double w5 = w2 * w3;
+ const double _5w5 = 5.0 * w5;
+ const double _10w5 = 10.0 * w5;
+ const double a = w5 + r5_1 * 2.0 * fw4p8f4w + _4r5_12 * f2w3p2f3w2 + _32f5;
+ const double b = _5w5 + r5_1 * 6.0 * fw4m8f4w + _4r5_12 * f2w3m2f3w2 - _160f5;
+ const double c = _10w5 + r5_1 * 4.0 * fw4p8f4w + _4r5_12 * -2.0 * f2w3p2f3w2 + _320f5;
+ const double d = _10w5 + r5_1 * -4.0 * fw4m8f4w + _4r5_12 * -2.0 * f2w3m2f3w2 - _320f5;
+ const double e = _5w5 + r5_1 * -6.0 * fw4p8f4w + _4r5_12 * f2w3p2f3w2 + _160f5;
+ const double f = w5 + r5_1 * -2.0 * fw4m8f4w + _4r5_12 * f2w3m2f3w2 - _32f5;
+ data->signal[i] = (w5 * (x
+ + 5.0 * (data->x1
+ + data->x4)
+ + 10.0 * (data->x2
+ + data->x3)
+ + data->x5)
+ - (b * data->y1
+ + c * data->y2
+ + d * data->y3
+ + e * data->y4
+ + f * data->y5)) / a;
+ data->x5 = data->x4;
+ data->x4 = data->x3;
+ data->x3 = data->x2;
+ data->x2 = data->x1;
+ data->x1 = x;
+ data->y5 = data->y4;
+ data->y4 = data->y3;
+ data->y3 = data->y2;
+ data->y2 = data->y1;
+ data->y1 = data->signal[i];
+ i++;
+ }
+ return 0;
+}
diff --git a/lib/signal/sawtooth.c b/lib/signal/sawtooth.c
new file mode 100644
index 0000000..ef1a064
--- /dev/null
+++ b/lib/signal/sawtooth.c
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ * Copyright 2020 Judy Najnudel <judy.najnudel@gmail.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <math.h>
+#include <stdio.h>
+#include <rtbuf/rtbuf.h>
+#include <rtbuf/signal.h>
+
+int rtbuf_signal_sawtooth_start (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_sawtooth_data *data;
+ assert(rtb->proc->out_bytes == sizeof(*data));
+ data = (s_rtbuf_signal_sawtooth_data*) rtb->data;
+ data->phase = 0;
+ return 0;
+}
+
+int rtbuf_signal_sawtooth (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_fun freq;
+ s_rtbuf_signal_fun amp;
+ s_rtbuf_signal_sawtooth_data *data;
+ unsigned int i = 0;
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_SAWTOOTH_IN_FREQUENCY, &freq);
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_SAWTOOTH_IN_AMPLITUDE, &);
+ data = (s_rtbuf_signal_sawtooth_data*) rtb->data;
+ while (i < RTBUF_SIGNAL_SAMPLES) {
+ double f = freq.sample_fun(freq.signal, i);
+ double a = amp.sample_fun(amp.signal, i);
+ f = max(0.0, f);
+ a = max(0.0, a);
+ f /= (double) RTBUF_SIGNAL_SAMPLERATE;
+ data->phase = fmod(data->phase + f, 1.0);
+ data->signal[i] = a * (2.0 * data->phase - 1.0);
+ i++;
+ }
+ return 0;
+}
diff --git a/lib/signal/sinus.c b/lib/signal/sinus.c
new file mode 100644
index 0000000..c29e691
--- /dev/null
+++ b/lib/signal/sinus.c
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ * Copyright 2018 Judy Najnudel <judy.najnudel@gmail.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <math.h>
+#include <stdio.h>
+#include <rtbuf/rtbuf.h>
+#include <rtbuf/signal.h>
+
+int rtbuf_signal_sinus_start (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_sinus_data *data;
+ assert(rtb->proc->out_bytes == sizeof(*data));
+ data = (s_rtbuf_signal_sinus_data*) rtb->data;
+ data->phase = 0;
+ return 0;
+}
+
+int rtbuf_signal_sinus (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_fun freq;
+ s_rtbuf_signal_fun amp;
+ s_rtbuf_signal_sinus_data *data;
+ unsigned int i = 0;
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_SINUS_IN_FREQUENCY, &freq);
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_SINUS_IN_AMPLITUDE, &);
+ data = (s_rtbuf_signal_sinus_data*) rtb->data;
+ while (i < RTBUF_SIGNAL_SAMPLES) {
+ double f = freq.sample_fun(freq.signal, i);
+ double a = amp.sample_fun(amp.signal, i);
+ f = max(0.0, f);
+ a = max(0.0, a);
+ f /= (double) RTBUF_SIGNAL_SAMPLERATE;
+ data->phase = fmod(data->phase + 2.0 * M_PI * f, 2.0 * M_PI);
+ data->signal[i] = a * sin(data->phase);
+ /* printf(" i=%u f=%f a=%f %f", i, f, a, data->samples[i]); */
+ i++;
+ }
+ return 0;
+}
diff --git a/lib/signal/square.c b/lib/signal/square.c
new file mode 100644
index 0000000..b3b004a
--- /dev/null
+++ b/lib/signal/square.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <math.h>
+#include <stdio.h>
+#include <rtbuf/rtbuf.h>
+#include <rtbuf/signal.h>
+
+static
+double square (double amp, double phase, double pulse)
+{
+ return phase < pulse ? amp : -amp;
+}
+
+int rtbuf_signal_square (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_fun freq;
+ s_rtbuf_signal_fun amp;
+ s_rtbuf_signal_fun pulse;
+ s_rtbuf_signal_square_data *data;
+ unsigned int i = 0;
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_SQUARE_IN_FREQUENCY, &freq);
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_SQUARE_IN_AMPLITUDE, &);
+ rtbuf_signal_fun(rtb, RTBUF_SIGNAL_SQUARE_IN_PULSE, &pulse);
+ data = (s_rtbuf_signal_square_data*) rtb->data;
+ while (i < RTBUF_SIGNAL_SAMPLES) {
+ double f = freq.sample_fun(freq.signal, i);
+ double a = amp.sample_fun(amp.signal, i);
+ double p = pulse.sample_fun(pulse.signal, i);
+ f = max(0.0, f);
+ a = max(0.0, a);
+ p = clamp(0.0, p, 1.0);
+ /* printf(" i=%u freq=%f amp=%f pulse=%f", i, f, a, p); */
+ f /= (double) RTBUF_SIGNAL_SAMPLERATE;
+ data->phase = fmod(data->phase + f, 1.0);
+ data->signal[i] = square(a, data->phase, p);
+ /* printf(" f=%f a=%f p=%f square=%f", f, a, p, data->samples[i]); */
+ i++;
+ }
+ return 0;
+}
+
+int rtbuf_signal_square_start (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_square_data *data;
+ assert(rtb->proc->out_bytes == sizeof(*data));
+ data = (s_rtbuf_signal_square_data*) rtb->data;
+ data->phase = 0;
+ return 0;
+}
diff --git a/lib/signal_type.c b/lib/signal_type.c
new file mode 100644
index 0000000..f8446ee
--- /dev/null
+++ b/lib/signal_type.c
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <rtbuf/rtbuf.h>
+#include <rtbuf/signal.h>
+
+int main ()
+{
+ printf("/* file generated by rtbuf_signal_type */\n");
+ printf("#ifndef RTBUF_SIGNAL_TYPE_H\n"
+ "#define RTBUF_SIGNAL_TYPE_H\n"
+ "\n");
+ printf("#define RTBUF_SIGNAL_TYPE"
+ " RTBUF_SIGNAL_SAMPLE_TYPE \"[%u]\"\n",
+ RTBUF_SIGNAL_SAMPLES);
+ printf("#define RTBUF_SIGNAL_DELAY_TYPE"
+ " RTBUF_SIGNAL_SAMPLE_TYPE \"[%u]\"\n",
+ RTBUF_SIGNAL_DELAY_SAMPLES_MAX);
+ printf("#define RTBUF_SIGNAL_FLANGER_TYPE"
+ " RTBUF_SIGNAL_SAMPLE_TYPE \"[%u]\"\n",
+ RTBUF_SIGNAL_FLANGER_SAMPLES_MAX);
+ printf("\n"
+ "#endif\n");
+ return 0;
+}
diff --git a/lib/sndio/rtbuf_sndio.c b/lib/sndio/rtbuf_sndio.c
new file mode 100644
index 0000000..be4ce7d
--- /dev/null
+++ b/lib/sndio/rtbuf_sndio.c
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sndio.h>
+#include <stdio.h>
+#include <strings.h>
+#include "rtbuf.h"
+#include "rtbuf_lib.h"
+#include "rtbuf_signal.h"
+#include "rtbuf_signal_type.h"
+#include "rtbuf_sndio.h"
+#include "rtbuf_sndio_type.h"
+
+s_rtbuf_lib_proc_out g_rtbuf_sndio_input_out[] = {
+ { "left", RTBUF_SIGNAL_TYPE },
+ { "right", RTBUF_SIGNAL_TYPE },
+ { "samples", RTBUF_SNDIO_SAMPLES_TYPE },
+ { 0, 0 } };
+
+s_rtbuf_lib_proc_in g_rtbuf_sndio_output_in[] = {
+ { "left", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
+ { "right", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
+ { 0, 0, 0.0, 0.0, 0.0 } };
+
+s_rtbuf_lib_proc_out g_rtbuf_sndio_output_out[] = {
+ { "samples", RTBUF_SNDIO_SAMPLES_TYPE },
+ { "reserved", RTBUF_SNDIO_OUTPUT_RESERVED_TYPE },
+ { 0, 0 } };
+
+const char *rtbuf_lib_name = "sndio";
+unsigned long rtbuf_lib_ver = RTBUF_LIB_VER;
+s_rtbuf_lib_proc rtbuf_lib_proc[] = {
+ { "input", rtbuf_sndio_input, rtbuf_sndio_input_start,
+ rtbuf_sndio_input_stop, 0, g_rtbuf_sndio_input_out },
+ { "output", rtbuf_sndio_output, rtbuf_sndio_output_start,
+ rtbuf_sndio_output_stop, g_rtbuf_sndio_output_in,
+ g_rtbuf_sndio_output_out },
+ { 0, 0, 0, 0, 0, 0 } };
+
+void print_sio_par (struct sio_par *par)
+{
+ printf("#<sio_par bits=%i sig=%i rchan=%i pchan=%i rate=%i>",
+ par->bits, par->sig, par->rchan, par->pchan, par->rate);
+}
diff --git a/lib/sndio/rtbuf_sndio.h b/lib/sndio/rtbuf_sndio.h
new file mode 100644
index 0000000..f8f7da2
--- /dev/null
+++ b/lib/sndio/rtbuf_sndio.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifndef RTBUF_SNDIO_H
+#define RTBUF_SNDIO_H
+
+#include <sndio.h>
+#include "rtbuf_signal.h"
+
+void print_sio_par (struct sio_par *par);
+
+enum {
+ RTBUF_SNDIO_LEFT = 0,
+ RTBUF_SNDIO_RIGHT,
+ RTBUF_SNDIO_CHANNELS
+};
+
+#define RTBUF_SNDIO_SAMPLE_TYPE "short"
+#define RTBUF_SNDIO_SAMPLES \
+ (RTBUF_SNDIO_CHANNELS * RTBUF_SIGNAL_SAMPLES)
+
+typedef short t_rtbuf_sndio_sample;
+typedef t_rtbuf_sndio_sample t_rtbuf_sndio_samples[RTBUF_SNDIO_SAMPLES];
+
+typedef struct rtbuf_sndio_input_data {
+ t_rtbuf_signal signal[RTBUF_SNDIO_CHANNELS];
+ t_rtbuf_sndio_samples samples;
+} s_rtbuf_sndio_input_data;
+
+int rtbuf_sndio_input (s_rtbuf *rtb);
+int rtbuf_sndio_input_start (s_rtbuf *rtb);
+int rtbuf_sndio_input_stop (s_rtbuf *rtb);
+
+typedef struct rtbuf_sndio_output_reserved {
+ struct sio_hdl *sio_hdl;
+ struct sio_par want;
+ struct sio_par have;
+} s_rtbuf_sndio_output_reserved;
+
+typedef struct rtbuf_sndio_output_data {
+ t_rtbuf_sndio_samples samples;
+ s_rtbuf_sndio_output_reserved reserved;
+} s_rtbuf_sndio_output_data;
+
+#define RTBUF_SNDIO_OUTPUT_RESERVED_SIZE \
+ sizeof(s_rtbuf_sndio_output_reserved)
+
+int rtbuf_sndio_output (s_rtbuf *rtb);
+int rtbuf_sndio_output_start (s_rtbuf *rtb);
+int rtbuf_sndio_output_stop (s_rtbuf *rtb);
+
+#endif
diff --git a/lib/sndio/rtbuf_sndio_input.c b/lib/sndio/rtbuf_sndio_input.c
new file mode 100644
index 0000000..86a9598
--- /dev/null
+++ b/lib/sndio/rtbuf_sndio_input.c
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sndio.h>
+#include <stdio.h>
+#include <strings.h>
+#include "rtbuf.h"
+#include "rtbuf_signal.h"
+#include "rtbuf_sndio.h"
+
+int rtbuf_sndio_input (s_rtbuf *rtb)
+{
+ /*
+ s_sndio_input_data *data = (s_sndio_input_data*) rtb->data;
+ */
+ (void) rtb;
+ return 0;
+}
+
+int rtbuf_sndio_input_start (s_rtbuf *rtb)
+{
+ s_rtbuf_sndio_input_data *data;
+ assert(rtb->proc->out_bytes == sizeof(*data));
+ data = (s_rtbuf_sndio_input_data*) rtb->data;
+ return 0;
+}
+
+int rtbuf_sndio_input_stop (s_rtbuf *rtb)
+{
+ (void) rtb;
+ return 0;
+}
diff --git a/lib/sndio/rtbuf_sndio_output.c b/lib/sndio/rtbuf_sndio_output.c
new file mode 100644
index 0000000..72f0653
--- /dev/null
+++ b/lib/sndio/rtbuf_sndio_output.c
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <limits.h>
+#include <sndio.h>
+#include <stdio.h>
+#include <strings.h>
+#include "rtbuf.h"
+#include "rtbuf_sndio.h"
+
+void rtbuf_sndio_output_parameters (struct sio_par *want)
+{
+ bzero(want, sizeof(struct sio_par));
+ sio_initpar(want);
+ want->bits = 16;
+ want->sig = 1;
+ want->rchan = 0;
+ want->pchan = RTBUF_SNDIO_CHANNELS;
+ want->rate = RTBUF_SIGNAL_SAMPLERATE;
+ want->appbufsz = RTBUF_SIGNAL_SAMPLES;
+ want->xrun = SIO_IGNORE;
+ print_sio_par(want); printf("\n");
+}
+
+int rtbuf_sndio_output_check_parameters (struct sio_par *have)
+{
+ int ok;
+ print_sio_par(have);
+ printf("\n");
+ ok = (have->bits == 16 &&
+ have->sig == 1 &&
+ have->rchan == 0 &&
+ have->pchan == RTBUF_SNDIO_CHANNELS &&
+ have->rate == RTBUF_SIGNAL_SAMPLERATE);
+ return ok;
+}
+
+int rtbuf_sndio_output_start (s_rtbuf *rtb)
+{
+ s_rtbuf_sndio_output_data *data;
+ s_rtbuf_sndio_output_reserved *res;
+ int err = 0;
+ assert(rtb->proc->out_bytes == sizeof(*data));
+ data = (s_rtbuf_sndio_output_data*) rtb->data;
+ res = &data->reserved;
+ if (!res->sio_hdl) {
+ res->sio_hdl = sio_open(SIO_DEVANY, SIO_PLAY, 0);
+ if (!res->sio_hdl)
+ err = rtbuf_err("sndio_output_start: sio_open failed");
+ else {
+ rtbuf_sndio_output_parameters(&res->want);
+ if (sio_setpar(res->sio_hdl,
+ &res->want) != 1)
+ err = rtbuf_err("sndio_output_start: sio_setpar failed");
+ else if (sio_getpar(res->sio_hdl,
+ &res->have) != 1)
+ err = rtbuf_err("sndio_output_start: sio_getpar failed");
+ else if (!rtbuf_sndio_output_check_parameters(&res->have))
+ err = rtbuf_err("sndio_output_start: check_parameters failed");
+ else if (sio_start(res->sio_hdl) != 1)
+ err = rtbuf_err("sndio_output_start: sio_start failed");
+ }
+ }
+ return err;
+}
+
+int rtbuf_sndio_output_stop (s_rtbuf *rtb)
+{
+ s_rtbuf_sndio_output_data *data;
+ data = (s_rtbuf_sndio_output_data*) rtb->data;
+ if (data->reserved.sio_hdl) {
+ sio_close(data->reserved.sio_hdl);
+ data->reserved.sio_hdl = 0;
+ }
+ return 0;
+}
+
+int rtbuf_sndio_output (s_rtbuf *rtb)
+{
+ s_rtbuf_signal_fun in[RTBUF_SNDIO_CHANNELS];
+ s_rtbuf_sndio_output_data *data;
+ short *sample;
+ unsigned int i = 0;
+ unsigned int j = 0;
+ assert(rtb);
+ assert(rtb->data);
+ assert(rtb->proc);
+ while (j < RTBUF_SNDIO_CHANNELS) {
+ rtbuf_signal_fun(rtb, j, &in[j]);
+ j++;
+ }
+ data = (s_rtbuf_sndio_output_data*) rtb->data;
+ sample = data->samples;
+ /* printf("sndio_output"); */
+ while (i < RTBUF_SIGNAL_SAMPLES) {
+ j = 0;
+ while (j < RTBUF_SNDIO_CHANNELS) {
+ double in_ = in[j].sample_fun(in[j].signal, i);
+ in_ = clamp(-1.0, in_, 1.0);
+ if (in_ < 0.0)
+ in_ *= -SHRT_MIN;
+ else
+ in_ *= SHRT_MAX;
+ *sample = (short) in_;
+ sample++;
+ j++;
+ }
+ i++;
+ }
+ sio_write(data->reserved.sio_hdl, data->samples,
+ sizeof(t_rtbuf_sndio_samples));
+ /* printf("\n"); */
+ return 0;
+}
diff --git a/lib/sndio/rtbuf_sndio_type.c b/lib/sndio/rtbuf_sndio_type.c
new file mode 100644
index 0000000..a616900
--- /dev/null
+++ b/lib/sndio/rtbuf_sndio_type.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include "rtbuf.h"
+#include "rtbuf_sndio.h"
+
+int main ()
+{
+ printf("/* file generated by rtbuf_sndio_type */\n");
+ printf("#ifndef RTBUF_SNDIO_TYPE_H\n"
+ "#define RTBUF_SNDIO_TYPE_H\n"
+ "\n");
+ printf("#define RTBUF_SNDIO_SAMPLES_TYPE RTBUF_SNDIO_SAMPLE_TYPE"
+ " \"[%u]\"\n",
+ RTBUF_SNDIO_SAMPLES);
+ printf("#define RTBUF_SNDIO_OUTPUT_RESERVED_TYPE"
+ " \"char[%u]\"\n",
+ (unsigned int) RTBUF_SNDIO_OUTPUT_RESERVED_SIZE);
+ printf("\n"
+ "#endif\n");
+ return 0;
+}
diff --git a/lib/synth/rtbuf_synth.c b/lib/synth/rtbuf_synth.c
new file mode 100644
index 0000000..8fd9cef
--- /dev/null
+++ b/lib/synth/rtbuf_synth.c
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <float.h>
+#include <stdio.h>
+#include "rtbuf.h"
+#include "rtbuf_lib.h"
+#include "rtbuf_signal.h"
+#include "rtbuf_signal_type.h"
+#include "rtbuf_music.h"
+#include "rtbuf_music_type.h"
+#include "rtbuf_synth.h"
+
+s_rtbuf_lib_proc_in g_rtbuf_synth_adsr_in[] = {
+ RTBUF_MUSIC_NOTE_IN(),
+ { "attack", RTBUF_SIGNAL_TYPE, 0.02, 0.0, 2.0 },
+ { "decay", RTBUF_SIGNAL_TYPE, 0.01, 0.0, 2.0 },
+ { "sustain", RTBUF_SIGNAL_TYPE, 0.4, 0.0, 1.0 },
+ { "release", RTBUF_SIGNAL_TYPE, 0.3, 0.0, 10.0 },
+ { 0, 0, 0.0, 0.0, 0.0 } };
+
+s_rtbuf_lib_proc_out g_rtbuf_synth_adsr_out[] = {
+ { "signal", RTBUF_SIGNAL_TYPE },
+ { "state", "int" },
+ { 0, 0 } };
+
+s_rtbuf_lib_proc_in g_rtbuf_synth_synth_in[] = {
+ { "envelope", RTBUF_SIGNAL_TYPE, 1.0, 0.0, 1.0 },
+ { "oscillator", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
+ RTBUF_MUSIC_NOTES_IN("note"),
+ { 0, 0, 0.0, 0.0, 0.0 } };
+
+s_rtbuf_lib_proc_out g_rtbuf_synth_synth_out[] = {
+ { "signal", RTBUF_SIGNAL_TYPE },
+ { "note_n", "unsigned int" },
+ { 0, 0 } };
+
+const char *rtbuf_lib_name = "synth";
+unsigned long rtbuf_lib_ver = RTBUF_LIB_VER;
+s_rtbuf_lib_proc rtbuf_lib_proc[] = {
+ { "adsr", rtbuf_synth_adsr, rtbuf_synth_adsr_start, 0,
+ g_rtbuf_synth_adsr_in, g_rtbuf_synth_adsr_out },
+ { "synth", rtbuf_synth_synth, rtbuf_synth_synth_start, 0,
+ g_rtbuf_synth_synth_in, g_rtbuf_synth_synth_out },
+ { 0, 0, 0, 0, 0, 0 } };
+
+int rtbuf_lib_init (s_rtbuf_lib *lib)
+{
+ (void) lib;
+ rtbuf_music_init();
+ return 0;
+}
diff --git a/lib/synth/rtbuf_synth.h b/lib/synth/rtbuf_synth.h
new file mode 100644
index 0000000..a1124b1
--- /dev/null
+++ b/lib/synth/rtbuf_synth.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifndef RTBUF_SYNTH_H
+#define RTBUF_SYNTH_H
+
+#include "rtbuf.h"
+#include "rtbuf_music.h"
+#include "rtbuf_music_type.h"
+#include "rtbuf_signal.h"
+#include "rtbuf_synth_type.h"
+
+/* adsr */
+
+enum {
+ RTBUF_MUSIC_NOTE_IN_ENUM(RTBUF_SYNTH_ADSR_IN),
+ RTBUF_SYNTH_ADSR_IN_ATTACK,
+ RTBUF_SYNTH_ADSR_IN_DECAY,
+ RTBUF_SYNTH_ADSR_IN_SUSTAIN,
+ RTBUF_SYNTH_ADSR_IN_RELEASE,
+ RTBUF_SYNTH_ADSR_IN_N
+};
+
+enum {
+ RTBUF_SYNTH_ENVELOPE_STATE_NOT_STARTED = 0,
+ RTBUF_SYNTH_ENVELOPE_STATE_STARTED,
+ RTBUF_SYNTH_ENVELOPE_STATE_ENDED
+};
+
+#pragma pack(push,1)
+typedef struct rtbuf_synth_adsr_data {
+ t_rtbuf_signal signal;
+ int state;
+} s_rtbuf_synth_adsr_data;
+#pragma pack(pop)
+
+int rtbuf_synth_adsr (s_rtbuf *rtb);
+int rtbuf_synth_adsr_start (s_rtbuf *rtb);
+
+/* synth */
+
+enum {
+ RTBUF_SYNTH_SYNTH_IN_ENVELOPE = 0,
+ RTBUF_SYNTH_SYNTH_IN_OSCILLATOR,
+ RTBUF_SYNTH_SYNTH_IN_NOTES,
+ RTBUF_SYNTH_NOTES_IN_ENUM(RTBUF_SYNTH_SYNTH_IN_NOTE),
+ RTBUF_SYNTH_SYNTH_IN_N
+};
+
+#define RTBUF_SYNTH_SYNTH_IN_NOTE_ENVELOPE(i) \
+ (RTBUF_SYNTH_SYNTH_IN_NOTE_0_ENVELOPE + 2 * i)
+
+#define RTBUF_SYNTH_SYNTH_IN_NOTE_OSCILLATOR(i) \
+ (RTBUF_SYNTH_SYNTH_IN_NOTE_0_OSCILLATOR + 2 * i)
+
+#pragma pack(push,1)
+typedef struct rtbuf_synth_synth_data
+{
+ t_rtbuf_signal signal;
+ unsigned int note_n;
+} s_rtbuf_synth_synth_data;
+#pragma pack(pop)
+
+int rtbuf_synth_synth (s_rtbuf *rtb);
+int rtbuf_synth_synth_start (s_rtbuf *rtb);
+
+#endif /* RTBUF_SYNTH_H */
diff --git a/lib/synth/rtbuf_synth_adsr.c b/lib/synth/rtbuf_synth_adsr.c
new file mode 100644
index 0000000..3fbcf51
--- /dev/null
+++ b/lib/synth/rtbuf_synth_adsr.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ * Copyright 2018 Judy Najnudel <judy.najnudel@gmail.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <strings.h>
+#include "rtbuf.h"
+#include "rtbuf_synth.h"
+
+static
+double adsr (double attack, double decay, double sustain,
+ double release, double start, double stop)
+{
+ double t = start;
+ double x;
+ if (stop >= 0.0)
+ t = start - stop;
+ if (t < attack)
+ x = t / attack;
+ else if (t - attack < decay)
+ x = 1.0 + (sustain - 1.0) * (t - attack) / decay;
+ else
+ x = sustain;
+ if (stop < 0.0)
+ return x;
+ if (stop < release)
+ return x * (1.0 - stop / release);
+ return 0.0;
+}
+
+void rtbuf_synth_adsr_signal (s_rtbuf *rtb, double *signal,
+ double velocity, double start,
+ double stop, double r)
+{
+ double a =
+ rtbuf_signal_sample(rtb, RTBUF_SYNTH_ADSR_IN_ATTACK, 0.02);
+ double d =
+ rtbuf_signal_sample(rtb, RTBUF_SYNTH_ADSR_IN_DECAY, 0.01);
+ double s =
+ rtbuf_signal_sample(rtb, RTBUF_SYNTH_ADSR_IN_SUSTAIN, 0.4);
+ unsigned int i = 0;
+ (void) velocity;
+ (void) start;
+ (void) stop;
+ while (i < RTBUF_SIGNAL_SAMPLES) {
+ double dt = (double) i / RTBUF_SIGNAL_SAMPLERATE;
+ double start_i = start + dt;
+ double stop_i = stop < 0 ? stop : stop + dt;
+ a = max(0.0, a);
+ d = max(0.0, d);
+ s = max(0.0, s);
+ r = max(0.0, r);
+ *signal = velocity * adsr(a, d, s, r, start_i, stop_i);
+ signal++;
+ i++;
+ }
+}
+
+int rtbuf_synth_adsr (s_rtbuf *rtb)
+{
+ double vel;
+ double start;
+ s_rtbuf_synth_adsr_data *data;
+ assert(rtb);
+ assert(rtb->data);
+ vel = rtbuf_signal_sample(rtb, RTBUF_SYNTH_ADSR_IN_VELOCITY, 0.0);
+ start = rtbuf_signal_sample(rtb, RTBUF_SYNTH_ADSR_IN_START, -1.0);
+ data = (s_rtbuf_synth_adsr_data*) rtb->data;
+ if (data->state == RTBUF_SYNTH_ENVELOPE_STATE_NOT_STARTED) {
+ if (vel > 0.0 && start >= 0.0)
+ data->state = RTBUF_SYNTH_ENVELOPE_STATE_STARTED;
+ else
+ return 0;
+ }
+ if (data->state == RTBUF_SYNTH_ENVELOPE_STATE_ENDED)
+ return 0;
+ if (data->state == RTBUF_SYNTH_ENVELOPE_STATE_STARTED) {
+ double stop =
+ rtbuf_signal_sample(rtb, RTBUF_SYNTH_ADSR_IN_STOP, -1.0);
+ double rel =
+ rtbuf_signal_sample(rtb, RTBUF_SYNTH_ADSR_IN_RELEASE, 0.3);
+ if (stop > rel) {
+ rtbuf_signal_zero(data->signal);
+ data->state = RTBUF_SYNTH_ENVELOPE_STATE_ENDED;
+ return 0;
+ }
+ rtbuf_synth_adsr_signal(rtb, data->signal, vel, start, stop, rel);
+ return 0;
+ }
+ assert(data->state != data->state);
+ return 0;
+}
+
+int rtbuf_synth_adsr_start (s_rtbuf *rtb)
+{
+ s_rtbuf_synth_adsr_data *data;
+ assert(rtb->data);
+ assert(rtb->proc);
+ assert(rtb->proc->out_bytes == sizeof(*data));
+ data = (s_rtbuf_synth_adsr_data*) rtb->data;
+ data->state = RTBUF_SYNTH_ENVELOPE_STATE_NOT_STARTED;
+ bzero(data->signal, sizeof(t_rtbuf_signal));
+ return 0;
+}
diff --git a/lib/synth/rtbuf_synth_synth.c b/lib/synth/rtbuf_synth_synth.c
new file mode 100644
index 0000000..a165606
--- /dev/null
+++ b/lib/synth/rtbuf_synth_synth.c
@@ -0,0 +1,244 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <strings.h>
+#include "rtbuf.h"
+#include "rtbuf_synth.h"
+#include "rtbuf_synth_type.h"
+
+s_rtbuf * rtbuf_in_rtbuf (s_rtbuf *rtb, unsigned int in)
+{
+ int i;
+ assert(in < rtb->proc->in_n);
+ if ((i = rtb->in[in].rtb) < 0)
+ return 0;
+ return &g_rtbuf[i];
+}
+
+s_rtbuf * rtbuf_synth_synth_note_envelope (s_rtbuf *rtb, unsigned int i)
+{
+ unsigned int j;
+ assert(i < RTBUF_MUSIC_NOTE_MAX);
+ j = RTBUF_SYNTH_SYNTH_IN_NOTE_ENVELOPE(i);
+ return rtbuf_in_rtbuf(rtb, j);
+}
+
+s_rtbuf * rtbuf_synth_synth_note_oscillator (s_rtbuf *rtb,
+ unsigned int i)
+{
+ unsigned int j;
+ assert(i < RTBUF_MUSIC_NOTE_MAX);
+ j = RTBUF_SYNTH_SYNTH_IN_NOTE_OSCILLATOR(i);
+ return rtbuf_in_rtbuf(rtb, j);
+}
+
+void rtbuf_synth_synth_delete_note (s_rtbuf *rtb,
+ unsigned int i)
+{
+ s_rtbuf *env = rtbuf_synth_synth_note_envelope(rtb, i);
+ s_rtbuf *osc = rtbuf_synth_synth_note_oscillator(rtb, i);
+ s_rtbuf_synth_synth_data *data;
+ data = (s_rtbuf_synth_synth_data*) rtb->data;
+ if (env || osc) {
+ printf("synth_synth_delete_note %u\n", i);
+ if (env)
+ rtbuf_delete(env);
+ if (osc)
+ rtbuf_delete(osc);
+ data->note_n--;
+ }
+}
+
+void rtbuf_synth_synth_delete_notes (s_rtbuf *rtb)
+{
+ s_rtbuf_synth_synth_data *data;
+ unsigned int i = 0;
+ data = (s_rtbuf_synth_synth_data*) rtb->data;
+ while (i < RTBUF_MUSIC_NOTE_MAX && data->note_n > 0) {
+ rtbuf_synth_synth_delete_note(rtb, i);
+ i++;
+ }
+}
+
+s_rtbuf * rtbuf_synth_synth_new_envelope (s_rtbuf *rtb,
+ unsigned int i)
+{
+ s_rtbuf *ref = rtbuf_in_rtbuf(rtb, RTBUF_SYNTH_SYNTH_IN_ENVELOPE);
+ int env_i;
+ s_rtbuf *env;
+ unsigned int env_vel;
+ unsigned int env_freq;
+ unsigned int env_start;
+ unsigned int env_stop;
+ s_rtbuf_binding *v = &rtb->in[RTBUF_SYNTH_SYNTH_IN_NOTES];
+ unsigned int kbd_i = v->rtb;
+ unsigned int kbd_notes = v->out;
+ unsigned int note_vel = RTBUF_MUSIC_NOTE_IN_VELOCITY(kbd_notes, i);
+ unsigned int note_freq = RTBUF_MUSIC_NOTE_IN_FREQUENCY(kbd_notes, i);
+ unsigned int note_start = RTBUF_MUSIC_NOTE_IN_START(kbd_notes, i);
+ unsigned int note_stop = RTBUF_MUSIC_NOTE_IN_STOP(kbd_notes, i);
+ assert(rtb > g_rtbuf);
+ if (!ref)
+ return 0;
+ if((env_i = rtbuf_clone(ref)) < 0)
+ return 0;
+ env = &g_rtbuf[env_i];
+ env_vel = rtbuf_in_find(env, "velocity");
+ env_freq = rtbuf_in_find(env, "frequency");
+ env_start = rtbuf_in_find(env, "start");
+ env_stop = rtbuf_in_find(env, "stop");
+ rtbuf_bind(kbd_i, note_vel , env, env_vel);
+ rtbuf_bind(kbd_i, note_freq , env, env_freq);
+ rtbuf_bind(kbd_i, note_start, env, env_start);
+ rtbuf_bind(kbd_i, note_stop , env, env_stop);
+ rtbuf_bind(env_i, 0, rtb, RTBUF_SYNTH_SYNTH_IN_NOTE_ENVELOPE(i));
+ if (env->proc->start)
+ env->proc->start(env);
+ if (env->proc->f)
+ env->proc->f(env);
+ /* rtbuf_print_long(env_i); */
+ printf("synth_synth_new_envelope %u\n", i);
+ return env;
+}
+
+s_rtbuf * rtbuf_synth_synth_new_oscillator (s_rtbuf *rtb,
+ unsigned int i)
+{
+ s_rtbuf *ref =
+ rtbuf_in_rtbuf(rtb, RTBUF_SYNTH_SYNTH_IN_OSCILLATOR);
+ int osc_i;
+ s_rtbuf *osc;
+ unsigned int osc_freq;
+ s_rtbuf_binding *v = &rtb->in[RTBUF_SYNTH_SYNTH_IN_NOTES];
+ unsigned int kbd_i = v->rtb;
+ unsigned int kbd_notes = v->out;
+ unsigned int note_freq = RTBUF_MUSIC_NOTE_IN_FREQUENCY(kbd_notes, i);
+ assert(rtb > g_rtbuf);
+ if (!ref)
+ return 0;
+ if ((osc_i = rtbuf_clone(ref)) < 0)
+ return 0;
+ osc = &g_rtbuf[osc_i];
+ osc_freq = rtbuf_in_find(osc, "frequency");
+ rtbuf_bind(kbd_i, note_freq, osc, osc_freq);
+ rtbuf_bind(osc_i, 0, rtb, RTBUF_SYNTH_SYNTH_IN_NOTE_OSCILLATOR(i));
+ if (osc->proc->start)
+ osc->proc->start(osc);
+ if (osc->proc->f)
+ osc->proc->f(osc);
+ /* rtbuf_print_long(osc_i); */
+ return osc;
+}
+
+void rtbuf_synth_synth_update_note_signal (s_rtbuf *rtb,
+ unsigned int i)
+{
+ s_rtbuf_synth_synth_data *data;
+ s_rtbuf_signal_fun env;
+ s_rtbuf_signal_fun osc;
+ unsigned int j = 0;
+ double *signal;
+ assert(rtb);
+ assert(rtb->data);
+ assert(i < RTBUF_MUSIC_NOTE_MAX);
+ rtbuf_signal_fun(rtb, RTBUF_SYNTH_SYNTH_IN_NOTE_ENVELOPE(i), &env);
+ rtbuf_signal_fun(rtb, RTBUF_SYNTH_SYNTH_IN_NOTE_OSCILLATOR(i), &osc);
+ data = (s_rtbuf_synth_synth_data *) rtb->data;
+ signal = data->signal;
+ while (j < RTBUF_SIGNAL_SAMPLES) {
+ double e = env.sample_fun(env.signal, j);
+ double o = osc.sample_fun(osc.signal, j);
+ e = max(0.0, e);
+ *signal += e * o;
+ /* printf(" e=%f o=%f s=%f", e, o, *signal); */
+ signal++;
+ j++;
+ }
+}
+
+void rtbuf_synth_synth_update_note (s_rtbuf *rtb,
+ unsigned int i)
+{
+ s_rtbuf_synth_synth_data *data;
+ s_rtbuf_music_notes *notes =
+ rtbuf_music_notes(rtb, RTBUF_SYNTH_SYNTH_IN_NOTES);
+ s_rtbuf_music_note *note;
+ assert(notes);
+ assert(i < RTBUF_MUSIC_NOTE_MAX);
+ assert(rtb->data);
+ data = (s_rtbuf_synth_synth_data*) rtb->data;
+ note = ¬es->note[i];
+ if (note->velocity > 0.0 && note->start >= 0.0) {
+ s_rtbuf *env = rtbuf_synth_synth_note_envelope(rtb, i);
+ s_rtbuf *osc = rtbuf_synth_synth_note_oscillator(rtb, i);
+ if (!env || !osc) {
+ if (!env)
+ env = rtbuf_synth_synth_new_envelope(rtb, i);
+ if (!osc)
+ osc = rtbuf_synth_synth_new_oscillator(rtb, i);
+ data->note_n++;
+ }
+ if (env && osc) {
+ unsigned int env_state_out = rtbuf_proc_out_find(env->proc,
+ "state");
+ int env_state = rtbuf_out_int(env, env_state_out,
+ RTBUF_SYNTH_ENVELOPE_STATE_STARTED);
+ if (env_state == RTBUF_SYNTH_ENVELOPE_STATE_STARTED)
+ rtbuf_synth_synth_update_note_signal(rtb, i);
+ }
+ }
+ else
+ rtbuf_synth_synth_delete_note(rtb, i);
+}
+
+int rtbuf_synth_synth (s_rtbuf *rtb)
+{
+ s_rtbuf_music_notes *notes =
+ rtbuf_music_notes(rtb, RTBUF_SYNTH_SYNTH_IN_NOTES);
+ s_rtbuf_synth_synth_data *data;
+ unsigned int i = 0;
+ unsigned int notes_n = notes ? notes->note_n : 0;
+ unsigned int n;
+ data = (s_rtbuf_synth_synth_data*) rtb->data;
+ n = data->note_n;
+ rtbuf_signal_zero(data->signal);
+ while (i < RTBUF_MUSIC_NOTE_MAX && (n > 0 || notes_n > 0)) {
+ s_rtbuf_music_note *note = notes ? ¬es->note[i] : 0;
+ if (rtbuf_music_note_p(note))
+ notes_n--;
+ if (rtbuf_synth_synth_note_envelope(rtb, i))
+ n--;
+ rtbuf_synth_synth_update_note(rtb, i);
+ i++;
+ }
+ return 0;
+}
+
+int rtbuf_synth_synth_start (s_rtbuf *rtb)
+{
+ s_rtbuf_synth_synth_data *data;
+ assert(rtb->proc->out_bytes == sizeof(*data));
+ data = (s_rtbuf_synth_synth_data*) rtb->data;
+ return 0;
+}
+
+int rtbuf_synth_synth_stop (s_rtbuf *rtb)
+{
+ rtbuf_synth_synth_delete_notes(rtb);
+ return 0;
+}
diff --git a/lib/synth/rtbuf_synth_type.c b/lib/synth/rtbuf_synth_type.c
new file mode 100644
index 0000000..c127198
--- /dev/null
+++ b/lib/synth/rtbuf_synth_type.c
@@ -0,0 +1,45 @@
+
+#include <stdio.h>
+#include "rtbuf.h"
+#include "rtbuf_music.h"
+#include "rtbuf_music_type.h"
+
+void notes_in ()
+{
+ unsigned int i = 0;
+ const char *st = "RTBUF_SIGNAL_TYPE";
+ printf("\n"
+ "#define RTBUF_SYNTH_NOTES_IN(note) \\\n");
+ while (i < RTBUF_MUSIC_NOTE_MAX) {
+ printf(" { note \"[%u].envelope\" , %s }, \\\n", i, st);
+ printf(" { note \"[%u].oscillator\", %s }", i, st);
+ if (i < RTBUF_MUSIC_NOTE_MAX - 1)
+ printf(", \\");
+ printf("\n");
+ i++;
+ }
+ i = 0;
+ printf("\n"
+ "#define RTBUF_SYNTH_NOTES_IN_ENUM(note) \\\n");
+ while (i < RTBUF_MUSIC_NOTE_MAX) {
+ printf(" note ## _%u_ENVELOPE , \\\n", i);
+ printf(" note ## _%u_OSCILLATOR", i);
+ if (i < RTBUF_MUSIC_NOTE_MAX - 1)
+ printf(", \\");
+ printf("\n");
+ i++;
+ }
+}
+
+int main ()
+{
+ printf("/* file generated by rtbuf_synth_type */\n");
+ printf("#ifndef RTBUF_SYNTH_TYPE_H\n"
+ "#define RTBUF_SYNTH_TYPE_H\n"
+ "\n"
+ "#include \"rtbuf_signal_type.h\"\n");
+ notes_in();
+ printf("\n"
+ "#endif\n");
+ return 0;
+}
diff --git a/librtbuf/Makefile b/librtbuf/Makefile
new file mode 100644
index 0000000..b28fbf4
--- /dev/null
+++ b/librtbuf/Makefile
@@ -0,0 +1,793 @@
+# Makefile.in generated by automake 1.16.2 from Makefile.am.
+# librtbuf/Makefile. Generated from Makefile.in by configure.
+
+# Copyright (C) 1994-2020 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+
+
+
+
+am__is_gnu_make = { \
+ if test -z '$(MAKELEVEL)'; then \
+ false; \
+ elif test -n '$(MAKE_HOST)'; then \
+ true; \
+ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+ true; \
+ else \
+ false; \
+ fi; \
+}
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/rtbuf
+pkgincludedir = $(includedir)/rtbuf
+pkglibdir = $(libdir)/rtbuf
+pkglibexecdir = $(libexecdir)/rtbuf
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = x86_64-unknown-openbsd6.7
+host_triplet = x86_64-unknown-openbsd6.7
+subdir = librtbuf
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/build-aux/m4/libtool.m4 \
+ $(top_srcdir)/build-aux/m4/ltoptions.m4 \
+ $(top_srcdir)/build-aux/m4/ltsugar.m4 \
+ $(top_srcdir)/build-aux/m4/ltversion.m4 \
+ $(top_srcdir)/build-aux/m4/lt~obsolete.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(rtbuf_include_HEADERS) \
+ $(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+ test -z "$$files" \
+ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+ $(am__cd) "$$dir" && rm -f $$files; }; \
+ }
+am__installdirs = "$(DESTDIR)$(libdir)" \
+ "$(DESTDIR)$(rtbuf_includedir)"
+LTLIBRARIES = $(lib_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+librtbuf_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
+am_librtbuf_la_OBJECTS = librtbuf_la-data.lo librtbuf_la-symbol.lo \
+ librtbuf_la-rtbuf_lib.lo librtbuf_la-rtbuf_type.lo \
+ librtbuf_la-rtbuf_proc.lo librtbuf_la-rtbuf_var.lo \
+ librtbuf_la-rtbuf.lo
+librtbuf_la_OBJECTS = $(am_librtbuf_la_OBJECTS)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+am__v_lt_1 =
+librtbuf_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(librtbuf_la_CFLAGS) \
+ $(CFLAGS) $(librtbuf_la_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_P = $(am__v_P_$(V))
+am__v_P_ = $(am__v_P_$(AM_DEFAULT_VERBOSITY))
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+am__v_at_1 =
+DEFAULT_INCLUDES = -I. -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp
+am__maybe_remake_depfiles = depfiles
+am__depfiles_remade = ./$(DEPDIR)/librtbuf_la-data.Plo \
+ ./$(DEPDIR)/librtbuf_la-rtbuf.Plo \
+ ./$(DEPDIR)/librtbuf_la-rtbuf_lib.Plo \
+ ./$(DEPDIR)/librtbuf_la-rtbuf_proc.Plo \
+ ./$(DEPDIR)/librtbuf_la-rtbuf_type.Plo \
+ ./$(DEPDIR)/librtbuf_la-rtbuf_var.Plo \
+ ./$(DEPDIR)/librtbuf_la-symbol.Plo
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_$(V))
+am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
+am__v_CC_0 = @echo " CC " $@;
+am__v_CC_1 =
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_$(V))
+am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CCLD_0 = @echo " CCLD " $@;
+am__v_CCLD_1 =
+SOURCES = $(librtbuf_la_SOURCES)
+DIST_SOURCES = $(librtbuf_la_SOURCES)
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+HEADERS = $(rtbuf_include_HEADERS)
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates. Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+ BEGIN { nonempty = 0; } \
+ { items[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique. This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+ list='$(am__tagged_files)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in \
+ $(top_srcdir)/build-aux/depcomp
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = ${SHELL} /home/dx/c/rtbuf/rtbuf/build-aux/missing aclocal-1.16
+AMTAR = $${TAR-tar}
+AM_DEFAULT_VERBOSITY = 1
+AR = ar
+AUTOCONF = ${SHELL} /home/dx/c/rtbuf/rtbuf/build-aux/missing autoconf
+AUTOHEADER = ${SHELL} /home/dx/c/rtbuf/rtbuf/build-aux/missing autoheader
+AUTOMAKE = ${SHELL} /home/dx/c/rtbuf/rtbuf/build-aux/missing automake-1.16
+AWK = awk
+CC = cc
+CCDEPMODE = depmode=gcc3
+CFLAGS = -g -O2 -std=c89 -W -Wall -Werror
+CPP = cc -E
+CPPFLAGS = -I/home/dx/c/rtbuf/rtbuf/librtbuf/include -I/home/dx/c/rtbuf/rtbuf/lib/include -I/usr/local/include -I/usr/include
+CYGPATH_W = echo
+DEFS = -DHAVE_CONFIG_H
+DEPDIR = .deps
+DLLTOOL = false
+DSYMUTIL =
+DUMPBIN =
+ECHO_C =
+ECHO_N = -n
+ECHO_T =
+EGREP = /usr/bin/grep -E
+EXEEXT =
+FGREP = /usr/bin/grep -F
+GLFW3_CFLAGS = -I/usr/local/include -I/usr/X11R6/include
+GLFW3_LIBS = -L/usr/local/lib -lglfw
+GREP = /usr/bin/grep
+GTK3_CFLAGS = -I/usr/local/include/gtk-3.0 -I/usr/local/include/at-spi2-atk/2.0 -I/usr/local/include/at-spi-2.0 -I/usr/X11R6/include -I/usr/local/include/dbus-1.0 -I/usr/local/lib/dbus-1.0/include -I/usr/local/include -I/usr/local/include/gio-unix-2.0 -I/usr/local/include/cairo -I/usr/X11R6/include/libdrm -I/usr/local/include/pango-1.0 -I/usr/local/include/fribidi -I/usr/local/include/harfbuzz -I/usr/local/include/atk-1.0 -I/usr/X11R6/include/pixman-1 -I/usr/X11R6/include/freetype2 -I/usr/local/include/libpng16 -I/usr/local/include/gdk-pixbuf-2.0 -pthread -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include
+GTK3_LIBS = -L/usr/local/lib -Wl,-rpath-link,/usr/X11R6/lib -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl
+INSTALL = /usr/bin/install -c
+INSTALL_DATA = ${INSTALL} -m 644
+INSTALL_PROGRAM = ${INSTALL}
+INSTALL_SCRIPT = ${INSTALL}
+INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
+LD = /usr/bin/ld
+LDFLAGS = -L/usr/local/lib -L/usr/lib
+LIBOBJS =
+LIBRTBUF_CFLAGS =
+LIBRTBUF_LIBS =
+LIBS =
+LIBTOOL = $(SHELL) $(top_builddir)/libtool
+LIPO =
+LN_S = ln -s
+LTLIBOBJS =
+MAKEINFO = ${SHELL} /home/dx/c/rtbuf/rtbuf/build-aux/missing makeinfo
+MANIFEST_TOOL = :
+MKDIR_P = ../build-aux/install-sh -c -d
+MUSIC_LIBS = -lm
+NM = /usr/bin/nm -B
+NMEDIT =
+OBJDUMP = objdump
+OBJEXT = o
+OTOOL =
+OTOOL64 =
+PACKAGE = rtbuf
+PACKAGE_BUGREPORT = kmx.io
+PACKAGE_NAME = rtbuf
+PACKAGE_STRING = rtbuf 0.2.3
+PACKAGE_TARNAME = rtbuf
+PACKAGE_URL = http://kmx.io/
+PACKAGE_VERSION = 0.2.3
+PATH_SEPARATOR = :
+PKG_CONFIG = /usr/bin/pkg-config
+PKG_CONFIG_LIBDIR =
+PKG_CONFIG_PATH =
+PORTAUDIO_LIBS = -lportaudio
+RANLIB = ranlib
+RTBUF_LIBS = -lpthread -lreadline -ltermcap
+SED = /usr/bin/sed
+SET_MAKE =
+SHELL = /bin/sh
+SIGNAL_LIBS = -lm
+SNDIO_LIBS = -lsndio
+STRIP = strip
+VERSION = 0.2.3
+abs_builddir = /home/dx/c/rtbuf/rtbuf/librtbuf
+abs_srcdir = /home/dx/c/rtbuf/rtbuf/librtbuf
+abs_top_builddir = /home/dx/c/rtbuf/rtbuf
+abs_top_srcdir = /home/dx/c/rtbuf/rtbuf
+ac_ct_AR = ar
+ac_ct_CC = cc
+ac_ct_DUMPBIN =
+am__include = include
+am__leading_dot = .
+am__quote =
+am__tar = $${TAR-tar} chof - "$$tardir"
+am__untar = $${TAR-tar} xf -
+bindir = ${exec_prefix}/bin
+build = x86_64-unknown-openbsd6.7
+build_alias =
+build_cpu = x86_64
+build_os = openbsd6.7
+build_vendor = unknown
+builddir = .
+datadir = ${datarootdir}
+datarootdir = ${prefix}/share
+docdir = ${datarootdir}/doc/${PACKAGE_TARNAME}
+dvidir = ${docdir}
+enable_nsis = false
+exec_prefix = ${prefix}
+host = x86_64-unknown-openbsd6.7
+host_alias =
+host_cpu = x86_64
+host_os = openbsd6.7
+host_vendor = unknown
+htmldir = ${docdir}
+includedir = ${prefix}/include
+infodir = ${datarootdir}/info
+install_sh = ${SHELL} /home/dx/c/rtbuf/rtbuf/build-aux/install-sh
+libdir = ${exec_prefix}/lib
+libexecdir = ${exec_prefix}/libexec
+localedir = ${datarootdir}/locale
+localstatedir = ${prefix}/var
+mandir = ${datarootdir}/man
+mkdir_p = $(MKDIR_P)
+oldincludedir = /usr/include
+pdfdir = ${docdir}
+prefix = /home/dx/.rtbuf
+program_transform_name = s,x,x,
+psdir = ${docdir}
+sbindir = ${exec_prefix}/sbin
+sharedstatedir = ${prefix}/com
+srcdir = .
+sysconfdir = ${prefix}/etc
+target_alias =
+top_build_prefix = ../
+top_builddir = ..
+top_srcdir = ..
+lib_LTLIBRARIES = librtbuf.la
+librtbuf_la_CFLAGS = ${LIBRTBUF_CFLAGS}
+librtbuf_la_LDFLAGS = -no-undefined
+librtbuf_la_LIBADD = ${LIBRTBUF_LIBS}
+librtbuf_la_SOURCES = \
+ data.c \
+ symbol.c \
+ rtbuf_lib.c \
+ rtbuf_type.c \
+ rtbuf_proc.c \
+ rtbuf_var.c \
+ rtbuf.c
+
+rtbuf_includedir = $(includedir)/rtbuf
+rtbuf_include_HEADERS = \
+ include/rtbuf/data.h \
+ include/rtbuf/symbol.h \
+ include/rtbuf/defs.h \
+ include/rtbuf/lib.h \
+ include/rtbuf/proc.h \
+ include/rtbuf/type.h \
+ include/rtbuf/var.h \
+ include/rtbuf/rtbuf.h
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu librtbuf/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu librtbuf/Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+install-libLTLIBRARIES: $(lib_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
+ list2=; for p in $$list; do \
+ if test -f $$p; then \
+ list2="$$list2 $$p"; \
+ else :; fi; \
+ done; \
+ test -z "$$list2" || { \
+ echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
+ }
+
+uninstall-libLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
+ for p in $$list; do \
+ $(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
+ done
+
+clean-libLTLIBRARIES:
+ -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
+ @list='$(lib_LTLIBRARIES)'; \
+ locs=`for p in $$list; do echo $$p; done | \
+ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+ sort -u`; \
+ test -z "$$locs" || { \
+ echo rm -f $${locs}; \
+ rm -f $${locs}; \
+ }
+
+librtbuf.la: $(librtbuf_la_OBJECTS) $(librtbuf_la_DEPENDENCIES) $(EXTRA_librtbuf_la_DEPENDENCIES)
+ $(AM_V_CCLD)$(librtbuf_la_LINK) -rpath $(libdir) $(librtbuf_la_OBJECTS) $(librtbuf_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+include ./$(DEPDIR)/librtbuf_la-data.Plo # am--include-marker
+include ./$(DEPDIR)/librtbuf_la-rtbuf.Plo # am--include-marker
+include ./$(DEPDIR)/librtbuf_la-rtbuf_lib.Plo # am--include-marker
+include ./$(DEPDIR)/librtbuf_la-rtbuf_proc.Plo # am--include-marker
+include ./$(DEPDIR)/librtbuf_la-rtbuf_type.Plo # am--include-marker
+include ./$(DEPDIR)/librtbuf_la-rtbuf_var.Plo # am--include-marker
+include ./$(DEPDIR)/librtbuf_la-symbol.Plo # am--include-marker
+
+$(am__depfiles_remade):
+ @$(MKDIR_P) $(@D)
+ @echo '# dummy' >$@-t && $(am__mv) $@-t $@
+
+am--depfiles: $(am__depfiles_remade)
+
+.c.o:
+ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+# $(AM_V_CC)source='$<' object='$@' libtool=no \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(AM_V_CC_no)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+# $(AM_V_CC)source='$<' object='$@' libtool=no \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(AM_V_CC_no)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.c.lo:
+ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+# $(AM_V_CC)source='$<' object='$@' libtool=yes \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(AM_V_CC_no)$(LTCOMPILE) -c -o $@ $<
+
+librtbuf_la-data.lo: data.c
+ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librtbuf_la_CFLAGS) $(CFLAGS) -MT librtbuf_la-data.lo -MD -MP -MF $(DEPDIR)/librtbuf_la-data.Tpo -c -o librtbuf_la-data.lo `test -f 'data.c' || echo '$(srcdir)/'`data.c
+ $(AM_V_at)$(am__mv) $(DEPDIR)/librtbuf_la-data.Tpo $(DEPDIR)/librtbuf_la-data.Plo
+# $(AM_V_CC)source='data.c' object='librtbuf_la-data.lo' libtool=yes \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(AM_V_CC_no)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librtbuf_la_CFLAGS) $(CFLAGS) -c -o librtbuf_la-data.lo `test -f 'data.c' || echo '$(srcdir)/'`data.c
+
+librtbuf_la-symbol.lo: symbol.c
+ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librtbuf_la_CFLAGS) $(CFLAGS) -MT librtbuf_la-symbol.lo -MD -MP -MF $(DEPDIR)/librtbuf_la-symbol.Tpo -c -o librtbuf_la-symbol.lo `test -f 'symbol.c' || echo '$(srcdir)/'`symbol.c
+ $(AM_V_at)$(am__mv) $(DEPDIR)/librtbuf_la-symbol.Tpo $(DEPDIR)/librtbuf_la-symbol.Plo
+# $(AM_V_CC)source='symbol.c' object='librtbuf_la-symbol.lo' libtool=yes \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(AM_V_CC_no)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librtbuf_la_CFLAGS) $(CFLAGS) -c -o librtbuf_la-symbol.lo `test -f 'symbol.c' || echo '$(srcdir)/'`symbol.c
+
+librtbuf_la-rtbuf_lib.lo: rtbuf_lib.c
+ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librtbuf_la_CFLAGS) $(CFLAGS) -MT librtbuf_la-rtbuf_lib.lo -MD -MP -MF $(DEPDIR)/librtbuf_la-rtbuf_lib.Tpo -c -o librtbuf_la-rtbuf_lib.lo `test -f 'rtbuf_lib.c' || echo '$(srcdir)/'`rtbuf_lib.c
+ $(AM_V_at)$(am__mv) $(DEPDIR)/librtbuf_la-rtbuf_lib.Tpo $(DEPDIR)/librtbuf_la-rtbuf_lib.Plo
+# $(AM_V_CC)source='rtbuf_lib.c' object='librtbuf_la-rtbuf_lib.lo' libtool=yes \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(AM_V_CC_no)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librtbuf_la_CFLAGS) $(CFLAGS) -c -o librtbuf_la-rtbuf_lib.lo `test -f 'rtbuf_lib.c' || echo '$(srcdir)/'`rtbuf_lib.c
+
+librtbuf_la-rtbuf_type.lo: rtbuf_type.c
+ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librtbuf_la_CFLAGS) $(CFLAGS) -MT librtbuf_la-rtbuf_type.lo -MD -MP -MF $(DEPDIR)/librtbuf_la-rtbuf_type.Tpo -c -o librtbuf_la-rtbuf_type.lo `test -f 'rtbuf_type.c' || echo '$(srcdir)/'`rtbuf_type.c
+ $(AM_V_at)$(am__mv) $(DEPDIR)/librtbuf_la-rtbuf_type.Tpo $(DEPDIR)/librtbuf_la-rtbuf_type.Plo
+# $(AM_V_CC)source='rtbuf_type.c' object='librtbuf_la-rtbuf_type.lo' libtool=yes \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(AM_V_CC_no)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librtbuf_la_CFLAGS) $(CFLAGS) -c -o librtbuf_la-rtbuf_type.lo `test -f 'rtbuf_type.c' || echo '$(srcdir)/'`rtbuf_type.c
+
+librtbuf_la-rtbuf_proc.lo: rtbuf_proc.c
+ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librtbuf_la_CFLAGS) $(CFLAGS) -MT librtbuf_la-rtbuf_proc.lo -MD -MP -MF $(DEPDIR)/librtbuf_la-rtbuf_proc.Tpo -c -o librtbuf_la-rtbuf_proc.lo `test -f 'rtbuf_proc.c' || echo '$(srcdir)/'`rtbuf_proc.c
+ $(AM_V_at)$(am__mv) $(DEPDIR)/librtbuf_la-rtbuf_proc.Tpo $(DEPDIR)/librtbuf_la-rtbuf_proc.Plo
+# $(AM_V_CC)source='rtbuf_proc.c' object='librtbuf_la-rtbuf_proc.lo' libtool=yes \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(AM_V_CC_no)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librtbuf_la_CFLAGS) $(CFLAGS) -c -o librtbuf_la-rtbuf_proc.lo `test -f 'rtbuf_proc.c' || echo '$(srcdir)/'`rtbuf_proc.c
+
+librtbuf_la-rtbuf_var.lo: rtbuf_var.c
+ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librtbuf_la_CFLAGS) $(CFLAGS) -MT librtbuf_la-rtbuf_var.lo -MD -MP -MF $(DEPDIR)/librtbuf_la-rtbuf_var.Tpo -c -o librtbuf_la-rtbuf_var.lo `test -f 'rtbuf_var.c' || echo '$(srcdir)/'`rtbuf_var.c
+ $(AM_V_at)$(am__mv) $(DEPDIR)/librtbuf_la-rtbuf_var.Tpo $(DEPDIR)/librtbuf_la-rtbuf_var.Plo
+# $(AM_V_CC)source='rtbuf_var.c' object='librtbuf_la-rtbuf_var.lo' libtool=yes \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(AM_V_CC_no)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librtbuf_la_CFLAGS) $(CFLAGS) -c -o librtbuf_la-rtbuf_var.lo `test -f 'rtbuf_var.c' || echo '$(srcdir)/'`rtbuf_var.c
+
+librtbuf_la-rtbuf.lo: rtbuf.c
+ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librtbuf_la_CFLAGS) $(CFLAGS) -MT librtbuf_la-rtbuf.lo -MD -MP -MF $(DEPDIR)/librtbuf_la-rtbuf.Tpo -c -o librtbuf_la-rtbuf.lo `test -f 'rtbuf.c' || echo '$(srcdir)/'`rtbuf.c
+ $(AM_V_at)$(am__mv) $(DEPDIR)/librtbuf_la-rtbuf.Tpo $(DEPDIR)/librtbuf_la-rtbuf.Plo
+# $(AM_V_CC)source='rtbuf.c' object='librtbuf_la-rtbuf.lo' libtool=yes \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(AM_V_CC_no)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(librtbuf_la_CFLAGS) $(CFLAGS) -c -o librtbuf_la-rtbuf.lo `test -f 'rtbuf.c' || echo '$(srcdir)/'`rtbuf.c
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+install-rtbuf_includeHEADERS: $(rtbuf_include_HEADERS)
+ @$(NORMAL_INSTALL)
+ @list='$(rtbuf_include_HEADERS)'; test -n "$(rtbuf_includedir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(rtbuf_includedir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(rtbuf_includedir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(rtbuf_includedir)'"; \
+ $(INSTALL_HEADER) $$files "$(DESTDIR)$(rtbuf_includedir)" || exit $$?; \
+ done
+
+uninstall-rtbuf_includeHEADERS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(rtbuf_include_HEADERS)'; test -n "$(rtbuf_includedir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ dir='$(DESTDIR)$(rtbuf_includedir)'; $(am__uninstall_files_from_dir)
+
+ID: $(am__tagged_files)
+ $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ set x; \
+ here=`pwd`; \
+ $(am__define_uniq_tagged_files); \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ $(am__define_uniq_tagged_files); \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+ list='$(am__tagged_files)'; \
+ case "$(srcdir)" in \
+ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+ *) sdir=$(subdir)/$(srcdir) ;; \
+ esac; \
+ for i in $$list; do \
+ if test -f "$$i"; then \
+ echo "$(subdir)/$$i"; \
+ else \
+ echo "$$sdir/$$i"; \
+ fi; \
+ done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) distdir-am
+
+distdir-am: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
+installdirs:
+ for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(rtbuf_includedir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -f ./$(DEPDIR)/librtbuf_la-data.Plo
+ -rm -f ./$(DEPDIR)/librtbuf_la-rtbuf.Plo
+ -rm -f ./$(DEPDIR)/librtbuf_la-rtbuf_lib.Plo
+ -rm -f ./$(DEPDIR)/librtbuf_la-rtbuf_proc.Plo
+ -rm -f ./$(DEPDIR)/librtbuf_la-rtbuf_type.Plo
+ -rm -f ./$(DEPDIR)/librtbuf_la-rtbuf_var.Plo
+ -rm -f ./$(DEPDIR)/librtbuf_la-symbol.Plo
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-rtbuf_includeHEADERS
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-libLTLIBRARIES
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -f ./$(DEPDIR)/librtbuf_la-data.Plo
+ -rm -f ./$(DEPDIR)/librtbuf_la-rtbuf.Plo
+ -rm -f ./$(DEPDIR)/librtbuf_la-rtbuf_lib.Plo
+ -rm -f ./$(DEPDIR)/librtbuf_la-rtbuf_proc.Plo
+ -rm -f ./$(DEPDIR)/librtbuf_la-rtbuf_type.Plo
+ -rm -f ./$(DEPDIR)/librtbuf_la-rtbuf_var.Plo
+ -rm -f ./$(DEPDIR)/librtbuf_la-symbol.Plo
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-libLTLIBRARIES uninstall-rtbuf_includeHEADERS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \
+ clean-generic clean-libLTLIBRARIES clean-libtool cscopelist-am \
+ ctags ctags-am distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-data \
+ install-data-am install-dvi install-dvi-am install-exec \
+ install-exec-am install-html install-html-am install-info \
+ install-info-am install-libLTLIBRARIES install-man install-pdf \
+ install-pdf-am install-ps install-ps-am \
+ install-rtbuf_includeHEADERS install-strip installcheck \
+ installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags tags-am uninstall uninstall-am uninstall-libLTLIBRARIES \
+ uninstall-rtbuf_includeHEADERS
+
+.PRECIOUS: Makefile
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/librtbuf/Makefile.am b/librtbuf/Makefile.am
new file mode 100644
index 0000000..6b104f6
--- /dev/null
+++ b/librtbuf/Makefile.am
@@ -0,0 +1,24 @@
+
+lib_LTLIBRARIES = librtbuf.la
+librtbuf_la_CFLAGS = ${LIBRTBUF_CFLAGS}
+librtbuf_la_LDFLAGS = -no-undefined
+librtbuf_la_LIBADD = ${LIBRTBUF_LIBS}
+librtbuf_la_SOURCES = \
+ data.c \
+ symbol.c \
+ rtbuf_lib.c \
+ rtbuf_type.c \
+ rtbuf_proc.c \
+ rtbuf_var.c \
+ rtbuf.c
+
+rtbuf_includedir = $(includedir)/rtbuf
+rtbuf_include_HEADERS = \
+ include/rtbuf/data.h \
+ include/rtbuf/symbol.h \
+ include/rtbuf/defs.h \
+ include/rtbuf/lib.h \
+ include/rtbuf/proc.h \
+ include/rtbuf/type.h \
+ include/rtbuf/var.h \
+ include/rtbuf/rtbuf.h
diff --git a/librtbuf/data.c b/librtbuf/data.c
new file mode 100644
index 0000000..90373dc
--- /dev/null
+++ b/librtbuf/data.c
@@ -0,0 +1,158 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <assert.h>
+#include <stdlib.h>
+#include <strings.h>
+#include <rtbuf/data.h>
+
+s_data_type g_data_alloc_type = {
+ sizeof(s_data_alloc) * 8,
+ DATA_TYPE_BITS
+};
+s_data_alloc g_data_alloc;
+
+s_data_type g_data_type_type = {
+ sizeof(u_data_type) * 8,
+ DATA_TYPE_BITS
+};
+s_data_alloc *g_data_type_alloc = 0;
+
+int libdata_init ()
+{
+ data_alloc_init(&g_data_alloc, &g_data_alloc_type,
+ DATA_ALLOC_MAX, 0, (f_data_clean*) data_alloc_clean);
+ return 0;
+}
+
+void data_alloc_init (s_data_alloc *da, s_data_type *t,
+ unsigned int max, f_data_init *init,
+ f_data_clean *clean)
+{
+ assert(da);
+ assert(t);
+ da->t = t;
+ da->max = max;
+ da->mem = calloc(max, (t->bits + 7) / 8);
+ da->n = 0;
+ da->free = calloc(max, sizeof(unsigned int));
+ da->free_n = 0;
+ da->init = init;
+ da->clean = clean;
+}
+
+void data_alloc_clean (s_data_alloc *da)
+{
+ assert(da);
+ bzero(da->mem, da->max * ((da->t->bits + 7) / 8));
+ bzero(da->free, da->max * sizeof(unsigned int));
+ free(da->mem);
+ free(da->free);
+}
+
+void * data_new_at (s_data_alloc *da, unsigned int i)
+{
+ unsigned int octets = (da->t->bits + 7) / 8;
+ unsigned int offset = i * octets;
+ void *m = da->mem + offset;
+ bzero(m, octets);
+ if (da->init)
+ da->init(m);
+ return m;
+}
+
+void * data_new (s_data_alloc *da)
+{
+ assert(da);
+ if (da->free_n) {
+ unsigned int i = da->free[--da->free_n];
+ da->free[da->free_n] = 0;
+ return data_new_at(da, i);
+ }
+ if (da->n < da->max) {
+ unsigned int i = da->n++;
+ return data_new_at(da, i);
+ }
+ return 0;
+}
+
+int data_new_i (s_data_alloc *da)
+{
+ assert(da);
+ if (da->free_n) {
+ unsigned int i = da->free[--da->free_n];
+ da->free[da->free_n] = 0;
+ data_new_at(da, i);
+ return i;
+ }
+ if (da->n < da->max) {
+ unsigned int i = da->n++;
+ data_new_at(da, i);
+ return i;
+ }
+ return -1;
+}
+
+void data_delete (s_data_alloc *da, void *data)
+{
+ unsigned int octets;
+ unsigned int i;
+ assert(da);
+ assert(da->t);
+ octets = ((da->t->bits + 7) / 8);
+ assert(da->mem <= data);
+ assert(data < da->mem + da->max * octets);
+ if (da->clean)
+ da->clean(data);
+ bzero(data, octets);
+ i = (data - da->mem) / octets;
+ da->free[da->free_n++] = i;
+}
+
+s_data_alloc * data_alloc_new (s_data_type *t, unsigned int max,
+ f_data_init *init, f_data_clean *clean)
+{
+ s_data_alloc *da = data_new(&g_data_alloc);
+ assert(da);
+ data_alloc_init(da, t, max, init, clean);
+ return da;
+}
+
+void data_alloc_delete (s_data_alloc *da)
+{
+ assert(da);
+ data_delete(&g_data_alloc, da);
+}
+
+u_data_type * data_type_new (unsigned int bits, unsigned int type)
+{
+ u_data_type *t;
+ if (!g_data_type_alloc)
+ g_data_type_alloc = data_alloc_new(&g_data_type_type, DATA_TYPE_MAX,
+ 0, 0);
+ assert(g_data_type_alloc);
+ t = data_new(g_data_type_alloc);
+ assert(t);
+ t->t.bits = bits;
+ t->t.type = type;
+ return t;
+}
+
+void data_type_delete (s_data_type *t)
+{
+ assert(g_data_type_alloc);
+ data_delete(g_data_type_alloc, t);
+}
diff --git a/librtbuf/include/rtbuf/data.h b/librtbuf/include/rtbuf/data.h
new file mode 100644
index 0000000..8e61f96
--- /dev/null
+++ b/librtbuf/include/rtbuf/data.h
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifndef DATA_H
+#define DATA_H
+
+typedef enum {
+ DATA_TYPE_BITS,
+ DATA_TYPE_VECTOR,
+ DATA_TYPE_INTEGER,
+ DATA_TYPE_FLOAT,
+ DATA_TYPE_STRUCT
+} e_data_type;
+
+#define DATA_TYPE_SIGNED 1
+#define DATA_TYPE_BIG_ENDIAN 2
+
+typedef struct data_type {
+ unsigned int bits;
+ unsigned int type;
+} s_data_type;
+
+typedef struct data_type_vector {
+ s_data_type t;
+ s_data_type *element_type;
+ unsigned int nmemb;
+} s_data_type_vector;
+
+typedef struct data_type_integer {
+ s_data_type t;
+ unsigned int flags;
+} s_data_type_integer;
+
+typedef struct data_type_float {
+ s_data_type t;
+} s_data_type_float;
+
+typedef struct data_type_struct {
+ s_data_type t;
+ s_data_type *first;
+ struct data_type_struct *rest;
+} s_data_type_struct;
+
+typedef union data_type_ {
+ s_data_type t;
+ s_data_type_vector t_vector;
+ s_data_type_integer t_integer;
+ s_data_type_float t_float;
+ s_data_type_struct t_struct;
+} u_data_type;
+
+#define DATA_TYPE_MAX 1024
+
+u_data_type * data_type_new (unsigned int bits, unsigned int type);
+void data_type_delete (s_data_type *t);
+
+typedef void f_data_init (void *data);
+typedef void f_data_clean (void *data);
+
+typedef struct data_alloc {
+ s_data_type *t;
+ unsigned int max;
+ void *mem;
+ unsigned int n;
+ unsigned int *free;
+ unsigned int free_n;
+ f_data_init *init;
+ f_data_clean *clean;
+} s_data_alloc;
+
+#define DATA_ALLOC_MAX 1024
+
+void * data_new (s_data_alloc *da);
+int data_new_i (s_data_alloc *da);
+void data_delete (s_data_alloc *da, void *data);
+
+void data_alloc_init (s_data_alloc *da, s_data_type *t,
+ unsigned int max, f_data_init *init,
+ f_data_clean *clean);
+void data_alloc_clean (s_data_alloc *da);
+s_data_alloc * data_alloc_new (s_data_type *t,
+ unsigned int max, f_data_init *init,
+ f_data_clean *clean);
+void data_alloc_delete (s_data_alloc *da);
+
+int libdata_init ();
+
+#endif
diff --git a/librtbuf/include/rtbuf/defs.h b/librtbuf/include/rtbuf/defs.h
new file mode 100644
index 0000000..4d88bc7
--- /dev/null
+++ b/librtbuf/include/rtbuf/defs.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifndef RTBUF_DEFS_H
+#define RTBUF_DEFS_H
+
+typedef struct rtbuf s_rtbuf;
+typedef struct rtbuf_binding s_rtbuf_binding;
+typedef struct rtbuf_proc s_rtbuf_proc;
+typedef struct rtbuf_proc_in s_rtbuf_proc_in;
+typedef struct rtbuf_proc_out s_rtbuf_proc_out;
+typedef struct rtbuf_lib s_rtbuf_lib;
+typedef struct rtbuf_lib_proc s_rtbuf_lib_proc;
+typedef struct rtbuf_lib_proc_in s_rtbuf_lib_proc_in;
+typedef struct rtbuf_lib_proc_out s_rtbuf_lib_proc_out;
+typedef struct rtbuf_type s_rtbuf_type;
+typedef struct rtbuf_var s_rtbuf_var;
+typedef union rtbuf_var_data u_rtbuf_var_data;
+
+typedef enum rtbuf_var_type {
+ RTBUF_VAR_NULL = 0,
+ RTBUF_VAR_RTBUF = 1
+} e_rtbuf_var_type;
+
+typedef int f_rtbuf_proc (s_rtbuf *rtbuf);
+typedef int f_rtbuf_lib_init (s_rtbuf_lib *lib);
+
+#endif
diff --git a/librtbuf/include/rtbuf/lib.h b/librtbuf/include/rtbuf/lib.h
new file mode 100644
index 0000000..ad2fcf8
--- /dev/null
+++ b/librtbuf/include/rtbuf/lib.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifndef RTBUF_LIB_H
+#define RTBUF_LIB_H
+
+#include <rtbuf/defs.h>
+
+#define RTBUF_LIB_MAX 1000
+#define RTBUF_LIB_VER 0x00010001
+
+struct rtbuf_lib_proc_in {
+ const char *name;
+ const char *type;
+ double def;
+ double min;
+ double max;
+};
+
+struct rtbuf_lib_proc_out {
+ const char *name;
+ const char *type;
+};
+
+struct rtbuf_lib_proc {
+ const char *name;
+ f_rtbuf_proc *f;
+ f_rtbuf_proc *start;
+ f_rtbuf_proc *stop;
+ s_rtbuf_lib_proc_in *in; /* inputs, end with NULL */
+ s_rtbuf_lib_proc_out *out; /* outputs, end with NULL */
+};
+
+struct rtbuf_lib {
+ const char *name;
+ s_rtbuf_proc **proc;
+ unsigned int proc_n;
+ void *lib;
+ const char *path;
+};
+
+extern s_data_alloc g_rtbuf_lib_alloc;
+extern s_rtbuf_lib *g_rtbuf_lib;
+
+void rtbuf_lib_delete (s_rtbuf_lib *rl);
+int rtbuf_lib_find (const char *str);
+int rtbuf_lib_find_proc (s_rtbuf_lib *rl, const char *str);
+void rtbuf_lib_init_ ();
+s_rtbuf_lib * rtbuf_lib_load (const char *path);
+s_rtbuf_lib * rtbuf_lib_new ();
+void rtbuf_lib_print (const s_rtbuf_lib *lib);
+void rtbuf_lib_print_long (unsigned int i);
+
+void rtbuf_lib_proc_var_init_proc (s_rtbuf_proc *proc,
+ s_rtbuf_lib_proc_in *in);
+void rtbuf_lib_proc_out_init_proc (s_rtbuf_proc *proc,
+ s_rtbuf_lib_proc_out *out);
+void rtbuf_lib_proc_init_proc (s_rtbuf_proc *proc, s_rtbuf_lib_proc *x);
+
+#endif
diff --git a/librtbuf/include/rtbuf/proc.h b/librtbuf/include/rtbuf/proc.h
new file mode 100644
index 0000000..a829742
--- /dev/null
+++ b/librtbuf/include/rtbuf/proc.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifndef RTBUF_PROC_H
+#define RTBUF_PROC_H
+
+#include <rtbuf/data.h>
+#include <rtbuf/defs.h>
+#include <rtbuf/symbol.h>
+
+struct rtbuf_proc_in {
+ symbol name;
+ s_rtbuf_type *type;
+ double def;
+ double min;
+ double max;
+};
+
+struct rtbuf_proc_out {
+ symbol name;
+ s_rtbuf_type *type;
+ unsigned int offset;
+};
+
+#define RTBUF_PROC_IN_MAX 1024
+#define RTBUF_PROC_OUT_MAX 1024
+
+struct rtbuf_proc {
+ symbol name;
+ f_rtbuf_proc *f;
+ f_rtbuf_proc *start;
+ f_rtbuf_proc *stop;
+ s_rtbuf_proc_in in[RTBUF_PROC_IN_MAX]; /* inputs */
+ unsigned int in_n; /* number of inputs */
+ s_rtbuf_proc_out out[RTBUF_PROC_OUT_MAX]; /* outputs */
+ unsigned int out_n; /* number of outputs */
+ unsigned int out_bytes; /* size of output data in bytes */
+ s_rtbuf_lib *lib; /* the library this procedure comes from */
+ unsigned int lib_proc; /* the procedure index in library */
+ s_data_type type;
+ s_data_alloc alloc;
+};
+
+#define RTBUF_PROC_MAX 1024
+extern s_data_alloc g_rtbuf_proc_alloc;
+extern s_rtbuf_proc *g_rtbuf_proc;
+
+void rtbuf_proc_init ();
+int rtbuf_proc_p (s_rtbuf_proc *proc);
+s_rtbuf_proc * rtbuf_proc_new ();
+void rtbuf_proc_delete (s_rtbuf_proc *proc);
+s_rtbuf_proc * rtbuf_proc_find (const char *x);
+int rtbuf_proc_out_find (s_rtbuf_proc *proc,
+ const char *name);
+void rtbuf_proc_print (s_rtbuf_proc *proc);
+
+#endif
diff --git a/librtbuf/include/rtbuf/queue.h b/librtbuf/include/rtbuf/queue.h
new file mode 100644
index 0000000..f886dd3
--- /dev/null
+++ b/librtbuf/include/rtbuf/queue.h
@@ -0,0 +1,60 @@
+#ifndef QUEUE_H
+#define QUEUE_H
+
+/* static queue */
+
+#define QUEUE_TYPE(type, size) \
+ type ## _queue_ ## size
+
+#define QUEUE(type, size) \
+ struct QUEUE_TYPE(type, size) { \
+ unsigned int length; \
+ unsigned int read_index; \
+ unsigned int write_index; \
+ type item[size]; \
+ }
+
+#define S_QUEUE_TYPE(type, size) \
+ s_ ## QUEUE_TYPE(type, size)
+
+#define QUEUE_METHOD(type, size, method) \
+ QUEUE_TYPE(type, size) ## _ ## method
+
+#define DEFINE_QUEUE(type, size) \
+ typedef QUEUE(type, size) S_QUEUE_TYPE(type, size); \
+ static void QUEUE_METHOD(type, size, init) \
+ (S_QUEUE_TYPE(type, size) *q) \
+ { \
+ bzero(q, sizeof(q)); \
+ } \
+ static void QUEUE_METHOD(type, size, free) \
+ (S_QUEUE_TYPE(type, size) *q) \
+ { \
+ bzero(q, sizeof(q)); \
+ } \
+ static int QUEUE_METHOD(type, size, enqueue) \
+ (S_QUEUE_TYPE(type, size) *q, type item) \
+ { \
+ if (q->length < size) { \
+ unsigned int write_index = q->write_index; \
+ q->write_index = (q->write_index + 1) % size; \
+ q->item[write_index] = item; \
+ q->length++; \
+ return 0; \
+ } \
+ return -1; \
+ } \
+ static int QUEUE_METHOD(type, size, dequeue) \
+ (S_QUEUE_TYPE(type, size) *q, type *ptr) \
+ { \
+ if (q->length > 0) { \
+ unsigned int read_index = q->read_index; \
+ q->read_index = (read_index + 1) % size; \
+ *ptr = q->item[read_index]; \
+ q->length--; \
+ return 0; \
+ } \
+ return -1; \
+ }
+
+#endif
diff --git a/librtbuf/include/rtbuf/rtbuf.h b/librtbuf/include/rtbuf/rtbuf.h
new file mode 100644
index 0000000..1d3780d
--- /dev/null
+++ b/librtbuf/include/rtbuf/rtbuf.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2018-2020 Thomas de Grivel <thoxdg@gmail.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifndef RTBUF_H
+#define RTBUF_H
+
+#include <rtbuf/data.h>
+#include <rtbuf/defs.h>
+#include <rtbuf/type.h>
+#include <rtbuf/proc.h>
+
+#define RTBUF_SORT 0x0001
+#define RTBUF_DELETE 0x0002
+
+struct rtbuf_binding
+{
+ int rtb;
+ unsigned int out;
+};
+
+struct rtbuf
+{
+ void *data;
+ unsigned int flags;
+ s_rtbuf_proc *proc;
+ unsigned int refc;
+ s_rtbuf_binding in[RTBUF_PROC_IN_MAX];
+ unsigned int in_n;
+};
+
+#define RTBUF_MAX 10000
+#define RTBUF_INSTANCE_MAX 100
+
+extern s_data_alloc g_rtbuf_alloc;
+extern s_rtbuf *g_rtbuf;
+extern int g_rtbuf_run;
+
+int librtbuf_init ();
+
+int rtbuf_err (const char *msg);
+int rtbuf_new (s_rtbuf_proc *rp);
+void rtbuf_in_unbind (s_rtbuf *rtb, unsigned int var);
+void rtbuf_unbind_all (s_rtbuf *rtb);
+void rtbuf_delete (s_rtbuf *rtb);
+int rtbuf_clone (s_rtbuf *rtb);
+int rtbuf_find (symbol sym);
+int rtbuf_in_find (s_rtbuf *rtb, const char *x);
+void rtbuf_bind (unsigned int src, unsigned int out,
+ s_rtbuf *dest, unsigned int var);
+int rtbuf_out_find (s_rtbuf *rtb, symbol sym);
+int rtbuf_data_set (s_rtbuf *rtb, symbol name, void *value,
+ unsigned int size);
+void rtbuf_sort ();
+int rtbuf_start ();
+int rtbuf_run ();
+void rtbuf_stop ();
+void rtbuf_print (unsigned int i);
+void rtbuf_print_long (unsigned int i);
+void rtbuf_print_sorted ();
+
+int rtbuf_out_int (s_rtbuf *rtb, unsigned int out, int default_value);
+
+double min (double a, double b);
+double max (double a, double b);
+double clamp (double inf, double x, double sup);
+
+#endif /* RTBUF_H */
diff --git a/librtbuf/include/rtbuf/symbol.h b/librtbuf/include/rtbuf/symbol.h
new file mode 100644
index 0000000..02271dd
--- /dev/null
+++ b/librtbuf/include/rtbuf/symbol.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifndef SYMBOL_H
+#define SYMBOL_H
+
+typedef const char *symbol;
+
+#define STRING_MAX 65536
+extern char g_string[STRING_MAX];
+extern unsigned int g_string_n;
+
+#define SYMBOL_MAX 32768
+extern symbol g_symbols[SYMBOL_MAX];
+extern unsigned int g_symbols_n;
+
+void symbols_init ();
+symbol symbol_new (symbol name);
+void symbol_delete (symbol sym);
+symbol symbol_find (symbol name);
+symbol symbol_intern (const char *name);
+
+#endif
diff --git a/librtbuf/include/rtbuf/type.h b/librtbuf/include/rtbuf/type.h
new file mode 100644
index 0000000..76b4e4e
--- /dev/null
+++ b/librtbuf/include/rtbuf/type.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifndef RTBUF_TYPE_H
+#define RTBUF_TYPE_H
+
+#include <rtbuf/data.h>
+#include <rtbuf/defs.h>
+#include <rtbuf/symbol.h>
+
+struct rtbuf_type {
+ symbol name;
+ s_data_type t;
+ s_data_alloc alloc;
+};
+
+#define RTBUF_TYPE_MAX 1024
+
+void rtbuf_type_init ();
+s_rtbuf_type * rtbuf_type_new (const char *name,
+ unsigned int size);
+void rtbuf_type_delete (s_rtbuf_type *rt);
+s_rtbuf_type * rtbuf_type_find (symbol name);
+s_rtbuf_type * rtbuf_type_define (const char *name,
+ unsigned int size);
+s_rtbuf_type * rtbuf_type (const char *name);
+s_rtbuf_type * rtbuf_type_array (const char *element_type,
+ unsigned int size);
+
+#define RTBUF_TYPE_CHAR_ARRAY(size) ("char[" #size "]")
+#define RTBUF_TYPE_SHORT_ARRAY(size) ("short[" #size "]")
+#define RTBUF_TYPE_DOUBLE_ARRAY(size) ("double[" #size "]")
+
+#endif
diff --git a/librtbuf/include/rtbuf/var.h b/librtbuf/include/rtbuf/var.h
new file mode 100644
index 0000000..0d37215
--- /dev/null
+++ b/librtbuf/include/rtbuf/var.h
@@ -0,0 +1,19 @@
+#ifndef RTBUF_VAR_H
+#define RTBUF_VAR_H
+
+#include <rtbuf/defs.h>
+
+#define RTBUF_VAR_MAX 1000
+
+struct rtbuf_var {
+ e_rtbuf_var_type type;
+ const char *name;
+ unsigned index;
+};
+
+void rtbuf_var_init (void);
+s_rtbuf_var * rtbuf_var_find (const char *name);
+s_rtbuf_var * rtbuf_var_rtbuf_set (const char *name, unsigned i);
+void rtbuf_var_print (const s_rtbuf_var *v);
+
+#endif
diff --git a/librtbuf/rtbuf.c b/librtbuf/rtbuf.c
new file mode 100644
index 0000000..0b883ff
--- /dev/null
+++ b/librtbuf/rtbuf.c
@@ -0,0 +1,548 @@
+/*
+ * Copyright 2018,2020 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <rtbuf/data.h>
+#include <rtbuf/rtbuf.h>
+#include <rtbuf/lib.h>
+#include <rtbuf/var.h>
+#include <rtbuf/symbol.h>
+
+s_data_type g_rtbuf_type = {
+ sizeof(s_rtbuf) * 8,
+ DATA_TYPE_BITS
+};
+s_data_alloc g_rtbuf_alloc;
+s_rtbuf *g_rtbuf = 0;
+int g_rtbuf_run = 0;
+unsigned int g_rtbuf_sort = 0;
+unsigned int g_rtbuf_sorted[RTBUF_MAX];
+unsigned int g_rtbuf_sorted_n = 0;
+
+int librtbuf_init ()
+{
+ libdata_init();
+ bzero(g_rtbuf_sorted, sizeof(g_rtbuf_sorted));
+ data_alloc_init(&g_rtbuf_alloc, &g_rtbuf_type, RTBUF_MAX, NULL, NULL);
+ g_rtbuf = g_rtbuf_alloc.mem;
+ assert(g_rtbuf);
+ rtbuf_type_init();
+ rtbuf_proc_init();
+ rtbuf_lib_init_();
+ rtbuf_var_init();
+ return 0;
+}
+
+int rtbuf_new (s_rtbuf_proc *rp)
+{
+ int i;
+ s_rtbuf *rtb;
+ void *data;
+ unsigned int j = 0;
+ assert(rp);
+ assert(g_rtbuf);
+ data = data_new(&rp->alloc);
+ if (!data)
+ return rtbuf_err("rtbuf data allocation failed, "
+ "please increase RTBUF_INSTANCE_MAX");
+ if ((i = data_new_i(&g_rtbuf_alloc)) < 0)
+ return rtbuf_err("rtbuf allocation failed, "
+ "please increase RTBUF_MAX");
+ rtb = &g_rtbuf[i];
+ rtb->data = data;
+ rtb->flags = 0;
+ rtb->proc = rp;
+ while (j < RTBUF_PROC_IN_MAX) {
+ rtb->in[j].rtb = -1;
+ j++;
+ }
+ g_rtbuf_sort = 1;
+ return i;
+}
+
+void rtbuf_in_unbind (s_rtbuf *rtb, unsigned int in)
+{
+ s_rtbuf_binding *v = &rtb->in[in];
+ if (v->rtb >= 0) {
+ s_rtbuf *src = &g_rtbuf[v->rtb];
+ src->refc--;
+ v->rtb = -1;
+ v->out = 0;
+ rtb->in_n--;
+ }
+}
+
+static
+void rtbuf_unbind_all_out_rtbuf (s_rtbuf *rtb, unsigned int rtb_i,
+ s_rtbuf *dest)
+{
+ unsigned int i = 0;
+ unsigned int n;
+ assert(dest);
+ n = dest->in_n;
+ while (i < dest->proc->in_n && n > 0 && rtb->refc) {
+ s_rtbuf_binding *v = &dest->in[i];
+ if (v->rtb >= 0) {
+ if ((unsigned int) v->rtb == rtb_i)
+ rtbuf_in_unbind(dest, i);
+ n--;
+ }
+ i++;
+ }
+}
+
+void rtbuf_unbind_all_out (s_rtbuf *rtb)
+{
+ unsigned int rtb_i;
+ unsigned int i = 0;
+ unsigned int n = g_rtbuf_alloc.n - g_rtbuf_alloc.free_n;
+ assert(rtb);
+ assert(g_rtbuf <= rtb);
+ assert(rtb < g_rtbuf + RTBUF_MAX);
+ rtb_i = rtb - g_rtbuf;
+ while (i < g_rtbuf_alloc.n && rtb->refc) {
+ if (g_rtbuf[i].data) {
+ rtbuf_unbind_all_out_rtbuf(rtb, rtb_i, &g_rtbuf[i]);
+ n--;
+ }
+ i++;
+ }
+}
+
+void rtbuf_unbind_all (s_rtbuf *rtb)
+{
+ unsigned int i = 0;
+ assert(rtb);
+ assert(rtb->proc);
+ while (i < rtb->proc->in_n && rtb->in_n > 0) {
+ rtbuf_in_unbind(rtb, i);
+ i++;
+ }
+ rtbuf_unbind_all_out(rtb);
+}
+
+void rtbuf_delete_ (s_rtbuf *rtb)
+{
+ assert(rtb);
+ rtbuf_unbind_all(rtb);
+ bzero(rtb->data, rtb->proc->out_bytes);
+ data_delete(&rtb->proc->alloc, rtb->data);
+ data_delete(&g_rtbuf_alloc, rtb);
+}
+
+void rtbuf_delete (s_rtbuf *rtb)
+{
+ assert(rtb);
+ rtb->flags |= RTBUF_DELETE;
+ g_rtbuf_sort = 1;
+}
+
+int rtbuf_clone (s_rtbuf *rtb)
+{
+ int new_i;
+ s_rtbuf *new;
+ unsigned int j = 0;
+ assert(rtb);
+ if ((new_i = rtbuf_new(rtb->proc)) < 0)
+ return -1;
+ new = &g_rtbuf[new_i];
+ while (j < rtb->proc->in_n) {
+ new->in[j] = rtb->in[j];
+ j++;
+ }
+ new->in_n = rtb->in_n;
+ return new_i;
+}
+
+void rtbuf_bind (unsigned int src, unsigned int out,
+ s_rtbuf *dest, unsigned int in)
+{
+ s_rtbuf_binding *v = &dest->in[in];
+ if ((unsigned int) v->rtb == src && v->out == out)
+ return;
+ rtbuf_in_unbind(dest, in);
+ v->rtb = src;
+ v->out = out;
+ dest->in_n++;
+ g_rtbuf[src].refc++;
+ g_rtbuf_sort = 1;
+}
+
+int rtbuf_data_set (s_rtbuf *rtb, symbol name, void *value,
+ unsigned int size)
+{
+ int out_i = rtbuf_proc_out_find(rtb->proc, name);
+ if (out_i >= 0) {
+ s_rtbuf_proc_out *out = &rtb->proc->out[out_i];
+ if (out->type->t.bits == size * 8) {
+ void *data = rtb->data + out->offset;
+ memcpy(data, value, size);
+ return size;
+ }
+ }
+ return 0;
+}
+
+typedef struct rtbuf_in_ptr {
+ unsigned int rtb;
+ unsigned int in;
+} s_rtbuf_in_ptr;
+
+typedef struct rtbuf_in_stack {
+ s_rtbuf_in_ptr st[RTBUF_MAX];
+ unsigned int size;
+} s_rtbuf_in_stack;
+
+void rtbuf_in_stack_init (s_rtbuf_in_stack *rvs)
+{
+ /* printf("rtbuf_in_stack_init\n"); */
+ bzero(rvs, sizeof(s_rtbuf_in_stack));
+}
+
+s_rtbuf_in_ptr * rtbuf_in_stack_push (s_rtbuf_in_stack *rvs,
+ unsigned int rtb,
+ unsigned int in)
+{
+ /* printf("rtbuf_in_stack_push %i %i\n", rtb, in); */
+ s_rtbuf_in_ptr *top;
+ if (rvs->size >= RTBUF_MAX)
+ return 0;
+ top = &rvs->st[rvs->size];
+ top->rtb = rtb;
+ top->in = in;
+ rvs->size++;
+ return top;
+}
+
+s_rtbuf_in_ptr * rtbuf_in_stack_pop (s_rtbuf_in_stack *rvs)
+{
+ /* printf("rtbuf_in_stack_pop\n"); */
+ if (rvs->size <= 0)
+ return 0;
+ rvs->size--;
+ return &rvs->st[rvs->size];
+}
+
+s_rtbuf_in_ptr * rtbuf_in_stack_top (s_rtbuf_in_stack *rvs)
+{
+ s_rtbuf_in_ptr *top;
+ /* printf("rtbuf_in_stack_top\n"); */
+ if (rvs->size <= 0) {
+ /* printf(" rtbuf_in_stack_top => 0\n"); */
+ return 0;
+ }
+ top = &rvs->st[rvs->size - 1];
+ /* printf(" rtbuf_in_stack_top => { %u, %u }\n", top->rtb, top->in); */
+ return top;
+}
+
+void rtbuf_find_roots (s_rtbuf_in_stack *rvs)
+{
+ s_rtbuf *rtb = g_rtbuf;
+ unsigned int i = 0;
+ unsigned int n = g_rtbuf_alloc.n - g_rtbuf_alloc.free_n;
+ unsigned int c = 0;
+ /* printf("rtbuf_find_roots\n"); */
+ while (i < g_rtbuf_alloc.n && n > 0) {
+ /* printf(" rtbuf_find_roots %u %u\n", i, n); */
+ if (rtb->data) {
+ if (rtb->flags & RTBUF_DELETE)
+ rtbuf_delete_(rtb);
+ else {
+ if (rtb->refc == 0) {
+ rtbuf_in_stack_push(rvs, i, 0);
+ c++;
+ }
+ }
+ n--;
+ }
+ rtb++;
+ i++;
+ }
+ /* printf(" rtbuf_find_roots => %u\n", c); */
+}
+
+void rtbuf_sort_push_child (s_rtbuf_in_stack *rvs,
+ s_rtbuf_in_ptr *ptr)
+{
+ int rtb;
+ unsigned int i = 0;
+ int found = 0;
+ /* printf("rtbuf_sort_push_child { %u, %u }\n", ptr->rtb, ptr->in); */
+ rtb = g_rtbuf[ptr->rtb].in[ptr->in].rtb;
+ ptr->in++;
+ if (rtb >= 0) {
+ while (i < g_rtbuf_sorted_n && !found) {
+ if (g_rtbuf_sorted[i] == (unsigned) rtb)
+ found = 1;
+ i++;
+ }
+ i = 0;
+ while (i < rvs->size && !found) {
+ if (rvs->st[i].rtb == (unsigned int) rtb)
+ found = 1;
+ i++;
+ }
+ if (!found)
+ rtbuf_in_stack_push(rvs, rtb, 0);
+ }
+}
+
+void rtbuf_sort ()
+{
+ s_rtbuf_in_stack rvs;
+ s_rtbuf_in_ptr *ptr;
+ /* printf("rtbuf_sort\n"); */
+ if (g_rtbuf_alloc.n == 0)
+ return;
+ rtbuf_in_stack_init(&rvs);
+ rtbuf_find_roots(&rvs);
+ g_rtbuf_sorted_n = 0;
+ while ((ptr = rtbuf_in_stack_top(&rvs))) {
+ if (ptr->in == g_rtbuf[ptr->rtb].proc->in_n) {
+ g_rtbuf_sorted[g_rtbuf_sorted_n++] = ptr->rtb;
+ rtbuf_in_stack_pop(&rvs);
+ } else
+ rtbuf_sort_push_child(&rvs, ptr);
+ }
+ g_rtbuf_sort = 0;
+ rtbuf_print_sorted();
+}
+
+int rtbuf_start ()
+{
+ unsigned int i = 0;
+ /* printf("rtbuf_start\n"); */
+ if (g_rtbuf_sort)
+ rtbuf_sort();
+ while (i < g_rtbuf_sorted_n) {
+ s_rtbuf *rtb = &g_rtbuf[g_rtbuf_sorted[i]];
+ assert(rtb->data);
+ if (rtb->proc->start) {
+ /* printf(" start ");
+ rtbuf_print(g_rtbuf_sorted[i]);
+ printf(" ");
+ rtbuf_proc_print(rtb->proc);
+ printf("\n"); */
+ if (rtb->proc->start(rtb))
+ return 1;
+ }
+ i++;
+ }
+ return 0;
+}
+
+int rtbuf_run ()
+{
+ unsigned int i = 0;
+ /* printf("rtbuf_run\n"); */
+ if (g_rtbuf_sort)
+ rtbuf_sort();
+ while (i < g_rtbuf_sorted_n) {
+ s_rtbuf *rtb = &g_rtbuf[g_rtbuf_sorted[i]];
+ /* printf(" rtbuf_run %i ", i);
+ rtbuf_print(g_rtbuf_sorted[i]);
+ printf("\n"); */
+ assert(rtb->data);
+ if (rtb->proc->f)
+ if (rtb->proc->f(rtb))
+ return 1;
+ i++;
+ }
+ /* printf(" rtbuf_run => %u\n", i); */
+ return 0;
+}
+
+void rtbuf_stop ()
+{
+ unsigned int i = 0;
+ /* printf("rtbuf_stop\n"); */
+ if (g_rtbuf_sort)
+ rtbuf_sort();
+ while (i < g_rtbuf_sorted_n) {
+ s_rtbuf *rtb = &g_rtbuf[g_rtbuf_sorted[i]];
+ assert(rtb->data);
+ if (rtb->proc->stop)
+ rtb->proc->stop(rtb);
+ i++;
+ }
+}
+
+int rtbuf_find (const char *x)
+{
+ if ('0' <= x[0] && x[0] <= '9') {
+ int i = atoi(x);
+ if (0 <= i && (unsigned int) i < g_rtbuf_alloc.n &&
+ g_rtbuf[i].data && g_rtbuf[i].proc)
+ return i;
+ }
+ else {
+ s_rtbuf_var *v = rtbuf_var_find(x);
+ if (v)
+ return v->index;
+ }
+ return -1;
+}
+
+int rtbuf_in_find (s_rtbuf *rtb, const char *x)
+{
+ s_rtbuf_proc *proc = rtb->proc;
+ symbol sym;
+ /* printf("rtbuf_in_find %s\n", x); */
+ if ('0' <= x[0] && x[0] <= '9') {
+ int i = atoi(x);
+ if (0 <= i && (unsigned int) i < proc->in_n)
+ return i;
+ }
+ if ((sym = symbol_find(x))) {
+ unsigned int i = 0;
+ /* printf("rtbuf_in_find sym %s\n", sym); */
+ while (i < proc->in_n) {
+ if (sym == proc->in[i].name)
+ return i;
+ i++;
+ }
+ }
+ return -1;
+}
+
+int rtbuf_out_find (s_rtbuf *rtb, const char *x)
+{
+ s_rtbuf_proc *proc = rtb->proc;
+ symbol sym;
+ /* printf("rtbuf_out_find %s\n", x); */
+ if ('0' <= x[0] && x[0] <= '9') {
+ int i = atoi(x);
+ if (0 <= i && (unsigned int) i < proc->out_n)
+ return i;
+ }
+ if ((sym = symbol_find(x))) {
+ unsigned int i = 0;
+ /* printf("rtbuf_out_find sym %s\n", sym); */
+ while (i < proc->out_n) {
+ if (sym == proc->out[i].name)
+ return i;
+ i++;
+ }
+ }
+ return -1;
+}
+
+int rtbuf_out_int (s_rtbuf *rtb, unsigned int out, int default_value)
+{
+ s_rtbuf_proc_out *o;
+ assert(rtb);
+ assert(rtb->data);
+ assert(rtb->proc);
+ assert(out < rtb->proc->out_n);
+ o = &rtb->proc->out[out];
+ assert(o->type);
+ if (o->type->t.bits >= sizeof(int) * 8) {
+ int *i = (int*)(rtb->data + o->offset);
+ return *i;
+ }
+ return default_value;
+}
+
+void rtbuf_print (unsigned int i)
+{
+ assert(i < RTBUF_MAX);
+ printf("#<rtbuf %u>", i);
+ fflush(stdout);
+}
+
+void rtbuf_print_long_in (s_rtbuf *rtb, unsigned int j)
+{
+ assert(rtb);
+ assert(rtb->proc);
+ assert(j < rtb->proc->in_n);
+ assert(rtb->proc->in[j].name);
+ assert(rtb->proc->in[j].type);
+ assert(rtb->proc->in[j].type->name);
+ printf("\n in %i %s:%s", j, rtb->proc->in[j].name,
+ rtb->proc->in[j].type->name);
+ if (rtb->in[j].rtb >= 0) {
+ s_rtbuf *target = &g_rtbuf[rtb->in[j].rtb];
+ unsigned int target_out = rtb->in[j].out;
+ printf (" = ");
+ rtbuf_print(rtb->in[j].rtb);
+ printf(" out %u %s:%s", target_out,
+ target->proc->out[target_out].name,
+ target->proc->out[target_out].type->name);
+ }
+}
+
+void rtbuf_print_long (unsigned int i)
+{
+ s_rtbuf *rtb;
+ s_rtbuf_proc *proc;
+ unsigned int j = 0;
+ assert(i < RTBUF_MAX);
+ rtb = &g_rtbuf[i];
+ proc = rtb->proc;
+ printf("#<rtbuf %i", i);
+ printf(" %s %s", proc->lib->name, proc->name);
+ if (rtb->data) {
+ printf(" %d", rtb->refc);
+ while (j < proc->in_n)
+ rtbuf_print_long_in(rtb, j++);
+ j = 0;
+ while (j < proc->out_n) {
+ printf("\n out %i %s:%s", j, proc->out[j].name,
+ proc->out[j].type->name);
+ j++;
+ }
+ }
+ printf(">\n");
+ fflush(stdout);
+}
+
+void rtbuf_print_sorted ()
+{
+ unsigned int i = 0;
+ while (i < g_rtbuf_sorted_n) {
+ if (i)
+ printf(" ");
+ rtbuf_print(g_rtbuf_sorted[i]);
+ i++;
+ }
+ printf("\n");
+}
+
+double min (double a, double b)
+{
+ return a < b ? a : b;
+}
+
+double max (double a, double b)
+{
+ return a < b ? b : a;
+}
+
+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;
+}
diff --git a/librtbuf/rtbuf_fun.c b/librtbuf/rtbuf_fun.c
new file mode 100644
index 0000000..ea103e1
--- /dev/null
+++ b/librtbuf/rtbuf_fun.c
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <strings.h>
+#include "data.h"
+#include "rtbuf.h"
+#include "symbol.h"
+
+s_data_type g_rtbuf_proc_type = {
+ sizeof(s_rtbuf_proc) * 8,
+ DATA_TYPE_BITS
+};
+s_data_alloc g_rtbuf_proc_alloc;
+s_rtbuf_proc *g_rtbuf_proc;
+
+void rtbuf_proc_init ()
+{
+ data_alloc_init(&g_rtbuf_proc_alloc, &g_rtbuf_proc_type,
+ RTBUF_PROC_MAX, 0, 0);
+}
+
+int rtbuf_proc_p (s_rtbuf_proc *proc)
+{
+ return proc && proc->name;
+}
+
+s_rtbuf_proc * rtbuf_proc_new ()
+{
+ s_rtbuf_proc *rf = data_new(&g_rtbuf_proc_alloc);
+ return rf;
+}
+
+void rtbuf_proc_delete (s_rtbuf_proc *proc)
+{
+ assert(proc);
+ data_delete(&g_rtbuf_proc_alloc, proc);
+}
+
+s_rtbuf_proc * rtbuf_proc_find (const char *x)
+{
+ const char *sym = symbol_find(x);
+ if (sym) {
+ unsigned int i = 0;
+ unsigned int n = g_rtbuf_alloc.n - g_rtbuf_alloc.free_n;
+ while (i < g_rtbuf_proc_alloc.n && n > 0) {
+ if (rtbuf_proc_p(&g_rtbuf_proc[i])) {
+ if (sym == g_rtbuf_proc[i].name)
+ return &g_rtbuf_proc[i];
+ n--;
+ }
+ i++;
+ }
+ }
+ return 0;
+}
+
+int rtbuf_proc_out_find (s_rtbuf_proc *proc, const char *x)
+{
+ symbol sym;
+ if (x && '0' <= x[0] && x[0] <= '9') {
+ int i = atoi(x);
+ if (0 <= i && (unsigned int) i < proc->out_n)
+ return i;
+ }
+ if ((sym = symbol_find(x))) {
+ unsigned int i = 0;
+ while (i < proc->out_n) {
+ if (sym == proc->out[i].name)
+ return i;
+ i++;
+ }
+ }
+ return -1;
+}
+
+void rtbuf_proc_print (s_rtbuf_proc *proc)
+{
+ unsigned int i = 0;
+ printf("#<proc %i %s (", proc->lib_proc, proc->name);
+ while (i < proc->var_n) {
+ if (i > 0)
+ fputs(" ", stdout);
+ fputs(proc->var[i].name, stdout);
+ fputs(":", stdout);
+ fputs(proc->var[i].type->name, stdout);
+ i++;
+ }
+ printf(") -> (");
+ i = 0;
+ while (i < proc->out_n) {
+ if (i > 0)
+ fputs(" ", stdout);
+ fputs(proc->out[i].name, stdout);
+ fputs(":", stdout);
+ fputs(proc->out[i].type->name, stdout);
+ i++;
+ }
+ fputs(")>", stdout);
+}
diff --git a/librtbuf/rtbuf_lib.c b/librtbuf/rtbuf_lib.c
new file mode 100644
index 0000000..1f5ec01
--- /dev/null
+++ b/librtbuf/rtbuf_lib.c
@@ -0,0 +1,314 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <assert.h>
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <rtbuf/rtbuf.h>
+#include <rtbuf/lib.h>
+#include <rtbuf/symbol.h>
+
+s_data_type g_rtbuf_lib_type = {
+ sizeof(s_rtbuf_lib) * 8,
+ DATA_TYPE_BITS
+};
+s_data_alloc g_rtbuf_lib_alloc;
+s_rtbuf_lib *g_rtbuf_lib;
+
+char g_rtbuf_lib_user_dir[1024];
+char *g_rtbuf_lib_path[] = { "",
+ "./",
+ "./.libs/",
+ g_rtbuf_lib_user_dir,
+ "/usr/local/lib/",
+ "/usr/lib/",
+ 0 };
+
+void rtbuf_lib_init_ ()
+{
+ char *in = getenv("HOME");
+ char *out = g_rtbuf_lib_user_dir;
+ data_alloc_init(&g_rtbuf_lib_alloc, &g_rtbuf_lib_type,
+ RTBUF_LIB_MAX, 0, 0);
+ g_rtbuf_lib = g_rtbuf_lib_alloc.mem;
+ assert(g_rtbuf_lib);
+ if (!in)
+ in = ".";
+ while (*in)
+ *out++ = *in++;
+ in = "/.rtbuf/lib/";
+ while (*in)
+ *out++ = *in++;
+ *out = 0;
+}
+
+int rtbuf_lib_p (s_rtbuf_lib *lib)
+{
+ return lib->lib ? 1 : 0;
+}
+
+int rtbuf_lib_find (const char *str)
+{
+ const char *sym;
+ if ('0' <= str[0] && str[0] <= '9') {
+ int i = atoi(str);
+ if (0 <= i && (unsigned int) i < g_rtbuf_lib_alloc.n &&
+ rtbuf_lib_p(&g_rtbuf_lib[i]))
+ return i;
+ }
+ if ((sym = symbol_find(str))) {
+ unsigned int i = 0;
+ unsigned int n = g_rtbuf_lib_alloc.n - g_rtbuf_lib_alloc.free_n;
+ while (i < g_rtbuf_lib_alloc.n && n > 0) {
+ if (rtbuf_lib_p(&g_rtbuf_lib[i])) {
+ if (sym == g_rtbuf_lib[i].name)
+ return i;
+ n--;
+ }
+ i++;
+ }
+ }
+ return -1;
+}
+
+int rtbuf_lib_find_proc (s_rtbuf_lib *rl, const char *str)
+{
+ const char *sym;
+ if ('0' <= str[0] && str[0] <= '9') {
+ int i = atoi(str);
+ if (0 <= i && (unsigned) i < rl->proc_n)
+ return i;
+ }
+ if ((sym = symbol_find(str))) {
+ unsigned int i = 0;
+ while (i < rl->proc_n) {
+ if (sym == rl->proc[i]->name)
+ return i;
+ i++;
+ }
+ }
+ return -1;
+}
+
+s_rtbuf_lib * rtbuf_lib_new ()
+{
+ s_rtbuf_lib *lib = data_new(&g_rtbuf_lib_alloc);
+ return lib;
+}
+
+void rtbuf_lib_delete (s_rtbuf_lib *rl)
+{
+ unsigned int i = 0;
+ assert(rl);
+ if (rl->proc) {
+ while (i < rl->proc_n) {
+ rtbuf_proc_delete(rl->proc[i]);
+ rl->proc[i] = 0;
+ i++;
+ }
+ free(rl->proc);
+ }
+ data_delete(&g_rtbuf_lib_alloc, rl);
+}
+
+void rtbuf_lib_load_path (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 = "librtbuf_";
+ while (*in)
+ g_string[g_string_n++] = *in++;
+ in = name;
+ while (*in)
+ g_string[g_string_n++] = *in++;
+ in = ".so";
+ 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);
+ }
+}
+
+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;
+}
+
+s_rtbuf_lib * rtbuf_lib_load (const char *name)
+{
+ s_rtbuf_lib *lib = rtbuf_lib_new();
+ s_rtbuf_lib_proc *proc;
+ unsigned long *ver;
+ unsigned int i = 0;
+ union {
+ void *ptr;
+ f_rtbuf_lib_init *init;
+ } init_ptr;
+ if (!lib)
+ return 0;
+ rtbuf_lib_load_path(lib, name);
+ if (!lib->lib) {
+ 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); */
+ assert(*ver == RTBUF_LIB_VER);
+ lib->name = symbol_intern(name);
+ /* printf("lib_load name %s\n", lib->name); */
+ if ((init_ptr.ptr = dlsym(lib->lib, "rtbuf_lib_init")))
+ if (init_ptr.init(lib) < 0) {
+ rtbuf_lib_delete(lib);
+ return 0;
+ }
+ proc = dlsym(lib->lib, "rtbuf_lib_proc");
+ lib->proc_n = 0;
+ while (lib->proc_n < RTBUF_PROC_MAX &&
+ rtbuf_lib_proc_p(&proc[lib->proc_n]))
+ lib->proc_n++;
+ lib->proc = malloc(sizeof(s_rtbuf_proc*) * (lib->proc_n + 1));
+ while (i < lib->proc_n) {
+ lib->proc[i] = rtbuf_proc_new();
+ assert(lib->proc[i]);
+ rtbuf_lib_proc_init_proc(lib->proc[i], &proc[i]);
+ lib->proc[i]->lib = lib;
+ lib->proc[i]->lib_proc = i;
+ i++;
+ }
+ lib->proc[i] = 0;
+ return lib;
+}
+
+void rtbuf_lib_proc_in_init_proc (s_rtbuf_proc *proc,
+ s_rtbuf_lib_proc_in *in)
+{
+ unsigned int i = 0;
+ bzero(proc->in, sizeof(proc->in));
+ if (in) {
+ while (in->name && i < RTBUF_PROC_IN_MAX) {
+ s_rtbuf_proc_in *v = &proc->in[i];
+ v->name = symbol_intern(in->name);
+ v->type = rtbuf_type(in->type);
+ v->def = in->def;
+ v->min = in->min;
+ v->max = in->max;
+ in++;
+ i++;
+ }
+ assert(i < RTBUF_PROC_IN_MAX);
+ }
+ proc->in_n = i;
+}
+
+void rtbuf_lib_proc_out_init_proc (s_rtbuf_proc *proc,
+ s_rtbuf_lib_proc_out *out)
+{
+ unsigned int i = 0;
+ bzero(proc->out, sizeof(proc->out));
+ if (out) {
+ unsigned int offset = 0;
+ while (out->name && i < RTBUF_PROC_OUT_MAX) {
+ s_rtbuf_proc_out *o = &proc->out[i];
+ o->name = symbol_intern(out->name);
+ o->type = rtbuf_type(out->type);
+ assert(o->type);
+ o->offset = offset;
+ offset += (o->type->t.bits + 7) / 8;
+ out++;
+ i++;
+ }
+ assert(i < RTBUF_PROC_OUT_MAX);
+ proc->out_bytes = offset;
+ proc->type.bits = offset * 8;
+ proc->type.type = DATA_TYPE_BITS;
+ data_alloc_init(&proc->alloc, &proc->type, RTBUF_INSTANCE_MAX,
+ NULL, NULL);
+ }
+ proc->out_n = i;
+}
+
+void rtbuf_lib_proc_init_proc (s_rtbuf_proc *proc, s_rtbuf_lib_proc *x)
+{
+ proc->name = symbol_intern(x->name);
+ proc->f = x->f;
+ proc->start = x->start;
+ proc->stop = x->stop;
+ rtbuf_lib_proc_in_init_proc(proc, x->in);
+ rtbuf_lib_proc_out_init_proc(proc, x->out);
+}
+
+void rtbuf_lib_print (const s_rtbuf_lib *lib)
+{
+ unsigned int i;
+ if (lib >= g_rtbuf_lib &&
+ (i = lib - g_rtbuf_lib) < RTBUF_LIB_MAX)
+ printf("#<lib %i %s>\n", i, lib->name);
+ else
+ printf("#<lib %p %s>\n", lib, lib->name);
+}
+
+void rtbuf_lib_print_long (unsigned int i)
+{
+ s_rtbuf_lib *lib;
+ unsigned int j = 0;
+ assert(i < RTBUF_LIB_MAX);
+ lib = &g_rtbuf_lib[i];
+ printf("#<lib %i %s", i, lib->name);
+ printf("\n %s", lib->path);
+ while (j < lib->proc_n) {
+ printf("\n ");
+ rtbuf_proc_print(lib->proc[j]);
+ j++;
+ }
+ printf(">\n");
+ fflush(stdout);
+}
diff --git a/librtbuf/rtbuf_proc.c b/librtbuf/rtbuf_proc.c
new file mode 100644
index 0000000..b69c107
--- /dev/null
+++ b/librtbuf/rtbuf_proc.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <strings.h>
+#include <rtbuf/data.h>
+#include <rtbuf/rtbuf.h>
+#include <rtbuf/symbol.h>
+
+s_data_type g_rtbuf_proc_type = {
+ sizeof(s_rtbuf_proc) * 8,
+ DATA_TYPE_BITS
+};
+s_data_alloc g_rtbuf_proc_alloc;
+s_rtbuf_proc *g_rtbuf_proc;
+
+void rtbuf_proc_init ()
+{
+ data_alloc_init(&g_rtbuf_proc_alloc, &g_rtbuf_proc_type,
+ RTBUF_PROC_MAX, 0, 0);
+ g_rtbuf_proc = g_rtbuf_proc_alloc.mem;
+ assert(g_rtbuf_proc);
+}
+
+int rtbuf_proc_p (s_rtbuf_proc *proc)
+{
+ return proc && proc->name;
+}
+
+s_rtbuf_proc * rtbuf_proc_new ()
+{
+ s_rtbuf_proc *rf = data_new(&g_rtbuf_proc_alloc);
+ return rf;
+}
+
+void rtbuf_proc_delete (s_rtbuf_proc *proc)
+{
+ assert(proc);
+ data_delete(&g_rtbuf_proc_alloc, proc);
+}
+
+s_rtbuf_proc * rtbuf_proc_find (const char *x)
+{
+ const char *sym = symbol_find(x);
+ if (sym) {
+ unsigned int i = 0;
+ unsigned int n = g_rtbuf_alloc.n - g_rtbuf_alloc.free_n;
+ while (i < g_rtbuf_proc_alloc.n && n > 0) {
+ if (rtbuf_proc_p(&g_rtbuf_proc[i])) {
+ if (sym == g_rtbuf_proc[i].name)
+ return &g_rtbuf_proc[i];
+ n--;
+ }
+ i++;
+ }
+ }
+ return 0;
+}
+
+int rtbuf_proc_out_find (s_rtbuf_proc *proc, const char *x)
+{
+ symbol sym;
+ if (x && '0' <= x[0] && x[0] <= '9') {
+ int i = atoi(x);
+ if (0 <= i && (unsigned int) i < proc->out_n)
+ return i;
+ }
+ if ((sym = symbol_find(x))) {
+ unsigned int i = 0;
+ while (i < proc->out_n) {
+ if (sym == proc->out[i].name)
+ return i;
+ i++;
+ }
+ }
+ return -1;
+}
+
+void rtbuf_proc_print (s_rtbuf_proc *proc)
+{
+ unsigned int i = 0;
+ printf("#<proc %i %s (", proc->lib_proc, proc->name);
+ while (i < proc->in_n) {
+ if (i > 0)
+ fputs(" ", stdout);
+ fputs(proc->in[i].name, stdout);
+ fputs(":", stdout);
+ fputs(proc->in[i].type->name, stdout);
+ i++;
+ }
+ printf(") -> (");
+ i = 0;
+ while (i < proc->out_n) {
+ if (i > 0)
+ fputs(" ", stdout);
+ fputs(proc->out[i].name, stdout);
+ fputs(":", stdout);
+ fputs(proc->out[i].type->name, stdout);
+ i++;
+ }
+ fputs(")>", stdout);
+}
diff --git a/librtbuf/rtbuf_type.c b/librtbuf/rtbuf_type.c
new file mode 100644
index 0000000..21bcd24
--- /dev/null
+++ b/librtbuf/rtbuf_type.c
@@ -0,0 +1,137 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <rtbuf/type.h>
+#include <rtbuf/symbol.h>
+
+s_data_type g_rtbuf_data_type_type = {
+ sizeof(s_rtbuf_type) * 8,
+ DATA_TYPE_BITS
+};
+s_data_alloc g_rtbuf_data_type_alloc;
+s_rtbuf_type *g_rtbuf_data_type;
+
+void rtbuf_type_init ()
+{
+ data_alloc_init(&g_rtbuf_data_type_alloc, &g_rtbuf_data_type_type,
+ RTBUF_TYPE_MAX, 0, 0);
+ g_rtbuf_data_type = g_rtbuf_data_type_alloc.mem;
+ assert(g_rtbuf_data_type);
+ rtbuf_type_define("char" , sizeof(char));
+ rtbuf_type_define("unsigned char" , sizeof(unsigned char));
+ rtbuf_type_define("short" , sizeof(short));
+ rtbuf_type_define("unsigned short", sizeof(unsigned short));
+ rtbuf_type_define("int" , sizeof(int));
+ rtbuf_type_define("unsigned int" , sizeof(unsigned int));
+ rtbuf_type_define("long" , sizeof(long));
+ rtbuf_type_define("unsigned long" , sizeof(unsigned long));
+ rtbuf_type_define("float" , sizeof(float));
+ rtbuf_type_define("double" , sizeof(double));
+}
+
+s_rtbuf_type * rtbuf_type_new (const char *name, unsigned int size)
+{
+ s_rtbuf_type *rt = data_new(&g_rtbuf_data_type_alloc);
+ if (!rt)
+ return 0;
+ rt->name = symbol_intern(name);
+ rt->t.bits = size * 8;
+ rt->t.type = DATA_TYPE_BITS;
+ return rt;
+}
+
+void rtbuf_type_delete (s_rtbuf_type *rt)
+{
+ assert(rt);
+ data_delete(&g_rtbuf_data_type_alloc, rt);
+}
+
+s_rtbuf_type * rtbuf_type_find (symbol name)
+{
+ unsigned int i = 0;
+ unsigned int n =
+ g_rtbuf_data_type_alloc.n - g_rtbuf_data_type_alloc.free_n;
+ while (i < g_rtbuf_data_type_alloc.n && n > 0) {
+ if (g_rtbuf_data_type[i].name) {
+ if (name == g_rtbuf_data_type[i].name)
+ return &g_rtbuf_data_type[i];
+ n--;
+ }
+ i++;
+ }
+ return 0;
+}
+
+s_rtbuf_type * rtbuf_type_define (const char *name, unsigned int size)
+{
+ s_rtbuf_type *found = rtbuf_type_find(name);
+ if (found && found->t.bits == size * 8)
+ return found;
+ return rtbuf_type_new(name, size);
+}
+
+s_rtbuf_type * rtbuf_type_parse_array (const char *name)
+{
+ char *bracket = strchr(name, '[');
+ char *right_bracket = bracket ? strchr(bracket, ']') : 0;
+ if (right_bracket) {
+ char buf[1024];
+ unsigned int lb = bracket - name;
+ unsigned int rb = right_bracket - name;
+ s_rtbuf_type *element_type;
+ unsigned int size;
+ strlcpy(buf, name, sizeof(buf));
+ buf[lb] = 0;
+ if ((element_type = rtbuf_type(buf)) == 0)
+ return 0;
+ buf[rb] = 0;
+ size = atoi(&buf[lb + 1]);
+ return rtbuf_type_new(name, element_type->t.bits / 8 * size);
+ }
+ return 0;
+}
+
+s_rtbuf_type * rtbuf_type_parse_pointer (const char *name)
+{
+ char *star = strchr(name, '*');
+ if (star && star[1] == 0)
+ return rtbuf_type_new(name, sizeof(void*));
+ return 0;
+}
+
+s_rtbuf_type * rtbuf_type (const char *name)
+{
+ const char *sym = symbol_find(name);
+ s_rtbuf_type *rt;
+ if (!(rt = sym ? rtbuf_type_find(sym) : 0) &&
+ !(rt = rtbuf_type_parse_array(name)) &&
+ !(rt = rtbuf_type_parse_pointer(name)))
+ printf("type not found: %s\n", name);
+ return rt;
+}
+
+s_rtbuf_type * rtbuf_type_array (const char *element_type,
+ unsigned int size)
+{
+ char buf[1024];
+ snprintf(buf, sizeof(buf), "%s[%u]", element_type, size);
+ return rtbuf_type(buf);
+}
diff --git a/librtbuf/rtbuf_var.c b/librtbuf/rtbuf_var.c
new file mode 100644
index 0000000..5be53f3
--- /dev/null
+++ b/librtbuf/rtbuf_var.c
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <rtbuf/data.h>
+#include <rtbuf/var.h>
+#include <rtbuf/rtbuf.h>
+
+s_data_type g_rtbuf_var_type = {
+ sizeof(s_rtbuf_var) * 8,
+ DATA_TYPE_BITS
+};
+s_data_alloc g_rtbuf_var_alloc;
+s_rtbuf_var *g_rtbuf_var;
+
+void rtbuf_var_init (void)
+{
+ data_alloc_init(&g_rtbuf_var_alloc, &g_rtbuf_var_type, RTBUF_VAR_MAX, NULL, NULL);
+ g_rtbuf_var = g_rtbuf_var_alloc.mem;
+ assert(g_rtbuf_var);
+}
+
+s_rtbuf_var * rtbuf_var_new (const char *name)
+{
+ s_rtbuf_var *v = data_new(&g_rtbuf_var_alloc);
+ if (v)
+ v->name = symbol_intern(name);
+ return v;
+}
+
+s_rtbuf_var * rtbuf_var_find (const char *name)
+{
+ s_rtbuf_var *v = g_rtbuf_var + g_rtbuf_var_alloc.n;
+ unsigned i = g_rtbuf_var_alloc.n;
+ const char *sym = symbol_find(name);
+ if (sym)
+ while (v--, i--) {
+ assert(v >= g_rtbuf_var);
+ if (v->name == sym)
+ return v;
+ }
+ return NULL;
+}
+
+s_rtbuf_var * rtbuf_var_rtbuf_set (const char *name, unsigned i)
+{
+ s_rtbuf_var *v = rtbuf_var_find(name);
+ if (!v)
+ v = rtbuf_var_new(name);
+ if (v) {
+ v->type = RTBUF_VAR_RTBUF;
+ v->index = i;
+ }
+ return v;
+}
+
+void rtbuf_var_print (const s_rtbuf_var *v)
+{
+ if (v) {
+ printf("%s = ", v->name);
+ switch (v->type) {
+ case RTBUF_VAR_NULL:
+ printf("NULL");
+ fflush(stdout);
+ break;
+ case RTBUF_VAR_RTBUF:
+ rtbuf_print_long(v->index);
+ break;
+ default:
+ assert(0);
+ }
+ }
+}
diff --git a/librtbuf/symbol.c b/librtbuf/symbol.c
new file mode 100644
index 0000000..0f1f037
--- /dev/null
+++ b/librtbuf/symbol.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <rtbuf/symbol.h>
+
+char g_string[STRING_MAX];
+unsigned int g_string_n = 0;
+
+const char *g_symbols[SYMBOL_MAX];
+unsigned int g_symbols_n = 0;
+
+void symbols_init () {
+ bzero(g_string, sizeof(g_string));
+ bzero(g_symbols, sizeof(g_symbols));
+}
+
+symbol symbol_new (const char *name)
+{
+ unsigned int i = 0;
+ if (g_symbols_n == SYMBOL_MAX) {
+ fprintf(stderr, "maximum number of symbols exceeded\n");
+ return 0;
+ }
+ while (i < SYMBOL_MAX) {
+ if (g_symbols[i] == 0) {
+ const char *in = name;
+ char *out = &g_string[g_string_n];
+ g_symbols[i] = out;
+ while (*in) {
+ *out++ = *in++;
+ g_string_n++;
+ }
+ *out = 0;
+ g_string_n++;
+ g_symbols_n++;
+ return g_symbols[i];
+ }
+ i++;
+ }
+ return 0;
+}
+
+symbol symbol_find (const char *name)
+{
+ unsigned int i = 0;
+ unsigned int n = g_symbols_n;
+ while (i < SYMBOL_MAX && n > 0) {
+ if (g_symbols[i]) {
+ if (name == g_symbols[i] ||
+ strcmp(name, g_symbols[i]) == 0)
+ return g_symbols[i];
+ n--;
+ }
+ i++;
+ }
+ return 0;
+}
+
+symbol symbol_intern (const char *name)
+{
+ symbol sym = symbol_find(name);
+ if (sym == 0)
+ sym = symbol_new(name);
+ return sym;
+}
diff --git a/queue.h b/queue.h
deleted file mode 100644
index f886dd3..0000000
--- a/queue.h
+++ /dev/null
@@ -1,60 +0,0 @@
-#ifndef QUEUE_H
-#define QUEUE_H
-
-/* static queue */
-
-#define QUEUE_TYPE(type, size) \
- type ## _queue_ ## size
-
-#define QUEUE(type, size) \
- struct QUEUE_TYPE(type, size) { \
- unsigned int length; \
- unsigned int read_index; \
- unsigned int write_index; \
- type item[size]; \
- }
-
-#define S_QUEUE_TYPE(type, size) \
- s_ ## QUEUE_TYPE(type, size)
-
-#define QUEUE_METHOD(type, size, method) \
- QUEUE_TYPE(type, size) ## _ ## method
-
-#define DEFINE_QUEUE(type, size) \
- typedef QUEUE(type, size) S_QUEUE_TYPE(type, size); \
- static void QUEUE_METHOD(type, size, init) \
- (S_QUEUE_TYPE(type, size) *q) \
- { \
- bzero(q, sizeof(q)); \
- } \
- static void QUEUE_METHOD(type, size, free) \
- (S_QUEUE_TYPE(type, size) *q) \
- { \
- bzero(q, sizeof(q)); \
- } \
- static int QUEUE_METHOD(type, size, enqueue) \
- (S_QUEUE_TYPE(type, size) *q, type item) \
- { \
- if (q->length < size) { \
- unsigned int write_index = q->write_index; \
- q->write_index = (q->write_index + 1) % size; \
- q->item[write_index] = item; \
- q->length++; \
- return 0; \
- } \
- return -1; \
- } \
- static int QUEUE_METHOD(type, size, dequeue) \
- (S_QUEUE_TYPE(type, size) *q, type *ptr) \
- { \
- if (q->length > 0) { \
- unsigned int read_index = q->read_index; \
- q->read_index = (read_index + 1) % size; \
- *ptr = q->item[read_index]; \
- q->length--; \
- return 0; \
- } \
- return -1; \
- }
-
-#endif
diff --git a/rtbuf.c b/rtbuf.c
deleted file mode 100644
index d42b83b..0000000
--- a/rtbuf.c
+++ /dev/null
@@ -1,548 +0,0 @@
-/*
- * Copyright 2018,2020 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <strings.h>
-#include "data.h"
-#include "rtbuf.h"
-#include "rtbuf_lib.h"
-#include "rtbuf_var.h"
-#include "symbol.h"
-
-s_data_type g_rtbuf_type = {
- sizeof(s_rtbuf) * 8,
- DATA_TYPE_BITS
-};
-s_data_alloc g_rtbuf_alloc;
-s_rtbuf *g_rtbuf = 0;
-int g_rtbuf_run = 0;
-unsigned int g_rtbuf_sort = 0;
-unsigned int g_rtbuf_sorted[RTBUF_MAX];
-unsigned int g_rtbuf_sorted_n = 0;
-
-int librtbuf_init ()
-{
- libdata_init();
- bzero(g_rtbuf_sorted, sizeof(g_rtbuf_sorted));
- data_alloc_init(&g_rtbuf_alloc, &g_rtbuf_type, RTBUF_MAX, NULL, NULL);
- g_rtbuf = g_rtbuf_alloc.mem;
- assert(g_rtbuf);
- rtbuf_type_init();
- rtbuf_proc_init();
- rtbuf_lib_init_();
- rtbuf_var_init();
- return 0;
-}
-
-int rtbuf_new (s_rtbuf_proc *rp)
-{
- int i;
- s_rtbuf *rtb;
- void *data;
- unsigned int j = 0;
- assert(rp);
- assert(g_rtbuf);
- data = data_new(&rp->alloc);
- if (!data)
- return rtbuf_err("rtbuf data allocation failed, "
- "please increase RTBUF_INSTANCE_MAX");
- if ((i = data_new_i(&g_rtbuf_alloc)) < 0)
- return rtbuf_err("rtbuf allocation failed, "
- "please increase RTBUF_MAX");
- rtb = &g_rtbuf[i];
- rtb->data = data;
- rtb->flags = 0;
- rtb->proc = rp;
- while (j < RTBUF_PROC_IN_MAX) {
- rtb->in[j].rtb = -1;
- j++;
- }
- g_rtbuf_sort = 1;
- return i;
-}
-
-void rtbuf_in_unbind (s_rtbuf *rtb, unsigned int in)
-{
- s_rtbuf_binding *v = &rtb->in[in];
- if (v->rtb >= 0) {
- s_rtbuf *src = &g_rtbuf[v->rtb];
- src->refc--;
- v->rtb = -1;
- v->out = 0;
- rtb->in_n--;
- }
-}
-
-static
-void rtbuf_unbind_all_out_rtbuf (s_rtbuf *rtb, unsigned int rtb_i,
- s_rtbuf *dest)
-{
- unsigned int i = 0;
- unsigned int n;
- assert(dest);
- n = dest->in_n;
- while (i < dest->proc->in_n && n > 0 && rtb->refc) {
- s_rtbuf_binding *v = &dest->in[i];
- if (v->rtb >= 0) {
- if ((unsigned int) v->rtb == rtb_i)
- rtbuf_in_unbind(dest, i);
- n--;
- }
- i++;
- }
-}
-
-void rtbuf_unbind_all_out (s_rtbuf *rtb)
-{
- unsigned int rtb_i;
- unsigned int i = 0;
- unsigned int n = g_rtbuf_alloc.n - g_rtbuf_alloc.free_n;
- assert(rtb);
- assert(g_rtbuf <= rtb);
- assert(rtb < g_rtbuf + RTBUF_MAX);
- rtb_i = rtb - g_rtbuf;
- while (i < g_rtbuf_alloc.n && rtb->refc) {
- if (g_rtbuf[i].data) {
- rtbuf_unbind_all_out_rtbuf(rtb, rtb_i, &g_rtbuf[i]);
- n--;
- }
- i++;
- }
-}
-
-void rtbuf_unbind_all (s_rtbuf *rtb)
-{
- unsigned int i = 0;
- assert(rtb);
- assert(rtb->proc);
- while (i < rtb->proc->in_n && rtb->in_n > 0) {
- rtbuf_in_unbind(rtb, i);
- i++;
- }
- rtbuf_unbind_all_out(rtb);
-}
-
-void rtbuf_delete_ (s_rtbuf *rtb)
-{
- assert(rtb);
- rtbuf_unbind_all(rtb);
- bzero(rtb->data, rtb->proc->out_bytes);
- data_delete(&rtb->proc->alloc, rtb->data);
- data_delete(&g_rtbuf_alloc, rtb);
-}
-
-void rtbuf_delete (s_rtbuf *rtb)
-{
- assert(rtb);
- rtb->flags |= RTBUF_DELETE;
- g_rtbuf_sort = 1;
-}
-
-int rtbuf_clone (s_rtbuf *rtb)
-{
- int new_i;
- s_rtbuf *new;
- unsigned int j = 0;
- assert(rtb);
- if ((new_i = rtbuf_new(rtb->proc)) < 0)
- return -1;
- new = &g_rtbuf[new_i];
- while (j < rtb->proc->in_n) {
- new->in[j] = rtb->in[j];
- j++;
- }
- new->in_n = rtb->in_n;
- return new_i;
-}
-
-void rtbuf_bind (unsigned int src, unsigned int out,
- s_rtbuf *dest, unsigned int in)
-{
- s_rtbuf_binding *v = &dest->in[in];
- if ((unsigned int) v->rtb == src && v->out == out)
- return;
- rtbuf_in_unbind(dest, in);
- v->rtb = src;
- v->out = out;
- dest->in_n++;
- g_rtbuf[src].refc++;
- g_rtbuf_sort = 1;
-}
-
-int rtbuf_data_set (s_rtbuf *rtb, symbol name, void *value,
- unsigned int size)
-{
- int out_i = rtbuf_proc_out_find(rtb->proc, name);
- if (out_i >= 0) {
- s_rtbuf_proc_out *out = &rtb->proc->out[out_i];
- if (out->type->t.bits == size * 8) {
- void *data = rtb->data + out->offset;
- memcpy(data, value, size);
- return size;
- }
- }
- return 0;
-}
-
-typedef struct rtbuf_in_ptr {
- unsigned int rtb;
- unsigned int in;
-} s_rtbuf_in_ptr;
-
-typedef struct rtbuf_in_stack {
- s_rtbuf_in_ptr st[RTBUF_MAX];
- unsigned int size;
-} s_rtbuf_in_stack;
-
-void rtbuf_in_stack_init (s_rtbuf_in_stack *rvs)
-{
- //printf("rtbuf_in_stack_init\n");
- bzero(rvs, sizeof(s_rtbuf_in_stack));
-}
-
-s_rtbuf_in_ptr * rtbuf_in_stack_push (s_rtbuf_in_stack *rvs,
- unsigned int rtb,
- unsigned int in)
-{
- //printf("rtbuf_in_stack_push %i %i\n", rtb, in);
- s_rtbuf_in_ptr *top;
- if (rvs->size >= RTBUF_MAX)
- return 0;
- top = &rvs->st[rvs->size];
- top->rtb = rtb;
- top->in = in;
- rvs->size++;
- return top;
-}
-
-s_rtbuf_in_ptr * rtbuf_in_stack_pop (s_rtbuf_in_stack *rvs)
-{
- //printf("rtbuf_in_stack_pop\n");
- if (rvs->size <= 0)
- return 0;
- rvs->size--;
- return &rvs->st[rvs->size];
-}
-
-s_rtbuf_in_ptr * rtbuf_in_stack_top (s_rtbuf_in_stack *rvs)
-{
- s_rtbuf_in_ptr *top;
- //printf("rtbuf_in_stack_top\n");
- if (rvs->size <= 0) {
- //printf(" rtbuf_in_stack_top => 0\n");
- return 0;
- }
- top = &rvs->st[rvs->size - 1];
- //printf(" rtbuf_in_stack_top => { %u, %u }\n", top->rtb, top->in);
- return top;
-}
-
-void rtbuf_find_roots (s_rtbuf_in_stack *rvs)
-{
- s_rtbuf *rtb = g_rtbuf;
- unsigned int i = 0;
- unsigned int n = g_rtbuf_alloc.n - g_rtbuf_alloc.free_n;
- unsigned int c = 0;
- //printf("rtbuf_find_roots\n");
- while (i < g_rtbuf_alloc.n && n > 0) {
- //printf(" rtbuf_find_roots %u %u\n", i, n);
- if (rtb->data) {
- if (rtb->flags & RTBUF_DELETE)
- rtbuf_delete_(rtb);
- else {
- if (rtb->refc == 0) {
- rtbuf_in_stack_push(rvs, i, 0);
- c++;
- }
- }
- n--;
- }
- rtb++;
- i++;
- }
- //printf(" rtbuf_find_roots => %u\n", c);
-}
-
-void rtbuf_sort_push_child (s_rtbuf_in_stack *rvs,
- s_rtbuf_in_ptr *ptr)
-{
- int rtb;
- unsigned int i = 0;
- int found = 0;
- //printf("rtbuf_sort_push_child { %u, %u }\n", ptr->rtb, ptr->in);
- rtb = g_rtbuf[ptr->rtb].in[ptr->in].rtb;
- ptr->in++;
- if (rtb >= 0) {
- while (i < g_rtbuf_sorted_n && !found) {
- if (g_rtbuf_sorted[i] == (unsigned) rtb)
- found = 1;
- i++;
- }
- i = 0;
- while (i < rvs->size && !found) {
- if (rvs->st[i].rtb == (unsigned int) rtb)
- found = 1;
- i++;
- }
- if (!found)
- rtbuf_in_stack_push(rvs, rtb, 0);
- }
-}
-
-void rtbuf_sort ()
-{
- s_rtbuf_in_stack rvs;
- s_rtbuf_in_ptr *ptr;
- //printf("rtbuf_sort\n");
- if (g_rtbuf_alloc.n == 0)
- return;
- rtbuf_in_stack_init(&rvs);
- rtbuf_find_roots(&rvs);
- g_rtbuf_sorted_n = 0;
- while ((ptr = rtbuf_in_stack_top(&rvs))) {
- if (ptr->in == g_rtbuf[ptr->rtb].proc->in_n) {
- g_rtbuf_sorted[g_rtbuf_sorted_n++] = ptr->rtb;
- rtbuf_in_stack_pop(&rvs);
- } else
- rtbuf_sort_push_child(&rvs, ptr);
- }
- g_rtbuf_sort = 0;
- rtbuf_print_sorted();
-}
-
-int rtbuf_start ()
-{
- unsigned int i = 0;
- //printf("rtbuf_start\n");
- if (g_rtbuf_sort)
- rtbuf_sort();
- while (i < g_rtbuf_sorted_n) {
- s_rtbuf *rtb = &g_rtbuf[g_rtbuf_sorted[i]];
- assert(rtb->data);
- if (rtb->proc->start) {
- //printf(" start ");
- //rtbuf_print(g_rtbuf_sorted[i]);
- //printf(" ");
- //rtbuf_proc_print(rtb->proc);
- //printf("\n");
- if (rtb->proc->start(rtb))
- return 1;
- }
- i++;
- }
- return 0;
-}
-
-int rtbuf_run ()
-{
- unsigned int i = 0;
- //printf("rtbuf_run\n");
- if (g_rtbuf_sort)
- rtbuf_sort();
- while (i < g_rtbuf_sorted_n) {
- s_rtbuf *rtb = &g_rtbuf[g_rtbuf_sorted[i]];
- //printf(" rtbuf_run %i ", i);
- //rtbuf_print(g_rtbuf_sorted[i]);
- //printf("\n");
- assert(rtb->data);
- if (rtb->proc->f)
- if (rtb->proc->f(rtb))
- return 1;
- i++;
- }
- //printf(" rtbuf_run => %u\n", i);
- return 0;
-}
-
-void rtbuf_stop ()
-{
- unsigned int i = 0;
- //printf("rtbuf_stop\n");
- if (g_rtbuf_sort)
- rtbuf_sort();
- while (i < g_rtbuf_sorted_n) {
- s_rtbuf *rtb = &g_rtbuf[g_rtbuf_sorted[i]];
- assert(rtb->data);
- if (rtb->proc->stop)
- rtb->proc->stop(rtb);
- i++;
- }
-}
-
-int rtbuf_find (const char *x)
-{
- if ('0' <= x[0] && x[0] <= '9') {
- int i = atoi(x);
- if (0 <= i && (unsigned int) i < g_rtbuf_alloc.n &&
- g_rtbuf[i].data && g_rtbuf[i].proc)
- return i;
- }
- else {
- s_rtbuf_var *v = rtbuf_var_find(x);
- if (v)
- return v->index;
- }
- return -1;
-}
-
-int rtbuf_in_find (s_rtbuf *rtb, const char *x)
-{
- s_rtbuf_proc *proc = rtb->proc;
- symbol sym;
- //printf("rtbuf_in_find %s\n", x);
- if ('0' <= x[0] && x[0] <= '9') {
- int i = atoi(x);
- if (0 <= i && (unsigned int) i < proc->in_n)
- return i;
- }
- if ((sym = symbol_find(x))) {
- unsigned int i = 0;
- //printf("rtbuf_in_find sym %s\n", sym);
- while (i < proc->in_n) {
- if (sym == proc->in[i].name)
- return i;
- i++;
- }
- }
- return -1;
-}
-
-int rtbuf_out_find (s_rtbuf *rtb, const char *x)
-{
- s_rtbuf_proc *proc = rtb->proc;
- symbol sym;
- //printf("rtbuf_out_find %s\n", x);
- if ('0' <= x[0] && x[0] <= '9') {
- int i = atoi(x);
- if (0 <= i && (unsigned int) i < proc->out_n)
- return i;
- }
- if ((sym = symbol_find(x))) {
- unsigned int i = 0;
- //printf("rtbuf_out_find sym %s\n", sym);
- while (i < proc->out_n) {
- if (sym == proc->out[i].name)
- return i;
- i++;
- }
- }
- return -1;
-}
-
-int rtbuf_out_int (s_rtbuf *rtb, unsigned int out, int default_value)
-{
- s_rtbuf_proc_out *o;
- assert(rtb);
- assert(rtb->data);
- assert(rtb->proc);
- assert(out < rtb->proc->out_n);
- o = &rtb->proc->out[out];
- assert(o->type);
- if (o->type->t.bits >= sizeof(int) * 8) {
- int *i = (int*)(rtb->data + o->offset);
- return *i;
- }
- return default_value;
-}
-
-void rtbuf_print (unsigned int i)
-{
- assert(i < RTBUF_MAX);
- printf("#<rtbuf %u>", i);
- fflush(stdout);
-}
-
-void rtbuf_print_long_in (s_rtbuf *rtb, unsigned int j)
-{
- assert(rtb);
- assert(rtb->proc);
- assert(j < rtb->proc->in_n);
- assert(rtb->proc->in[j].name);
- assert(rtb->proc->in[j].type);
- assert(rtb->proc->in[j].type->name);
- printf("\n in %i %s:%s", j, rtb->proc->in[j].name,
- rtb->proc->in[j].type->name);
- if (rtb->in[j].rtb >= 0) {
- s_rtbuf *target = &g_rtbuf[rtb->in[j].rtb];
- unsigned int target_out = rtb->in[j].out;
- printf (" = ");
- rtbuf_print(rtb->in[j].rtb);
- printf(" out %u %s:%s", target_out,
- target->proc->out[target_out].name,
- target->proc->out[target_out].type->name);
- }
-}
-
-void rtbuf_print_long (unsigned int i)
-{
- s_rtbuf *rtb;
- s_rtbuf_proc *proc;
- unsigned int j = 0;
- assert(i < RTBUF_MAX);
- rtb = &g_rtbuf[i];
- proc = rtb->proc;
- printf("#<rtbuf %i", i);
- printf(" %s %s", proc->lib->name, proc->name);
- if (rtb->data) {
- printf(" %d", rtb->refc);
- while (j < proc->in_n)
- rtbuf_print_long_in(rtb, j++);
- j = 0;
- while (j < proc->out_n) {
- printf("\n out %i %s:%s", j, proc->out[j].name,
- proc->out[j].type->name);
- j++;
- }
- }
- printf(">\n");
- fflush(stdout);
-}
-
-void rtbuf_print_sorted ()
-{
- unsigned int i = 0;
- while (i < g_rtbuf_sorted_n) {
- if (i)
- printf(" ");
- rtbuf_print(g_rtbuf_sorted[i]);
- i++;
- }
- printf("\n");
-}
-
-double min (double a, double b)
-{
- return a < b ? a : b;
-}
-
-double max (double a, double b)
-{
- return a < b ? b : a;
-}
-
-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;
-}
diff --git a/rtbuf.h b/rtbuf.h
deleted file mode 100644
index ed3e2a0..0000000
--- a/rtbuf.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 2018-2020 Thomas de Grivel <thoxdg@gmail.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-#ifndef RTBUF_H
-#define RTBUF_H
-
-#include "data.h"
-#include "rtbuf_defs.h"
-#include "rtbuf_type.h"
-#include "rtbuf_proc.h"
-
-#define RTBUF_SORT 0x0001
-#define RTBUF_DELETE 0x0002
-
-struct rtbuf_binding
-{
- int rtb;
- unsigned int out;
-};
-
-struct rtbuf
-{
- void *data;
- unsigned int flags;
- s_rtbuf_proc *proc;
- unsigned int refc;
- s_rtbuf_binding in[RTBUF_PROC_IN_MAX];
- unsigned int in_n;
-};
-
-#define RTBUF_MAX 10000
-#define RTBUF_INSTANCE_MAX 100
-
-extern s_data_alloc g_rtbuf_alloc;
-extern s_rtbuf *g_rtbuf;
-extern int g_rtbuf_run;
-
-int librtbuf_init ();
-
-int rtbuf_err (const char *msg);
-int rtbuf_new (s_rtbuf_proc *rp);
-void rtbuf_in_unbind (s_rtbuf *rtb, unsigned int var);
-void rtbuf_unbind_all (s_rtbuf *rtb);
-void rtbuf_delete (s_rtbuf *rtb);
-int rtbuf_clone (s_rtbuf *rtb);
-int rtbuf_find (symbol sym);
-int rtbuf_in_find (s_rtbuf *rtb, const char *x);
-void rtbuf_bind (unsigned int src, unsigned int out,
- s_rtbuf *dest, unsigned int var);
-int rtbuf_out_find (s_rtbuf *rtb, symbol sym);
-int rtbuf_data_set (s_rtbuf *rtb, symbol name, void *value,
- unsigned int size);
-void rtbuf_sort ();
-int rtbuf_start ();
-int rtbuf_run ();
-void rtbuf_stop ();
-void rtbuf_print (unsigned int i);
-void rtbuf_print_long (unsigned int i);
-void rtbuf_print_sorted ();
-
-int rtbuf_out_int (s_rtbuf *rtb, unsigned int out, int default_value);
-
-double min (double a, double b);
-double max (double a, double b);
-double clamp (double inf, double x, double sup);
-
-#endif /* RTBUF_H */
diff --git a/rtbuf_cli.c b/rtbuf_cli.c
deleted file mode 100644
index a18a741..0000000
--- a/rtbuf_cli.c
+++ /dev/null
@@ -1,383 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <assert.h>
-#include <pthread.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include "cli.h"
-#include "symbol.h"
-#include "rtbuf.h"
-#include "rtbuf_lib.h"
-#include "rtbuf_var.h"
-
-s_cli g_cli;
-pthread_t g_rtbuf_cli_thread = 0;
-
-int rtbuf_cli_libs (int argc, const char *argv[])
-{
- unsigned int i = 0;
- unsigned int n = g_rtbuf_lib_alloc.n - g_rtbuf_lib_alloc.free_n;
- assert(argc == 0);
- (void) argv;
- printf("Listing %i libraries :\n", n);
- while (i < g_rtbuf_lib_alloc.n && n > 0) {
- if (g_rtbuf_lib[i].path[0]) {
- rtbuf_lib_print(&g_rtbuf_lib[i]);
- n--;
- }
- i++;
- }
- return 0;
-}
-
-int rtbuf_cli_lib (int argc, const char *argv[])
-{
- int i;
- if (argc != 1)
- return rtbuf_err("usage: lib LIBRARY");
- i = rtbuf_lib_find(argv[1]);
- if (0 <= i && i < RTBUF_LIB_MAX) {
- rtbuf_lib_print_long(i);
- return 0;
- }
- return rtbuf_err("library not found");
-}
-
-int rtbuf_cli_load (int argc, const char *argv[])
-{
- s_rtbuf_lib *lib;
- assert(argc == 1);
- lib = rtbuf_lib_load(argv[1]);
- if (!lib) {
- printf("load failed\n");
- return -1;
- }
- rtbuf_lib_print(lib);
- return 0;
-}
-
-int rtbuf_cli_buffers (int argc, const char *argv[])
-{
- unsigned int i = 0;
- unsigned int n = g_rtbuf_alloc.n;
- assert(argc == 0);
- (void) argv;
- printf("Listing %i buffers :\n", n);
- while (i < RTBUF_MAX && n > 0) {
- if (g_rtbuf[i].data) {
- rtbuf_print_long(i);
- printf("\n");
- n--;
- }
- i++;
- }
- return 0;
-}
-
-int rtbuf_cli_buffer (int argc, const char *argv[])
-{
- int i;
- if (argc != 1)
- return rtbuf_err("usage: buffer N");
- if ((i = rtbuf_find(argv[1])) < 0)
- return rtbuf_err("buffer not found");
- rtbuf_print_long(i);
- return 0;
-}
-
-int rtbuf_cli_new (int argc, const char *argv[])
-{
- int rl;
- int rf;
- int rtb;
- if (argc != 2)
- return rtbuf_err("usage: new LIBRARY PROCEDURE");
- if ((rl = rtbuf_lib_find(argv[1])) < 0)
- return rtbuf_err("library not found");
- if ((rf = rtbuf_lib_find_proc(&g_rtbuf_lib[rl], argv[2])) < 0)
- return rtbuf_err("procedure not found");
- if ((rtb = rtbuf_new(g_rtbuf_lib[rl].proc[rf])) < 0)
- return rtbuf_err("buffer not created");
- rtbuf_print(rtb);
- printf("\n");
- return 0;
-}
-
-
-int rtbuf_cli_set (int argc, const char *argv[])
-{
- s_rtbuf_var *v;
- if (argc < 4 || argv[2][0] != '=' || argv[2][1])
- return rtbuf_err("usage: set VAR = TYPE ARG [...]");
- if (strncmp("new", argv[3], 4) == 0) {
- int rl;
- int rf;
- int rtb;
- if (argc != 5)
- return rtbuf_err("usage: set VAR = new LIB PROC");
- if ((rl = rtbuf_lib_find(argv[4])) < 0)
- return rtbuf_err("library not found");
- if ((rf = rtbuf_lib_find_proc(&g_rtbuf_lib[rl], argv[5])) < 0)
- return rtbuf_err("procedure not found");
- if ((rtb = rtbuf_new(g_rtbuf_lib[rl].proc[rf])) < 0)
- return rtbuf_err("buffer not created");
- v = rtbuf_var_rtbuf_set(argv[1], rtb);
- assert(v);
- rtbuf_var_print(v);
- printf("\n");
- return 0;
- }
- else if (strncmp("buffer", argv[3], 7) == 0) {
- int rtb;
- if (argc != 4)
- return rtbuf_err("usage: set VAR = buffer N");
- if ((rtb = rtbuf_find(argv[4])) < 0)
- return rtbuf_err("buffer not found");
- v = rtbuf_var_rtbuf_set(argv[1], rtb);
- assert(v);
- rtbuf_var_print(v);
- return 0;
- }
- return rtbuf_err("unknown type for set");
-}
-
-int rtbuf_cli_delete (int argc, const char *argv[])
-{
- int i;
- if (argc != 1)
- return rtbuf_err("usage: delete N");
- i = rtbuf_find(argv[1]);
- if (i < 0)
- return rtbuf_err("buffer not found\n");
- rtbuf_delete(&g_rtbuf[i]);
- rtbuf_print(i);
- printf("\n");
- return 0;
-}
-
-int rtbuf_cli_bind (int argc, const char *argv[])
-{
- int src;
- int out;
- int dest;
- int in;
- if (argc != 4)
- return rtbuf_err("usage: bind SOURCE OUT DEST IN");
- if ((src = rtbuf_find(argv[1])) < 0)
- return rtbuf_err("source buffer not found");
- if ((out = rtbuf_out_find(&g_rtbuf[src], argv[2])) < 0)
- return rtbuf_err("output not found");
- if ((dest = rtbuf_find(argv[3])) < 0)
- return rtbuf_err("destination buffer not found");
- if ((in = rtbuf_in_find(&g_rtbuf[dest], argv[4])) < 0)
- return rtbuf_err("input not found");
- rtbuf_bind(src, out, &g_rtbuf[dest], in);
- rtbuf_print_long(dest);
- return 0;
-}
-
-int rtbuf_cli_unbind (int argc, const char *argv[])
-{
- int rtb;
- if (argc < 1 || argc > 2)
- return rtbuf_err("usage: unbind BUFFER [INPUT]");
- if ((rtb = rtbuf_find(argv[1])) < 0)
- return rtbuf_err("buffer not found");
- if (argc == 2) {
- int in = atoi(argv[2]);
- if (in < 0 || (unsigned int) in >= g_rtbuf[rtb].proc->in_n)
- return rtbuf_err("input not found");
- rtbuf_in_unbind(&g_rtbuf[rtb], in);
- }
- else
- rtbuf_unbind_all(&g_rtbuf[rtb]);
- rtbuf_print_long(rtb);
- return 0;
-}
-
-void * rtbuf_cli_thread_proc (void *arg)
-{
- (void) arg;
- printf("rtbuf thread: start\n");
- if (!rtbuf_start())
- g_rtbuf_run = 1;
- while (g_rtbuf_run) {
- if (rtbuf_run())
- g_rtbuf_run = 0;
- }
- printf("rtbuf thread: stop\n");
- rtbuf_stop();
- return 0;
-}
-
-int rtbuf_cli_start (int argc, const char *argv[])
-{
- (void) argv;
- if (argc != 0)
- return rtbuf_err("usage: start");
- if (!g_rtbuf_run && g_rtbuf_cli_thread) {
- if (pthread_join(g_rtbuf_cli_thread, 0))
- return rtbuf_err("pthread_join failed");
- g_rtbuf_cli_thread = 0;
- }
- if (!g_rtbuf_cli_thread) {
- if (pthread_create(&g_rtbuf_cli_thread, 0, &rtbuf_cli_thread_proc,
- 0))
- return rtbuf_err("pthread_create failed");
- }
- return 0;
-}
-
-int rtbuf_cli_stop (int argc, const char *argv[])
-{
- (void) argv;
- if (argc != 0)
- return rtbuf_err("usage: stop");
- if (g_rtbuf_run)
- g_rtbuf_run = 0;
- if (g_rtbuf_cli_thread) {
- if (pthread_join(g_rtbuf_cli_thread, 0))
- return rtbuf_err("pthread_join failed");
- g_rtbuf_cli_thread = 0;
- }
- return 0;
-}
-
-int rtbuf_cli_help (int argc, const char *argv[])
-{
- (void) argc;
- (void) argv;
- printf("Available commands :\n"
- " libs List loaded libraries.\n"
- " lib N Show library N.\n"
- " load PATH Load library at PATH.\n"
- " buffers List buffers.\n"
- " buffer N Show buffer N.\n"
- " set VAR = buffer N Set variable.\n");
- printf(" new LIB PROC Instanciate library procedure.\n"
- " set VAR = new LIB PROC Set variable.\n"
- " delete BUFFER Unlink and delete RTBUF.\n"
- " bind SOURCE OUT DEST IN Bind SOURCE OUT to DEST IN.\n"
- " unbind BUFFER IN Unbind BUFFER IN.\n"
- " help Show this help message.\n"
- " exit Quit RTBUF.\n");
- return 0;
-}
-
-int rtbuf_cli_exit (int argc, const char *argv[])
-{
- (void) argc;
- (void) argv;
- rtbuf_cli_stop(0, 0);
- close(0);
- exit(0);
- return 0;
-}
-
-s_cli_function rtbuf_cli_functions[] = {
- { "libs", 0, rtbuf_cli_libs },
- { "lib", 1, rtbuf_cli_lib },
- { "load", 1, rtbuf_cli_load },
- { "buffers", 0, rtbuf_cli_buffers },
- { "buffer", 1, rtbuf_cli_buffer },
- { "new", 2, rtbuf_cli_new },
- { "delete", 1, rtbuf_cli_delete },
- { "bind", 4, rtbuf_cli_bind },
- { "unbind", 1, rtbuf_cli_unbind },
- { "unbind", 2, rtbuf_cli_unbind },
- { "set", -1, rtbuf_cli_set },
- { "start", 0, rtbuf_cli_start },
- { "stop", 0, rtbuf_cli_stop },
- { "h", 0, rtbuf_cli_help },
- { "help", 0, rtbuf_cli_help },
- { "exit", 0, rtbuf_cli_exit },
- { 0, 0, 0 }
-};
-
-void debug_read (int argc, const char **argv, f_cli f)
-{
- union {
- f_cli f;
- void *p;
- } fp;
- if (argc < 1)
- return;
- printf("CLI READ %i %s(", argc, *argv);
- argv++;
- argc--;
- fp.f = f;
- while (1) {
- if (argc < 1) {
- printf("); %p\n", fp.p);
- return;
- }
- printf("%s", *argv);
- if (argc > 1)
- printf(", ");
- argv++;
- argc--;
- }
-}
-
-void repl_init ()
-{
- cli_init(&g_cli);
- cli_prompt(&g_cli, "rtbuf> ");
- cli_functions(&g_cli, rtbuf_cli_functions);
-}
-
-int load (const char *path)
-{
- FILE *fp = fopen(path, "r");
- if (!fp)
- return -1;
- printf("; Loading %s\n", path);
- while (cli_read_file(&g_cli, fp) >= 0)
- cli_eval(&g_cli);
- fclose(fp);
- return 0;
-}
-
-int repl ()
-{
- while (cli_read(&g_cli) >= 0) {
- /* debug_read(cli.argc, cli.argv, cli.f); */
- cli_eval(&g_cli);
- }
- return 0;
-}
-
-void rtbuf_cli_args (int argc, char *argv[])
-{
- while (--argc) {
- char *arg = *++argv;
- printf("loading script %s\n", arg);
- load(arg);
- }
-}
-
-int main (int argc, char *argv[])
-{
- symbols_init();
- librtbuf_init();
- assert(g_rtbuf);
- repl_init();
- rtbuf_cli_args(argc, argv);
- return repl();
-}
diff --git a/rtbuf_defs.h b/rtbuf_defs.h
deleted file mode 100644
index 4d88bc7..0000000
--- a/rtbuf_defs.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-#ifndef RTBUF_DEFS_H
-#define RTBUF_DEFS_H
-
-typedef struct rtbuf s_rtbuf;
-typedef struct rtbuf_binding s_rtbuf_binding;
-typedef struct rtbuf_proc s_rtbuf_proc;
-typedef struct rtbuf_proc_in s_rtbuf_proc_in;
-typedef struct rtbuf_proc_out s_rtbuf_proc_out;
-typedef struct rtbuf_lib s_rtbuf_lib;
-typedef struct rtbuf_lib_proc s_rtbuf_lib_proc;
-typedef struct rtbuf_lib_proc_in s_rtbuf_lib_proc_in;
-typedef struct rtbuf_lib_proc_out s_rtbuf_lib_proc_out;
-typedef struct rtbuf_type s_rtbuf_type;
-typedef struct rtbuf_var s_rtbuf_var;
-typedef union rtbuf_var_data u_rtbuf_var_data;
-
-typedef enum rtbuf_var_type {
- RTBUF_VAR_NULL = 0,
- RTBUF_VAR_RTBUF = 1
-} e_rtbuf_var_type;
-
-typedef int f_rtbuf_proc (s_rtbuf *rtbuf);
-typedef int f_rtbuf_lib_init (s_rtbuf_lib *lib);
-
-#endif
diff --git a/rtbuf_dynamic.c b/rtbuf_dynamic.c
deleted file mode 100644
index aa986b1..0000000
--- a/rtbuf_dynamic.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include "rtbuf.h"
-#include "rtbuf_lib.h"
-#include "rtbuf_signal.h"
-#include "rtbuf_signal_type.h"
-#include "rtbuf_dynamic.h"
-
-s_rtbuf_lib_proc_in g_rtbuf_dynamic_limiter_in[] = {
- { "signal" , RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
- { "gain" , RTBUF_SIGNAL_TYPE, 1.0, 0.0, 1.0 },
- { "treshold", RTBUF_SIGNAL_TYPE, 0.9, 0.0, 1.0 },
- { "attack" , RTBUF_SIGNAL_TYPE, 0.1, 0.0, 1.0 },
- { "release" , RTBUF_SIGNAL_TYPE, 1.0, 0.0, 1.0 },
- { 0, 0, 0.0, 0.0, 0.0 } };
-
-s_rtbuf_lib_proc_out g_rtbuf_dynamic_limiter_out[] = {
- { "signal", RTBUF_SIGNAL_TYPE },
- { "ratio" , RTBUF_SIGNAL_SAMPLE_TYPE },
- { 0, 0 } };
-
-const char *rtbuf_lib_name = "dynamic";
-unsigned long rtbuf_lib_ver = RTBUF_LIB_VER;
-s_rtbuf_lib_proc rtbuf_lib_proc[] = {
- { "limiter", rtbuf_dynamic_limiter, rtbuf_dynamic_limiter_start, 0,
- g_rtbuf_dynamic_limiter_in, g_rtbuf_dynamic_limiter_out },
- { 0, 0, 0, 0, 0, 0 } };
diff --git a/rtbuf_dynamic.h b/rtbuf_dynamic.h
deleted file mode 100644
index 918f4d2..0000000
--- a/rtbuf_dynamic.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-#ifndef RTBUF_DYNAMIC_H
-#define RTBUF_DYNAMIC_H
-
-#include "rtbuf_signal.h"
-
-enum {
- RTBUF_DYNAMIC_LIMITER_IN_SIGNAL = 0,
- RTBUF_DYNAMIC_LIMITER_IN_GAIN,
- RTBUF_DYNAMIC_LIMITER_IN_TRESHOLD,
- RTBUF_DYNAMIC_LIMITER_IN_ATTACK,
- RTBUF_DYNAMIC_LIMITER_IN_RELEASE,
- RTBUF_DYNAMIC_LIMITER_IN_N
-};
-
-typedef struct rtbuf_dynamic_limiter_data {
- t_rtbuf_signal signal;
- t_rtbuf_signal_sample ratio;
-} s_rtbuf_dynamic_limiter_data;
-
-int rtbuf_dynamic_limiter (s_rtbuf *rtb);
-int rtbuf_dynamic_limiter_start (s_rtbuf *rtb);
-
-#endif
diff --git a/rtbuf_dynamic_limiter.c b/rtbuf_dynamic_limiter.c
deleted file mode 100644
index 82c5943..0000000
--- a/rtbuf_dynamic_limiter.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2019 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- * Copyright 2019 Judy Najnudel
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <math.h>
-#include "rtbuf.h"
-#include "rtbuf_dynamic.h"
-
-int rtbuf_dynamic_limiter (s_rtbuf *rtb)
-{
- s_rtbuf_signal_fun in_;
- s_rtbuf_signal_fun g_;
- s_rtbuf_signal_fun t_;
- s_rtbuf_signal_fun a_;
- s_rtbuf_signal_fun r_;
- s_rtbuf_dynamic_limiter_data *data;
- unsigned int i = 0;
- assert(rtb);
- assert(rtb->proc);
- assert(rtb->data);
- rtbuf_signal_fun(rtb, RTBUF_DYNAMIC_LIMITER_IN_SIGNAL , &in_);
- rtbuf_signal_fun(rtb, RTBUF_DYNAMIC_LIMITER_IN_GAIN , &g_);
- rtbuf_signal_fun(rtb, RTBUF_DYNAMIC_LIMITER_IN_TRESHOLD, &t_);
- rtbuf_signal_fun(rtb, RTBUF_DYNAMIC_LIMITER_IN_ATTACK , &a_);
- rtbuf_signal_fun(rtb, RTBUF_DYNAMIC_LIMITER_IN_RELEASE , &r_);
- data = (s_rtbuf_dynamic_limiter_data*) rtb->data;
- while (i < RTBUF_SIGNAL_SAMPLES) {
- double in = in_.sample_fun(in_.signal, i);
- double g = max(0.0, g_.sample_fun(g_.signal, i));
- double t = max(0.0, t_.sample_fun(t_.signal, i));
- double a = max(0.0, a_.sample_fun(a_.signal, i));
- double r = max(0.0, r_.sample_fun(r_.signal, i));
- double in_g = in * g;
- double s = in_g * data->ratio;
- if (s < t)
- if (data->ratio < 1.0) {
- data->ratio += 1.0 / (r * RTBUF_SIGNAL_SAMPLERATE);
- if (data->ratio > 1.0)
- data->ratio = 1.0;
- }
- if (s >= t) {
- data->ratio -= 1.0 / (a * RTBUF_SIGNAL_SAMPLERATE);
- if (data->ratio < 0.0)
- data->ratio = 0;
- }
- data->signal[i] = in_g * data->ratio;
- i++;
- }
- return 0;
-}
-
-int rtbuf_dynamic_limiter_start (s_rtbuf *rtb)
-{
- s_rtbuf_dynamic_limiter_data *data;
- assert(rtb);
- assert(rtb->proc);
- assert(rtb->data);
- assert(rtb->proc->out_bytes == sizeof(*data));
- data = (s_rtbuf_dynamic_limiter_data*) rtb->data;
- data->signal[RTBUF_SIGNAL_SAMPLES - 1] = 0.0;
- data->ratio = 1.0;
- return 0;
-}
diff --git a/rtbuf_fun.c b/rtbuf_fun.c
deleted file mode 100644
index ea103e1..0000000
--- a/rtbuf_fun.c
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <strings.h>
-#include "data.h"
-#include "rtbuf.h"
-#include "symbol.h"
-
-s_data_type g_rtbuf_proc_type = {
- sizeof(s_rtbuf_proc) * 8,
- DATA_TYPE_BITS
-};
-s_data_alloc g_rtbuf_proc_alloc;
-s_rtbuf_proc *g_rtbuf_proc;
-
-void rtbuf_proc_init ()
-{
- data_alloc_init(&g_rtbuf_proc_alloc, &g_rtbuf_proc_type,
- RTBUF_PROC_MAX, 0, 0);
-}
-
-int rtbuf_proc_p (s_rtbuf_proc *proc)
-{
- return proc && proc->name;
-}
-
-s_rtbuf_proc * rtbuf_proc_new ()
-{
- s_rtbuf_proc *rf = data_new(&g_rtbuf_proc_alloc);
- return rf;
-}
-
-void rtbuf_proc_delete (s_rtbuf_proc *proc)
-{
- assert(proc);
- data_delete(&g_rtbuf_proc_alloc, proc);
-}
-
-s_rtbuf_proc * rtbuf_proc_find (const char *x)
-{
- const char *sym = symbol_find(x);
- if (sym) {
- unsigned int i = 0;
- unsigned int n = g_rtbuf_alloc.n - g_rtbuf_alloc.free_n;
- while (i < g_rtbuf_proc_alloc.n && n > 0) {
- if (rtbuf_proc_p(&g_rtbuf_proc[i])) {
- if (sym == g_rtbuf_proc[i].name)
- return &g_rtbuf_proc[i];
- n--;
- }
- i++;
- }
- }
- return 0;
-}
-
-int rtbuf_proc_out_find (s_rtbuf_proc *proc, const char *x)
-{
- symbol sym;
- if (x && '0' <= x[0] && x[0] <= '9') {
- int i = atoi(x);
- if (0 <= i && (unsigned int) i < proc->out_n)
- return i;
- }
- if ((sym = symbol_find(x))) {
- unsigned int i = 0;
- while (i < proc->out_n) {
- if (sym == proc->out[i].name)
- return i;
- i++;
- }
- }
- return -1;
-}
-
-void rtbuf_proc_print (s_rtbuf_proc *proc)
-{
- unsigned int i = 0;
- printf("#<proc %i %s (", proc->lib_proc, proc->name);
- while (i < proc->var_n) {
- if (i > 0)
- fputs(" ", stdout);
- fputs(proc->var[i].name, stdout);
- fputs(":", stdout);
- fputs(proc->var[i].type->name, stdout);
- i++;
- }
- printf(") -> (");
- i = 0;
- while (i < proc->out_n) {
- if (i > 0)
- fputs(" ", stdout);
- fputs(proc->out[i].name, stdout);
- fputs(":", stdout);
- fputs(proc->out[i].type->name, stdout);
- i++;
- }
- fputs(")>", stdout);
-}
diff --git a/rtbuf_glfw3.c b/rtbuf_glfw3.c
deleted file mode 100644
index 6470431..0000000
--- a/rtbuf_glfw3.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include "rtbuf.h"
-#include "rtbuf_lib.h"
-#include "rtbuf_signal.h"
-#include "rtbuf_signal_type.h"
-#include "rtbuf_music.h"
-#include "rtbuf_music_type.h"
-#include "rtbuf_glfw3.h"
-
-s_rtbuf_lib_proc_out g_rtbuf_glfw3_keyboard_out[] = {
- RTBUF_MUSIC_NOTES_OUT("note"),
- { "window", "void*" },
- { "octave", "unsigned int" },
- { 0, 0 } };
-
-s_rtbuf_lib_proc_in g_rtbuf_glfw3_oscilloscope_in[] = {
- { "black", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
- { "red" , RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
- { "green", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
- { "blue" , RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
- { 0, 0, 0.0, 0.0, 0.0 } };
-
-s_rtbuf_lib_proc_out g_rtbuf_glfw3_oscilloscope_out[] = {
- { "window", "void*" },
- { 0, 0 } };
-
-const char *rtbuf_lib_name = "glfw3";
-unsigned long rtbuf_lib_ver = RTBUF_LIB_VER;
-s_rtbuf_lib_proc rtbuf_lib_proc[] = {
- { "keyboard", rtbuf_glfw3_keyboard, rtbuf_glfw3_keyboard_start,
- rtbuf_glfw3_keyboard_stop, 0, g_rtbuf_glfw3_keyboard_out },
- { "oscilloscope", rtbuf_glfw3_oscilloscope,
- rtbuf_glfw3_oscilloscope_start, 0, g_rtbuf_glfw3_oscilloscope_in,
- g_rtbuf_glfw3_oscilloscope_out },
- { 0, 0, 0, 0, 0, 0 } };
-
-int rtbuf_lib_init (s_rtbuf_lib *lib)
-{
- (void) lib;
- rtbuf_music_init();
- glfwInit();
- return 0;
-}
diff --git a/rtbuf_glfw3.h b/rtbuf_glfw3.h
deleted file mode 100644
index 1d89890..0000000
--- a/rtbuf_glfw3.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-#ifndef RTBUF_GLFW3_H
-#define RTBUF_GLFW3_H
-
-#include <GLFW/glfw3.h>
-#include "rtbuf.h"
-#include "rtbuf_music.h"
-
-#pragma pack(push,1)
-typedef struct rtbuf_glfw3_keyboard_data {
- s_rtbuf_music_notes notes;
- GLFWwindow *window;
- unsigned int octave;
-} s_rtbuf_glfw3_keyboard_data;
-#pragma pack(pop)
-
-int rtbuf_glfw3_keyboard (s_rtbuf *rtb);
-int rtbuf_glfw3_keyboard_start (s_rtbuf *rtb);
-int rtbuf_glfw3_keyboard_stop (s_rtbuf *rtb);
-
-enum {
- RTBUF_GLFW3_OSCILLOSCOPE_IN_BLACK,
- RTBUF_GLFW3_OSCILLOSCOPE_IN_RED,
- RTBUF_GLFW3_OSCILLOSCOPE_IN_GREEN,
- RTBUF_GLFW3_OSCILLOSCOPE_IN_BLUE,
- RTBUF_GLFW3_OSCILLOSCOPE_INS
-};
-
-#pragma pack(push,1)
-typedef struct rtbuf_glfw3_oscilloscope_data {
- GLFWwindow *window;
-} s_rtbuf_glfw3_oscilloscope_data;
-#pragma pack(pop)
-
-int rtbuf_glfw3_oscilloscope (s_rtbuf *rtb);
-int rtbuf_glfw3_oscilloscope_start (s_rtbuf *rtb);
-
-#endif
diff --git a/rtbuf_glfw3_keyboard.c b/rtbuf_glfw3_keyboard.c
deleted file mode 100644
index 80b88f2..0000000
--- a/rtbuf_glfw3_keyboard.c
+++ /dev/null
@@ -1,281 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <math.h>
-#include <stdio.h>
-#include <string.h>
-#include <strings.h>
-#include "rtbuf.h"
-#include "rtbuf_signal.h"
-#include "rtbuf_music.h"
-#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
-
-double scancode_frequency (int scancode, unsigned int octave)
-{
- int note = -1;
- double freq = 0.0;
- printf("scancode %i\n", scancode);
- switch (scancode) {
- case 52: note = 0; break; /* C */
- case 39: note = 1; break;
- case 53: note = 2; break; /* D */
- case 40: note = 3; break;
- case 54: note = 4; break; /* E */
- case 55: note = 5; break; /* F */
- case 42: note = 6; break;
- case 56: note = 7; break; /* G */
- case 43: note = 8; break;
- case 57: note = 9; break; /* A */
- case 44: note = 10; break;
- case 58: note = 11; break; /* B */
- case 59: /* C */
- case 24: note = 12; break;
- case 46:
- case 11: note = 13; break;
- case 60: /* D */
- case 25: note = 14; break;
- case 47:
- case 12: note = 15; break;
- case 61: /* E */
- case 26: note = 16; break;
- case 27: note = 17; break; /* F */
- case 14: note = 18; break;
- case 28: note = 19; break; /* G */
- case 15: note = 20; break;
- case 29: note = 21; break; /* A */
- case 16: note = 22; break;
- case 30: note = 23; break; /* B */
- case 31: note = 24; break; /* C */
- case 18: note = 25; break;
- case 32: note = 26; break; /* D */
- case 19: note = 27; break;
- case 33: note = 28; break; /* E */
- case 34: note = 29; break; /* F */
- case 21: note = 30; break;
- case 35: note = 31; break; /* G */
- }
- if (note >= 0)
- freq = rtbuf_music_note_frequency(octave, note);
- return freq;
-}
-
-static int find_note (s_rtbuf_music_notes *notes, double freq)
-{
- unsigned int i = 0;
- unsigned int n = notes->note_n;
- while (i < RTBUF_MUSIC_NOTE_MAX && n > 0) {
- s_rtbuf_music_note *note = ¬es->note[i];
- if (note->velocity > 0.0 && note->start >= 0.0 && note->stop < 0.0) {
- if (freq == notes->note[i].freq)
- return i;
- n--;
- }
- i++;
- }
- return -1;
-}
-
-void rtbuf_glfw3_keyboard_key (GLFWwindow *w, int key,
- int scancode, int action,
- int mods)
-{
- int i;
- double freq;
- s_rtbuf_music_note *note;
- s_rtbuf *rtb = (s_rtbuf*) glfwGetWindowUserPointer(w);
- s_rtbuf_glfw3_keyboard_data *data;
- s_rtbuf_music_notes *notes;
- data = (s_rtbuf_glfw3_keyboard_data*) rtb->data;
- notes = &data->notes;
- (void) key;
- (void) mods;
- switch (action) {
- case GLFW_RELEASE:
- freq = scancode_frequency(scancode, data->octave);
- if ((i = find_note(notes, freq)) >= 0)
- notes->note[i].stop = 0.0;
- break;
- case GLFW_PRESS:
- freq = scancode_frequency(scancode, data->octave);
- if ((i = rtbuf_music_notes_new(notes, 1.0)) < 0)
- break;
- note = ¬es->note[i];
- note->freq = freq;
- note->start = 0.0;
- note->stop = -1.0;
- break;
- case GLFW_REPEAT:
- break;
- }
-}
-
-void rtbuf_glfw3_keyboard_size (GLFWwindow *w, int width,
- int height)
-{
- (void) w;
- glViewport(0, 0, width, height);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(0.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
-}
-
-static
-void rtbuf_glfw3_keyboard_draw_panel (float y1, float y2)
-{
- glColor3f(0.5f, 0.5f, 0.5f);
- glBegin(GL_QUAD_STRIP);
- glVertex2f(0.0f, y1);
- glVertex2f(0.0f, y2);
- glVertex2f(1.0f, y1);
- glVertex2f(1.0f, y2);
- glEnd();
-}
-
-static
-void rtbuf_glfw3_keyboard_draw_white (unsigned int i, float n,
- float y1, float y2)
-{
- float x = (float) i / n;
- glBegin(GL_LINE_STRIP);
- glVertex2f(x, y1);
- glVertex2f(x, y2);
- i++;
- x = (float) i / n;
- glVertex2f(x, y2);
- glVertex2f(x, y1);
- glEnd();
-}
-
-static
-void rtbuf_glfw3_keyboard_draw_black (unsigned int i, float n,
- float y1, float y2)
-{
- float x1 = (i - 1.0f / 3.0f) / n;
- float x2 = (i + 1.0f / 3.0f) / n;
- glBegin(GL_QUAD_STRIP);
- glVertex2f(x1, y1);
- glVertex2f(x1, y2);
- glVertex2f(x2, y1);
- glVertex2f(x2, y2);
- glEnd();
-}
-
-void rtbuf_glfw3_keyboard_draw (GLFWwindow *w)
-{
- float y_buttons = 0.75f;
- float y_black = 0.36f;
- unsigned int notes = 32;
- float n = ceilf((notes + 1) * 7 / 12);
- unsigned int i = 0;
- unsigned int j = 0;
- glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
- glClear(GL_COLOR_BUFFER_BIT);
- rtbuf_glfw3_keyboard_draw_panel(1.0f, y_buttons);
- glColor3f(0.0f, 0.0f, 0.0f);
- while (i < notes) {
- int k = i % 12;
- if (k == 1 || k == 3 || k == 6 || k == 8 || k == 10)
- rtbuf_glfw3_keyboard_draw_black(j, n, y_buttons, y_black);
- else
- rtbuf_glfw3_keyboard_draw_white(j++, n, y_buttons, 0.0f);
- i++;
- }
- glfwSwapBuffers(w);
-}
-
-void rtbuf_glfw3_keyboard_close (GLFWwindow *window)
-{
- s_rtbuf *rtb = (s_rtbuf*) glfwGetWindowUserPointer(window);
- s_rtbuf_glfw3_keyboard_data* data = (s_rtbuf_glfw3_keyboard_data*)
- rtb->data;
- glfwDestroyWindow(window);
- data->window = 0;
-}
-
-GLFWwindow * rtbuf_glfw3_keyboard_window (s_rtbuf *rtb)
-{
- GLFWwindow *window = glfwCreateWindow(RTBUF_GLFW3_KEYBOARD_WIDTH,
- RTBUF_GLFW3_KEYBOARD_HEIGHT,
- "rtbuf_glfw3_keyboard",
- NULL, NULL);
- if (!window) {
- rtbuf_err("glfw3_keyboard: glfwCreateWindow failed");
- return 0;
- }
- glfwMakeContextCurrent(window);
- glfwSetWindowUserPointer(window, rtb);
- glfwSetKeyCallback(window, rtbuf_glfw3_keyboard_key);
- glfwSetWindowCloseCallback(window, rtbuf_glfw3_keyboard_close);
- glfwSetWindowSizeCallback(window, rtbuf_glfw3_keyboard_size);
- glfwSetWindowRefreshCallback(window,
- rtbuf_glfw3_keyboard_draw);
- glfwShowWindow(window);
- rtbuf_glfw3_keyboard_size(window, RTBUF_GLFW3_KEYBOARD_WIDTH,
- RTBUF_GLFW3_KEYBOARD_HEIGHT);
- return window;
-}
-
-int rtbuf_glfw3_keyboard_start (s_rtbuf *rtb)
-{
- s_rtbuf_glfw3_keyboard_data *data;
- assert(rtb->proc->out_bytes == sizeof(*data));
- data = (s_rtbuf_glfw3_keyboard_data*) rtb->data;
- if (!data->window &&
- !(data->window = rtbuf_glfw3_keyboard_window(rtb)))
- return -1;
- data->octave = 3;
- return 0;
-}
-
-int rtbuf_glfw3_keyboard_stop (s_rtbuf *rtb)
-{
- s_rtbuf_glfw3_keyboard_data *data;
- data = (s_rtbuf_glfw3_keyboard_data*) rtb->data;
- rtbuf_music_notes_delete_all(&data->notes);
- return 0;
-}
-
-int rtbuf_glfw3_keyboard (s_rtbuf *rtb)
-{
- s_rtbuf_glfw3_keyboard_data *data;
- unsigned int i = 0;
- unsigned int n;
- data = (s_rtbuf_glfw3_keyboard_data*) rtb->data;
- if (!data->window)
- return -1;
- n = data->notes.note_n;
- while (i < RTBUF_MUSIC_NOTE_MAX && n > 0) {
- s_rtbuf_music_note *note = &data->notes.note[i];
- if (note->velocity > 0.0) {
- assert(note->start >= 0.0);
- rtbuf_music_note_dt(note, RTBUF_SIGNAL_DT);
- if (note->stop > RTBUF_MUSIC_RELEASE_MAX)
- rtbuf_music_notes_delete(&data->notes, i);
- n--;
- }
- i++;
- }
- glfwPollEvents();
- return 0;
-}
diff --git a/rtbuf_glfw3_oscilloscope.c b/rtbuf_glfw3_oscilloscope.c
deleted file mode 100644
index 2be4650..0000000
--- a/rtbuf_glfw3_oscilloscope.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include "rtbuf.h"
-#include "rtbuf_signal.h"
-#include "rtbuf_glfw3.h"
-
-void rtbuf_glfw3_oscilloscope_size (GLFWwindow *w, int width,
- int height)
-{
- (void) w;
- glViewport(0, 0, width, height);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(0.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
-}
-
-void rtbuf_glfw3_oscilloscope_draw (GLFWwindow *window)
-{
- s_rtbuf *rtb = (s_rtbuf*) glfwGetWindowUserPointer(window);
- s_rtbuf_signal_fun in[4];
- const float color[4][3] = { { 0.0f, 0.0f, 0.0f },
- { 1.0f, 0.0f, 0.0f },
- { 0.0f, 1.0f, 0.0f },
- { 0.0f, 0.0f, 1.0f } };
- unsigned int i = 0;
- unsigned int j;
- assert(rtb);
- for (j = 0; j < 4; j++)
- rtbuf_signal_fun(rtb, j, &in[j]);
- glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
- glClear(GL_COLOR_BUFFER_BIT);
- for (j = 0; j < 4; j++) {
- glColor3f(color[j][0], color[j][1], color[j][2]);
- glBegin(GL_LINE_STRIP);
- for (i = 0; i < RTBUF_SIGNAL_SAMPLES; i++) {
- float x = (double) i / RTBUF_SIGNAL_SAMPLES;
- float s = in[j].sample_fun(in[j].signal, i);
- glVertex2f(x, s / 4.0f + 0.5f);
- }
- glEnd();
- }
- glfwSwapBuffers(window);
-}
-
-GLFWwindow * rtbuf_glfw3_oscilloscope_window (s_rtbuf *rtb)
-{
- GLFWwindow *window = glfwCreateWindow(512, 512,
- "rtbuf_glfw3_oscilloscope",
- NULL, NULL);
- if (!window) {
- rtbuf_err("glfw3_oscilloscope: glfwCreateWindow failed");
- return 0;
- }
- glfwMakeContextCurrent(window);
- glfwSetWindowUserPointer(window, rtb);
- glfwSetWindowSizeCallback(window, rtbuf_glfw3_oscilloscope_size);
- glfwSetWindowRefreshCallback(window, rtbuf_glfw3_oscilloscope_draw);
- glfwShowWindow(window);
- return window;
-}
-
-int rtbuf_glfw3_oscilloscope_start (s_rtbuf *rtb)
-{
- s_rtbuf_glfw3_oscilloscope_data *data;
- assert(rtb->proc->out_bytes == sizeof(*data));
- data = (s_rtbuf_glfw3_oscilloscope_data*) rtb->data;
- if (!data->window &&
- !(data->window = rtbuf_glfw3_oscilloscope_window(rtb)))
- return -1;
- return 0;
-}
-
-int rtbuf_glfw3_oscilloscope (s_rtbuf *rtb)
-{
- s_rtbuf_glfw3_oscilloscope_data *data;
- assert(rtb);
- assert(rtb->data);
- assert(rtb->proc);
- data = (s_rtbuf_glfw3_oscilloscope_data*) rtb->data;
- rtbuf_glfw3_oscilloscope_draw(data->window);
- glfwPollEvents();
- return 0;
-}
diff --git a/rtbuf_glfw3_type.c b/rtbuf_glfw3_type.c
deleted file mode 100644
index bf8d3ef..0000000
--- a/rtbuf_glfw3_type.c
+++ /dev/null
@@ -1,18 +0,0 @@
-
-#include <stdio.h>
-#include "rtbuf.h"
-#include "rtbuf_glfw3.h"
-
-int main ()
-{
- printf("/* file generated by rtbuf_glfw3_type */\n");
- printf("#ifndef RTBUF_GLFW3_TYPE_H\n"
- "#define RTBUF_GLFW3_TYPE_H\n"
- "\n");
- printf("#define RTBUF_GLFW3_SAMPLES_TYPE RTBUF_GLFW3_SAMPLE_TYPE"
- " \"[%u]\"\n",
- RTBUF_GLFW3_SAMPLES);
- printf("\n"
- "#endif\n");
- return 0;
-}
diff --git a/rtbuf_gtk.c b/rtbuf_gtk.c
deleted file mode 100644
index 02636a0..0000000
--- a/rtbuf_gtk.c
+++ /dev/null
@@ -1,398 +0,0 @@
-/*
- * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <assert.h>
-#include <gtk/gtk.h>
-#include <stdio.h>
-#include "rtbuf.h"
-#include "rtbuf_gtk.h"
-#include "rtbuf_input_widget.h"
-#include "rtbuf_lib.h"
-#include "rtbuf_var.h"
-#include "rtbuf_widget.h"
-
-unsigned int g_next_id = 0;
-
-GtkBuilder *builder = NULL;
-
-GtkWindow *modular = NULL;
-s_rtbuf_gtk_connection *modular_connections = NULL;
-GtkLayout *modular_layout = NULL;
-
-GtkMenu *library_menu = NULL;
-
-gint rtbuf_x = 100;
-gint rtbuf_y = 100;
-
-s_rtbuf_gtk_connection *drag_connection = NULL;
-GtkWidget *drag_widget = NULL;
-gint drag_x = 0;
-gint drag_y = 0;
-
-void rtbuf_gtk_drag_connection_end (RtbufInputWidget *input_widget)
-{
- if (drag_connection) {
- if (input_widget) {
- s_rtbuf_gtk_connection *dc = drag_connection;
- printf("rtbuf-gtk drag connection connected to input\n");
- drag_connection = NULL;
- if (!rtbuf_gtk_connection_find(modular_connections,
- dc->output_widget, input_widget)) {
- s_rtbuf *src = rtbuf_output_widget_get_rtbuf(dc->output_widget);
- unsigned int out = rtbuf_output_widget_get_out(dc->output_widget);
- s_rtbuf *dest = rtbuf_input_widget_get_rtbuf(input_widget);
- unsigned int in = rtbuf_input_widget_get_in(input_widget);
- unsigned int src_i = src - g_rtbuf;
- rtbuf_bind(src_i, out, dest, in);
- dc->input_widget = input_widget;
- }
- else
- rtbuf_gtk_connection_remove_one(&modular_connections, dc);
- gtk_widget_queue_draw(GTK_WIDGET(modular_layout));
- }
- else {
- printf("rtbuf-gtk drag connection abort\n");
- rtbuf_gtk_connection_remove_one(&modular_connections,
- drag_connection);
- drag_connection = NULL;
- gtk_widget_queue_draw(GTK_WIDGET(modular_layout));
- }
- }
-}
-
-gboolean rtbuf_gtk_input_button_press (RtbufInputWidget *widget,
- GdkEvent *event)
-{
- printf("rtbuf-gtk input button press\n");
- (void) widget;
- (void) event;
- if (drag_connection) {
- rtbuf_gtk_drag_connection_end(widget);
- return TRUE;
- }
- return TRUE;
-}
-
-RtbufWidget * rtbuf_gtk_modular_layout_new (s_rtbuf *rtbuf,
- const gint x, const gint y)
-{
- RtbufWidget *widget;
- GtkWidget *event_box;
- char label[1024];
- assert(rtbuf);
- assert(rtbuf >= g_rtbuf && (rtbuf - g_rtbuf) < RTBUF_MAX);
- printf("rtbuf-gtk modular layout new\n");
- assert(rtbuf->proc);
- assert(rtbuf->proc->name);
- snprintf(label, sizeof(label), "%s%02d",
- rtbuf->proc->name,
- g_next_id++);
- rtbuf_var_rtbuf_set(label, rtbuf - g_rtbuf);
- widget = rtbuf_widget_new(rtbuf, label);
- gtk_layout_put(modular_layout, GTK_WIDGET(widget), x, y);
- event_box = rtbuf_widget_get_event_box(widget);
- g_signal_connect_swapped(G_OBJECT(event_box), "button-press-event",
- G_CALLBACK(rtbuf_gtk_rtbuf_button_press),
- widget);
- rtbuf_widget_connect_inputs
- (widget, "button-press-event",
- G_CALLBACK(rtbuf_gtk_input_button_press));
- rtbuf_widget_connect_input_checks
- (widget, "button-press-event",
- G_CALLBACK(rtbuf_gtk_input_button_press));
- rtbuf_widget_connect_output_checks
- (widget, "button-press-event",
- G_CALLBACK(rtbuf_gtk_output_check_button_press));
- return widget;
-}
-
-RtbufWidget * rtbuf_gtk_new (gchar *library, gchar *proc,
- const gint x, const gint y)
-{
- int i;
- s_rtbuf_lib *rl = 0;
- s_rtbuf_proc *rp = 0;
- s_rtbuf *rtb = 0;
- printf("rtbuf-gtk new %s %s\n", library, proc);
- i = rtbuf_lib_find(library);
- if (i < 0) {
- printf("load %s\n", library);
- if (!(rl = rtbuf_lib_load(library))) {
- fprintf(stderr, "rtbuf-gtk: load failed: '%s'\n", library);
- return NULL;
- }
- rtbuf_lib_print(rl);
- }
- else {
- assert(i < RTBUF_LIB_MAX);
- rl = &g_rtbuf_lib[i];
- }
- i = rtbuf_lib_find_proc(rl, proc);
- if (i < 0) {
- fprintf(stderr, "rtbuf-gtk new: not found %s %s\n", library, proc);
- return NULL;
- }
- rp = rl->proc[i];
- assert(g_rtbuf);
- i = rtbuf_new(rp);
- if (i < 0) {
- fprintf(stderr, "rtbuf-gtk new rtbuf_new failed: %s %s\n", library, proc);
- return NULL;
- }
- rtb = &g_rtbuf[i];
- return rtbuf_gtk_modular_layout_new(rtb, x, y);
-}
-
-void rtbuf_gtk_library_menu_activate (GtkMenuItem *menuitem,
- gpointer data)
-{
- gchar *proc;
- gchar *library = (gchar*) data;
- g_object_get(menuitem, "label", &proc, NULL);
- rtbuf_gtk_new(library, proc, rtbuf_x, rtbuf_y);
- rtbuf_x = 100;
- rtbuf_y = 100;
- g_free(proc);
-}
-
-void rtbuf_gtk_library_menu_library_item (GtkWidget *menuitem, gpointer data)
-{
- gchar *library = (gchar*) data;
- g_signal_connect(menuitem, "activate", G_CALLBACK(rtbuf_gtk_library_menu_activate), library);
-}
-
-void rtbuf_gtk_library_menu_library (GtkWidget *menuitem, gpointer data)
-{
- GtkContainer *submenu;
- gchar *library;
- (void) data;
- g_object_get(menuitem,
- "label", &library,
- "submenu", &submenu,
- NULL);
- gtk_container_foreach(submenu,
- rtbuf_gtk_library_menu_library_item,
- library);
- g_object_unref(G_OBJECT(submenu));
-}
-
-void rtbuf_gtk_library_menu ()
-{
- library_menu = GTK_MENU(gtk_builder_get_object(builder, "library_menu"));
- gtk_container_foreach(GTK_CONTAINER(library_menu),
- rtbuf_gtk_library_menu_library,
- NULL);
-}
-
-void rtbuf_gtk_modular_close (GtkWidget *widget,
- gpointer data)
-{
- (void) widget;
- (void) data;
- printf("rtbuf-gtk modular close\n");
- gtk_main_quit();
-}
-
-void rtbuf_gtk_modular_draw_arrow (cairo_t *cr, int x1, int y1,
- int x2, int y2)
-{
- const int arrow_size = 4;
- int mx = (x2 - x1) / 3;
- if (mx < 0) {
- mx = -mx;
- mx += mx / 2;
- }
-
- cairo_move_to(cr, x1, y1);
- cairo_curve_to(cr,
- x1 + mx, y1,
- x2 - mx - arrow_size, y2,
- x2 - arrow_size, y2);
- cairo_move_to (cr, x2, y2);
- cairo_line_to (cr, x2 - arrow_size, y2);
- cairo_move_to (cr, x2 - arrow_size, y2 - arrow_size);
- cairo_line_to (cr, x2, y2);
- cairo_line_to (cr, x2 - arrow_size, y2 + arrow_size);
-}
-
-void rtbuf_gtk_modular_draw_connection (s_rtbuf_gtk_connection *c,
- cairo_t *cr)
-{
- int x1, y1, x2, y2;
- GtkWidget *out = GTK_WIDGET(c->output_widget);
- GtkAllocation allocation;
- gtk_widget_get_allocation(out, &allocation);
- gtk_widget_translate_coordinates(out, GTK_WIDGET(modular_layout),
- allocation.width,
- allocation.height / 2,
- &x1, &y1);
- if (c->input_widget) {
- GtkWidget *in = GTK_WIDGET(c->input_widget);
- gtk_widget_get_allocation(in, &allocation);
- gtk_widget_translate_coordinates(in, GTK_WIDGET(modular_layout),
- 0,
- allocation.height / 2,
- &x2, &y2);
- x2 -= 2;
- }
- 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);
-}
-
-gboolean rtbuf_gtk_modular_draw (GtkWidget *widget,
- cairo_t *cr,
- gpointer data)
-{
- (void) data;
- if ((GtkLayout*) widget == modular_layout) {
- s_rtbuf_gtk_connection *c = modular_connections;
- cairo_set_source_rgb(cr, 0.5, 0.5, 0.5);
- cairo_paint(cr);
- while (c) {
- rtbuf_gtk_modular_draw_connection(c, cr);
- c = c->next;
- }
- GTK_WIDGET_GET_CLASS(widget)->draw(widget, cr);
- return TRUE;
- }
- return FALSE;
-}
-
-gboolean rtbuf_gtk_modular_button_press (GtkWidget *widget,
- GdkEvent *event,
- gpointer data)
-{
- (void) widget;
- (void) data;
- if (widget == GTK_WIDGET(modular_layout) &&
- event->type == GDK_BUTTON_PRESS) {
- GdkEventButton *eb = (GdkEventButton*) event;
- if (eb->button == 1) {
- if (drag_connection) {
- rtbuf_gtk_drag_connection_end(NULL);
- return TRUE;
- }
- }
- else 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(window, eb->device,
- &rtbuf_x, &rtbuf_y, NULL);
- gtk_menu_popup_at_pointer(library_menu, event);
- return TRUE;
- }
- }
- return FALSE;
-}
-
-gboolean rtbuf_gtk_modular_motion (GtkWidget *widget,
- GdkEventMotion *event,
- gpointer data)
-{
- if (drag_widget) {
- if (!(event->state & GDK_BUTTON1_MASK)) {
- printf("rtbuf-gtk modular drop widget\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 (drag_connection) {
- GdkWindow *window;
- window = gtk_widget_get_window(GTK_WIDGET(modular_layout));
- gdk_window_get_device_position(window, event->device,
- &drag_x, &drag_y, NULL);
- drag_connection->input_widget = NULL;
- gtk_widget_queue_draw(GTK_WIDGET(modular_layout));
- return TRUE;
- }
- return FALSE;
-}
-
-void rtbuf_gtk_modular ()
-{
- GObject *button;
-
- modular = GTK_WINDOW(gtk_builder_get_object(builder, "modular"));
- g_signal_connect(modular, "destroy",
- G_CALLBACK(rtbuf_gtk_modular_close), NULL);
-
- button = gtk_builder_get_object(builder, "quit");
- g_signal_connect(button, "activate",
- G_CALLBACK(rtbuf_gtk_modular_close), NULL);
-
- modular_layout = GTK_LAYOUT(gtk_builder_get_object(builder, "modular_layout"));
- gtk_widget_add_events(GTK_WIDGET(modular_layout), GDK_BUTTON_PRESS_MASK);
- g_signal_connect(modular_layout, "button-press-event",
- G_CALLBACK(rtbuf_gtk_modular_button_press), NULL);
- g_signal_connect(modular_layout, "draw",
- G_CALLBACK(rtbuf_gtk_modular_draw), NULL);
-
- rtbuf_gtk_library_menu();
-
- g_signal_connect(modular_layout, "motion-notify-event",
- G_CALLBACK(rtbuf_gtk_modular_motion), NULL);
-}
-
-int rtbuf_gtk_builder ()
-{
- GError *error = NULL;
- builder = gtk_builder_new ();
- if (gtk_builder_add_from_resource(builder, "/rtbuf/rtbuf_modular.ui", &error) == 0) {
- g_printerr("Error loading resource /rtbuf/rtbuf_modular.ui: %s\n", error->message);
- g_clear_error(&error);
- return 1;
- }
- return 0;
-}
-
-int main (int argc, char *argv[])
-{
- symbols_init();
- librtbuf_init();
- assert(g_rtbuf);
- gtk_init(&argc, &argv);
- rtbuf_gtk_connection_init();
- rtbuf_gtk_output_init();
- if (rtbuf_gtk_builder())
- return 1;
- rtbuf_gtk_modular();
- gtk_main ();
- return 0;
-}
-
-extern int rtbuf_err (const char *msg)
-{
- fprintf(stderr, "rtbuf-gtk: %s\n", msg);
- return -1;
-}
diff --git a/rtbuf_gtk.gresource.xml b/rtbuf_gtk.gresource.xml
deleted file mode 100644
index 59fdc3c..0000000
--- a/rtbuf_gtk.gresource.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<gresources>
- <gresource prefix="/rtbuf/">
- <file preprocess="xml-stripblanks">rtbuf_input_widget.ui</file>
- <file preprocess="xml-stripblanks">rtbuf_modular.ui</file>
- <file preprocess="xml-stripblanks">rtbuf_output_widget.ui</file>
- <file preprocess="xml-stripblanks">rtbuf_widget.ui</file>
- </gresource>
-</gresources>
diff --git a/rtbuf_gtk.h b/rtbuf_gtk.h
deleted file mode 100644
index 564c3ba..0000000
--- a/rtbuf_gtk.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-#ifndef RTBUF_GTK_H
-#define RTBUF_GTK_H
-
-#include <gtk/gtk.h>
-#include "rtbuf_gtk_connection.h"
-#include "rtbuf_input_widget.h"
-#include "rtbuf_output_widget.h"
-#include "rtbuf_widget.h"
-
-enum dnd_targets {
- TARGET_RTBUF,
- TARGET_RTBUF_OUTPUT,
- N_TARGETS
-};
-
-typedef struct signal_binding {
- const char *signal;
- GCallback callback;
-} s_signal_binding;
-
-extern GtkLayout *modular_layout;
-extern s_rtbuf_gtk_connection *modular_connections;
-
-extern GtkTargetList *rtbuf_move_target_list;
-
-extern GtkWidget *drag_widget;
-extern s_rtbuf_gtk_connection *drag_connection;
-extern gint drag_x;
-extern gint drag_y;
-
-void rtbuf_gtk_drag_connection_end (RtbufInputWidget *input_widget);
-
-gboolean rtbuf_gtk_rtbuf_button_press (GtkWidget *widget,
- GdkEvent *event,
- gpointer data);
-
-gboolean rtbuf_gtk_input_check_button_press (RtbufInputWidget *widget,
- GdkEvent *event);
-
-void rtbuf_gtk_output_init ();
-gboolean rtbuf_gtk_output_check_button_press (RtbufOutputWidget *widget,
- GdkEvent *event);
-gboolean rtbuf_gtk_output_check_button_release (RtbufOutputWidget *widget,
- GdkEvent *event);
-
-#endif /* RTBUF_GTK_H */
diff --git a/rtbuf_gtk_connection.c b/rtbuf_gtk_connection.c
deleted file mode 100644
index 086cf53..0000000
--- a/rtbuf_gtk_connection.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <assert.h>
-#include "data.h"
-#include "rtbuf_gtk.h"
-
-s_data_type g_rtbuf_gtk_connection_type = {
- sizeof(s_rtbuf_gtk_connection) * 8,
- DATA_TYPE_BITS
-};
-s_data_alloc g_rtbuf_gtk_connection_alloc;
-
-void rtbuf_gtk_connection_init ()
-{
- data_alloc_init(&g_rtbuf_gtk_connection_alloc,
- &g_rtbuf_gtk_connection_type,
- RTBUF_MAX * 10, NULL, NULL);
-}
-
-s_rtbuf_gtk_connection * rtbuf_gtk_connection_new ()
-{
- s_rtbuf_gtk_connection *connection = data_new(&g_rtbuf_gtk_connection_alloc);
- return connection;
-}
-
-void rtbuf_gtk_connection_delete (s_rtbuf_gtk_connection *connection)
-{
- data_delete(&g_rtbuf_gtk_connection_alloc, connection);
-}
-
-void rtbuf_gtk_connection_push (s_rtbuf_gtk_connection **head,
- s_rtbuf_gtk_connection *item)
-{
- assert(!item->next);
- item->next = *head;
- *head = item;
-}
-
-int rtbuf_gtk_connection_remove_one (s_rtbuf_gtk_connection **head,
- s_rtbuf_gtk_connection *item)
-{
- s_rtbuf_gtk_connection **next = head;
- while (*next && *next != item)
- next = &(*next)->next;
- if (*next == item) {
- *next = item->next;
- return 1;
- }
- return 0;
-}
-
-s_rtbuf_gtk_connection * rtbuf_gtk_connection_find
-(s_rtbuf_gtk_connection *c,
- RtbufOutputWidget *output_widget,
- RtbufInputWidget *input_widget)
-{
- while (c && (c->output_widget != output_widget ||
- c->input_widget != input_widget))
- c = c->next;
- return c;
-}
-
diff --git a/rtbuf_gtk_connection.h b/rtbuf_gtk_connection.h
deleted file mode 100644
index eba2c4a..0000000
--- a/rtbuf_gtk_connection.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef RTBUF_GTK_CONNECTION_H
-#define RTBUF_GTK_CONNECTION_H
-
-#include "rtbuf_input_widget.h"
-#include "rtbuf_output_widget.h"
-
-typedef struct rtbuf_gtk_connection s_rtbuf_gtk_connection;
-
-struct rtbuf_gtk_connection {
- RtbufOutputWidget *output_widget;
- RtbufInputWidget *input_widget;
- s_rtbuf_gtk_connection *next;
-};
-
-void rtbuf_gtk_connection_init ();
-s_rtbuf_gtk_connection * rtbuf_gtk_connection_new ();
-void rtbuf_gtk_connection_delete (s_rtbuf_gtk_connection *connection);
-
-void rtbuf_gtk_connection_push (s_rtbuf_gtk_connection **head,
- s_rtbuf_gtk_connection *item);
-int rtbuf_gtk_connection_remove_one (s_rtbuf_gtk_connection **head,
- s_rtbuf_gtk_connection *item);
-s_rtbuf_gtk_connection * rtbuf_gtk_connection_find
-(s_rtbuf_gtk_connection *c,
- RtbufOutputWidget *output_widget,
- RtbufInputWidget *input_widget);
-
-#endif
diff --git a/rtbuf_gtk_input.c b/rtbuf_gtk_input.c
deleted file mode 100644
index 7449501..0000000
--- a/rtbuf_gtk_input.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <assert.h>
-#include <gtk/gtk.h>
-#include <stdio.h>
-#include "rtbuf.h"
-#include "rtbuf_gtk.h"
-#include "rtbuf_input_widget.h"
-
-GtkTargetList *rtbuf_gtk_input_target_list;
-#define RTBUF_GTK_INPUT_TARGETS 1
-GtkTargetEntry rtbuf_gtk_input_target_entry[RTBUF_GTK_INPUT_TARGETS]
-= {
- {"RtbufOutputWidget", GTK_TARGET_SAME_APP, TARGET_RTBUF_OUTPUT}
-};
-
-void rtbuf_gtk_input_init ()
-{
- rtbuf_gtk_input_target_list =
- gtk_target_list_new(rtbuf_gtk_input_target_entry,
- RTBUF_GTK_INPUT_TARGETS);
-}
-
-void rtbuf_gtk_input_disconnect (RtbufInputWidget *widget)
-{
- (void) widget;
- printf("rtbuf-gtk input disconnect\n");
-}
-
-void rtbuf_gtk_input_menu (RtbufInputWidget *widget, GdkEvent *event)
-{
- static GtkMenu *menu = 0;
- static GtkWidget *disconnect;
- static guint signal;
- printf("rtbuf-gtk input menu\n");
- if (!menu) {
- signal = g_signal_lookup("activate", GTK_TYPE_MENU_ITEM);
- assert(signal);
- menu = GTK_MENU(gtk_menu_new());
- disconnect = gtk_menu_item_new_with_label("Disconnect");
- gtk_container_add(GTK_CONTAINER(menu), disconnect);
- gtk_widget_show(disconnect);
- }
- g_signal_handlers_disconnect_matched(G_OBJECT(disconnect),
- G_SIGNAL_MATCH_FUNC,
- signal,
- 0,
- NULL,
- G_CALLBACK(rtbuf_gtk_input_disconnect),
- NULL);
- g_signal_connect_swapped(G_OBJECT(disconnect), "activate",
- G_CALLBACK(rtbuf_gtk_input_disconnect),
- widget);
- gtk_menu_popup_at_pointer(menu, event);
-}
-
-gboolean rtbuf_gtk_input_check_button_press (RtbufInputWidget *widget,
- GdkEvent *event)
-{
- printf("rtbuf-gtk input check button press\n");
- if (event->type == GDK_BUTTON_PRESS) {
- GdkEventButton *eb = (GdkEventButton*) event;
- if (eb->button == 3) {
- rtbuf_gtk_input_menu(widget, event);
- return TRUE;
- }
- }
- return FALSE;
-}
diff --git a/rtbuf_gtk_output.c b/rtbuf_gtk_output.c
deleted file mode 100644
index 9dac2fd..0000000
--- a/rtbuf_gtk_output.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <assert.h>
-#include <gtk/gtk.h>
-#include <stdio.h>
-#include "rtbuf.h"
-#include "rtbuf_gtk.h"
-#include "rtbuf_output_widget.h"
-
-GtkTargetList *rtbuf_gtk_output_target_list;
-#define RTBUF_GTK_OUTPUT_TARGETS 1
-GtkTargetEntry rtbuf_gtk_output_target_entry[RTBUF_GTK_OUTPUT_TARGETS]
-= {
- {"RtbufOutputWidget", GTK_TARGET_SAME_APP, TARGET_RTBUF_OUTPUT}
-};
-
-void rtbuf_gtk_output_init ()
-{
- rtbuf_gtk_output_target_list =
- gtk_target_list_new(rtbuf_gtk_output_target_entry,
- RTBUF_GTK_OUTPUT_TARGETS);
-}
-
-void rtbuf_gtk_output_disconnect (RtbufOutputWidget *widget)
-{
- (void) widget;
- printf("rtbuf-gtk output disconnect\n");
-}
-
-void rtbuf_gtk_output_menu (RtbufOutputWidget *widget, GdkEvent *event)
-{
- static GtkMenu *menu = 0;
- static GtkWidget *disconnect;
- static guint signal;
- printf("rtbuf-gtk output menu\n");
- if (!menu) {
- signal = g_signal_lookup("activate", GTK_TYPE_MENU_ITEM);
- assert(signal);
- menu = GTK_MENU(gtk_menu_new());
- disconnect = gtk_menu_item_new_with_label("Disconnect");
- gtk_container_add(GTK_CONTAINER(menu), disconnect);
- gtk_widget_show(disconnect);
- }
- g_signal_handlers_disconnect_matched(G_OBJECT(disconnect),
- G_SIGNAL_MATCH_FUNC,
- signal,
- 0,
- NULL,
- G_CALLBACK(rtbuf_gtk_output_disconnect),
- NULL);
- g_signal_connect_swapped(G_OBJECT(disconnect), "activate",
- G_CALLBACK(rtbuf_gtk_output_disconnect),
- widget);
- gtk_menu_popup_at_pointer(menu, event);
-}
-
-void rtbuf_gtk_output_drag (RtbufOutputWidget *widget,
- GdkEventButton *event)
-{
- s_rtbuf_gtk_connection *connection;
- printf("rtbuf-gtk output drag\n");
- connection = rtbuf_gtk_connection_new();
- if (!connection) {
- rtbuf_err("failed to allocate rtbuf_gtk_connection");
- return;
- }
- connection->output_widget = widget;
- rtbuf_gtk_connection_push(&modular_connections, connection);
- drag_connection = connection;
-}
-
-gboolean rtbuf_gtk_output_check_button_press (RtbufOutputWidget *widget,
- GdkEvent *event)
-{
- printf("rtbuf-gtk output check button press\n");
- if (event->type == GDK_BUTTON_PRESS) {
- GdkEventButton *eb = (GdkEventButton*) event;
- if (eb->button == 1) {
- rtbuf_gtk_output_drag(widget, eb);
- return TRUE;
- }
- else if (eb->button == 3) {
- rtbuf_gtk_output_menu(widget, event);
- return TRUE;
- }
- }
- return FALSE;
-}
diff --git a/rtbuf_gtk_rtbuf.c b/rtbuf_gtk_rtbuf.c
deleted file mode 100644
index 5a6bae0..0000000
--- a/rtbuf_gtk_rtbuf.c
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <assert.h>
-#include <gtk/gtk.h>
-#include <stdio.h>
-#include "rtbuf.h"
-#include "rtbuf_gtk.h"
-#include "rtbuf_widget.h"
-
-void rtbuf_gtk_rtbuf_rename (RtbufWidget *widget)
-{
- (void) widget;
- printf("rtbuf-gtk rtbuf rename\n");
-}
-
-void rtbuf_gtk_rtbuf_delete (RtbufWidget *widget)
-{
- s_rtbuf *rtbuf = rtbuf_widget_get_rtbuf(widget);
- printf("rtbuf-gtk rtbuf delete\n");
- gtk_container_remove(GTK_CONTAINER(modular_layout),
- GTK_WIDGET(widget));
- rtbuf_delete(rtbuf);
-}
-
-void rtbuf_gtk_rtbuf_menu (RtbufWidget *widget, GdkEvent *event)
-{
- static GtkMenu *menu = 0;
- static GtkWidget *rename;
- static GtkWidget *delete;
- static guint signal;
- printf("rtbuf-gtk rtbuf menu\n");
- if (!menu) {
- signal = g_signal_lookup("activate", GTK_TYPE_MENU_ITEM);
- assert(signal);
- menu = GTK_MENU(gtk_menu_new());
- rename = gtk_menu_item_new_with_label("Rename...");
- gtk_container_add(GTK_CONTAINER(menu), rename);
- gtk_widget_show(rename);
- delete = gtk_menu_item_new_with_label("Delete");
- gtk_container_add(GTK_CONTAINER(menu), delete);
- gtk_widget_show(delete);
- }
- g_signal_handlers_disconnect_matched(G_OBJECT(rename),
- G_SIGNAL_MATCH_FUNC,
- signal,
- 0,
- NULL,
- G_CALLBACK(rtbuf_gtk_rtbuf_rename),
- NULL);
- g_signal_connect_swapped(G_OBJECT(rename), "activate",
- G_CALLBACK(rtbuf_gtk_rtbuf_rename),
- widget);
- g_signal_handlers_disconnect_matched(G_OBJECT(delete),
- G_SIGNAL_MATCH_FUNC,
- signal,
- 0,
- NULL,
- G_CALLBACK(rtbuf_gtk_rtbuf_delete),
- NULL);
- g_signal_connect_swapped(G_OBJECT(delete), "activate",
- G_CALLBACK(rtbuf_gtk_rtbuf_delete),
- widget);
- gtk_menu_popup_at_pointer(menu, event);
-}
-
-void rtbuf_gtk_rtbuf_drag (RtbufWidget *widget,
- GdkEventButton *event)
-{
- GtkWidget *gtk_widget = GTK_WIDGET(widget);
- printf("rtbuf-gtk rtbuf drag\n");
- gdk_window_get_device_position(event->window, event->device,
- &drag_x, &drag_y, NULL);
- drag_widget = gtk_widget;
-}
-
-gboolean rtbuf_gtk_rtbuf_button_press (GtkWidget *widget,
- GdkEvent *event,
- gpointer data)
-{
- RtbufWidget *rtbuf_widget = RTBUF_WIDGET(widget);
- (void) data;
- printf("rtbuf-gtk rtbuf button press\n");
- if (event->type == GDK_BUTTON_PRESS) {
- GdkEventButton *eb = (GdkEventButton*) event;
- if (eb->button == 1) {
- rtbuf_gtk_rtbuf_drag(rtbuf_widget, eb);
- return TRUE;
- }
- else if (eb->button == 3) {
- rtbuf_gtk_rtbuf_menu(rtbuf_widget, event);
- return TRUE;
- }
- }
- return FALSE;
-}
diff --git a/rtbuf_input_widget.c b/rtbuf_input_widget.c
deleted file mode 100644
index 990ea02..0000000
--- a/rtbuf_input_widget.c
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <assert.h>
-#include <gtk/gtk.h>
-#include "rtbuf_gtk.h"
-#include "rtbuf_input_widget.h"
-#include "rtbuf.h"
-
-struct _RtbufInputWidgetPrivate {
- s_rtbuf *rtbuf;
- int in;
- GtkWidget *check;
- GtkWidget *label;
- GtkWidget *value;
- GtkWidget *min;
- GtkWidget *slider;
- GtkWidget *max;
-};
-
-enum {
- PROP_0,
- PROP_RTBUF,
- PROP_IN,
- LAST_PROP
-};
-
-static GParamSpec *rtbuf_input_widget_props[LAST_PROP];
-
-static void rtbuf_input_widget_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec);
-static void rtbuf_input_widget_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec);
-static void rtbuf_input_widget_finalize (GObject *object);
-
-G_DEFINE_TYPE_WITH_PRIVATE (RtbufInputWidget, rtbuf_input_widget, GTK_TYPE_BOX)
-
-static void
-rtbuf_input_widget_class_init (RtbufInputWidgetClass *klass)
-{
- GObjectClass *gobject_class = (GObjectClass*) klass;
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
- printf("rtbuf_input_widget class init\n");
- gobject_class->finalize = rtbuf_input_widget_finalize;
- gobject_class->set_property = rtbuf_input_widget_set_property;
- gobject_class->get_property = rtbuf_input_widget_get_property;
- rtbuf_input_widget_props[PROP_RTBUF] =
- g_param_spec_pointer("rtbuf",
- "Rtbuf",
- "Pointer to a s_rtbuf",
- G_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
- rtbuf_input_widget_props[PROP_IN] =
- g_param_spec_int("in",
- "Input",
- "rtbuf input index",
- -1, /* min */
- RTBUF_PROC_IN_MAX, /* max */
- -1, /* default */
- G_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
- g_object_class_install_properties(gobject_class, LAST_PROP, rtbuf_input_widget_props);
- gtk_widget_class_set_template_from_resource(widget_class,
- "/rtbuf/rtbuf_input_widget.ui");
- gtk_widget_class_bind_template_child_private(widget_class,
- RtbufInputWidget, check);
- gtk_widget_class_bind_template_child_private(widget_class,
- RtbufInputWidget, label);
- gtk_widget_class_bind_template_child_private(widget_class,
- RtbufInputWidget, value);
- gtk_widget_class_bind_template_child_private(widget_class,
- RtbufInputWidget, min);
- gtk_widget_class_bind_template_child_private(widget_class,
- RtbufInputWidget, slider);
- gtk_widget_class_bind_template_child_private(widget_class,
- RtbufInputWidget, max);
-}
-
-static void
-rtbuf_input_widget_init (RtbufInputWidget *widget)
-{
- printf("rtbuf_input_widget init\n");
- gtk_widget_init_template(GTK_WIDGET(widget));
-}
-
-static void
-rtbuf_input_widget_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- RtbufInputWidget *widget = RTBUF_INPUT_WIDGET(object);
- RtbufInputWidgetPrivate *priv =
- rtbuf_input_widget_get_instance_private(widget);
- switch (prop_id) {
- case PROP_RTBUF:
- priv->rtbuf = g_value_get_pointer(value);
- rtbuf_input_widget_update(widget);
- break;
- case PROP_IN:
- priv->in = g_value_get_int(value);
- rtbuf_input_widget_update(widget);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
- break;
- }
-}
-
-static void
-rtbuf_input_widget_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- RtbufInputWidget *widget = RTBUF_INPUT_WIDGET(object);
- RtbufInputWidgetPrivate *priv =
- rtbuf_input_widget_get_instance_private(widget);
- switch (prop_id) {
- case PROP_RTBUF:
- g_value_set_pointer(value, priv->rtbuf);
- break;
- case PROP_IN:
- g_value_set_int(value, priv->in);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
- break;
- }
-}
-
-static void
-rtbuf_input_widget_finalize (GObject *object)
-{
- RtbufInputWidget *widget = RTBUF_INPUT_WIDGET(object);
- RtbufInputWidgetPrivate *priv =
- rtbuf_input_widget_get_instance_private(widget);
- g_clear_object(&priv->check);
- g_clear_object(&priv->label);
- g_clear_object(&priv->value);
- g_clear_object(&priv->min);
- g_clear_object(&priv->slider);
- g_clear_object(&priv->max);
- G_OBJECT_CLASS(rtbuf_input_widget_parent_class)->finalize(object);
-}
-
-RtbufInputWidget *
-rtbuf_input_widget_new (s_rtbuf *rtbuf, unsigned int in)
-{
- return (RtbufInputWidget*) g_object_new(RTBUF_INPUT_WIDGET_TYPE,
- "rtbuf", rtbuf,
- "in", in,
- NULL);
-}
-
-s_rtbuf *
-rtbuf_input_widget_get_rtbuf (RtbufInputWidget *widget)
-{
- RtbufInputWidgetPrivate *priv =
- rtbuf_input_widget_get_instance_private(widget);
- if (priv)
- return priv->rtbuf;
- return NULL;
-}
-
-unsigned int
-rtbuf_input_widget_get_in (RtbufInputWidget *widget)
-{
- RtbufInputWidgetPrivate *priv =
- rtbuf_input_widget_get_instance_private(widget);
- if (priv)
- return priv->in;
- return 0;
-}
-
-GtkWidget *
-rtbuf_input_widget_get_check (RtbufInputWidget *widget)
-{
- RtbufInputWidgetPrivate *priv =
- rtbuf_input_widget_get_instance_private(widget);
- if (priv)
- return priv->check;
- return NULL;
-}
-
-void
-rtbuf_input_widget_update (RtbufInputWidget *widget)
-{
- const RtbufInputWidgetPrivate *priv =
- rtbuf_input_widget_get_instance_private(widget);
- if (priv && priv->rtbuf && priv->in >= 0) {
- const s_rtbuf_proc *proc = priv->rtbuf->proc;
- const char *label;
- assert(priv->in < proc->in_n);
- label = proc->in[priv->in].name;
- gtk_label_set_text(GTK_LABEL(priv->label), label);
- }
-}
-
-void rtbuf_input_widget_connect (GtkWidget *widget,
- gpointer data)
-{
- s_signal_binding *sb = (s_signal_binding*) data;
- g_signal_connect(G_OBJECT(widget), sb->signal,
- sb->callback, NULL);
-}
-
-void rtbuf_input_widget_connect_check (GtkWidget *input,
- gpointer data)
-{
- RtbufInputWidget *widget = RTBUF_INPUT_WIDGET(input);
- RtbufInputWidgetPrivate *priv =
- rtbuf_input_widget_get_instance_private(widget);
- s_signal_binding *sb = (s_signal_binding*) data;
- g_signal_connect_swapped(G_OBJECT(priv->check), sb->signal,
- sb->callback, widget);
-}
diff --git a/rtbuf_input_widget.h b/rtbuf_input_widget.h
deleted file mode 100644
index 887fba7..0000000
--- a/rtbuf_input_widget.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef RTBUF_INPUT_WIDGET_H
-#define RTBUF_INPUT_WIDGET_H
-
-#include "rtbuf.h"
-
-#define RTBUF_INPUT_WIDGET_TYPE \
- (rtbuf_input_widget_get_type())
-
-#define RTBUF_INPUT_WIDGET(object) \
- (G_TYPE_CHECK_INSTANCE_CAST((object), RTBUF_INPUT_WIDGET_TYPE, \
- RtbufInputWidget))
-
-#define RTBUF_INPUT_WIDGET_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), RTBUF_INPUT_WIDGET_TYPE, \
- RtbufInputWidgetClass))
-
-#define IS_RTBUF_INPUT_WIDGET(object) \
- (G_TYPE_CHECK_INSTANCE_TYPE((object), RTBUF_INPUT_WIDGET_TYPE))
-
-#define IS_RTBUF_INPUT_WIDGET_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass), RTBUF_INPUT_WIDGET_TYPE))
-
-#define RTBUF_INPUT_WIDGET_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS((obj), RTBUF_INPUT_WIDGET_TYPE, \
- RtbufInputWidgetClass))
-
-typedef struct _RtbufInputWidget RtbufInputWidget;
-typedef struct _RtbufInputWidgetClass RtbufInputWidgetClass;
-typedef struct _RtbufInputWidgetPrivate RtbufInputWidgetPrivate;
-
-struct _RtbufInputWidget {
- GtkBox box;
-};
-
-struct _RtbufInputWidgetClass {
- GtkBoxClass parent_class;
-};
-
-GType rtbuf_input_widget_get_type (void) G_GNUC_CONST;
-RtbufInputWidget * rtbuf_input_widget_new (s_rtbuf *rtbuf,
- unsigned int in);
-s_rtbuf * rtbuf_input_widget_get_rtbuf (RtbufInputWidget *widget);
-unsigned int rtbuf_input_widget_get_in (RtbufInputWidget *widget);
-GtkWidget * rtbuf_input_widget_get_check (RtbufInputWidget *widget);
-void rtbuf_input_widget_update (RtbufInputWidget *widget);
-void rtbuf_input_widget_connect (GtkWidget *input,
- gpointer data);
-void rtbuf_input_widget_connect_check (GtkWidget *input,
- gpointer data);
-
-#endif
diff --git a/rtbuf_input_widget.ui b/rtbuf_input_widget.ui
deleted file mode 100644
index 450a8a3..0000000
--- a/rtbuf_input_widget.ui
+++ /dev/null
@@ -1,96 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.22.2 -->
-<interface>
- <requires lib="gtk+" version="3.20"/>
- <template class="RtbufInputWidget" parent="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_BUTTON_MOTION_MASK | GDK_STRUCTURE_MASK</property>
- <child>
- <object class="GtkCheckButton" id="check">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_BUTTON_MOTION_MASK | GDK_STRUCTURE_MASK</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_BUTTON_MOTION_MASK | GDK_STRUCTURE_MASK</property>
- <property name="label" translatable="yes">input</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="value">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">0.5</property>
- <property name="width_chars">9</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="min">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="has_frame">False</property>
- <property name="width_chars">9</property>
- <property name="text" translatable="yes">0.0</property>
- <property name="caps_lock_warning">False</property>
- <property name="input_purpose">number</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkScale" id="slider">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="round_digits">1</property>
- <property name="digits">3</property>
- <property name="draw_value">False</property>
- <property name="value_pos">left</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">4</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="max">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="has_frame">False</property>
- <property name="width_chars">9</property>
- <property name="text" translatable="yes">1.0</property>
- <property name="input_purpose">number</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">5</property>
- </packing>
- </child>
- </template>
-</interface>
diff --git a/rtbuf_lib.c b/rtbuf_lib.c
deleted file mode 100644
index 775e987..0000000
--- a/rtbuf_lib.c
+++ /dev/null
@@ -1,314 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <assert.h>
-#include <dlfcn.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <strings.h>
-#include "rtbuf.h"
-#include "rtbuf_lib.h"
-#include "symbol.h"
-
-s_data_type g_rtbuf_lib_type = {
- sizeof(s_rtbuf_lib) * 8,
- DATA_TYPE_BITS
-};
-s_data_alloc g_rtbuf_lib_alloc;
-s_rtbuf_lib *g_rtbuf_lib;
-
-char g_rtbuf_lib_user_dir[1024];
-char *g_rtbuf_lib_path[] = { "",
- "./",
- "./.libs/",
- g_rtbuf_lib_user_dir,
- "/usr/local/lib/",
- "/usr/lib/",
- 0 };
-
-void rtbuf_lib_init_ ()
-{
- char *in = getenv("HOME");
- char *out = g_rtbuf_lib_user_dir;
- data_alloc_init(&g_rtbuf_lib_alloc, &g_rtbuf_lib_type,
- RTBUF_LIB_MAX, 0, 0);
- g_rtbuf_lib = g_rtbuf_lib_alloc.mem;
- assert(g_rtbuf_lib);
- if (!in)
- in = ".";
- while (*in)
- *out++ = *in++;
- in = "/.rtbuf/lib/";
- while (*in)
- *out++ = *in++;
- *out = 0;
-}
-
-int rtbuf_lib_p (s_rtbuf_lib *lib)
-{
- return lib->lib ? 1 : 0;
-}
-
-int rtbuf_lib_find (const char *str)
-{
- const char *sym;
- if ('0' <= str[0] && str[0] <= '9') {
- int i = atoi(str);
- if (0 <= i && (unsigned int) i < g_rtbuf_lib_alloc.n &&
- rtbuf_lib_p(&g_rtbuf_lib[i]))
- return i;
- }
- if ((sym = symbol_find(str))) {
- unsigned int i = 0;
- unsigned int n = g_rtbuf_lib_alloc.n - g_rtbuf_lib_alloc.free_n;
- while (i < g_rtbuf_lib_alloc.n && n > 0) {
- if (rtbuf_lib_p(&g_rtbuf_lib[i])) {
- if (sym == g_rtbuf_lib[i].name)
- return i;
- n--;
- }
- i++;
- }
- }
- return -1;
-}
-
-int rtbuf_lib_find_proc (s_rtbuf_lib *rl, const char *str)
-{
- const char *sym;
- if ('0' <= str[0] && str[0] <= '9') {
- int i = atoi(str);
- if (0 <= i && (unsigned) i < rl->proc_n)
- return i;
- }
- if ((sym = symbol_find(str))) {
- unsigned int i = 0;
- while (i < rl->proc_n) {
- if (sym == rl->proc[i]->name)
- return i;
- i++;
- }
- }
- return -1;
-}
-
-s_rtbuf_lib * rtbuf_lib_new ()
-{
- s_rtbuf_lib *lib = data_new(&g_rtbuf_lib_alloc);
- return lib;
-}
-
-void rtbuf_lib_delete (s_rtbuf_lib *rl)
-{
- unsigned int i = 0;
- assert(rl);
- if (rl->proc) {
- while (i < rl->proc_n) {
- rtbuf_proc_delete(rl->proc[i]);
- rl->proc[i] = 0;
- i++;
- }
- free(rl->proc);
- }
- data_delete(&g_rtbuf_lib_alloc, rl);
-}
-
-void rtbuf_lib_load_path (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 = "librtbuf_";
- while (*in)
- g_string[g_string_n++] = *in++;
- in = name;
- while (*in)
- g_string[g_string_n++] = *in++;
- in = ".so";
- 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);
- }
-}
-
-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;
-}
-
-s_rtbuf_lib * rtbuf_lib_load (const char *name)
-{
- s_rtbuf_lib *lib = rtbuf_lib_new();
- s_rtbuf_lib_proc *proc;
- unsigned long *ver;
- unsigned int i = 0;
- union {
- void *ptr;
- f_rtbuf_lib_init *init;
- } init_ptr;
- if (!lib)
- return 0;
- rtbuf_lib_load_path(lib, name);
- if (!lib->lib) {
- 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); */
- assert(*ver == RTBUF_LIB_VER);
- lib->name = symbol_intern(name);
- /* printf("lib_load name %s\n", lib->name); */
- if ((init_ptr.ptr = dlsym(lib->lib, "rtbuf_lib_init")))
- if (init_ptr.init(lib) < 0) {
- rtbuf_lib_delete(lib);
- return 0;
- }
- proc = dlsym(lib->lib, "rtbuf_lib_proc");
- lib->proc_n = 0;
- while (lib->proc_n < RTBUF_PROC_MAX &&
- rtbuf_lib_proc_p(&proc[lib->proc_n]))
- lib->proc_n++;
- lib->proc = malloc(sizeof(s_rtbuf_proc*) * (lib->proc_n + 1));
- while (i < lib->proc_n) {
- lib->proc[i] = rtbuf_proc_new();
- assert(lib->proc[i]);
- rtbuf_lib_proc_init_proc(lib->proc[i], &proc[i]);
- lib->proc[i]->lib = lib;
- lib->proc[i]->lib_proc = i;
- i++;
- }
- lib->proc[i] = 0;
- return lib;
-}
-
-void rtbuf_lib_proc_in_init_proc (s_rtbuf_proc *proc,
- s_rtbuf_lib_proc_in *in)
-{
- unsigned int i = 0;
- bzero(proc->in, sizeof(proc->in));
- if (in) {
- while (in->name && i < RTBUF_PROC_IN_MAX) {
- s_rtbuf_proc_in *v = &proc->in[i];
- v->name = symbol_intern(in->name);
- v->type = rtbuf_type(in->type);
- v->def = in->def;
- v->min = in->min;
- v->max = in->max;
- in++;
- i++;
- }
- assert(i < RTBUF_PROC_IN_MAX);
- }
- proc->in_n = i;
-}
-
-void rtbuf_lib_proc_out_init_proc (s_rtbuf_proc *proc,
- s_rtbuf_lib_proc_out *out)
-{
- unsigned int i = 0;
- bzero(proc->out, sizeof(proc->out));
- if (out) {
- unsigned int offset = 0;
- while (out->name && i < RTBUF_PROC_OUT_MAX) {
- s_rtbuf_proc_out *o = &proc->out[i];
- o->name = symbol_intern(out->name);
- o->type = rtbuf_type(out->type);
- assert(o->type);
- o->offset = offset;
- offset += (o->type->t.bits + 7) / 8;
- out++;
- i++;
- }
- assert(i < RTBUF_PROC_OUT_MAX);
- proc->out_bytes = offset;
- proc->type.bits = offset * 8;
- proc->type.type = DATA_TYPE_BITS;
- data_alloc_init(&proc->alloc, &proc->type, RTBUF_INSTANCE_MAX,
- NULL, NULL);
- }
- proc->out_n = i;
-}
-
-void rtbuf_lib_proc_init_proc (s_rtbuf_proc *proc, s_rtbuf_lib_proc *x)
-{
- proc->name = symbol_intern(x->name);
- proc->f = x->f;
- proc->start = x->start;
- proc->stop = x->stop;
- rtbuf_lib_proc_in_init_proc(proc, x->in);
- rtbuf_lib_proc_out_init_proc(proc, x->out);
-}
-
-void rtbuf_lib_print (const s_rtbuf_lib *lib)
-{
- unsigned int i;
- if (lib >= g_rtbuf_lib &&
- (i = lib - g_rtbuf_lib) < RTBUF_LIB_MAX)
- printf("#<lib %i %s>\n", i, lib->name);
- else
- printf("#<lib %p %s>\n", lib, lib->name);
-}
-
-void rtbuf_lib_print_long (unsigned int i)
-{
- s_rtbuf_lib *lib;
- unsigned int j = 0;
- assert(i < RTBUF_LIB_MAX);
- lib = &g_rtbuf_lib[i];
- printf("#<lib %i %s", i, lib->name);
- printf("\n %s", lib->path);
- while (j < lib->proc_n) {
- printf("\n ");
- rtbuf_proc_print(lib->proc[j]);
- j++;
- }
- printf(">\n");
- fflush(stdout);
-}
diff --git a/rtbuf_lib.h b/rtbuf_lib.h
deleted file mode 100644
index 863c266..0000000
--- a/rtbuf_lib.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-#ifndef RTBUF_LIB_H
-#define RTBUF_LIB_H
-
-#include "rtbuf_defs.h"
-
-#define RTBUF_LIB_MAX 1000
-#define RTBUF_LIB_VER 0x00010001
-
-struct rtbuf_lib_proc_in {
- const char *name;
- const char *type;
- double def;
- double min;
- double max;
-};
-
-struct rtbuf_lib_proc_out {
- const char *name;
- const char *type;
-};
-
-struct rtbuf_lib_proc {
- const char *name;
- f_rtbuf_proc *f;
- f_rtbuf_proc *start;
- f_rtbuf_proc *stop;
- s_rtbuf_lib_proc_in *in; /* inputs, end with NULL */
- s_rtbuf_lib_proc_out *out; /* outputs, end with NULL */
-};
-
-struct rtbuf_lib {
- const char *name;
- s_rtbuf_proc **proc;
- unsigned int proc_n;
- void *lib;
- const char *path;
-};
-
-extern s_data_alloc g_rtbuf_lib_alloc;
-extern s_rtbuf_lib *g_rtbuf_lib;
-
-void rtbuf_lib_delete (s_rtbuf_lib *rl);
-int rtbuf_lib_find (const char *str);
-int rtbuf_lib_find_proc (s_rtbuf_lib *rl, const char *str);
-void rtbuf_lib_init_ ();
-s_rtbuf_lib * rtbuf_lib_load (const char *path);
-s_rtbuf_lib * rtbuf_lib_new ();
-void rtbuf_lib_print (const s_rtbuf_lib *lib);
-void rtbuf_lib_print_long (unsigned int i);
-
-void rtbuf_lib_proc_var_init_proc (s_rtbuf_proc *proc,
- s_rtbuf_lib_proc_in *in);
-void rtbuf_lib_proc_out_init_proc (s_rtbuf_proc *proc,
- s_rtbuf_lib_proc_out *out);
-void rtbuf_lib_proc_init_proc (s_rtbuf_proc *proc, s_rtbuf_lib_proc *x);
-
-#endif
diff --git a/rtbuf_modular.ui b/rtbuf_modular.ui
deleted file mode 100644
index 58ccab7..0000000
--- a/rtbuf_modular.ui
+++ /dev/null
@@ -1,247 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.22.1 -->
-<interface>
- <requires lib="gtk+" version="3.20"/>
- <object class="GtkWindow" id="modular">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child type="titlebar">
- <placeholder/>
- </child>
- <child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkMenuBar">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkMenuItem">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">_File</property>
- <property name="use_underline">True</property>
- <child type="submenu">
- <object class="GtkMenu">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkImageMenuItem">
- <property name="label">gtk-new</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem">
- <property name="label">gtk-open</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem">
- <property name="label">gtk-save</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem">
- <property name="label">gtk-save-as</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- </object>
- </child>
- <child>
- <object class="GtkSeparatorMenuItem">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem" id="quit">
- <property name="label">gtk-quit</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkMenuItem">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">_Edit</property>
- <property name="use_underline">True</property>
- <child type="submenu">
- <object class="GtkMenu">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkImageMenuItem">
- <property name="label">gtk-cut</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem">
- <property name="label">gtk-copy</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem">
- <property name="label">gtk-paste</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem">
- <property name="label">gtk-delete</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkMenuItem">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">_Library</property>
- <property name="use_underline">True</property>
- <child type="submenu">
- <object class="GtkMenu" id="library_menu">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkMenuItem">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label">signal</property>
- <child type="submenu">
- <object class="GtkMenu">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkMenuItem">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label">sinus</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkMenuItem">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">_View</property>
- <property name="use_underline">True</property>
- </object>
- </child>
- <child>
- <object class="GtkMenuItem">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">_Help</property>
- <property name="use_underline">True</property>
- <child type="submenu">
- <object class="GtkMenu">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkImageMenuItem">
- <property name="label">gtk-about</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolbar">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkScrolledWindow">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <property name="shadow_type">in</property>
- <child>
- <object class="GtkLayout" id="modular_layout">
- <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>
- <property name="height">8192</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
-</interface>
diff --git a/rtbuf_music.c b/rtbuf_music.c
deleted file mode 100644
index 028c9c4..0000000
--- a/rtbuf_music.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <assert.h>
-#include <math.h>
-#include <stdio.h>
-#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;
-
-int rtbuf_music_init ()
-{
- double tune_c;
- if (g_rtbuf_music_init)
- return 0;
- rtbuf_type_define(RTBUF_MUSIC_NOTE_TYPE, RTBUF_MUSIC_NOTE_SIZE);
- rtbuf_type_define(RTBUF_MUSIC_NOTES_TYPE, RTBUF_MUSIC_NOTES_SIZE);
- tune_c = fmod(log2(RTBUF_MUSIC_TUNE_A) - 9.0 / 12.0, 1.0);
- g_rtbuf_music_tune = RTBUF_MUSIC_BASE_OCTAVE + tune_c;
- g_rtbuf_music_init = 1;
- return 0;
-}
-
-double rtbuf_music_note_frequency (unsigned int octave,
- unsigned int note)
-{
- return exp2(octave + note / 12.0 + g_rtbuf_music_tune);
-}
-
-double rtbuf_music_frequency_note (double f)
-{
- return log2(f) * 12.0 - g_rtbuf_music_tune;
-}
-
-int rtbuf_music_notes_new (s_rtbuf_music_notes *notes, double velocity)
-{
- unsigned int i = 0;
- assert(notes);
- if (velocity == 0.0)
- return rtbuf_err("music_notes_new: zero velocity");
- if (notes->note_n >= RTBUF_MUSIC_NOTE_MAX)
- return rtbuf_err("RTBUF_MUSIC_NOTE_MAX exhausted");
- while (i < RTBUF_MUSIC_NOTE_MAX) {
- if (notes->note[i].velocity == 0.0) {
- notes->note[i].velocity = velocity;
- notes->note_n++;
- printf("music_notes_new %u\n", i);
- return i;
- }
- i++;
- }
- return -1;
-}
-
-void rtbuf_music_notes_delete (s_rtbuf_music_notes *notes,
- unsigned int i)
-{
- s_rtbuf_music_note *note;
- assert(notes);
- assert(i < RTBUF_MUSIC_NOTE_MAX);
- note = ¬es->note[i];
- if (note->velocity > 0.0 && note->start >= 0.0) {
- printf("music_notes_delete %u\n", i);
- notes->note_n--;
- }
- note->velocity = 0.0;
- note->freq = 0.0;
- note->start = -1.0;
- note->stop = -1.0;
-}
-
-void rtbuf_music_notes_delete_all (s_rtbuf_music_notes *notes)
-{
- unsigned int i = 0;
- while (i < RTBUF_MUSIC_NOTE_MAX && notes->note_n > 0) {
- rtbuf_music_notes_delete(notes, i);
- i++;
- }
-}
-
-void rtbuf_music_note_dt (s_rtbuf_music_note *note, double dt)
-{
- assert(note);
- if (note->start >= 0.0) {
- note->start += dt;
- if (note->stop >= 0.0)
- note->stop += dt;
- }
-}
-
-void rtbuf_music_notes_dt (s_rtbuf_music_notes *notes, double dt)
-{
- unsigned int i = 0;
- if (notes) {
- unsigned int n = notes->note_n;
- while (i < RTBUF_MUSIC_NOTE_MAX && n > 0) {
- if (notes->note[i].velocity > 0.0) {
- rtbuf_music_note_dt(¬es->note[i], dt);
- n--;
- }
- i++;
- }
- }
-}
-
-s_rtbuf_music_notes * rtbuf_music_notes (s_rtbuf *rtb,
- unsigned int in)
-{
- s_rtbuf_binding *v;
- s_rtbuf *target;
- unsigned int offset;
- v = &rtb->in[in];
- if (v->rtb < 0)
- return 0;
- assert(v->rtb < RTBUF_MAX);
- target = &g_rtbuf[v->rtb];
- assert(target->proc);
- assert(v->out < target->proc->out_n);
- offset = target->proc->out[v->out].offset;
- return (s_rtbuf_music_notes*) ((char*) target->data + offset);
-}
-
-int rtbuf_music_note_p (s_rtbuf_music_note *note)
-{
- return (note && note->velocity > 0.0);
-}
diff --git a/rtbuf_music.h b/rtbuf_music.h
deleted file mode 100644
index 1858b0b..0000000
--- a/rtbuf_music.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-#ifndef RTBUF_MUSIC_H
-#define RTBUF_MUSIC_H
-
-#include "rtbuf_signal.h"
-
-#define RTBUF_MUSIC_TUNE_A 440.0
-#define RTBUF_MUSIC_BASE_OCTAVE 4
-
-#define RTBUF_MUSIC_RELEASE_MAX 1.0
-
-#define RTBUF_MUSIC_NOTE_SIZE RTBUF_SIGNAL_SAMPLE_SIZE
-#define RTBUF_MUSIC_NOTE_TYPE "music_note"
-
-#pragma pack(push,1)
-typedef struct rtbuf_music_note {
- t_rtbuf_signal_sample velocity; /* between 0.0 and 1.0 */
- t_rtbuf_signal_sample freq; /* above 0.0 */
- t_rtbuf_signal_sample start; /* time since start */
- t_rtbuf_signal_sample stop; /* time since stop, or -1.0 */
-} s_rtbuf_music_note;
-#pragma pack(pop)
-
-#define RTBUF_MUSIC_NOTE_IN(note) \
- { note "velocity", RTBUF_SIGNAL_SAMPLE_TYPE, 1.0, 0.0, 1.0 }, \
- { note "frequency", RTBUF_SIGNAL_SAMPLE_TYPE, 220.0, 0.0, \
- RTBUF_SIGNAL_SAMPLERATE / 2.0 }, \
- { note "start", RTBUF_SIGNAL_SAMPLE_TYPE, -1.0, -1.0, FLT_MAX }, \
- { note "stop", RTBUF_SIGNAL_SAMPLE_TYPE, -1.0, -1.0, FLT_MAX }
-
-#define RTBUF_MUSIC_NOTE_IN_ENUM(note) \
- note ## _VELOCITY , \
- note ## _FREQUENCY, \
- note ## _START , \
- note ## _STOP
-
-enum {
- RTBUF_MUSIC_NOTE_IN_VELOCITY = 0,
- RTBUF_MUSIC_NOTE_IN_FREQUENCY,
- RTBUF_MUSIC_NOTE_IN_START,
- RTBUF_MUSIC_NOTE_IN_STOP,
- RTBUF_MUSIC_NOTE_INS
-};
-
-#define RTBUF_MUSIC_NOTE_IN_VELOCITY(notes, i) \
- (notes + 1 + RTBUF_MUSIC_NOTE_INS * i + \
- RTBUF_MUSIC_NOTE_IN_VELOCITY)
-#define RTBUF_MUSIC_NOTE_IN_FREQUENCY(notes, i) \
- (notes + 1 + RTBUF_MUSIC_NOTE_INS * i + \
- RTBUF_MUSIC_NOTE_IN_FREQUENCY)
-#define RTBUF_MUSIC_NOTE_IN_START(notes, i) \
- (notes + 1 + RTBUF_MUSIC_NOTE_INS * i + RTBUF_MUSIC_NOTE_IN_START)
-#define RTBUF_MUSIC_NOTE_IN_STOP(notes, i) \
- (notes + 1 + RTBUF_MUSIC_NOTE_INS * i + RTBUF_MUSIC_NOTE_IN_STOP)
-
-#define RTBUF_MUSIC_NOTE_MAX 32
-
-#pragma pack(push,1)
-typedef struct rtbuf_music_notes {
- unsigned int note_n;
- s_rtbuf_music_note note[RTBUF_MUSIC_NOTE_MAX];
-} s_rtbuf_music_notes;
-#pragma pack(pop)
-
-#define RTBUF_MUSIC_NOTES_SIZE sizeof(unsigned int)
-#define RTBUF_MUSIC_NOTES_TYPE "music_notes"
-
-int rtbuf_music_init ();
-void rtbuf_music_notes_init (s_rtbuf_music_notes *notes);
-int rtbuf_music_notes_new (s_rtbuf_music_notes *notes, double velocity);
-void rtbuf_music_notes_delete (s_rtbuf_music_notes *notes,
- unsigned int i);
-void rtbuf_music_notes_delete_all (s_rtbuf_music_notes *notes);
-void rtbuf_music_notes_dt (s_rtbuf_music_notes *notes, double dt);
-int rtbuf_music_note_p (s_rtbuf_music_note *note);
-void rtbuf_music_note_dt (s_rtbuf_music_note *note, double dt);
-
-s_rtbuf_music_notes * rtbuf_music_notes (s_rtbuf *rtb,
- unsigned int in);
-
-t_rtbuf_signal_sample rtbuf_music_note_frequency (unsigned int octave,
- unsigned int note);
-double rtbuf_music_frequency_note (double f);
-
-#endif
diff --git a/rtbuf_music_type.c b/rtbuf_music_type.c
deleted file mode 100644
index ee099fd..0000000
--- a/rtbuf_music_type.c
+++ /dev/null
@@ -1,71 +0,0 @@
-
-#include <stdio.h>
-#include "rtbuf.h"
-#include "rtbuf_music.h"
-
-void notes_in ()
-{
- unsigned int i = 0;
- const char *st = "RTBUF_SIGNAL_SAMPLE_TYPE";
- printf("\n"
- "#define RTBUF_MUSIC_NOTES_IN(note) \\\n"
- " { note \"s\" , RTBUF_MUSIC_NOTES_TYPE, 0.0, 0.0, 0.0 }"
- ", \\\n");
- while (i < RTBUF_MUSIC_NOTE_MAX) {
- printf(" { note \"[%u].velocity\" , %s, 0.0, 0.0, 1.0 }, \\\n", i, st);
- printf(" { note \"[%u].frequency\", %s, 0.0, 0.0, "
- "RTBUF_SIGNAL_SAMPLERATE / 2.0 }, \\\n", i, st);
- printf(" { note \"[%u].start\" , %s, -1.0, -1.0, FLT_MAX }, \\\n", i, st);
- printf(" { note \"[%u].stop\" , %s, -1.0, -1.0, FLT_MAX }", i, st);
- if (i < RTBUF_MUSIC_NOTE_MAX - 1)
- printf(", \\");
- printf("\n");
- i++;
- }
- i = 0;
- printf("\n"
- "#define RTBUF_MUSIC_NOTES_IN_ENUM(note) \\\n"
- " note ## S , \\\n");
- while (i < RTBUF_MUSIC_NOTE_MAX) {
- printf(" note ## _%u_VELOCITY , \\\n", i);
- printf(" note ## _%u_FREQUENCY, \\\n", i);
- printf(" note ## _%u_START , \\\n", i);
- printf(" note ## _%u_STOP", i);
- if (i < RTBUF_MUSIC_NOTE_MAX - 1)
- printf(" , \\");
- printf("\n");
- i++;
- }
-}
-
-void notes_out ()
-{
- unsigned int i = 0;
- const char *st = "RTBUF_SIGNAL_SAMPLE_TYPE";
- printf("\n"
- "#define RTBUF_MUSIC_NOTES_OUT(note) \\\n"
- " { note \"s\" , RTBUF_MUSIC_NOTES_TYPE }"
- ", \\\n");
- while (i < RTBUF_MUSIC_NOTE_MAX) {
- printf(" { note \"[%u].velocity\" , %s }, \\\n", i, st);
- printf(" { note \"[%u].frequency\", %s }, \\\n", i, st);
- printf(" { note \"[%u].start\" , %s }, \\\n", i, st);
- printf(" { note \"[%u].stop\" , %s }", i, st);
- if (i < RTBUF_MUSIC_NOTE_MAX - 1)
- printf(", \\");
- printf("\n");
- i++;
- }
-}
-
-int main ()
-{
- printf("/* file generated by rtbuf_music_type */\n");
- printf("#ifndef RTBUF_MUSIC_TYPE_H\n"
- "#define RTBUF_MUSIC_TYPE_H\n");
- notes_in();
- notes_out();
- printf("\n"
- "#endif\n");
- return 0;
-}
diff --git a/rtbuf_output_widget.c b/rtbuf_output_widget.c
deleted file mode 100644
index 97df00c..0000000
--- a/rtbuf_output_widget.c
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <assert.h>
-#include <gtk/gtk.h>
-#include "rtbuf_gtk.h"
-#include "rtbuf_output_widget.h"
-#include "rtbuf.h"
-
-struct _RtbufOutputWidgetPrivate {
- s_rtbuf *rtbuf;
- int out;
- GtkWidget *check;
- GtkWidget *label;
-};
-
-enum {
- PROP_0,
- PROP_RTBUF,
- PROP_OUT,
- LAST_PROP
-};
-
-static GParamSpec *rtbuf_output_widget_props[LAST_PROP];
-
-static void rtbuf_output_widget_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec);
-static void rtbuf_output_widget_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec);
-static void rtbuf_output_widget_finalize (GObject *object);
-
-G_DEFINE_TYPE_WITH_PRIVATE (RtbufOutputWidget, rtbuf_output_widget, GTK_TYPE_BOX)
-
-static void
-rtbuf_output_widget_class_init (RtbufOutputWidgetClass *klass)
-{
- GObjectClass *gobject_class = (GObjectClass*) klass;
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
- printf("rtbuf_output_widget class init\n");
- gobject_class->finalize = rtbuf_output_widget_finalize;
- gobject_class->set_property = rtbuf_output_widget_set_property;
- gobject_class->get_property = rtbuf_output_widget_get_property;
- rtbuf_output_widget_props[PROP_RTBUF] =
- g_param_spec_pointer("rtbuf",
- "Rtbuf",
- "Pointer to a s_rtbuf",
- G_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
- rtbuf_output_widget_props[PROP_OUT] =
- g_param_spec_int("out",
- "Output",
- "rtbuf output index",
- -1, /* min */
- RTBUF_PROC_OUT_MAX, /* max */
- -1, /* default */
- G_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
- g_object_class_install_properties(gobject_class, LAST_PROP, rtbuf_output_widget_props);
- gtk_widget_class_set_template_from_resource(widget_class,
- "/rtbuf/rtbuf_output_widget.ui");
- gtk_widget_class_bind_template_child_private(widget_class,
- RtbufOutputWidget, check);
- gtk_widget_class_bind_template_child_private(widget_class,
- RtbufOutputWidget, label);
-}
-
-static void
-rtbuf_output_widget_init (RtbufOutputWidget *widget)
-{
- printf("rtbuf_output_widget init\n");
- gtk_widget_init_template(GTK_WIDGET(widget));
-}
-
-static void
-rtbuf_output_widget_set_property (GObject *object, guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- RtbufOutputWidget *widget = RTBUF_OUTPUT_WIDGET(object);
- RtbufOutputWidgetPrivate *priv =
- rtbuf_output_widget_get_instance_private(widget);
- switch (prop_id) {
- case PROP_RTBUF:
- priv->rtbuf = g_value_get_pointer(value);
- rtbuf_output_widget_update(widget);
- break;
- case PROP_OUT:
- priv->out = g_value_get_int(value);
- rtbuf_output_widget_update(widget);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
- break;
- }
-}
-
-static void
-rtbuf_output_widget_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- RtbufOutputWidget *widget = RTBUF_OUTPUT_WIDGET(object);
- RtbufOutputWidgetPrivate *priv =
- rtbuf_output_widget_get_instance_private(widget);
- switch (prop_id) {
- case PROP_RTBUF:
- g_value_set_pointer(value, priv->rtbuf);
- break;
- case PROP_OUT:
- g_value_set_int(value, priv->out);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
- break;
- }
-}
-
-static void
-rtbuf_output_widget_finalize (GObject *object)
-{
- RtbufOutputWidget *widget = RTBUF_OUTPUT_WIDGET(object);
- RtbufOutputWidgetPrivate *priv =
- rtbuf_output_widget_get_instance_private(widget);
- g_clear_object(&priv->check);
- g_clear_object(&priv->label);
- G_OBJECT_CLASS(rtbuf_output_widget_parent_class)->finalize(object);
-}
-
-RtbufOutputWidget *
-rtbuf_output_widget_new (s_rtbuf *rtbuf, unsigned int out)
-{
- return (RtbufOutputWidget*) g_object_new(RTBUF_OUTPUT_WIDGET_TYPE,
- "rtbuf", rtbuf,
- "out", out,
- NULL);
-}
-
-s_rtbuf *
-rtbuf_output_widget_get_rtbuf (RtbufOutputWidget *widget)
-{
- RtbufOutputWidgetPrivate *priv =
- rtbuf_output_widget_get_instance_private(widget);
- if (priv)
- return priv->rtbuf;
- return NULL;
-}
-
-unsigned int
-rtbuf_output_widget_get_out (RtbufOutputWidget *widget)
-{
- RtbufOutputWidgetPrivate *priv =
- rtbuf_output_widget_get_instance_private(widget);
- if (priv)
- return priv->out;
- return 0;
-}
-
-GtkWidget *
-rtbuf_output_widget_get_check (RtbufOutputWidget *widget)
-{
- RtbufOutputWidgetPrivate *priv =
- rtbuf_output_widget_get_instance_private(widget);
- if (priv)
- return priv->check;
- return NULL;
-}
-
-void
-rtbuf_output_widget_update (RtbufOutputWidget *widget)
-{
- const RtbufOutputWidgetPrivate *priv =
- rtbuf_output_widget_get_instance_private(widget);
- if (priv && priv->rtbuf && priv->out >= 0) {
- const s_rtbuf_proc *proc = priv->rtbuf->proc;
- const char *label;
- assert(priv->out < proc->out_n);
- label = proc->out[priv->out].name;
- gtk_label_set_text(GTK_LABEL(priv->label), label);
- }
-}
-
-void rtbuf_output_widget_connect_check (GtkWidget *output,
- gpointer data)
-{
- RtbufOutputWidget *widget = RTBUF_OUTPUT_WIDGET(output);
- RtbufOutputWidgetPrivate *priv =
- rtbuf_output_widget_get_instance_private(widget);
- s_signal_binding *sb = (s_signal_binding*) data;
- g_signal_connect_swapped(G_OBJECT(priv->check), sb->signal,
- sb->callback, widget);
-}
diff --git a/rtbuf_output_widget.h b/rtbuf_output_widget.h
deleted file mode 100644
index e54cce5..0000000
--- a/rtbuf_output_widget.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef RTBUF_OUTPUT_WIDGET_H
-#define RTBUF_OUTPUT_WIDGET_H
-
-#include "rtbuf.h"
-
-#define RTBUF_OUTPUT_WIDGET_TYPE \
- (rtbuf_output_widget_get_type())
-
-#define RTBUF_OUTPUT_WIDGET(object) \
- (G_TYPE_CHECK_INSTANCE_CAST((object), RTBUF_OUTPUT_WIDGET_TYPE, \
- RtbufOutputWidget))
-
-#define RTBUF_OUTPUT_WIDGET_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), RTBUF_OUTPUT_WIDGET_TYPE, \
- RtbufOutputWidgetClass))
-
-#define IS_RTBUF_OUTPUT_WIDGET(object) \
- (G_TYPE_CHECK_INSTANCE_TYPE((object), RTBUF_OUTPUT_WIDGET_TYPE))
-
-#define IS_RTBUF_OUTPUT_WIDGET_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass), RTBUF_OUTPUT_WIDGET_TYPE))
-
-#define RTBUF_OUTPUT_WIDGET_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS((obj), RTBUF_OUTPUT_WIDGET_TYPE, \
- RtbufOutputWidgetClass))
-
-typedef struct _RtbufOutputWidget RtbufOutputWidget;
-typedef struct _RtbufOutputWidgetClass RtbufOutputWidgetClass;
-typedef struct _RtbufOutputWidgetPrivate RtbufOutputWidgetPrivate;
-
-struct _RtbufOutputWidget {
- GtkBox box;
-};
-
-struct _RtbufOutputWidgetClass {
- GtkBoxClass parent_class;
-};
-
-GType rtbuf_output_widget_get_type (void) G_GNUC_CONST;
-RtbufOutputWidget * rtbuf_output_widget_new (s_rtbuf *rtbuf,
- unsigned int out);
-s_rtbuf * rtbuf_output_widget_get_rtbuf (RtbufOutputWidget *widget);
-unsigned int rtbuf_output_widget_get_out (RtbufOutputWidget *widget);
-GtkWidget * rtbuf_output_widget_get_check (RtbufOutputWidget *widget);
-void rtbuf_output_widget_update (RtbufOutputWidget *widget);
-void rtbuf_output_widget_connect_check (GtkWidget *output,
- gpointer data);
-
-#endif
diff --git a/rtbuf_output_widget.ui b/rtbuf_output_widget.ui
deleted file mode 100644
index fc3a250..0000000
--- a/rtbuf_output_widget.ui
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.22.2 -->
-<interface>
- <requires lib="gtk+" version="3.20"/>
- <template class="RtbufOutputWidget" parent="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkCheckButton" id="check">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="draw_indicator">True</property>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">end</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">output</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">end</property>
- <property name="position">1</property>
- </packing>
- </child>
- </template>
-</interface>
diff --git a/rtbuf_portaudio.c b/rtbuf_portaudio.c
deleted file mode 100644
index 338014b..0000000
--- a/rtbuf_portaudio.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <portaudio.h>
-#include <stdio.h>
-#include <strings.h>
-#include "rtbuf.h"
-#include "rtbuf_lib.h"
-#include "rtbuf_signal.h"
-#include "rtbuf_signal_type.h"
-#include "rtbuf_portaudio.h"
-#include "rtbuf_portaudio_type.h"
-
-s_rtbuf_lib_proc_out g_rtbuf_portaudio_input_out[] = {
- { "left", RTBUF_SIGNAL_TYPE },
- { "right", RTBUF_SIGNAL_TYPE },
- { "samples", RTBUF_PORTAUDIO_SAMPLES_TYPE },
- { 0, 0 } };
-
-s_rtbuf_lib_proc_in g_rtbuf_portaudio_output_in[] = {
- { "left", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
- { "right", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
- { 0, 0, 0.0, 0.0, 0.0 } };
-
-s_rtbuf_lib_proc_out g_rtbuf_portaudio_output_out[] = {
- { "samples", RTBUF_PORTAUDIO_SAMPLES_TYPE },
- { "reserved", RTBUF_PORTAUDIO_OUTPUT_RESERVED_TYPE },
- { 0, 0 } };
-
-const char *rtbuf_lib_name = "portaudio";
-unsigned long rtbuf_lib_ver = RTBUF_LIB_VER;
-s_rtbuf_lib_proc rtbuf_lib_proc[] = {
- { "input", rtbuf_portaudio_input, rtbuf_portaudio_input_start,
- rtbuf_portaudio_input_stop, 0, g_rtbuf_portaudio_input_out },
- { "output", rtbuf_portaudio_output, rtbuf_portaudio_output_start,
- rtbuf_portaudio_output_stop, g_rtbuf_portaudio_output_in,
- g_rtbuf_portaudio_output_out },
- { 0, 0, 0, 0, 0, 0 } };
diff --git a/rtbuf_portaudio.h b/rtbuf_portaudio.h
deleted file mode 100644
index 13e044b..0000000
--- a/rtbuf_portaudio.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-#ifndef RTBUF_PORTAUDIO_H
-#define RTBUF_PORTAUDIO_H
-
-#include <portaudio.h>
-#include "rtbuf_signal.h"
-
-enum {
- RTBUF_PORTAUDIO_LEFT = 0,
- RTBUF_PORTAUDIO_RIGHT,
- RTBUF_PORTAUDIO_CHANNELS
-};
-
-#define RTBUF_PORTAUDIO_SAMPLE_TYPE "short"
-#define RTBUF_PORTAUDIO_SAMPLES \
- (RTBUF_PORTAUDIO_CHANNELS * RTBUF_SIGNAL_SAMPLES)
-
-typedef short t_rtbuf_portaudio_sample;
-typedef t_rtbuf_portaudio_sample t_rtbuf_portaudio_samples[RTBUF_PORTAUDIO_SAMPLES];
-
-typedef struct rtbuf_portaudio_input_data {
- t_rtbuf_signal signal[RTBUF_PORTAUDIO_CHANNELS];
- t_rtbuf_portaudio_samples samples;
-} s_rtbuf_portaudio_input_data;
-
-int rtbuf_portaudio_input (s_rtbuf *rtb);
-int rtbuf_portaudio_input_start (s_rtbuf *rtb);
-int rtbuf_portaudio_input_stop (s_rtbuf *rtb);
-
-typedef struct rtbuf_portaudio_output_reserved {
- PaStream *stream;
-} s_rtbuf_portaudio_output_reserved;
-
-typedef struct rtbuf_portaudio_output_data {
- t_rtbuf_portaudio_samples samples;
- s_rtbuf_portaudio_output_reserved reserved;
-} s_rtbuf_portaudio_output_data;
-
-#define RTBUF_PORTAUDIO_OUTPUT_RESERVED_SIZE \
- sizeof(s_rtbuf_portaudio_output_reserved)
-
-int rtbuf_portaudio_output (s_rtbuf *rtb);
-int rtbuf_portaudio_output_start (s_rtbuf *rtb);
-int rtbuf_portaudio_output_stop (s_rtbuf *rtb);
-
-#endif
diff --git a/rtbuf_portaudio_input.c b/rtbuf_portaudio_input.c
deleted file mode 100644
index 6ee5709..0000000
--- a/rtbuf_portaudio_input.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <portaudio.h>
-#include <stdio.h>
-#include <strings.h>
-#include "rtbuf.h"
-#include "rtbuf_signal.h"
-#include "rtbuf_portaudio.h"
-
-int rtbuf_portaudio_input (s_rtbuf *rtb)
-{
- /*
- s_portaudio_input_data *data = (s_portaudio_input_data*) rtb->data;
- */
- (void) rtb;
- return 0;
-}
-
-int rtbuf_portaudio_input_start (s_rtbuf *rtb)
-{
- s_rtbuf_portaudio_input_data *data;
- assert(rtb->proc->out_bytes == sizeof(*data));
- data = (s_rtbuf_portaudio_input_data*) rtb->data;
- return 0;
-}
-
-int rtbuf_portaudio_input_stop (s_rtbuf *rtb)
-{
- (void) rtb;
- return 0;
-}
diff --git a/rtbuf_portaudio_output.c b/rtbuf_portaudio_output.c
deleted file mode 100644
index 0d210b6..0000000
--- a/rtbuf_portaudio_output.c
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <limits.h>
-#include <portaudio.h>
-#include <stdio.h>
-#include <strings.h>
-#include "rtbuf.h"
-#include "rtbuf_portaudio.h"
-
-int g_initialized = 0;
-
-int rtbuf_portaudio_output_start (s_rtbuf *rtb)
-{
- s_rtbuf_portaudio_output_data *data;
- PaError err;
- assert(rtb->proc->out_bytes == sizeof(*data));
- data = (s_rtbuf_portaudio_output_data*) rtb->data;
- if (!g_initialized) {
- if (Pa_Initialize() != paNoError)
- return rtbuf_err("portaudio_output_start: Pa_Initialize() failed");
- g_initialized = 1;
- }
- err = Pa_OpenDefaultStream(&data->reserved.stream, /* stream pointer */
- 0, /* input channels */
- RTBUF_PORTAUDIO_CHANNELS, /* output channels */
- paInt16, /* sample format */
- RTBUF_SIGNAL_SAMPLERATE, /* sample rate */
- RTBUF_SIGNAL_SAMPLES, /* frames per buffer */
- NULL, /* stream callback */
- NULL); /* user data */
- if (err != paNoError) {
- rtbuf_err(Pa_GetErrorText(err));
- return rtbuf_err("portaudio_output_start: Pa_OpenDefaultStream() failed");
- }
- err = Pa_StartStream(data->reserved.stream);
- if (err != paNoError) {
- rtbuf_err(Pa_GetErrorText(err));
- return rtbuf_err("portaudio output start: Pa_StartStream() failed");
- }
- return 0;
-}
-
-int rtbuf_portaudio_output_stop (s_rtbuf *rtb)
-{
- s_rtbuf_portaudio_output_data *data;
- data = (s_rtbuf_portaudio_output_data*) rtb->data;
- if (data->reserved.stream) {
- Pa_StopStream(data->reserved.stream);
- Pa_CloseStream(data->reserved.stream);
- data->reserved.stream = 0;
- }
- return 0;
-}
-
-int rtbuf_portaudio_output (s_rtbuf *rtb)
-{
- s_rtbuf_signal_fun in[RTBUF_PORTAUDIO_CHANNELS];
- s_rtbuf_portaudio_output_data *data;
- short *sample;
- unsigned int i = 0;
- unsigned int j = 0;
- PaError err;
- assert(rtb);
- assert(rtb->data);
- assert(rtb->proc);
- while (j < RTBUF_PORTAUDIO_CHANNELS) {
- rtbuf_signal_fun(rtb, j, &in[j]);
- j++;
- }
- data = (s_rtbuf_portaudio_output_data*) rtb->data;
- sample = data->samples;
- /* printf("portaudio_output"); */
- while (i < RTBUF_SIGNAL_SAMPLES) {
- j = 0;
- while (j < RTBUF_PORTAUDIO_CHANNELS) {
- double in_ = in[j].sample_fun(in[j].signal, i);
- in_ = clamp(-1.0, in_, 1.0);
- if (in_ < 0.0)
- in_ *= -SHRT_MIN;
- else
- in_ *= SHRT_MAX;
- *sample = (short) in_;
- sample++;
- j++;
- }
- i++;
- }
- err = Pa_WriteStream(data->reserved.stream, data->samples, RTBUF_SIGNAL_SAMPLES);
- if (err != paNoError) {
- rtbuf_err(Pa_GetErrorText(err));
- rtbuf_err("portaudio output: Pa_WriteStream failed");
- }
- /* printf("\n"); */
- return 0;
-}
diff --git a/rtbuf_portaudio_type.c b/rtbuf_portaudio_type.c
deleted file mode 100644
index 3bef91f..0000000
--- a/rtbuf_portaudio_type.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <stdio.h>
-#include "rtbuf.h"
-#include "rtbuf_portaudio.h"
-
-int main ()
-{
- printf("/* file generated by rtbuf_portaudio_type */\n");
- printf("#ifndef RTBUF_PORTAUDIO_TYPE_H\n"
- "#define RTBUF_PORTAUDIO_TYPE_H\n"
- "\n");
- printf("#define RTBUF_PORTAUDIO_SAMPLES_TYPE RTBUF_PORTAUDIO_SAMPLE_TYPE"
- " \"[%u]\"\n",
- RTBUF_PORTAUDIO_SAMPLES);
- printf("#define RTBUF_PORTAUDIO_OUTPUT_RESERVED_TYPE"
- " \"char[%u]\"\n",
- (unsigned int) RTBUF_PORTAUDIO_OUTPUT_RESERVED_SIZE);
- printf("\n"
- "#endif\n");
- return 0;
-}
diff --git a/rtbuf_proc.c b/rtbuf_proc.c
deleted file mode 100644
index 7a44d07..0000000
--- a/rtbuf_proc.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <strings.h>
-#include "data.h"
-#include "rtbuf.h"
-#include "symbol.h"
-
-s_data_type g_rtbuf_proc_type = {
- sizeof(s_rtbuf_proc) * 8,
- DATA_TYPE_BITS
-};
-s_data_alloc g_rtbuf_proc_alloc;
-s_rtbuf_proc *g_rtbuf_proc;
-
-void rtbuf_proc_init ()
-{
- data_alloc_init(&g_rtbuf_proc_alloc, &g_rtbuf_proc_type,
- RTBUF_PROC_MAX, 0, 0);
- g_rtbuf_proc = g_rtbuf_proc_alloc.mem;
- assert(g_rtbuf_proc);
-}
-
-int rtbuf_proc_p (s_rtbuf_proc *proc)
-{
- return proc && proc->name;
-}
-
-s_rtbuf_proc * rtbuf_proc_new ()
-{
- s_rtbuf_proc *rf = data_new(&g_rtbuf_proc_alloc);
- return rf;
-}
-
-void rtbuf_proc_delete (s_rtbuf_proc *proc)
-{
- assert(proc);
- data_delete(&g_rtbuf_proc_alloc, proc);
-}
-
-s_rtbuf_proc * rtbuf_proc_find (const char *x)
-{
- const char *sym = symbol_find(x);
- if (sym) {
- unsigned int i = 0;
- unsigned int n = g_rtbuf_alloc.n - g_rtbuf_alloc.free_n;
- while (i < g_rtbuf_proc_alloc.n && n > 0) {
- if (rtbuf_proc_p(&g_rtbuf_proc[i])) {
- if (sym == g_rtbuf_proc[i].name)
- return &g_rtbuf_proc[i];
- n--;
- }
- i++;
- }
- }
- return 0;
-}
-
-int rtbuf_proc_out_find (s_rtbuf_proc *proc, const char *x)
-{
- symbol sym;
- if (x && '0' <= x[0] && x[0] <= '9') {
- int i = atoi(x);
- if (0 <= i && (unsigned int) i < proc->out_n)
- return i;
- }
- if ((sym = symbol_find(x))) {
- unsigned int i = 0;
- while (i < proc->out_n) {
- if (sym == proc->out[i].name)
- return i;
- i++;
- }
- }
- return -1;
-}
-
-void rtbuf_proc_print (s_rtbuf_proc *proc)
-{
- unsigned int i = 0;
- printf("#<proc %i %s (", proc->lib_proc, proc->name);
- while (i < proc->in_n) {
- if (i > 0)
- fputs(" ", stdout);
- fputs(proc->in[i].name, stdout);
- fputs(":", stdout);
- fputs(proc->in[i].type->name, stdout);
- i++;
- }
- printf(") -> (");
- i = 0;
- while (i < proc->out_n) {
- if (i > 0)
- fputs(" ", stdout);
- fputs(proc->out[i].name, stdout);
- fputs(":", stdout);
- fputs(proc->out[i].type->name, stdout);
- i++;
- }
- fputs(")>", stdout);
-}
diff --git a/rtbuf_proc.h b/rtbuf_proc.h
deleted file mode 100644
index d39964a..0000000
--- a/rtbuf_proc.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-#ifndef RTBUF_PROC_H
-#define RTBUF_PROC_H
-
-#include "data.h"
-#include "rtbuf_defs.h"
-#include "symbol.h"
-
-struct rtbuf_proc_in {
- symbol name;
- s_rtbuf_type *type;
- double def;
- double min;
- double max;
-};
-
-struct rtbuf_proc_out {
- symbol name;
- s_rtbuf_type *type;
- unsigned int offset;
-};
-
-#define RTBUF_PROC_IN_MAX 1024
-#define RTBUF_PROC_OUT_MAX 1024
-
-struct rtbuf_proc {
- symbol name;
- f_rtbuf_proc *f;
- f_rtbuf_proc *start;
- f_rtbuf_proc *stop;
- s_rtbuf_proc_in in[RTBUF_PROC_IN_MAX]; /* inputs */
- unsigned int in_n; /* number of inputs */
- s_rtbuf_proc_out out[RTBUF_PROC_OUT_MAX]; /* outputs */
- unsigned int out_n; /* number of outputs */
- unsigned int out_bytes; /* size of output data in bytes */
- s_rtbuf_lib *lib; /* the library this procedure comes from */
- unsigned int lib_proc; /* the procedure index in library */
- s_data_type type;
- s_data_alloc alloc;
-};
-
-#define RTBUF_PROC_MAX 1024
-extern s_data_alloc g_rtbuf_proc_alloc;
-extern s_rtbuf_proc *g_rtbuf_proc;
-
-void rtbuf_proc_init ();
-int rtbuf_proc_p (s_rtbuf_proc *proc);
-s_rtbuf_proc * rtbuf_proc_new ();
-void rtbuf_proc_delete (s_rtbuf_proc *proc);
-s_rtbuf_proc * rtbuf_proc_find (const char *x);
-int rtbuf_proc_out_find (s_rtbuf_proc *proc,
- const char *name);
-void rtbuf_proc_print (s_rtbuf_proc *proc);
-
-#endif
diff --git a/rtbuf_reverb.c b/rtbuf_reverb.c
deleted file mode 100644
index d6d41e6..0000000
--- a/rtbuf_reverb.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <math.h>
-#include <stdio.h>
-#include <strings.h>
-#include "rtbuf.h"
-#include "rtbuf_lib.h"
-#include "rtbuf_signal.h"
-#include "rtbuf_signal_type.h"
-#include "rtbuf_reverb.h"
-#include "rtbuf_reverb_type.h"
-
-s_rtbuf_lib_proc_in g_rtbuf_reverb_fdn4_in[] = {
- { "signal", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
- { "time", RTBUF_SIGNAL_TYPE, 1.0, 0.0, 100.0 },
- { "dry_level", RTBUF_SIGNAL_TYPE, 0.8, 0.0, 1.0 },
- { "wet_level", RTBUF_SIGNAL_TYPE, 0.2, 0.0, 1.0 },
- { 0, 0, 0.0, 0.0, 0.0 } };
-
-s_rtbuf_lib_proc_out g_rtbuf_reverb_fdn4_out[] = {
- { "signal", RTBUF_SIGNAL_TYPE },
- { "d0", RTBUF_REVERB_FDN4_DELAY_TYPE },
- { "d1", RTBUF_REVERB_FDN4_DELAY_TYPE },
- { "d2", RTBUF_REVERB_FDN4_DELAY_TYPE },
- { "d3", RTBUF_REVERB_FDN4_DELAY_TYPE },
- { "pos", "unsigned int" },
- { 0, 0 } };
-
-const char *rtbuf_lib_name = "reverb";
-unsigned long rtbuf_lib_ver = RTBUF_LIB_VER;
-s_rtbuf_lib_proc rtbuf_lib_proc[] = {
- { "fdn4", rtbuf_reverb_fdn4, rtbuf_reverb_fdn4_start, 0,
- g_rtbuf_reverb_fdn4_in, g_rtbuf_reverb_fdn4_out },
- { 0, 0, 0, 0, 0, 0 } };
diff --git a/rtbuf_reverb.h b/rtbuf_reverb.h
deleted file mode 100644
index 934fb57..0000000
--- a/rtbuf_reverb.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-#ifndef RTBUF_REVERB_H
-#define RTBUF_REVERB_H
-
-#include <assert.h>
-#include "rtbuf.h"
-#include "rtbuf_signal.h"
-
-/* Feedback delay network with fourth order Hadamard matrix */
-
-#define RTBUF_REVERB_FDN4_DELAY_SAMPLES_MAX \
- RTBUF_SIGNAL_SAMPLERATE
-
-#pragma pack(push,1)
-typedef struct rtbuf_reverb_fdn4_data {
- t_rtbuf_signal signal;
- t_rtbuf_signal_sample d0[RTBUF_REVERB_FDN4_DELAY_SAMPLES_MAX];
- t_rtbuf_signal_sample d1[RTBUF_REVERB_FDN4_DELAY_SAMPLES_MAX];
- t_rtbuf_signal_sample d2[RTBUF_REVERB_FDN4_DELAY_SAMPLES_MAX];
- t_rtbuf_signal_sample d3[RTBUF_REVERB_FDN4_DELAY_SAMPLES_MAX];
- unsigned int pos;
-} s_rtbuf_reverb_fdn4_data;
-#pragma pack(pop)
-
-enum {
- RTBUF_REVERB_FDN4_IN_SIGNAL = 0,
- RTBUF_REVERB_FDN4_IN_TIME,
- RTBUF_REVERB_FDN4_IN_DRY_LEVEL,
- RTBUF_REVERB_FDN4_IN_WET_LEVEL,
- RTBUF_REVERB_FDN4_INS
-};
-
-int rtbuf_reverb_fdn4 (s_rtbuf *rtb);
-int rtbuf_reverb_fdn4_start (s_rtbuf *rtb);
-
-#endif /* RTBUF_REVERB_H */
diff --git a/rtbuf_reverb_fdn4.c b/rtbuf_reverb_fdn4.c
deleted file mode 100644
index 79b786f..0000000
--- a/rtbuf_reverb_fdn4.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <math.h>
-#include <stdio.h>
-#include <strings.h>
-#include "hadamard.h"
-#include "rtbuf.h"
-#include "rtbuf_reverb.h"
-
-int rtbuf_reverb_fdn4_start (s_rtbuf *rtb)
-{
- s_rtbuf_reverb_fdn4_data *data;
- assert(rtb->proc->out_bytes == sizeof(*data));
- data = (s_rtbuf_reverb_fdn4_data*) rtb->data;
- bzero(data, sizeof(*data));
- return 0;
-}
-
-int rtbuf_reverb_fdn4 (s_rtbuf *rtb)
-{
- s_rtbuf_signal_fun signal;
- s_rtbuf_signal_fun time;
- s_rtbuf_signal_fun dry_level;
- s_rtbuf_signal_fun wet_level;
- s_rtbuf_reverb_fdn4_data *data;
- unsigned int i = 0;
- rtbuf_signal_fun(rtb, RTBUF_REVERB_FDN4_IN_SIGNAL, &signal);
- rtbuf_signal_fun(rtb, RTBUF_REVERB_FDN4_IN_TIME, &time);
- rtbuf_signal_fun(rtb, RTBUF_REVERB_FDN4_IN_DRY_LEVEL, &dry_level);
- rtbuf_signal_fun(rtb, RTBUF_REVERB_FDN4_IN_WET_LEVEL, &wet_level);
- data = (s_rtbuf_reverb_fdn4_data*) rtb->data;
- while (i < RTBUF_SIGNAL_SAMPLES) {
- const double x = signal.sample_fun(signal.signal, i);
- const double t = max(0.0, time.sample_fun(time.signal, i));
- const double dl = dry_level.sample_fun(dry_level.signal, i);
- const double wl = wet_level.sample_fun(wet_level.signal, i);
- const double r = 0.0 * t;
- data->signal[i] = dl * x + wl * r;
- i++;
- }
- return 0;
-}
diff --git a/rtbuf_reverb_type.c b/rtbuf_reverb_type.c
deleted file mode 100644
index 56c7122..0000000
--- a/rtbuf_reverb_type.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <stdio.h>
-#include "rtbuf.h"
-#include "rtbuf_reverb.h"
-
-int main ()
-{
- printf("/* file generated by rtbuf_reverb_type */\n");
- printf("#ifndef RTBUF_REVERB_TYPE_H\n"
- "#define RTBUF_REVERB_TYPE_H\n"
- "\n");
- printf("#define RTBUF_REVERB_FDN4_DELAY_TYPE"
- " RTBUF_SIGNAL_SAMPLE_TYPE \"[%u]\"\n",
- RTBUF_REVERB_FDN4_DELAY_SAMPLES_MAX);
- printf("\n"
- "#endif\n");
- return 0;
-}
diff --git a/rtbuf_signal.c b/rtbuf_signal.c
deleted file mode 100644
index cc27b97..0000000
--- a/rtbuf_signal.c
+++ /dev/null
@@ -1,450 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <math.h>
-#include <stdio.h>
-#include <strings.h>
-#include "rtbuf.h"
-#include "rtbuf_lib.h"
-#include "rtbuf_signal.h"
-#include "rtbuf_signal_type.h"
-
-const double g_rtbuf_signal_sample_zero = 0.0;
-const double g_rtbuf_signal_sample_half = 0.5;
-const double g_rtbuf_signal_sample_one = 1.0;
-const double g_rtbuf_signal_default_frequency = 220.0;
-
-s_rtbuf_lib_proc_in g_rtbuf_signal_bandpass2_in[] = {
- { "signal", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
- { "cutoff", RTBUF_SIGNAL_TYPE, 400.0, 0.0, RTBUF_SIGNAL_SAMPLERATE / 2.0 },
- { "qfactor", RTBUF_SIGNAL_TYPE, 1.0, 0.0, 1000.0 },
- { 0, 0, 0.0, 0.0, 0.0 } };
-
-s_rtbuf_lib_proc_out g_rtbuf_signal_bandpass2_out[] = {
- { "signal", RTBUF_SIGNAL_TYPE },
- { "x1", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "x2", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "x3", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "x4", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y1", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y2", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y3", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y4", RTBUF_SIGNAL_SAMPLE_TYPE },
- { 0, 0 } };
-
-s_rtbuf_lib_proc_in g_rtbuf_signal_delay_in[] = {
- { "signal", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
- { "delay", RTBUF_SIGNAL_TYPE, 0.4, 0.0, RTBUF_SIGNAL_DELAY_MAX },
- { "feedback", RTBUF_SIGNAL_TYPE, 0.5, 0.0, 1.0 },
- { 0, 0, 0.0, 0.0, 0.0 } };
-
-s_rtbuf_lib_proc_out g_rtbuf_signal_delay_out[] = {
- { "signal", RTBUF_SIGNAL_TYPE },
- { "in", RTBUF_SIGNAL_DELAY_TYPE },
- { "pos", "unsigned int" },
- { 0, 0 } };
-
-s_rtbuf_lib_proc_in g_rtbuf_signal_equalizer10_in[] = {
- { "signal", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
- { "amp32", RTBUF_SIGNAL_TYPE, 1.0, 0.0, 2.0 },
- { "amp64", RTBUF_SIGNAL_TYPE, 1.0, 0.0, 2.0 },
- { "amp128", RTBUF_SIGNAL_TYPE, 1.0, 0.0, 2.0 },
- { "amp256", RTBUF_SIGNAL_TYPE, 1.0, 0.0, 2.0 },
- { "amp512", RTBUF_SIGNAL_TYPE, 1.0, 0.0, 2.0 },
- { "amp1k", RTBUF_SIGNAL_TYPE, 1.0, 0.0, 2.0 },
- { "amp2k", RTBUF_SIGNAL_TYPE, 1.0, 0.0, 2.0 },
- { "amp4k", RTBUF_SIGNAL_TYPE, 1.0, 0.0, 2.0 },
- { "amp8k", RTBUF_SIGNAL_TYPE, 1.0, 0.0, 2.0 },
- { "amp16k", RTBUF_SIGNAL_TYPE, 1.0, 0.0, 2.0 },
- { 0, 0, 0.0, 0.0, 0.0 } };
-
-s_rtbuf_lib_proc_out g_rtbuf_signal_equalizer10_out[] = {
- { "signal", RTBUF_SIGNAL_TYPE },
- { "signal32", RTBUF_SIGNAL_TYPE },
- { "signal64", RTBUF_SIGNAL_TYPE },
- { "signal128", RTBUF_SIGNAL_TYPE },
- { "signal256", RTBUF_SIGNAL_TYPE },
- { "signal512", RTBUF_SIGNAL_TYPE },
- { "signal1k", RTBUF_SIGNAL_TYPE },
- { "signal2k", RTBUF_SIGNAL_TYPE },
- { "signal4k", RTBUF_SIGNAL_TYPE },
- { "signal8k", RTBUF_SIGNAL_TYPE },
- { "signal16k", RTBUF_SIGNAL_TYPE },
- { "x1", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "x2", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "x3", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "x4", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y0_1", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y0_2", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y0_3", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y0_4", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y1_1", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y1_2", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y1_3", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y1_4", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y2_1", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y2_2", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y2_3", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y2_4", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y3_1", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y3_2", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y3_3", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y3_4", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y4_1", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y4_2", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y4_3", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y4_4", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y5_1", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y5_2", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y5_3", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y5_4", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y6_1", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y6_2", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y6_3", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y6_4", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y7_1", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y7_2", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y7_3", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y7_4", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y8_1", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y8_2", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y8_3", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y8_4", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y9_1", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y9_2", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y9_3", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y9_4", RTBUF_SIGNAL_SAMPLE_TYPE },
- { 0, 0 } };
-
-s_rtbuf_lib_proc_in g_rtbuf_signal_flanger_in[] = {
- { "signal", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
- { "frequency", RTBUF_SIGNAL_TYPE, 0.5, 0.0, RTBUF_SIGNAL_SAMPLERATE / 2.0 },
- { "amplitude", RTBUF_SIGNAL_TYPE, 0.02, 0.0, 1.0 },
- { "delay", RTBUF_SIGNAL_TYPE, 0.0001, 0.0, 1.0 },
- { "feedback", RTBUF_SIGNAL_TYPE, 0.01, 0.0, 1.0 },
- { 0, 0, 0.0, 0.0, 0.0 } };
-
-s_rtbuf_lib_proc_out g_rtbuf_signal_flanger_out[] = {
- { "signal", RTBUF_SIGNAL_TYPE },
- { "phase", "double" },
- { "in", RTBUF_SIGNAL_FLANGER_TYPE },
- { "pos", "unsigned int" },
- { "ds", "unsigned int" },
- { 0, 0 } };
-
-s_rtbuf_lib_proc_in g_rtbuf_signal_hipass_in[] = {
- { "signal", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
- { "cutoff", RTBUF_SIGNAL_TYPE, 8000.0, 0.0, RTBUF_SIGNAL_SAMPLERATE / 2.0 },
- { 0, 0, 0.0, 0.0, 0.0 } };
-
-s_rtbuf_lib_proc_out g_rtbuf_signal_hipass_out[] = {
- { "signal", RTBUF_SIGNAL_TYPE },
- { "x", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y", RTBUF_SIGNAL_SAMPLE_TYPE },
- { 0, 0 } };
-
-s_rtbuf_lib_proc_in g_rtbuf_signal_hipass2_in[] = {
- { "signal", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
- { "cutoff", RTBUF_SIGNAL_TYPE, 8000.0, 0.0, RTBUF_SIGNAL_SAMPLERATE / 2.0 },
- { 0, 0, 0.0, 0.0, 0.0 } };
-
-s_rtbuf_lib_proc_out g_rtbuf_signal_hipass2_out[] = {
- { "signal", RTBUF_SIGNAL_TYPE },
- { "x1", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "x2", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y1", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y2", RTBUF_SIGNAL_SAMPLE_TYPE },
- { 0, 0 } };
-
-s_rtbuf_lib_proc_in g_rtbuf_signal_hipass3_in[] = {
- { "signal", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
- { "cutoff", RTBUF_SIGNAL_TYPE, 8000.0, 0.0, RTBUF_SIGNAL_SAMPLERATE / 2.0 },
- { 0, 0, 0.0, 0.0, 0.0 } };
-
-s_rtbuf_lib_proc_out g_rtbuf_signal_hipass3_out[] = {
- { "signal", RTBUF_SIGNAL_TYPE },
- { "x1", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "x2", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "x3", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y1", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y2", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y3", RTBUF_SIGNAL_SAMPLE_TYPE },
- { 0, 0 } };
-
-s_rtbuf_lib_proc_in g_rtbuf_signal_hipass4_in[] = {
- { "signal", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
- { "cutoff", RTBUF_SIGNAL_TYPE, 8000.0, 0.0, RTBUF_SIGNAL_SAMPLERATE / 2.0 },
- { 0, 0, 0.0, 0.0, 0.0 } };
-
-s_rtbuf_lib_proc_out g_rtbuf_signal_hipass4_out[] = {
- { "signal", RTBUF_SIGNAL_TYPE },
- { "x1", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "x2", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "x3", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "x4", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y1", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y2", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y3", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y4", RTBUF_SIGNAL_SAMPLE_TYPE },
- { 0, 0 } };
-
-s_rtbuf_lib_proc_in g_rtbuf_signal_hipass5_in[] = {
- { "signal", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
- { "cutoff", RTBUF_SIGNAL_TYPE, 400.0, 0.0, RTBUF_SIGNAL_SAMPLERATE / 2.0 },
- { 0, 0, 0.0, 0.0, 0.0 } };
-
-s_rtbuf_lib_proc_out g_rtbuf_signal_hipass5_out[] = {
- { "signal", RTBUF_SIGNAL_TYPE },
- { "x1", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "x2", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "x3", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "x4", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "x5", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y1", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y2", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y3", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y4", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y5", RTBUF_SIGNAL_SAMPLE_TYPE },
- { 0, 0 } };
-
-s_rtbuf_lib_proc_in g_rtbuf_signal_lowpass_in[] = {
- { "signal", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
- { "cutoff", RTBUF_SIGNAL_TYPE, 400.0, 0.0, RTBUF_SIGNAL_SAMPLERATE / 2.0 },
- { 0, 0, 0.0, 0.0, 0.0 } };
-
-s_rtbuf_lib_proc_out g_rtbuf_signal_lowpass_out[] = {
- { "signal", RTBUF_SIGNAL_TYPE },
- { "x", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y", RTBUF_SIGNAL_SAMPLE_TYPE },
- { 0, 0 } };
-
-s_rtbuf_lib_proc_in g_rtbuf_signal_lowpass2_in[] = {
- { "signal", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
- { "cutoff", RTBUF_SIGNAL_TYPE, 400.0, 0.0, RTBUF_SIGNAL_SAMPLERATE / 2.0 },
- { 0, 0, 0.0, 0.0, 0.0 } };
-
-s_rtbuf_lib_proc_out g_rtbuf_signal_lowpass2_out[] = {
- { "signal", RTBUF_SIGNAL_TYPE },
- { "x1", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "x2", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y1", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y2", RTBUF_SIGNAL_SAMPLE_TYPE },
- { 0, 0 } };
-
-s_rtbuf_lib_proc_in g_rtbuf_signal_lowpass3_in[] = {
- { "signal", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
- { "cutoff", RTBUF_SIGNAL_TYPE, 400.0, 0.0, RTBUF_SIGNAL_SAMPLERATE / 2.0 },
- { 0, 0, 0.0, 0.0, 0.0 } };
-
-s_rtbuf_lib_proc_out g_rtbuf_signal_lowpass3_out[] = {
- { "signal", RTBUF_SIGNAL_TYPE },
- { "x1", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "x2", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "x3", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y1", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y2", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y3", RTBUF_SIGNAL_SAMPLE_TYPE },
- { 0, 0 } };
-
-s_rtbuf_lib_proc_in g_rtbuf_signal_lowpass4_in[] = {
- { "signal", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
- { "cutoff", RTBUF_SIGNAL_TYPE, 400.0, 0.0, RTBUF_SIGNAL_SAMPLERATE / 2.0 },
- { 0, 0, 0.0, 0.0, 0.0 } };
-
-s_rtbuf_lib_proc_out g_rtbuf_signal_lowpass4_out[] = {
- { "signal", RTBUF_SIGNAL_TYPE },
- { "x1", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "x2", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "x3", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "x4", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y1", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y2", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y3", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y4", RTBUF_SIGNAL_SAMPLE_TYPE },
- { 0, 0 } };
-
-s_rtbuf_lib_proc_in g_rtbuf_signal_lowpass5_in[] = {
- { "signal", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
- { "cutoff", RTBUF_SIGNAL_TYPE, 400.0, 0.0, RTBUF_SIGNAL_SAMPLERATE / 2.0 },
- { 0, 0, 0.0, 0.0, 0.0 } };
-
-s_rtbuf_lib_proc_out g_rtbuf_signal_lowpass5_out[] = {
- { "signal", RTBUF_SIGNAL_TYPE },
- { "x1", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "x2", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "x3", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "x4", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "x5", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y1", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y2", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y3", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y4", RTBUF_SIGNAL_SAMPLE_TYPE },
- { "y5", RTBUF_SIGNAL_SAMPLE_TYPE },
- { 0, 0 } };
-
-s_rtbuf_lib_proc_in g_rtbuf_signal_sawtooth_in[] = {
- { "frequency", RTBUF_SIGNAL_TYPE, 220.0, 0.0, RTBUF_SIGNAL_SAMPLERATE / 2.0 },
- { "amplitude", RTBUF_SIGNAL_TYPE, 1.0, 0.0, 1.0 },
- { 0, 0, 0.0, 0.0, 0.0 } };
-
-s_rtbuf_lib_proc_out g_rtbuf_signal_sawtooth_out[] = {
- { "signal", RTBUF_SIGNAL_TYPE },
- { "phase", "double" },
- { 0, 0 } };
-
-s_rtbuf_lib_proc_in g_rtbuf_signal_sinus_in[] = {
- { "frequency", RTBUF_SIGNAL_TYPE, 220.0, 0.0, RTBUF_SIGNAL_SAMPLERATE / 2.0 },
- { "amplitude", RTBUF_SIGNAL_TYPE, 1.0, 0.0, 1.0 },
- { 0, 0, 0.0, 0.0, 0.0 } };
-
-s_rtbuf_lib_proc_out g_rtbuf_signal_sinus_out[] = {
- { "signal", RTBUF_SIGNAL_TYPE },
- { "phase", "double" },
- { 0, 0 } };
-
-s_rtbuf_lib_proc_in g_rtbuf_signal_square_in[] = {
- { "frequency", RTBUF_SIGNAL_TYPE, 220.0, 0.0, RTBUF_SIGNAL_SAMPLERATE / 2.0 },
- { "amplitude", RTBUF_SIGNAL_TYPE, 1.0, 0.0, 1.0 },
- { "pulse", RTBUF_SIGNAL_TYPE, 0.5, 0.0, 1.0 },
- { 0, 0, 0.0, 0.0, 0.0 } };
-
-s_rtbuf_lib_proc_out g_rtbuf_signal_square_out[] = {
- { "signal", RTBUF_SIGNAL_TYPE },
- { "phase", "double" },
- { 0, 0 } };
-
-const char *rtbuf_lib_name = "signal";
-unsigned long rtbuf_lib_ver = RTBUF_LIB_VER;
-s_rtbuf_lib_proc rtbuf_lib_proc[] = {
- { "bandpass2", rtbuf_signal_bandpass2, rtbuf_signal_bandpass2_start, 0,
- g_rtbuf_signal_bandpass2_in, g_rtbuf_signal_bandpass2_out },
- { "delay", rtbuf_signal_delay, rtbuf_signal_delay_start, 0,
- g_rtbuf_signal_delay_in, g_rtbuf_signal_delay_out },
- { "equalizer10", rtbuf_signal_equalizer10, rtbuf_signal_equalizer10_start, 0,
- g_rtbuf_signal_equalizer10_in, g_rtbuf_signal_equalizer10_out },
- { "flanger", rtbuf_signal_flanger, rtbuf_signal_flanger_start, 0,
- g_rtbuf_signal_flanger_in, g_rtbuf_signal_flanger_out },
- { "hipass", rtbuf_signal_hipass, rtbuf_signal_hipass_start, 0,
- g_rtbuf_signal_hipass_in, g_rtbuf_signal_hipass_out },
- { "hipass2", rtbuf_signal_hipass2, rtbuf_signal_hipass2_start, 0,
- g_rtbuf_signal_hipass2_in, g_rtbuf_signal_hipass2_out },
- { "hipass3", rtbuf_signal_hipass3, rtbuf_signal_hipass3_start, 0,
- g_rtbuf_signal_hipass3_in, g_rtbuf_signal_hipass3_out },
- { "hipass4", rtbuf_signal_hipass4, rtbuf_signal_hipass4_start, 0,
- g_rtbuf_signal_hipass4_in, g_rtbuf_signal_hipass4_out },
- { "hipass5", rtbuf_signal_hipass5, rtbuf_signal_hipass5_start, 0,
- g_rtbuf_signal_hipass5_in, g_rtbuf_signal_hipass5_out },
- { "lowpass", rtbuf_signal_lowpass, rtbuf_signal_lowpass_start, 0,
- g_rtbuf_signal_lowpass_in, g_rtbuf_signal_lowpass_out },
- { "lowpass2", rtbuf_signal_lowpass2, rtbuf_signal_lowpass2_start, 0,
- g_rtbuf_signal_lowpass2_in, g_rtbuf_signal_lowpass2_out },
- { "lowpass3", rtbuf_signal_lowpass3, rtbuf_signal_lowpass3_start, 0,
- g_rtbuf_signal_lowpass3_in, g_rtbuf_signal_lowpass3_out },
- { "lowpass4", rtbuf_signal_lowpass4, rtbuf_signal_lowpass4_start, 0,
- g_rtbuf_signal_lowpass4_in, g_rtbuf_signal_lowpass4_out },
- { "lowpass5", rtbuf_signal_lowpass5, rtbuf_signal_lowpass5_start, 0,
- g_rtbuf_signal_lowpass5_in, g_rtbuf_signal_lowpass5_out },
- { "sawtooth", rtbuf_signal_sawtooth, rtbuf_signal_sawtooth_start, 0,
- g_rtbuf_signal_sawtooth_in, g_rtbuf_signal_sawtooth_out },
- { "sinus", rtbuf_signal_sinus, rtbuf_signal_sinus_start, 0,
- g_rtbuf_signal_sinus_in, g_rtbuf_signal_sinus_out },
- { "square", rtbuf_signal_square, rtbuf_signal_square_start, 0,
- g_rtbuf_signal_square_in, g_rtbuf_signal_square_out },
- { 0, 0, 0, 0, 0, 0 } };
-
-void rtbuf_signal_zero (t_rtbuf_signal_sample *signal)
-{
- assert(signal);
- bzero(signal, sizeof(t_rtbuf_signal));
-}
-
-t_rtbuf_signal_sample
-rtbuf_signal_sample (s_rtbuf *rtb,
- unsigned int in,
- t_rtbuf_signal_sample default_value)
-{
- s_rtbuf_binding *v;
- assert(rtb);
- assert(rtb->proc);
- assert(in < rtb->proc->in_n);
- v = &rtb->in[in];
- if (v->rtb >= 0) {
- s_rtbuf *src;
- s_rtbuf_proc_out *out;
- assert(v->rtb < RTBUF_MAX);
- src = &g_rtbuf[v->rtb];
- assert(src->data);
- assert(src->proc);
- assert(v->out < src->proc->out_n);
- out = &src->proc->out[v->out];
- assert(out->type);
- if (out->type->t.bits >= sizeof(t_rtbuf_signal_sample) * 8) {
- t_rtbuf_signal_sample *sample = (t_rtbuf_signal_sample*)
- ((char*) src->data + out->offset);
- return *sample;
- }
- }
- return default_value;
-}
-
-double rtbuf_signal_sample_from_sample (const double *signal,
- unsigned int i)
-{
- (void) i;
- assert(signal);
- return *signal;
-}
-
-double rtbuf_signal_sample_from_signal (const double *signal,
- unsigned int i)
-{
- assert(signal);
- assert(i < RTBUF_SIGNAL_SAMPLES);
- return signal[i];
-}
-
-void rtbuf_signal_fun (s_rtbuf *rtb,
- unsigned int in,
- s_rtbuf_signal_fun *rsf)
-{
- s_rtbuf_binding *v;
- const double *default_value;
- assert(rtb);
- assert(rtb->proc);
- assert(in < rtb->proc->in_n);
- assert(rsf);
- default_value = &rtb->proc->in[in].def;
- rsf->signal = default_value;
- rsf->sample_fun = rtbuf_signal_sample_from_sample;
- v = &rtb->in[in];
- if (v->rtb >= 0) {
- s_rtbuf *dest;
- s_rtbuf_proc_out *out;
- assert(v->rtb < RTBUF_MAX);
- dest = &g_rtbuf[v->rtb];
- assert(dest->data);
- assert(dest->proc);
- assert(v->out < dest->proc->out_n);
- out = &dest->proc->out[v->out];
- assert(out->type);
- if (out->type->t.bits >= sizeof(t_rtbuf_signal_sample) * 8)
- rsf->signal = (double*)((char*) dest->data + out->offset);
- if (out->type->t.bits >= sizeof(t_rtbuf_signal) * 8)
- rsf->sample_fun = rtbuf_signal_sample_from_signal;
- }
-}
-
-const double sqrt2_2 = M_SQRT2 * M_SQRT2;
diff --git a/rtbuf_signal.h b/rtbuf_signal.h
deleted file mode 100644
index a0b246c..0000000
--- a/rtbuf_signal.h
+++ /dev/null
@@ -1,466 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-#ifndef RTBUF_SIGNAL_H
-#define RTBUF_SIGNAL_H
-
-#include <assert.h>
-#include "rtbuf.h"
-
-typedef double t_rtbuf_signal_sample;
-#define RTBUF_SIGNAL_SAMPLE_SIZE sizeof(t_rtbuf_signal_sample)
-#define RTBUF_SIGNAL_SAMPLE_TYPE "double"
-
-#define RTBUF_SIGNAL_SAMPLES 1024
-#define RTBUF_SIGNAL_SAMPLERATE 48000
-#define RTBUF_SIGNAL_DT \
- ((double) RTBUF_SIGNAL_SAMPLES / RTBUF_SIGNAL_SAMPLERATE)
-
-typedef t_rtbuf_signal_sample t_rtbuf_signal[RTBUF_SIGNAL_SAMPLES];
-
-#define RTBUF_SIGNAL_SIZE sizeof(t_rtbuf_signal)
-
-typedef t_rtbuf_signal_sample
-f_rtbuf_signal (const t_rtbuf_signal_sample *signal,
- unsigned int sample);
-
-typedef struct rtbuf_signal_fun {
- f_rtbuf_signal *sample_fun;
- const t_rtbuf_signal_sample *signal;
-} s_rtbuf_signal_fun;
-
-void rtbuf_signal_zero (t_rtbuf_signal_sample *signal);
-t_rtbuf_signal_sample
-rtbuf_signal_sample (s_rtbuf *rtb,
- unsigned int in,
- t_rtbuf_signal_sample default_value);
-void rtbuf_signal_fun (s_rtbuf *rtb,
- unsigned int in,
- s_rtbuf_signal_fun *data);
-
-f_rtbuf_signal rtbuf_signal_sample_from_sample;
-f_rtbuf_signal rtbuf_signal_sample_from_signal;
-
-const double g_rtbuf_signal_sample_zero;
-const double g_rtbuf_signal_sample_half;
-const double g_rtbuf_signal_sample_one;
-const double g_rtbuf_signal_sample_2pi;
-const double g_rtbuf_signal_default_frequency;
-
-/* butterworth bandpass filter, second order */
-
-#pragma pack(push,1)
-typedef struct rtbuf_signal_bandpass2_data {
- t_rtbuf_signal signal;
- t_rtbuf_signal_sample x1;
- t_rtbuf_signal_sample x2;
- t_rtbuf_signal_sample x3;
- t_rtbuf_signal_sample x4;
- t_rtbuf_signal_sample y1;
- t_rtbuf_signal_sample y2;
- t_rtbuf_signal_sample y3;
- t_rtbuf_signal_sample y4;
-} s_rtbuf_signal_bandpass2_data;
-#pragma pack(pop)
-
-enum {
- RTBUF_SIGNAL_BANDPASS_IN_SIGNAL = 0,
- RTBUF_SIGNAL_BANDPASS_IN_CUTOFF,
- RTBUF_SIGNAL_BANDPASS_IN_QFACTOR,
- RTBUF_SIGNAL_BANDPASS_INS
-};
-
-int rtbuf_signal_bandpass2 (s_rtbuf *rtb);
-int rtbuf_signal_bandpass2_start (s_rtbuf *rtb);
-
-/* delay */
-
-#define RTBUF_SIGNAL_DELAY_MAX 10
-#define RTBUF_SIGNAL_DELAY_SAMPLES_MAX (RTBUF_SIGNAL_DELAY_MAX * \
- RTBUF_SIGNAL_SAMPLERATE)
-
-#pragma pack(push,1)
-typedef struct rtbuf_signal_delay_data {
- t_rtbuf_signal signal;
- t_rtbuf_signal_sample in[RTBUF_SIGNAL_DELAY_SAMPLES_MAX];
- unsigned int pos;
-} s_rtbuf_signal_delay_data;
-#pragma pack(pop)
-
-enum {
- RTBUF_SIGNAL_DELAY_IN_SIGNAL = 0,
- RTBUF_SIGNAL_DELAY_IN_DELAY,
- RTBUF_SIGNAL_DELAY_IN_FEEDBACK,
- RTBUF_SIGNAL_DELAY_INS
-};
-
-int rtbuf_signal_delay (s_rtbuf *rtb);
-int rtbuf_signal_delay_start (s_rtbuf *rtb);
-
-/* butterworth second order 10 band equalizer */
-
-#pragma pack(push,1)
-typedef struct rtbuf_signal_equalizer10_data {
- t_rtbuf_signal signal;
- t_rtbuf_signal signal32;
- t_rtbuf_signal signal64;
- t_rtbuf_signal signal128;
- t_rtbuf_signal signal256;
- t_rtbuf_signal signal512;
- t_rtbuf_signal signal1k;
- t_rtbuf_signal signal2k;
- t_rtbuf_signal signal4k;
- t_rtbuf_signal signal8k;
- t_rtbuf_signal signal16k;
- t_rtbuf_signal_sample x1;
- t_rtbuf_signal_sample x2;
- t_rtbuf_signal_sample x3;
- t_rtbuf_signal_sample x4;
- t_rtbuf_signal_sample y0_1;
- t_rtbuf_signal_sample y0_2;
- t_rtbuf_signal_sample y0_3;
- t_rtbuf_signal_sample y0_4;
- t_rtbuf_signal_sample y1_1;
- t_rtbuf_signal_sample y1_2;
- t_rtbuf_signal_sample y1_3;
- t_rtbuf_signal_sample y1_4;
- t_rtbuf_signal_sample y2_1;
- t_rtbuf_signal_sample y2_2;
- t_rtbuf_signal_sample y2_3;
- t_rtbuf_signal_sample y2_4;
- t_rtbuf_signal_sample y3_1;
- t_rtbuf_signal_sample y3_2;
- t_rtbuf_signal_sample y3_3;
- t_rtbuf_signal_sample y3_4;
- t_rtbuf_signal_sample y4_1;
- t_rtbuf_signal_sample y4_2;
- t_rtbuf_signal_sample y4_3;
- t_rtbuf_signal_sample y4_4;
- t_rtbuf_signal_sample y5_1;
- t_rtbuf_signal_sample y5_2;
- t_rtbuf_signal_sample y5_3;
- t_rtbuf_signal_sample y5_4;
- t_rtbuf_signal_sample y6_1;
- t_rtbuf_signal_sample y6_2;
- t_rtbuf_signal_sample y6_3;
- t_rtbuf_signal_sample y6_4;
- t_rtbuf_signal_sample y7_1;
- t_rtbuf_signal_sample y7_2;
- t_rtbuf_signal_sample y7_3;
- t_rtbuf_signal_sample y7_4;
- t_rtbuf_signal_sample y8_1;
- t_rtbuf_signal_sample y8_2;
- t_rtbuf_signal_sample y8_3;
- t_rtbuf_signal_sample y8_4;
- t_rtbuf_signal_sample y9_1;
- t_rtbuf_signal_sample y9_2;
- t_rtbuf_signal_sample y9_3;
- t_rtbuf_signal_sample y9_4;
-} s_rtbuf_signal_equalizer10_data;
-#pragma pack(pop)
-
-enum {
- RTBUF_SIGNAL_EQUALIZER10_IN_SIGNAL = 0,
- RTBUF_SIGNAL_EQUALIZER10_IN_AMP32,
- RTBUF_SIGNAL_EQUALIZER10_IN_AMP64,
- RTBUF_SIGNAL_EQUALIZER10_IN_AMP128,
- RTBUF_SIGNAL_EQUALIZER10_IN_AMP256,
- RTBUF_SIGNAL_EQUALIZER10_IN_AMP512,
- RTBUF_SIGNAL_EQUALIZER10_IN_AMP1K,
- RTBUF_SIGNAL_EQUALIZER10_IN_AMP2K,
- RTBUF_SIGNAL_EQUALIZER10_IN_AMP4K,
- RTBUF_SIGNAL_EQUALIZER10_IN_AMP8K,
- RTBUF_SIGNAL_EQUALIZER10_IN_AMP16K,
- RTBUF_SIGNAL_EQUALIZER10_INS
-};
-
-int rtbuf_signal_equalizer10 (s_rtbuf *rtb);
-int rtbuf_signal_equalizer10_start (s_rtbuf *rtb);
-
-/* flanger */
-
-#define RTBUF_SIGNAL_FLANGER_MAX 1
-#define RTBUF_SIGNAL_FLANGER_SAMPLES_MAX (RTBUF_SIGNAL_FLANGER_MAX * \
- RTBUF_SIGNAL_SAMPLERATE)
-
-#pragma pack(push,1)
-typedef struct rtbuf_signal_flanger_data {
- t_rtbuf_signal signal;
- double phase;
- t_rtbuf_signal_sample in[RTBUF_SIGNAL_FLANGER_SAMPLES_MAX];
- unsigned int pos;
- unsigned int ds;
-} s_rtbuf_signal_flanger_data;
-#pragma pack(pop)
-
-enum {
- RTBUF_SIGNAL_FLANGER_IN_SIGNAL = 0,
- RTBUF_SIGNAL_FLANGER_IN_FREQUENCY,
- RTBUF_SIGNAL_FLANGER_IN_AMPLITUDE,
- RTBUF_SIGNAL_FLANGER_IN_DELAY,
- RTBUF_SIGNAL_FLANGER_IN_FEEDBACK,
- RTBUF_SIGNAL_FLANGER_IN_N
-};
-
-int rtbuf_signal_flanger (s_rtbuf *rtb);
-int rtbuf_signal_flanger_start (s_rtbuf *rtb);
-
-/* butterworth hipass filter, first order */
-
-#pragma pack(push,1)
-typedef struct rtbuf_signal_hipass_data {
- t_rtbuf_signal signal;
- t_rtbuf_signal_sample x1;
- t_rtbuf_signal_sample y1;
-} s_rtbuf_signal_hipass_data;
-#pragma pack(pop)
-
-enum {
- RTBUF_SIGNAL_HIPASS_IN_SIGNAL = 0,
- RTBUF_SIGNAL_HIPASS_IN_CUTOFF,
- RTBUF_SIGNAL_HIPASS_INS
-};
-
-int rtbuf_signal_hipass (s_rtbuf *rtb);
-int rtbuf_signal_hipass_start (s_rtbuf *rtb);
-
-/* butterworth hipass filter, second order */
-
-#pragma pack(push,1)
-typedef struct rtbuf_signal_hipass2_data {
- t_rtbuf_signal signal;
- t_rtbuf_signal_sample x1;
- t_rtbuf_signal_sample x2;
- t_rtbuf_signal_sample y1;
- t_rtbuf_signal_sample y2;
-} s_rtbuf_signal_hipass2_data;
-#pragma pack(pop)
-
-int rtbuf_signal_hipass2 (s_rtbuf *rtb);
-int rtbuf_signal_hipass2_start (s_rtbuf *rtb);
-
-/* butterworth hipass filter, third order */
-
-#pragma pack(push,1)
-typedef struct rtbuf_signal_hipass3_data {
- t_rtbuf_signal signal;
- t_rtbuf_signal_sample x1;
- t_rtbuf_signal_sample x2;
- t_rtbuf_signal_sample x3;
- t_rtbuf_signal_sample y1;
- t_rtbuf_signal_sample y2;
- t_rtbuf_signal_sample y3;
-} s_rtbuf_signal_hipass3_data;
-#pragma pack(pop)
-
-int rtbuf_signal_hipass3 (s_rtbuf *rtb);
-int rtbuf_signal_hipass3_start (s_rtbuf *rtb);
-
-/* butterworth hipass filter, fourth order */
-
-#pragma pack(push,1)
-typedef struct rtbuf_signal_hipass4_data {
- t_rtbuf_signal signal;
- t_rtbuf_signal_sample x1;
- t_rtbuf_signal_sample x2;
- t_rtbuf_signal_sample x3;
- t_rtbuf_signal_sample x4;
- t_rtbuf_signal_sample y1;
- t_rtbuf_signal_sample y2;
- t_rtbuf_signal_sample y3;
- t_rtbuf_signal_sample y4;
-} s_rtbuf_signal_hipass4_data;
-#pragma pack(pop)
-
-int rtbuf_signal_hipass4 (s_rtbuf *rtb);
-int rtbuf_signal_hipass4_start (s_rtbuf *rtb);
-
-/* butterworth hipass filter, fifth order */
-
-#pragma pack(push,1)
-typedef struct rtbuf_signal_hipass5_data {
- t_rtbuf_signal signal;
- t_rtbuf_signal_sample x1;
- t_rtbuf_signal_sample x2;
- t_rtbuf_signal_sample x3;
- t_rtbuf_signal_sample x4;
- t_rtbuf_signal_sample x5;
- t_rtbuf_signal_sample y1;
- t_rtbuf_signal_sample y2;
- t_rtbuf_signal_sample y3;
- t_rtbuf_signal_sample y4;
- t_rtbuf_signal_sample y5;
-} s_rtbuf_signal_hipass5_data;
-#pragma pack(pop)
-
-int rtbuf_signal_hipass5 (s_rtbuf *rtb);
-int rtbuf_signal_hipass5_start (s_rtbuf *rtb);
-
-/* butterworth lowpass filter, first order */
-
-#pragma pack(push,1)
-typedef struct rtbuf_signal_lowpass_data {
- t_rtbuf_signal signal;
- t_rtbuf_signal_sample x1;
- t_rtbuf_signal_sample y1;
-} s_rtbuf_signal_lowpass_data;
-#pragma pack(pop)
-
-enum {
- RTBUF_SIGNAL_LOWPASS_IN_SIGNAL = 0,
- RTBUF_SIGNAL_LOWPASS_IN_CUTOFF,
- RTBUF_SIGNAL_LOWPASS_INS
-};
-
-int rtbuf_signal_lowpass (s_rtbuf *rtb);
-int rtbuf_signal_lowpass_start (s_rtbuf *rtb);
-
-/* butterworth lowpass filter, second order */
-
-#pragma pack(push,1)
-typedef struct rtbuf_signal_lowpass2_data {
- t_rtbuf_signal signal;
- t_rtbuf_signal_sample x1;
- t_rtbuf_signal_sample x2;
- t_rtbuf_signal_sample y1;
- t_rtbuf_signal_sample y2;
-} s_rtbuf_signal_lowpass2_data;
-#pragma pack(pop)
-
-int rtbuf_signal_lowpass2 (s_rtbuf *rtb);
-int rtbuf_signal_lowpass2_start (s_rtbuf *rtb);
-
-/* butterworth lowpass filter, third order */
-
-#pragma pack(push,1)
-typedef struct rtbuf_signal_lowpass3_data {
- t_rtbuf_signal signal;
- t_rtbuf_signal_sample x1;
- t_rtbuf_signal_sample x2;
- t_rtbuf_signal_sample x3;
- t_rtbuf_signal_sample y1;
- t_rtbuf_signal_sample y2;
- t_rtbuf_signal_sample y3;
-} s_rtbuf_signal_lowpass3_data;
-#pragma pack(pop)
-
-int rtbuf_signal_lowpass3 (s_rtbuf *rtb);
-int rtbuf_signal_lowpass3_start (s_rtbuf *rtb);
-
-/* butterworth lowpass filter, fourth order */
-
-#pragma pack(push,1)
-typedef struct rtbuf_signal_lowpass4_data {
- t_rtbuf_signal signal;
- t_rtbuf_signal_sample x1;
- t_rtbuf_signal_sample x2;
- t_rtbuf_signal_sample x3;
- t_rtbuf_signal_sample x4;
- t_rtbuf_signal_sample y1;
- t_rtbuf_signal_sample y2;
- t_rtbuf_signal_sample y3;
- t_rtbuf_signal_sample y4;
-} s_rtbuf_signal_lowpass4_data;
-#pragma pack(pop)
-
-int rtbuf_signal_lowpass4 (s_rtbuf *rtb);
-int rtbuf_signal_lowpass4_start (s_rtbuf *rtb);
-
-/* butterworth lowpass filter, fifth order */
-
-#pragma pack(push,1)
-typedef struct rtbuf_signal_lowpass5_data {
- t_rtbuf_signal signal;
- t_rtbuf_signal_sample x1;
- t_rtbuf_signal_sample x2;
- t_rtbuf_signal_sample x3;
- t_rtbuf_signal_sample x4;
- t_rtbuf_signal_sample x5;
- t_rtbuf_signal_sample y1;
- t_rtbuf_signal_sample y2;
- t_rtbuf_signal_sample y3;
- t_rtbuf_signal_sample y4;
- t_rtbuf_signal_sample y5;
-} s_rtbuf_signal_lowpass5_data;
-#pragma pack(pop)
-
-int rtbuf_signal_lowpass5 (s_rtbuf *rtb);
-int rtbuf_signal_lowpass5_start (s_rtbuf *rtb);
-
-/* sawtooth */
-
-#pragma pack(push,1)
-typedef struct rtbuf_signal_sawtooth_data {
- t_rtbuf_signal signal;
- double phase;
-} s_rtbuf_signal_sawtooth_data;
-#pragma pack(pop)
-
-enum {
- RTBUF_SIGNAL_SAWTOOTH_IN_FREQUENCY = 0,
- RTBUF_SIGNAL_SAWTOOTH_IN_AMPLITUDE,
- RTBUF_SIGNAL_SAWTOOTH_IN_N
-};
-
-int rtbuf_signal_sawtooth (s_rtbuf *rtb);
-int rtbuf_signal_sawtooth_start (s_rtbuf *rtb);
-
-/* sinus */
-
-#pragma pack(push,1)
-typedef struct rtbuf_signal_sinus_data {
- t_rtbuf_signal signal;
- double phase;
-} s_rtbuf_signal_sinus_data;
-#pragma pack(pop)
-
-enum {
- RTBUF_SIGNAL_SINUS_IN_FREQUENCY = 0,
- RTBUF_SIGNAL_SINUS_IN_AMPLITUDE,
- RTBUF_SIGNAL_SINUS_IN_N
-};
-
-int rtbuf_signal_sinus (s_rtbuf *rtb);
-int rtbuf_signal_sinus_start (s_rtbuf *rtb);
-
-/* square */
-
-enum {
- RTBUF_SIGNAL_SQUARE_IN_FREQUENCY = 0,
- RTBUF_SIGNAL_SQUARE_IN_AMPLITUDE,
- RTBUF_SIGNAL_SQUARE_IN_PULSE,
- RTBUF_SIGNAL_SQUARE_IN_N
-};
-
-#pragma pack(push,1)
-typedef struct rtbuf_signal_square_data {
- t_rtbuf_signal signal;
- double phase;
-} s_rtbuf_signal_square_data;
-#pragma pack(pop)
-
-int rtbuf_signal_square (s_rtbuf *rtb);
-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 */
diff --git a/rtbuf_signal_bandpass2.c b/rtbuf_signal_bandpass2.c
deleted file mode 100644
index 911d32c..0000000
--- a/rtbuf_signal_bandpass2.c
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-/* Butterworth bandpass second order filter
-s: 2*f*(1-z)/(1+z) $
-B2: (q*(s/w+w/s))^2+sqrt(2)*(q*(s/w+w/s))+1 $
-H: 1/B2 $
-ratsimp(H);
- 2 2 4 2 2 2 2 2
-(%o25) (4 f w z - 8 f w z + 4 f w )
- 2 4 3/2 3 2 2 2 2 7/2 3 4 2 4
-/((q w - 2 f q w + (8 f q + 4 f ) w - 2 f q w + 16 f q ) z
- 2 4 5/2 3 9/2 3 4 2 3
- + (4 q w - 2 f q w + 2 f q w - 64 f q ) z
- 2 4 2 2 2 2 4 2 2
- + (6 q w + ((- 16 f q ) - 8 f ) w + 96 f q ) z
- 2 4 5/2 3 9/2 3 4 2 2 4 3/2 3
- + (4 q w + 2 f q w - 2 f q w - 64 f q ) z + q w + 2 f q w
- 2 2 2 2 7/2 3 4 2
- + (8 f q + 4 f ) w + 2 f q w + 16 f q )
-
-a: q2 w4 + sqrt(2)^3 f q w3 + (8 f2 q2 + 4 f2) w2 + sqrt(2)^7 f3 q w + 16 f4 q2;
-b: 4 q2 w4 + sqrt(2)^5 f q w3 - sqrt(2)^9 f3 q w - 64 f4 q2;
-c: 6 q2 w4 - 2 (8 f2 q2 + 4 f2) w2 + 96 f4 q2;
-d: 4 q2 w4 - sqrt(2)^5 f q w3 + sqrt(2)^9 f3 q w - 64 f4 q2;
-e: q2 w4 - sqrt(2)^3 f q w3 + (8 f2 q2 + 4 f2) w2 - sqrt(2)^7 f3 q w + 16 f4 q2;
------------------------------------------------------------------------------------
-a: q2 w4 + sqrt(2)^3 f q w3 + (2 q2 + 1) 4 f2 w2 + sqrt(2)^7 f3 q w + 16 f4 q2;
-b: 4 q2 w4 + sqrt(2)^5 f q w3 - sqrt(2)^9 f3 q w - 64 f4 q2;
-c: 6 q2 w4 - 2 (2 q2 + 1) 4 f2 w2 + 96 f4 q2;
-d: 4 q2 w4 - sqrt(2)^5 f q w3 + sqrt(2)^9 f3 q w - 64 f4 q2;
-e: q2 w4 - sqrt(2)^3 f q w3 + (2 q2 + 1) 4 f2 w2 - sqrt(2)^7 f3 q w + 16 f4 q2;
------------------------------------------------------------------------------------
-y: (4 f2 w2 (x4 - 2 x2 + x) - (b y1 + c y2 + d y3 + e y4)) / a;
-*/
-#include <math.h>
-#include "rtbuf.h"
-#include "rtbuf_signal.h"
-
-int rtbuf_signal_bandpass2_start (s_rtbuf *rtb)
-{
- s_rtbuf_signal_bandpass2_data *data;
- assert(rtb->proc->out_bytes == sizeof(*data));
- data = (s_rtbuf_signal_bandpass2_data*) rtb->data;
- data->x1 = 0.0;
- data->x2 = 0.0;
- data->x3 = 0.0;
- data->x4 = 0.0;
- data->y1 = 0.0;
- data->y2 = 0.0;
- data->y3 = 0.0;
- data->y4 = 0.0;
- return 0;
-}
-
-int rtbuf_signal_bandpass2 (s_rtbuf *rtb)
-{
- s_rtbuf_signal_fun in;
- s_rtbuf_signal_fun cutoff;
- s_rtbuf_signal_fun qfactor;
- s_rtbuf_signal_bandpass2_data *data;
- unsigned int i = 0;
- const double sqrt2_3 = sqrt2_2 * M_SQRT2;
- const double sqrt2_5 = sqrt2_3 * sqrt2_2;
- const double sqrt2_7 = sqrt2_5 * sqrt2_2;
- const double sqrt2_9 = sqrt2_7 * sqrt2_2;
- const double f = RTBUF_SIGNAL_SAMPLERATE;
- const double f2 = f * f;
- const double f3 = f2 * f;
- const double f4 = f2 * f2;
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_BANDPASS_IN_SIGNAL, &in);
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_BANDPASS_IN_CUTOFF, &cutoff);
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_BANDPASS_IN_QFACTOR, &qfactor);
- data = (s_rtbuf_signal_bandpass2_data*) rtb->data;
- while (i < RTBUF_SIGNAL_SAMPLES) {
- const double x = in.sample_fun(in.signal, i);
- const double fc = cutoff.sample_fun(cutoff.signal, i);
- const double q = qfactor.sample_fun(qfactor.signal, i);
- const double q2 = q * q;
- const double f4q2 = f4 * q2;
- const double _16f4q2 = 16.0 * f4q2;
- const double _64f4q2 = 64.0 * f4q2;
- const double w = 2.0 * M_PI * fc;
- const double f3qw = f3 * q * w;
- const double sqrt2_7f3qw = sqrt2_7 * f3qw;
- const double sqrt2_9f3qw = sqrt2_9 * f3qw;
- const double w2 = w * w;
- const double _4f2w2 = 4.0 * f2 * w2;
- const double _2q2_1_4f2w2 = (2.0 * q2 + 1.0) * _4f2w2;
- const double w3 = w2 * w;
- const double fqw3 = f * q * w3;
- const double sqrt2_3fqw3 = sqrt2_3 * fqw3;
- const double sqrt2_5fqw3 = sqrt2_5 * fqw3;
- const double w4 = w2 * w2;
- const double q2w4 = q2 * w4;
- const double _4q2w4 = 4.0 * q2w4;
- const double a = q2w4 + sqrt2_3fqw3 + _2q2_1_4f2w2 + sqrt2_7f3qw + _16f4q2;
- const double b = _4q2w4 + sqrt2_5fqw3 - sqrt2_9f3qw - _64f4q2;
- const double c = 6.0 * q2w4 - 2.0 * _2q2_1_4f2w2 + 96.0 * f4q2;
- const double d = _4q2w4 - sqrt2_5fqw3 + sqrt2_9f3qw - _64f4q2;
- const double e = q2w4 - sqrt2_3fqw3 + _2q2_1_4f2w2 - sqrt2_7f3qw + _16f4q2;
- data->signal[i] = (_4f2w2 * (x
- - 2.0 * data->x2
- + data->x4)
- - (b * data->y1
- + c * data->y2
- + d * data->y3
- + e * data->y4)) / a;
- data->x4 = data->x3;
- data->x3 = data->x2;
- data->x2 = data->x1;
- data->x1 = x;
- data->y4 = data->y3;
- data->y3 = data->y2;
- data->y2 = data->y1;
- data->y1 = data->signal[i];
- i++;
- }
- return 0;
-}
diff --git a/rtbuf_signal_delay.c b/rtbuf_signal_delay.c
deleted file mode 100644
index d5b7191..0000000
--- a/rtbuf_signal_delay.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <stdio.h>
-#include <strings.h>
-#include "rtbuf.h"
-#include "rtbuf_signal.h"
-
-int rtbuf_signal_delay_start (s_rtbuf *rtb)
-{
- s_rtbuf_signal_delay_data *data;
- assert(rtb->proc->out_bytes == sizeof(*data));
- data = (s_rtbuf_signal_delay_data*) rtb->data;
- bzero(data->in, sizeof(data->in));
- data->pos = 0;
- return 0;
-}
-
-int rtbuf_signal_delay (s_rtbuf *rtb)
-{
- s_rtbuf_signal_fun in;
- s_rtbuf_signal_fun delay;
- s_rtbuf_signal_fun feedback;
- s_rtbuf_signal_delay_data *data;
- unsigned int i = 0;
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_DELAY_IN_SIGNAL, &in);
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_DELAY_IN_DELAY, &delay);
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_DELAY_IN_DELAY, &feedback);
- data = (s_rtbuf_signal_delay_data*) rtb->data;
- while (i < RTBUF_SIGNAL_SAMPLES) {
- double s = in.sample_fun(in.signal, i);
- double d = min(max(0.0, delay.sample_fun(delay.signal, i)),
- RTBUF_SIGNAL_DELAY_MAX);
- double fb = min(max(0.0, feedback.sample_fun(feedback.signal, i)), 1.0);
- unsigned int ds = d * RTBUF_SIGNAL_SAMPLERATE;
- unsigned int p = (data->pos + RTBUF_SIGNAL_DELAY_SAMPLES_MAX - ds) %
- RTBUF_SIGNAL_DELAY_SAMPLES_MAX;
- data->signal[i] = data->in[p];
- data->in[data->pos] = (1.0 - fb) * s + fb * data->in[p];
- data->pos = (data->pos + 1) % RTBUF_SIGNAL_DELAY_SAMPLES_MAX;
- i++;
- }
- return 0;
-}
diff --git a/rtbuf_signal_equalizer10.c b/rtbuf_signal_equalizer10.c
deleted file mode 100644
index a1e1f84..0000000
--- a/rtbuf_signal_equalizer10.c
+++ /dev/null
@@ -1,303 +0,0 @@
-/*
- * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-/* Butterworth bandpass second order filter
-s: 2*f*(1-z)/(1+z) $
-B2: (q*(s/w+w/s))^2+sqrt(2)*(q*(s/w+w/s))+1 $
-H: 1/B2 $
-ratsimp(H);
- 2 2 4 2 2 2 2 2
-(%o25) (4 f w z - 8 f w z + 4 f w )
- 2 4 3/2 3 2 2 2 2 7/2 3 4 2 4
-/((q w - 2 f q w + (8 f q + 4 f ) w - 2 f q w + 16 f q ) z
- 2 4 5/2 3 9/2 3 4 2 3
- + (4 q w - 2 f q w + 2 f q w - 64 f q ) z
- 2 4 2 2 2 2 4 2 2
- + (6 q w + ((- 16 f q ) - 8 f ) w + 96 f q ) z
- 2 4 5/2 3 9/2 3 4 2 2 4 3/2 3
- + (4 q w + 2 f q w - 2 f q w - 64 f q ) z + q w + 2 f q w
- 2 2 2 2 7/2 3 4 2
- + (8 f q + 4 f ) w + 2 f q w + 16 f q )
-
-a: q2 w4 + sqrt(2)^3 f q w3 + (8 f2 q2 + 4 f2) w2 + sqrt(2)^7 f3 q w + 16 f4 q2;
-b: 4 q2 w4 + sqrt(2)^5 f q w3 - sqrt(2)^9 f3 q w - 64 f4 q2;
-c: 6 q2 w4 - 2 (8 f2 q2 + 4 f2) w2 + 96 f4 q2;
-d: 4 q2 w4 - sqrt(2)^5 f q w3 + sqrt(2)^9 f3 q w - 64 f4 q2;
-e: q2 w4 - sqrt(2)^3 f q w3 + (8 f2 q2 + 4 f2) w2 - sqrt(2)^7 f3 q w + 16 f4 q2;
------------------------------------------------------------------------------------
-a: q2 w4 + sqrt(2)^3 f q w3 + (2 q2 + 1) 4 f2 w2 + sqrt(2)^7 f3 q w + 16 f4 q2;
-b: 4 q2 w4 + sqrt(2)^5 f q w3 - sqrt(2)^9 f3 q w - 64 f4 q2;
-c: 6 q2 w4 - 2 (2 q2 + 1) 4 f2 w2 + 96 f4 q2;
-d: 4 q2 w4 - sqrt(2)^5 f q w3 + sqrt(2)^9 f3 q w - 64 f4 q2;
-e: q2 w4 - sqrt(2)^3 f q w3 + (2 q2 + 1) 4 f2 w2 - sqrt(2)^7 f3 q w + 16 f4 q2;
------------------------------------------------------------------------------------
-y: (4 f2 w2 (x4 - 2 x2 + x) - (b y1 + c y2 + d y3 + e y4)) / a;
-
-12db/octave
-fc: -3db
-3/12 = 1/4 octave = 3/4 et 5/4
-q: 2
-*/
-#include <math.h>
-#include "rtbuf.h"
-#include "rtbuf_signal.h"
-
-double sqrt2_3 = 0.0;
-double sqrt2_5;
-double sqrt2_7;
-double sqrt2_9;
-double f;
-double f2;
-double f3;
-double f4;
-
-int rtbuf_signal_equalizer10_start (s_rtbuf *rtb)
-{
- s_rtbuf_signal_equalizer10_data *data;
- assert(rtb->proc->out_bytes == sizeof(*data));
- data = (s_rtbuf_signal_equalizer10_data*) rtb->data;
- data->x1 = 0.0;
- data->x2 = 0.0;
- data->x3 = 0.0;
- data->x4 = 0.0;
- data->y0_1 = 0.0;
- data->y0_2 = 0.0;
- data->y0_3 = 0.0;
- data->y0_4 = 0.0;
- data->y1_1 = 0.0;
- data->y1_2 = 0.0;
- data->y1_3 = 0.0;
- data->y1_4 = 0.0;
- data->y2_1 = 0.0;
- data->y2_2 = 0.0;
- data->y2_3 = 0.0;
- data->y2_4 = 0.0;
- data->y3_1 = 0.0;
- data->y3_2 = 0.0;
- data->y3_3 = 0.0;
- data->y3_4 = 0.0;
- data->y4_1 = 0.0;
- data->y4_2 = 0.0;
- data->y4_3 = 0.0;
- data->y4_4 = 0.0;
- data->y5_1 = 0.0;
- data->y5_2 = 0.0;
- data->y5_3 = 0.0;
- data->y5_4 = 0.0;
- data->y6_1 = 0.0;
- data->y6_2 = 0.0;
- data->y6_3 = 0.0;
- data->y6_4 = 0.0;
- data->y7_1 = 0.0;
- data->y7_2 = 0.0;
- data->y7_3 = 0.0;
- data->y7_4 = 0.0;
- data->y8_1 = 0.0;
- data->y8_2 = 0.0;
- data->y8_3 = 0.0;
- data->y8_4 = 0.0;
- data->y9_1 = 0.0;
- data->y9_2 = 0.0;
- data->y9_3 = 0.0;
- data->y9_4 = 0.0;
- sqrt2_3 = sqrt2_2 * M_SQRT2;
- sqrt2_5 = sqrt2_3 * sqrt2_2;
- sqrt2_7 = sqrt2_5 * sqrt2_2;
- sqrt2_9 = sqrt2_7 * sqrt2_2;
- f = RTBUF_SIGNAL_SAMPLERATE;
- f2 = f * f;
- f3 = f2 * f;
- f4 = f2 * f2;
- return 0;
-}
-
-double butterworth_bandpass2 (const double x, const double fc,
- const double q, const double x2,
- const double x4, const double y1,
- const double y2, const double y3,
- const double y4)
-{
- const double q2 = q * q;
- const double f4q2 = f4 * q2;
- const double _16f4q2 = 16.0 * f4q2;
- const double _64f4q2 = 64.0 * f4q2;
- const double w = 2.0 * M_PI * fc;
- const double f3qw = f3 * q * w;
- const double sqrt2_7f3qw = sqrt2_7 * f3qw;
- const double sqrt2_9f3qw = sqrt2_9 * f3qw;
- const double w2 = w * w;
- const double _4f2w2 = 4.0 * f2 * w2;
- const double _2q2_1_4f2w2 = (2.0 * q2 + 1.0) * _4f2w2;
- const double w3 = w2 * w;
- const double fqw3 = f * q * w3;
- const double sqrt2_3fqw3 = sqrt2_3 * fqw3;
- const double sqrt2_5fqw3 = sqrt2_5 * fqw3;
- const double w4 = w2 * w2;
- const double q2w4 = q2 * w4;
- const double _4q2w4 = 4.0 * q2w4;
- const double a = q2w4 + sqrt2_3fqw3 + _2q2_1_4f2w2 + sqrt2_7f3qw + _16f4q2;
- const double b = _4q2w4 + sqrt2_5fqw3 - sqrt2_9f3qw - _64f4q2;
- const double c = 6.0 * q2w4 - 2.0 * _2q2_1_4f2w2 + 96.0 * f4q2;
- const double d = _4q2w4 - sqrt2_5fqw3 + sqrt2_9f3qw - _64f4q2;
- const double e = q2w4 - sqrt2_3fqw3 + _2q2_1_4f2w2 - sqrt2_7f3qw + _16f4q2;
- const double y = (_4f2w2 * (x
- - 2.0 * x2
- + x4)
- - (b * y1
- + c * y2
- + d * y3
- + e * y4)) / a;
- return y;
-}
-
-int rtbuf_signal_equalizer10 (s_rtbuf *rtb)
-{
- s_rtbuf_signal_fun in;
- s_rtbuf_signal_fun amp32;
- s_rtbuf_signal_fun amp64;
- s_rtbuf_signal_fun amp128;
- s_rtbuf_signal_fun amp256;
- s_rtbuf_signal_fun amp512;
- s_rtbuf_signal_fun amp1k;
- s_rtbuf_signal_fun amp2k;
- s_rtbuf_signal_fun amp4k;
- s_rtbuf_signal_fun amp8k;
- s_rtbuf_signal_fun amp16k;
- s_rtbuf_signal_equalizer10_data *data;
- unsigned int i = 0;
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_EQUALIZER10_IN_SIGNAL, &in);
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_EQUALIZER10_IN_AMP32, &32);
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_EQUALIZER10_IN_AMP64, &64);
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_EQUALIZER10_IN_AMP128, &128);
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_EQUALIZER10_IN_AMP256, &256);
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_EQUALIZER10_IN_AMP512, &512);
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_EQUALIZER10_IN_AMP1K, &1k);
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_EQUALIZER10_IN_AMP2K, &2k);
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_EQUALIZER10_IN_AMP4K, &4k);
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_EQUALIZER10_IN_AMP8K, &8k);
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_EQUALIZER10_IN_AMP16K, &16k);
- data = (s_rtbuf_signal_equalizer10_data*) rtb->data;
- while (i < RTBUF_SIGNAL_SAMPLES) {
- const double x = in.sample_fun(in.signal, i);
- const double a0 = amp32.sample_fun(amp32.signal, i);
- const double a1 = amp32.sample_fun(amp64.signal, i);
- const double a2 = amp32.sample_fun(amp128.signal, i);
- const double a3 = amp32.sample_fun(amp256.signal, i);
- const double a4 = amp32.sample_fun(amp512.signal, i);
- const double a5 = amp32.sample_fun(amp1k.signal, i);
- const double a6 = amp32.sample_fun(amp2k.signal, i);
- const double a7 = amp32.sample_fun(amp4k.signal, i);
- const double a8 = amp32.sample_fun(amp8k.signal, i);
- const double a9 = amp32.sample_fun(amp16k.signal, i);
- const double y0 = butterworth_bandpass2(x, 32.0, 2.0,
- data->x2, data->x4,
- data->y0_1, data->y0_2,
- data->y0_3, data->y0_4);
- const double y1 = butterworth_bandpass2(x, 64.0, 2.0,
- data->x2, data->x4,
- data->y1_1, data->y1_2,
- data->y1_3, data->y1_4);
- const double y2 = butterworth_bandpass2(x, 128.0, 2.0,
- data->x2, data->x4,
- data->y2_1, data->y2_2,
- data->y2_3, data->y2_4);
- const double y3 = butterworth_bandpass2(x, 256.0, 2.0,
- data->x2, data->x4,
- data->y3_1, data->y3_2,
- data->y3_3, data->y3_4);
- const double y4 = butterworth_bandpass2(x, 512.0, 2.0,
- data->x2, data->x4,
- data->y4_1, data->y4_2,
- data->y4_3, data->y4_4);
- const double y5 = butterworth_bandpass2(x, 1024.0, 2.0,
- data->x2, data->x4,
- data->y5_1, data->y5_2,
- data->y5_3, data->y5_4);
- const double y6 = butterworth_bandpass2(x, 2048.0, 2.0,
- data->x2, data->x4,
- data->y6_1, data->y6_2,
- data->y6_3, data->y6_4);
- const double y7 = butterworth_bandpass2(x, 4096.0, 2.0,
- data->x2, data->x4,
- data->y7_1, data->y7_2,
- data->y7_3, data->y7_4);
- const double y8 = butterworth_bandpass2(x, 8192.0, 2.0,
- data->x2, data->x4,
- data->y8_1, data->y8_2,
- data->y8_3, data->y8_4);
- const double y9 = butterworth_bandpass2(x, 16384.0, 2.0,
- data->x2, data->x4,
- data->y9_1, data->y9_2,
- data->y9_3, data->y9_4);
- data->signal[i] = (a0 * y0 + a1 * y1 + a2 * y2 + a3 * y3 + a4 * y4 +
- a5 * y5 + a6 * y6 + a7 * y7 + a8 * y8 + a9 * y9);
- data->signal32[i] = y0;
- data->signal64[i] = y1;
- data->signal128[i] = y2;
- data->signal256[i] = y3;
- data->signal512[i] = y4;
- data->signal1k[i] = y5;
- data->signal2k[i] = y6;
- data->signal4k[i] = y7;
- data->signal8k[i] = y8;
- data->signal16k[i] = y9;
- data->x4 = data->x3;
- data->x3 = data->x2;
- data->x2 = data->x1;
- data->x1 = x;
- data->y0_4 = data->y0_3;
- data->y0_3 = data->y0_2;
- data->y0_2 = data->y0_1;
- data->y0_1 = y0;
- data->y1_4 = data->y1_3;
- data->y1_3 = data->y1_2;
- data->y1_2 = data->y1_1;
- data->y1_1 = y1;
- data->y2_4 = data->y2_3;
- data->y2_3 = data->y2_2;
- data->y2_2 = data->y2_1;
- data->y2_1 = y2;
- data->y3_4 = data->y3_3;
- data->y3_3 = data->y3_2;
- data->y3_2 = data->y3_1;
- data->y3_1 = y3;
- data->y4_4 = data->y4_3;
- data->y4_3 = data->y4_2;
- data->y4_2 = data->y4_1;
- data->y4_1 = y4;
- data->y5_4 = data->y5_3;
- data->y5_3 = data->y5_2;
- data->y5_2 = data->y5_1;
- data->y5_1 = y5;
- data->y6_4 = data->y6_3;
- data->y6_3 = data->y6_2;
- data->y6_2 = data->y6_1;
- data->y6_1 = y6;
- data->y7_4 = data->y7_3;
- data->y7_3 = data->y7_2;
- data->y7_2 = data->y7_1;
- data->y7_1 = y7;
- data->y8_4 = data->y8_3;
- data->y8_3 = data->y8_2;
- data->y8_2 = data->y8_1;
- data->y8_1 = y8;
- data->y9_4 = data->y9_3;
- data->y9_3 = data->y9_2;
- data->y9_2 = data->y9_1;
- data->y9_1 = y9;
- i++;
- }
- return 0;
-}
diff --git a/rtbuf_signal_flanger.c b/rtbuf_signal_flanger.c
deleted file mode 100644
index d273ccd..0000000
--- a/rtbuf_signal_flanger.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright 2018,2020 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- * Copyright 2018 Judy Najnudel <judy.najnudel@gmail.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <math.h>
-#include <stdio.h>
-#include <string.h>
-#include <strings.h>
-#include "rtbuf.h"
-#include "rtbuf_signal.h"
-
-int rtbuf_signal_flanger_start (s_rtbuf *rtb)
-{
- s_rtbuf_signal_flanger_data *data;
- assert(rtb->proc->out_bytes == sizeof(*data));
- data = (s_rtbuf_signal_flanger_data*) rtb->data;
- data->phase = 0;
- bzero(data->in, sizeof(data->in));
- data->pos = 0;
- data->ds = 0;
- return 0;
-}
-
-int rtbuf_signal_flanger (s_rtbuf *rtb)
-{
- s_rtbuf_signal_fun in;
- s_rtbuf_signal_fun freq;
- s_rtbuf_signal_fun amp;
- s_rtbuf_signal_fun delay;
- s_rtbuf_signal_fun feedback;
- s_rtbuf_signal_flanger_data *data;
- unsigned int i = 0;
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_FLANGER_IN_SIGNAL, &in);
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_FLANGER_IN_FREQUENCY, &freq);
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_FLANGER_IN_AMPLITUDE, &);
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_FLANGER_IN_DELAY, &delay);
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_FLANGER_IN_FEEDBACK, &feedback);
- data = (s_rtbuf_signal_flanger_data*) rtb->data;
- while (i < RTBUF_SIGNAL_SAMPLES) {
- double s = in.sample_fun(in.signal, i);
- double f = freq.sample_fun(freq.signal, i);
- double a = amp.sample_fun(amp.signal, i);
- double d = delay.sample_fun(delay.signal, i);
- double delay;
- double fb = feedback.sample_fun(feedback.signal, i);
- unsigned int ds;
- unsigned int pos;
- f = max(0.0, f);
- f /= (double) RTBUF_SIGNAL_SAMPLERATE;
- data->phase = fmod(data->phase + 2.0 * M_PI * f, 2.0 * M_PI);
- delay = a * (sin(data->phase) * 0.5 + 0.5) + d;
- ds = max(0.0, min(delay * RTBUF_SIGNAL_SAMPLERATE,
- RTBUF_SIGNAL_FLANGER_SAMPLES_MAX));
- pos = (data->pos + RTBUF_SIGNAL_FLANGER_SAMPLES_MAX - ds) %
- RTBUF_SIGNAL_FLANGER_SAMPLES_MAX;
- data->signal[i] = (data->in[pos] + s) / 2.0;
- data->in[data->pos++] = (1.0 - fb) * s + fb * data->in[pos];
- data->pos %= RTBUF_SIGNAL_FLANGER_SAMPLES_MAX;
- i++;
- }
- return 0;
-}
diff --git a/rtbuf_signal_hipass.c b/rtbuf_signal_hipass.c
deleted file mode 100644
index 727e627..0000000
--- a/rtbuf_signal_hipass.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <math.h>
-#include "rtbuf.h"
-#include "rtbuf_signal.h"
-
-int rtbuf_signal_hipass_start (s_rtbuf *rtb)
-{
- s_rtbuf_signal_hipass_data *data;
- assert(rtb->proc->out_bytes == sizeof(*data));
- data = (s_rtbuf_signal_hipass_data*) rtb->data;
- data->x1 = 0;
- data->y1 = 0;
- return 0;
-}
-
-int rtbuf_signal_hipass (s_rtbuf *rtb)
-{
- s_rtbuf_signal_fun in;
- s_rtbuf_signal_fun cutoff;
- s_rtbuf_signal_hipass_data *data;
- unsigned int i = 0;
- double k = 2.0 * RTBUF_SIGNAL_SAMPLERATE;
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_HIPASS_IN_SIGNAL, &in);
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_HIPASS_IN_CUTOFF, &cutoff);
- data = (s_rtbuf_signal_hipass_data*) rtb->data;
- while (i < RTBUF_SIGNAL_SAMPLES) {
- double x = in.sample_fun(in.signal, i);
- double fc = cutoff.sample_fun(cutoff.signal, i);
- double wc = 2.0 * M_PI * fc;
- data->signal[i] = (k * (x - data->x1) + (k - wc) * data->y1) / (k + wc);
- data->x1 = x;
- data->y1 = data->signal[i];
- i++;
- }
- return 0;
-}
diff --git a/rtbuf_signal_hipass2.c b/rtbuf_signal_hipass2.c
deleted file mode 100644
index c11fef4..0000000
--- a/rtbuf_signal_hipass2.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <math.h>
-#include "rtbuf.h"
-#include "rtbuf_signal.h"
-
-int rtbuf_signal_hipass2_start (s_rtbuf *rtb)
-{
- s_rtbuf_signal_hipass2_data *data;
- assert(rtb->proc->out_bytes == sizeof(*data));
- data = (s_rtbuf_signal_hipass2_data*) rtb->data;
- data->x1 = 0;
- data->x2 = 0;
- data->y1 = 0;
- data->y2 = 0;
- return 0;
-}
-
-int rtbuf_signal_hipass2 (s_rtbuf *rtb)
-{
- s_rtbuf_signal_fun in;
- s_rtbuf_signal_fun cutoff;
- s_rtbuf_signal_hipass2_data *data;
- unsigned int i = 0;
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_HIPASS_IN_SIGNAL, &in);
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_HIPASS_IN_CUTOFF, &cutoff);
- data = (s_rtbuf_signal_hipass2_data*) rtb->data;
- while (i < RTBUF_SIGNAL_SAMPLES) {
- double x = in.sample_fun(in.signal, i);
- double fc = cutoff.sample_fun(cutoff.signal, i);
- double wc = 2.0 * M_PI * fc;
- double wc2 = wc * wc;
- double _2fs = 2.0 * RTBUF_SIGNAL_SAMPLERATE;
- double k = M_SQRT2 * _2fs * wc;
- double _4fs2 = _2fs * _2fs;
- data->signal[i] = (_4fs2 * (x
- + data->x1 * -2.0
- + data->x2)
- + data->y1 * (2.0 * _4fs2 - 2.0 * wc2)
- + data->y2 * (k - (_4fs2 + wc2)))
- / (wc2 + k + _4fs2);
- data->x2 = data->x1;
- data->x1 = x;
- data->y2 = data->y1;
- data->y1 = data->signal[i];
- i++;
- }
- return 0;
-}
diff --git a/rtbuf_signal_hipass3.c b/rtbuf_signal_hipass3.c
deleted file mode 100644
index 0ff13a0..0000000
--- a/rtbuf_signal_hipass3.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- * Copyright 2020 Judy Najnudel
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-/*
-
-Polynomial for Butterworth third order high pass filter
-b: (w/s+1)*((w/s)^2+w/s+1) $
-
-Transfer function
-h: 1/b $
-
-Bilinear transform:
-s: 2*F*(1-z)/(1+z) $
-
-ratsimp(h);
--(8 F³ z³ - 24 F³ z² + 24 F³ z - 8 F³)
-/((w³ - 4 F w² + 8 F² w - 8 F³) z³
- + (3 w³ - 4 F w² - 8 F² w + 24 F³) z²
- + (3 w³ + 4 F w² - 8 F² w - 24 F³) z
- + w³ + 4 F w² + 8 F² w + 8 F³)
-
-a: w³ - 4 F w² + 8 F² w - 8 F³
-b: 3 w³ - 4 F w² - 8 F² w + 24 F³
-c: 3 w³ + 4 F w² - 8 F² w - 24 F³
-d: w³ + 4 F w² + 8 F² w + 8 F³
-
-y: (8 F³ ((x - x3) + 3 (x2 - x1)) - (a y3 + b y2 + c y1)) / d
-
-*/
-#include <math.h>
-#include "rtbuf.h"
-#include "rtbuf_signal.h"
-
-int rtbuf_signal_hipass3_start (s_rtbuf *rtb)
-{
- s_rtbuf_signal_hipass3_data *data;
- assert(rtb->proc->out_bytes == sizeof(*data));
- data = (s_rtbuf_signal_hipass3_data*) rtb->data;
- data->x1 = 0.0;
- data->x2 = 0.0;
- data->x3 = 0.0;
- data->y1 = 0.0;
- data->y2 = 0.0;
- data->y3 = 0.0;
- return 0;
-}
-
-int rtbuf_signal_hipass3 (s_rtbuf *rtb)
-{
- s_rtbuf_signal_fun in;
- s_rtbuf_signal_fun cutoff;
- s_rtbuf_signal_hipass3_data *data;
- unsigned int i = 0;
- const double fs = RTBUF_SIGNAL_SAMPLERATE;
- const double fs2 = fs * fs;
- const double fs3 = fs2 * fs;
- const double _8fs3 = 8.0 * fs3;
- const double _24fs3 = 24.0 * fs3;
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_HIPASS_IN_SIGNAL, &in);
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_HIPASS_IN_CUTOFF, &cutoff);
- data = (s_rtbuf_signal_hipass3_data*) rtb->data;
- while (i < RTBUF_SIGNAL_SAMPLES) {
- const double x = in.sample_fun(in.signal, i);
- const double fc = cutoff.sample_fun(cutoff.signal, i);
- const double wc = 2.0 * M_PI * fc;
- const double wc2 = wc * wc;
- const double wc3 = wc2 * wc;
- const double _8fs2wc = 8.0 * fs2 * wc;
- const double _4fswc2 = 4.0 * fs * wc2;
- const double _3wc3 = 3.0 * wc3;
- const double a = wc3 - _4fswc2 + _8fs2wc - _8fs3;
- const double b = _3wc3 - _4fswc2 - _8fs2wc + _24fs3;
- const double c = _3wc3 + _4fswc2 - _8fs2wc - _24fs3;
- const double d = wc3 + _4fswc2 + _8fs2wc + _8fs3;
- data->signal[i] = (_8fs3 * (x
- + 3.0 * (data->x2
- - data->x1)
- - data->x3)
- - (a * data->y3
- + b * data->y2
- + c * data-> y1)) / d;
- data->x3 = data->x2;
- data->x2 = data->x1;
- data->x1 = x;
- data->y3 = data->y2;
- data->y2 = data->y1;
- data->y1 = data->signal[i];
- i++;
- }
- return 0;
-}
diff --git a/rtbuf_signal_hipass4.c b/rtbuf_signal_hipass4.c
deleted file mode 100644
index c90c3af..0000000
--- a/rtbuf_signal_hipass4.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-/* Butterworth hipass fourth order filter
-a: cos(5*%pi/8) $
-b: cos(7*%pi/8) $
-s: 2*F*(1-z)/(1+z) $
-B4:((w/s)^2-2*(w/s)*a+1)*((w/s)^2-2*w/s*b+1) $
-H: 1/B4 $
-ratsimp(H);
- 4 4 4 3 4 2 4 4
-(16 F z - 64 F z + 96 F z - 64 F z + 16 F )
- 4 3 2 2 2 3 3
-/((w + (4 F b + 4 F a) w + (16 F a b + 8 F ) w + (16 F b + 16 F a) w
- 4 4 4 3 3 3
- + 16 F ) z + (4 w + (8 F b + 8 F a) w + ((- 32 F b) - 32 F a) w
- 4 3 4 2 2 2 4 2
- - 64 F ) z + (6 w + ((- 32 F a b) - 16 F ) w + 96 F ) z
- 4 3 3 3 4 4
- + (4 w + ((- 8 F b) - 8 F a) w + (32 F b + 32 F a) w - 64 F ) z + w
- 3 2 2 2
- + ((- 4 F b) - 4 F a) w + (16 F a b + 8 F ) w
- 3 3 4
- + ((- 16 F b) - 16 F a) w + 16 F )
-
-a: w4 - 4 (a + b) F w3 + (16 a b + 8) f2 w2 - 16 (a + b) f3 w + 16 f4 $
-b: 4 w4 - 8 (a + b) F w3 + 32 (a + b) f3 w - 64 f4 $
-c: 6 w4 - (32 a b + 16) f2 w2 + 96 f4 $
-d: 4 w4 + 8 (a + b) F w3 - 32 (a + b) f3 w - 64 f4 $
-e: w4 + 4 (a + b) F w3 + (16 a b + 8) f2 w2 + 16 (a + b) f3 w + 16 f4 $
-
-y: f4 (16 x4 - 64 x3 + 96 x2 - 64 x1 + 16 x - (e y4 + d y3 + c y2 + b y1)) / a $
-y: f4 (16 (x4 + x) - 64 (x3 + x1) + 96 x2 - (e y4 + d y3 + c y2 + b y1)) / a $
-
-*/
-#include <math.h>
-#include "rtbuf.h"
-#include "rtbuf_signal.h"
-
-int rtbuf_signal_hipass4_start (s_rtbuf *rtb)
-{
- s_rtbuf_signal_hipass4_data *data;
- assert(rtb->proc->out_bytes == sizeof(*data));
- data = (s_rtbuf_signal_hipass4_data*) rtb->data;
- data->x1 = 0.0;
- data->x2 = 0.0;
- data->x3 = 0.0;
- data->x4 = 0.0;
- data->y1 = 0.0;
- data->y2 = 0.0;
- data->y3 = 0.0;
- data->y4 = 0.0;
- return 0;
-}
-
-int rtbuf_signal_hipass4 (s_rtbuf *rtb)
-{
- s_rtbuf_signal_fun in;
- s_rtbuf_signal_fun cutoff;
- s_rtbuf_signal_hipass4_data *data;
- unsigned int i = 0;
- const double a = cos(5.0 * M_PI / 8.0);
- const double b = cos(7.0 * M_PI / 8.0);
- const double f = RTBUF_SIGNAL_SAMPLERATE;
- const double _4a_bf = 4.0 * (a + b) * f;
- const double f2 = f * f;
- const double _16ab_8f2 = (16.0 * a * b + 8.0) * f2;
- const double f3 = f2 * f;
- const double _16a_bf3 = 16.0 * (a + b) * f3;
- const double f4 = f2 * f2;
- const double _16f4 = 16.0 * f4;
- const double _64f4 = 64.0 * f4;
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_HIPASS_IN_SIGNAL, &in);
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_HIPASS_IN_CUTOFF, &cutoff);
- data = (s_rtbuf_signal_hipass4_data*) rtb->data;
- while (i < RTBUF_SIGNAL_SAMPLES) {
- const double x = in.sample_fun(in.signal, i);
- const double fc = cutoff.sample_fun(cutoff.signal, i);
- const double w = 2.0 * M_PI * fc;
- const double _16a_bf3w = _16a_bf3 * w;
- const double _32a_bf3w = 2.0 * _16a_bf3w;
- const double w2 = w * w;
- const double _16ab_8f2w2 = _16ab_8f2 * w2;
- const double _32ab_16f2w2 = 2 * _16ab_8f2w2;
- const double w3 = w2 * w;
- const double _4a_bfw3 = _4a_bf * w3;
- const double _8a_bfw3 = 2.0 * _4a_bfw3;
- const double w4 = w2 * w2;
- const double _4w4 = 4.0 * w4;
- const double a = w4 - _4a_bfw3 + _16ab_8f2w2 - _16a_bf3w + _16f4;
- const double b = _4w4 - _8a_bfw3 + _32a_bf3w - _64f4;
- const double c = 6.0 * w4 - _32ab_16f2w2 + 96.0 * f4;
- const double d = _4w4 + _8a_bfw3 - _32a_bf3w - _64f4;
- const double e = w4 + _4a_bfw3 + _16ab_8f2w2 + _16a_bf3w + _16f4;
- data->signal[i] = (f4 * (16.0 * (x + data->x4)
- - 64.0 * (data->x1 +
- data->x3)
- + 96.0 * data->x2)
- - (e * data->y4
- + d * data->y3
- + c * data->y2
- + b * data->y1)) / a;
- data->x4 = data->x3;
- data->x3 = data->x2;
- data->x2 = data->x1;
- data->x1 = x;
- data->y4 = data->y3;
- data->y3 = data->y2;
- data->y2 = data->y1;
- data->y1 = data->signal[i];
- i++;
- }
- return 0;
-}
diff --git a/rtbuf_signal_hipass5.c b/rtbuf_signal_hipass5.c
deleted file mode 100644
index 81c7a3e..0000000
--- a/rtbuf_signal_hipass5.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-/* Butterworth hipass fifth order filter
-a: (sqrt(5)-1)/2 $
-b: (sqrt(5)+1)/2 $
-s: 2*F*(1-z)/(1+z) $
-B5:(w/s+1)*((w/s)^2+a*(w/s)+1)*((w/s)^2+b*w/s+1) $
-H: 1/B5 $
-ratsimp(H);
- 5 5 5 4 5 3 5 2 5 5
-- (32 F z - 160 F z + 320 F z - 320 F z + 160 F z - 32 F )
- 5 4 2 3
-/((w + ((- 2 sqrt(5)) - 2) F w + (4 sqrt(5) + 12) F w
- 3 2 4 5 5
- + ((- 8 sqrt(5)) - 24) F w + (16 sqrt(5) + 16) F w - 32 F ) z
- 5 4 2 3
- + (5 w + ((- 6 sqrt(5)) - 6) F w + (4 sqrt(5) + 12) F w
- 3 2 4 5 4
- + (8 sqrt(5) + 24) F w + ((- 48 sqrt(5)) - 48) F w + 160 F ) z
- 5 4 2 3
- + (10 w + ((- 4 sqrt(5)) - 4) F w + ((- 8 sqrt(5)) - 24) F w
- 3 2 4 5 3
- + (16 sqrt(5) + 48) F w + (32 sqrt(5) + 32) F w - 320 F ) z
- 5 4 2 3
- + (10 w + (4 sqrt(5) + 4) F w + ((- 8 sqrt(5)) - 24) F w
- 3 2 4 5 2
- + ((- 16 sqrt(5)) - 48) F w + (32 sqrt(5) + 32) F w + 320 F ) z
- 5 4 2 3
- + (5 w + (6 sqrt(5) + 6) F w + (4 sqrt(5) + 12) F w
- 3 2 4 5
- + ((- 8 sqrt(5)) - 24) F w + ((- 48 sqrt(5)) - 48) F w - 160 F ) z
- 5 4 2 3
- + w + (2 sqrt(5) + 2) F w + (4 sqrt(5) + 12) F w
- 3 2 4 5
- + (8 sqrt(5) + 24) F w + (16 sqrt(5) + 16) F w + 32 F )
-
-a: w5 + (r5 + 1)( 2)(f w4 + 8 f4 w) + (4 r5 + 12) (f2 w3 + 2 f3 w2) + 32 f5; z
-b: 5 w5 + (r5 + 1)( 6)(f w4 - 8 f4 w) + (4 r5 + 12) (f2 w3 - 2 f3 w2) - 160 f5; z1
-c: 10 w5 + (r5 + 1)( 4)(f w4 + 8 f4 w) + (4 r5 + 12)(-2)(f2 w3 + 2 f3 w2) + 320 f5; z2
-d: 10 w5 + (r5 + 1)(-4)(f w4 - 8 f4 w) + (4 r5 + 12)(-2)(f2 w3 - 2 f3 w2) - 320 f5; z3
-e: 5 w5 + (r5 + 1)(-6)(f w4 + 8 f4 w) + (4 r5 + 12) (f2 w3 + 2 f3 w2) + 160 f5; z4
-f: w5 + (r5 + 1)(-2)(f w4 - 8 f4 w) + (4 r5 + 12) (f2 w3 - 2 f3 w2) - 32 f5; z5
-
-y: (f5 (32 (x - x5) + 160 (x4 - x1) + 320 (x2 - x3)) - (b y1 + c y2 + d y3 + e y4 + f y5)) / a;
-
-*/
-#include <math.h>
-#include "rtbuf.h"
-#include "rtbuf_signal.h"
-
-int rtbuf_signal_hipass5_start (s_rtbuf *rtb)
-{
- s_rtbuf_signal_hipass5_data *data;
- assert(rtb->proc->out_bytes == sizeof(*data));
- data = (s_rtbuf_signal_hipass5_data*) rtb->data;
- data->x1 = 0.0;
- data->x2 = 0.0;
- data->x3 = 0.0;
- data->x4 = 0.0;
- data->x5 = 0.0;
- data->y1 = 0.0;
- data->y2 = 0.0;
- data->y3 = 0.0;
- data->y4 = 0.0;
- data->y5 = 0.0;
- return 0;
-}
-
-int rtbuf_signal_hipass5 (s_rtbuf *rtb)
-{
- s_rtbuf_signal_fun in;
- s_rtbuf_signal_fun cutoff;
- s_rtbuf_signal_hipass5_data *data;
- unsigned int i = 0;
- const double r5_1 = sqrt(5.0) + 1.0;
- const double _4r5_12 = 4.0 * sqrt(5.0) + 12.0;
- const double f = RTBUF_SIGNAL_SAMPLERATE;
- const double f2 = f * f;
- const double f3 = f2 * f;
- const double f4 = f2 * f2;
- const double f5 = f2 * f3;
- const double _32f5 = 32.0 * f5;
- const double _160f5 = 160.0 * f5;
- const double _320f5 = 320.0 * f5;
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_HIPASS_IN_SIGNAL, &in);
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_HIPASS_IN_CUTOFF, &cutoff);
- data = (s_rtbuf_signal_hipass5_data*) rtb->data;
- while (i < RTBUF_SIGNAL_SAMPLES) {
- const double x = in.sample_fun(in.signal, i);
- const double fc = cutoff.sample_fun(cutoff.signal, i);
- const double w = 2.0 * M_PI * fc;
- const double _8f4w = 8.0 * f4 * w;
- const double w2 = w * w;
- const double _2f3w2 = 2.0 * f3 * w2;
- const double w3 = w2 * w;
- const double f2w3 = f2 * w3;
- const double f2w3p2f3w2 = f2w3 + _2f3w2;
- const double f2w3m2f3w2 = f2w3 - _2f3w2;
- const double w4 = w2 * w2;
- const double fw4 = f * w4;
- const double fw4p8f4w = (fw4 + _8f4w);
- const double fw4m8f4w = (fw4 - _8f4w);
- const double w5 = w2 * w3;
- const double _5w5 = 5.0 * w5;
- const double _10w5 = 10.0 * w5;
- const double a = w5 + r5_1 * 2.0 * fw4p8f4w + _4r5_12 * f2w3p2f3w2 + _32f5;
- const double b = _5w5 + r5_1 * 6.0 * fw4m8f4w + _4r5_12 * f2w3m2f3w2 - _160f5;
- const double c = _10w5 + r5_1 * 4.0 * fw4p8f4w + _4r5_12 * -2.0 * f2w3p2f3w2 + _320f5;
- const double d = _10w5 + r5_1 * -4.0 * fw4m8f4w + _4r5_12 * -2.0 * f2w3m2f3w2 - _320f5;
- const double e = _5w5 + r5_1 * -6.0 * fw4p8f4w + _4r5_12 * f2w3p2f3w2 + _160f5;
- const double f = w5 + r5_1 * -2.0 * fw4m8f4w + _4r5_12 * f2w3m2f3w2 - _32f5;
- data->signal[i] = (f5 * (32.0 * (x - data->x5)
- + 160.0 * (data->x4
- - data->x1)
- + 320.0 * (data->x2
- - data->x3))
- - (b * data->y1
- + c * data->y2
- + d * data->y3
- + e * data->y4
- + f * data->y5)) / a;
- data->x5 = data->x4;
- data->x4 = data->x3;
- data->x3 = data->x2;
- data->x2 = data->x1;
- data->x1 = x;
- data->y5 = data->y4;
- data->y4 = data->y3;
- data->y3 = data->y2;
- data->y2 = data->y1;
- data->y1 = data->signal[i];
- i++;
- }
- return 0;
-}
diff --git a/rtbuf_signal_lowpass.c b/rtbuf_signal_lowpass.c
deleted file mode 100644
index 9370d96..0000000
--- a/rtbuf_signal_lowpass.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- * Copyright 2020 Judy Najnudel
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <math.h>
-#include "rtbuf.h"
-#include "rtbuf_signal.h"
-
-int rtbuf_signal_lowpass_start (s_rtbuf *rtb)
-{
- s_rtbuf_signal_lowpass_data *data;
- assert(rtb->proc->out_bytes == sizeof(*data));
- data = (s_rtbuf_signal_lowpass_data*) rtb->data;
- data->x1 = 0;
- data->y1 = 0;
- return 0;
-}
-
-int rtbuf_signal_lowpass (s_rtbuf *rtb)
-{
- s_rtbuf_signal_fun in;
- s_rtbuf_signal_fun cutoff;
- s_rtbuf_signal_lowpass_data *data;
- unsigned int i = 0;
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_LOWPASS_IN_SIGNAL, &in);
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_LOWPASS_IN_CUTOFF, &cutoff);
- data = (s_rtbuf_signal_lowpass_data*) rtb->data;
- while (i < RTBUF_SIGNAL_SAMPLES) {
- double x = in.sample_fun(in.signal, i);
- double fc = cutoff.sample_fun(cutoff.signal, i);
- double k = RTBUF_SIGNAL_SAMPLERATE / (M_PI * fc);
- data->signal[i] = (x + data->x1 + (k - 1.0) * data->y1) / (1.0 + k);
- data->x1 = x;
- data->y1 = data->signal[i];
- i++;
- }
- return 0;
-}
diff --git a/rtbuf_signal_lowpass2.c b/rtbuf_signal_lowpass2.c
deleted file mode 100644
index a6d8fd8..0000000
--- a/rtbuf_signal_lowpass2.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-/* Butterworth lowpass second order filter
-
-B2: s^2+sqrt(2)*s+1 $
-H: 1/B2 $
-
-*/
-#include <math.h>
-#include "rtbuf.h"
-#include "rtbuf_signal.h"
-
-int rtbuf_signal_lowpass2_start (s_rtbuf *rtb)
-{
- s_rtbuf_signal_lowpass2_data *data;
- assert(rtb->proc->out_bytes == sizeof(*data));
- data = (s_rtbuf_signal_lowpass2_data*) rtb->data;
- data->x1 = 0.0;
- data->x2 = 0.0;
- data->y1 = 0.0;
- data->y2 = 0.0;
- return 0;
-}
-
-int rtbuf_signal_lowpass2 (s_rtbuf *rtb)
-{
- s_rtbuf_signal_fun in;
- s_rtbuf_signal_fun cutoff;
- s_rtbuf_signal_lowpass2_data *data;
- unsigned int i = 0;
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_LOWPASS_IN_SIGNAL, &in);
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_LOWPASS_IN_CUTOFF, &cutoff);
- data = (s_rtbuf_signal_lowpass2_data*) rtb->data;
- while (i < RTBUF_SIGNAL_SAMPLES) {
- double x = in.sample_fun(in.signal, i);
- double fc = cutoff.sample_fun(cutoff.signal, i);
- double k = RTBUF_SIGNAL_SAMPLERATE / (M_PI * fc);
- double k2 = k * k;
- double k_sqrt2 = M_SQRT2 * k;
- double z = 1.0 / (k2 + k_sqrt2 + 1);
- data->signal[i] = z * (x
- + data->x1 * 2.0
- + data->x2
- + data->y1 * 2.0 * (k2 - 1.0)
- + data->y2 * (k_sqrt2 - (k2 + 1.0)));
- data->x2 = data->x1;
- data->x1 = x;
- data->y2 = data->y1;
- data->y1 = data->signal[i];
- i++;
- }
- return 0;
-}
diff --git a/rtbuf_signal_lowpass3.c b/rtbuf_signal_lowpass3.c
deleted file mode 100644
index e6329ff..0000000
--- a/rtbuf_signal_lowpass3.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- * Copyright 2020 Judy Najnudel
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <math.h>
-#include "rtbuf.h"
-#include "rtbuf_signal.h"
-
-int rtbuf_signal_lowpass3_start (s_rtbuf *rtb)
-{
- s_rtbuf_signal_lowpass3_data *data;
- assert(rtb->proc->out_bytes == sizeof(*data));
- data = (s_rtbuf_signal_lowpass3_data*) rtb->data;
- data->x1 = 0.0;
- data->x2 = 0.0;
- data->x3 = 0.0;
- data->y1 = 0.0;
- data->y2 = 0.0;
- data->y3 = 0.0;
- return 0;
-}
-
-int rtbuf_signal_lowpass3 (s_rtbuf *rtb)
-{
- s_rtbuf_signal_fun in;
- s_rtbuf_signal_fun cutoff;
- s_rtbuf_signal_lowpass3_data *data;
- unsigned int i = 0;
- const double fs = RTBUF_SIGNAL_SAMPLERATE;
- const double fs2 = fs * fs;
- const double fs3 = fs2 * fs;
- const double _8fs3 = 8.0 * fs3;
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_LOWPASS_IN_SIGNAL, &in);
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_LOWPASS_IN_CUTOFF, &cutoff);
- data = (s_rtbuf_signal_lowpass3_data*) rtb->data;
- while (i < RTBUF_SIGNAL_SAMPLES) {
- const double x = in.sample_fun(in.signal, i);
- const double fc = cutoff.sample_fun(cutoff.signal, i);
- const double wc = 2.0 * M_PI * fc;
- const double wc2 = wc * wc;
- const double wc3 = wc2 * wc;
- const double _4fs2wc = 4.0 * fs2 * wc;
- const double _8fs2wc = 2.0 * _4fs2wc;
- const double _4fswc2 = 4.0 * fs * wc2;
- const double _3wc3 = 3.0 * wc3;
- const double a = wc3 + _4fswc2 + _8fs2wc + _8fs3;
- const double b = _8fs2wc + 24.0 * fs3 - (_3wc3 + _4fswc2);
- const double c = _4fswc2 + _8fs2wc - (24.0 * fs3 + _3wc3);
- const double d = _8fs3 + _4fswc2 - (wc3 + _8fs2wc);
- data->signal[i] = (wc3 * (x
- + 3.0 * (data->x1 +
- data->x2)
- + data->x3)
- + b * data->y1
- + c * data->y2
- + d * data->y3) / a;
- data->x3 = data->x2;
- data->x2 = data->x1;
- data->x1 = x;
- data->y3 = data->y2;
- data->y2 = data->y1;
- data->y1 = data->signal[i];
- i++;
- }
- return 0;
-}
diff --git a/rtbuf_signal_lowpass4.c b/rtbuf_signal_lowpass4.c
deleted file mode 100644
index 5e1aa42..0000000
--- a/rtbuf_signal_lowpass4.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-/* Butterworth lowpass fourth order filter
-a: cos(5*%pi/8) $
-b: cos(7*%pi/8) $
-s: 2*F*(1-z)/(1+z) $
-B4:((s/w)^2-2*(s/w)*a+1)*((s/w)^2-2*s/w*b+1) $
-H: 1/B4 $
-ratsimp(H);
- 4 4 4 3 4 2 4 4
-(%o8) (w z + 4 w z + 6 w z + 4 w z + w )
- 4 3 2 2 2 3 3
-/((w + (4 F b + 4 F a) w + (16 F a b + 8 F ) w + (16 F b + 16 F a) w
- 4 4 4 3 3 3
- + 16 F ) z + (4 w + (8 F b + 8 F a) w + ((- 32 F b) - 32 F a) w
- 4 3 4 2 2 2 4 2
- - 64 F ) z + (6 w + ((- 32 F a b) - 16 F ) w + 96 F ) z
- 4 3 3 3 4 4
- + (4 w + ((- 8 F b) - 8 F a) w + (32 F b + 32 F a) w - 64 F ) z + w
- 3 2 2 2
- + ((- 4 F b) - 4 F a) w + (16 F a b + 8 F ) w
- 3 3 4
- + ((- 16 F b) - 16 F a) w + 16 F )
-
-c: 16*F^4+( 16*b+16*a)*F^3*w+(16*a*b +8)*F^2*w^2+( 4*b+4*a)*F*w^3+ w^4 $
-d: -64*F^4+(-32*b-32*a)*F^3*w +( 8*b+8*a)*F*w^3+4*w^4 $
-e: 96*F^4 +(-32*a*b-16)*F^2*w^2 +6*w^4 $
-f: -64*F^4+( 32*b+32*a)*F^3*w +(-8*b-8*a)*F*w^3+4*w^4 $
-g: 16*F^4+(-16*b-16*a)*F^3*w+(16*a*b +8)*F^2*w^2+(-4*b-4*a)*F*w^3+ w^4 $
-
-c: 16*F^4 + 16*(a+b)*F^3*w + (16*a*b+8)*F^2*w^2 + 4*(a+b)*F*w^3 + w^4 $
-d: -(64*F^4 + 32*(a+b)*F^3*w) + 8*(a+b)*F*w^3 + 4*w^4 $
-e: 96*F^4 -2*(16*a*b+8)*F^2*w^2 + 6*w^4 $
-f: -64*F^4 + 32*(a+b)*F^3*w - 8*(a+b)*F*w^3 + 4*w^4 $
-g: 16*F^4 - 16*(a+b)*F^3*w + (16*a*b+8)*F^2*w^2 - 4*(a+b)*F*w^3 + w^4 $
-
-y: (w4*(x4+4*x3+6*x2+4*x1+x)-(c*y4+d*y3+e*y2+f*y1))/g $
-*/
-#include <math.h>
-#include "rtbuf.h"
-#include "rtbuf_signal.h"
-
-int rtbuf_signal_lowpass4_start (s_rtbuf *rtb)
-{
- s_rtbuf_signal_lowpass4_data *data;
- assert(rtb->proc->out_bytes == sizeof(*data));
- data = (s_rtbuf_signal_lowpass4_data*) rtb->data;
- data->x1 = 0.0;
- data->x2 = 0.0;
- data->x3 = 0.0;
- data->x4 = 0.0;
- data->y1 = 0.0;
- data->y2 = 0.0;
- data->y3 = 0.0;
- data->y4 = 0.0;
- return 0;
-}
-
-int rtbuf_signal_lowpass4 (s_rtbuf *rtb)
-{
- s_rtbuf_signal_fun in;
- s_rtbuf_signal_fun cutoff;
- s_rtbuf_signal_lowpass4_data *data;
- unsigned int i = 0;
- const double a = cos(5.0 * M_PI / 8.0);
- const double b = cos(7.0 * M_PI / 8.0);
- const double f = RTBUF_SIGNAL_SAMPLERATE;
- const double _4a_bf = 4.0 * (a + b) * f;
- const double f2 = f * f;
- const double _16ab_8f2 = (16.0 * a * b + 8.0) * f2;
- const double f3 = f2 * f;
- const double _16a_bf3 = 16.0 * (a + b) * f3;
- const double f4 = f2 * f2;
- const double _16f4 = 16.0 * f4;
- const double _64f4 = 64.0 * f4;
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_LOWPASS_IN_SIGNAL, &in);
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_LOWPASS_IN_CUTOFF, &cutoff);
- data = (s_rtbuf_signal_lowpass4_data*) rtb->data;
- while (i < RTBUF_SIGNAL_SAMPLES) {
- const double x = in.sample_fun(in.signal, i);
- const double fc = cutoff.sample_fun(cutoff.signal, i);
- const double w = 2.0 * M_PI * fc;
- const double _16a_bf3w = _16a_bf3 * w;
- const double _32a_bf3w = 2.0 * _16a_bf3w;
- const double w2 = w * w;
- const double _16ab_8f2w2 = _16ab_8f2 * w2;
- const double w3 = w2 * w;
- const double _4a_bfw3 = _4a_bf * w3;
- const double _8a_bfw3 = 2.0 * _4a_bfw3;
- const double w4 = w2 * w2;
- const double _4w4 = 4.0 * w4;
- const double c = _16f4 + _16a_bf3w + _16ab_8f2w2 + _4a_bfw3 + w4;
- const double d = -(_64f4 + _32a_bf3w) + _8a_bfw3 + _4w4;
- const double e = 96.0 * f4 - 2.0 * _16ab_8f2w2 + 6.0 * w4;
- const double f = - _64f4 + _32a_bf3w - _8a_bfw3 + _4w4;
- const double g = _16f4 - _16a_bf3w + _16ab_8f2w2 - _4a_bfw3 + w4;
- data->signal[i] = (w4 * (x
- + 4.0 * (data->x1 +
- data->x3)
- + 6.0 * data->x2
- + data->x4)
- - (c * data->y4
- + d * data->y3
- + e * data->y2
- + f * data->y1)) / g;
- data->x4 = data->x3;
- data->x3 = data->x2;
- data->x2 = data->x1;
- data->x1 = x;
- data->y4 = data->y3;
- data->y3 = data->y2;
- data->y2 = data->y1;
- data->y1 = data->signal[i];
- i++;
- }
- return 0;
-}
diff --git a/rtbuf_signal_lowpass5.c b/rtbuf_signal_lowpass5.c
deleted file mode 100644
index 62603a2..0000000
--- a/rtbuf_signal_lowpass5.c
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-/* Butterworth lowpass fifth order filter
-a: (sqrt(5)-1)/2 $
-b: (sqrt(5)+1)/2 $
-s: 2*F*(1-z)/(1+z) $
-B5:(s/w+1)*((s/w)^2+a*(s/w)+1)*((s/w)^2+b*s/w+1) $
-H: 1/B5 $
-ratsimp(H);
- 5 5 5 4 5 3 5 2 5 5
-(w z + 5 w z + 10 w z + 10 w z + 5 w z + w )
- 5 4 2 3
-/((w + ((- 2 sqrt(5)) - 2) F w + (4 sqrt(5) + 12) F w
- 3 2 4 5 5
- + ((- 8 sqrt(5)) - 24) F w + (16 sqrt(5) + 16) F w - 32 F ) z
- 5 4 2 3
- + (5 w + ((- 6 sqrt(5)) - 6) F w + (4 sqrt(5) + 12) F w
- 3 2 4 5 4
- + (8 sqrt(5) + 24) F w + ((- 48 sqrt(5)) - 48) F w + 160 F ) z
- 5 4 2 3
- + (10 w + ((- 4 sqrt(5)) - 4) F w + ((- 8 sqrt(5)) - 24) F w
- 3 2 4 5 3
- + (16 sqrt(5) + 48) F w + (32 sqrt(5) + 32) F w - 320 F ) z
- 5 4 2 3
- + (10 w + (4 sqrt(5) + 4) F w + ((- 8 sqrt(5)) - 24) F w
- 3 2 4 5 2
- + ((- 16 sqrt(5)) - 48) F w + (32 sqrt(5) + 32) F w + 320 F ) z
- 5 4 2 3
- + (5 w + (6 sqrt(5) + 6) F w + (4 sqrt(5) + 12) F w
- 3 2 4 5
- + ((- 8 sqrt(5)) - 24) F w + ((- 48 sqrt(5)) - 48) F w - 160 F ) z
- 5 4 2 3
- + w + (2 sqrt(5) + 2) F w + (4 sqrt(5) + 12) F w
- 3 2 4 5
- + (8 sqrt(5) + 24) F w + (16 sqrt(5) + 16) F w + 32 F )
-
-a: w5 + (r5 + 1)( 2)(f w4 + 8 f4 w) + (4 r5 + 12) (f2 w3 + 2 f3 w2) + 32 f5; z
-b: 5 w5 + (r5 + 1)( 6)(f w4 - 8 f4 w) + (4 r5 + 12) (f2 w3 - 2 f3 w2) - 160 f5; z1
-c: 10 w5 + (r5 + 1)( 4)(f w4 + 8 f4 w) + (4 r5 + 12)(-2)(f2 w3 + 2 f3 w2) + 320 f5; z2
-d: 10 w5 + (r5 + 1)(-4)(f w4 - 8 f4 w) + (4 r5 + 12)(-2)(f2 w3 - 2 f3 w2) - 320 f5; z3
-e: 5 w5 + (r5 + 1)(-6)(f w4 + 8 f4 w) + (4 r5 + 12) (f2 w3 + 2 f3 w2) + 160 f5; z4
-f: w5 + (r5 + 1)(-2)(f w4 - 8 f4 w) + (4 r5 + 12) (f2 w3 - 2 f3 w2) - 32 f5; z5
-
-*/
-#include <math.h>
-#include "rtbuf.h"
-#include "rtbuf_signal.h"
-
-int rtbuf_signal_lowpass5_start (s_rtbuf *rtb)
-{
- s_rtbuf_signal_lowpass5_data *data;
- assert(rtb->proc->out_bytes == sizeof(*data));
- data = (s_rtbuf_signal_lowpass5_data*) rtb->data;
- data->x1 = 0.0;
- data->x2 = 0.0;
- data->x3 = 0.0;
- data->x4 = 0.0;
- data->x5 = 0.0;
- data->y1 = 0.0;
- data->y2 = 0.0;
- data->y3 = 0.0;
- data->y4 = 0.0;
- data->y5 = 0.0;
- return 0;
-}
-
-int rtbuf_signal_lowpass5 (s_rtbuf *rtb)
-{
- s_rtbuf_signal_fun in;
- s_rtbuf_signal_fun cutoff;
- s_rtbuf_signal_lowpass5_data *data;
- unsigned int i = 0;
- const double r5_1 = sqrt(5.0) + 1.0;
- const double _4r5_12 = 4.0 * sqrt(5.0) + 12.0;
- const double f = RTBUF_SIGNAL_SAMPLERATE;
- const double f2 = f * f;
- const double f3 = f2 * f;
- const double f4 = f2 * f2;
- const double f5 = f2 * f3;
- const double _32f5 = 32.0 * f5;
- const double _160f5 = 160.0 * f5;
- const double _320f5 = 320.0 * f5;
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_LOWPASS_IN_SIGNAL, &in);
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_LOWPASS_IN_CUTOFF, &cutoff);
- data = (s_rtbuf_signal_lowpass5_data*) rtb->data;
- while (i < RTBUF_SIGNAL_SAMPLES) {
- const double x = in.sample_fun(in.signal, i);
- const double fc = cutoff.sample_fun(cutoff.signal, i);
- const double w = 2.0 * M_PI * fc;
- const double _8f4w = 8.0 * f4 * w;
- const double w2 = w * w;
- const double _2f3w2 = 2.0 * f3 * w2;
- const double w3 = w2 * w;
- const double f2w3 = f2 * w3;
- const double f2w3p2f3w2 = f2w3 + _2f3w2;
- const double f2w3m2f3w2 = f2w3 - _2f3w2;
- const double w4 = w2 * w2;
- const double fw4 = f * w4;
- const double fw4p8f4w = (fw4 + _8f4w);
- const double fw4m8f4w = (fw4 - _8f4w);
- const double w5 = w2 * w3;
- const double _5w5 = 5.0 * w5;
- const double _10w5 = 10.0 * w5;
- const double a = w5 + r5_1 * 2.0 * fw4p8f4w + _4r5_12 * f2w3p2f3w2 + _32f5;
- const double b = _5w5 + r5_1 * 6.0 * fw4m8f4w + _4r5_12 * f2w3m2f3w2 - _160f5;
- const double c = _10w5 + r5_1 * 4.0 * fw4p8f4w + _4r5_12 * -2.0 * f2w3p2f3w2 + _320f5;
- const double d = _10w5 + r5_1 * -4.0 * fw4m8f4w + _4r5_12 * -2.0 * f2w3m2f3w2 - _320f5;
- const double e = _5w5 + r5_1 * -6.0 * fw4p8f4w + _4r5_12 * f2w3p2f3w2 + _160f5;
- const double f = w5 + r5_1 * -2.0 * fw4m8f4w + _4r5_12 * f2w3m2f3w2 - _32f5;
- data->signal[i] = (w5 * (x
- + 5.0 * (data->x1
- + data->x4)
- + 10.0 * (data->x2
- + data->x3)
- + data->x5)
- - (b * data->y1
- + c * data->y2
- + d * data->y3
- + e * data->y4
- + f * data->y5)) / a;
- data->x5 = data->x4;
- data->x4 = data->x3;
- data->x3 = data->x2;
- data->x2 = data->x1;
- data->x1 = x;
- data->y5 = data->y4;
- data->y4 = data->y3;
- data->y3 = data->y2;
- data->y2 = data->y1;
- data->y1 = data->signal[i];
- i++;
- }
- return 0;
-}
diff --git a/rtbuf_signal_sawtooth.c b/rtbuf_signal_sawtooth.c
deleted file mode 100644
index 1531770..0000000
--- a/rtbuf_signal_sawtooth.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- * Copyright 2020 Judy Najnudel <judy.najnudel@gmail.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <math.h>
-#include <stdio.h>
-#include "rtbuf.h"
-#include "rtbuf_signal.h"
-
-int rtbuf_signal_sawtooth_start (s_rtbuf *rtb)
-{
- s_rtbuf_signal_sawtooth_data *data;
- assert(rtb->proc->out_bytes == sizeof(*data));
- data = (s_rtbuf_signal_sawtooth_data*) rtb->data;
- data->phase = 0;
- return 0;
-}
-
-int rtbuf_signal_sawtooth (s_rtbuf *rtb)
-{
- s_rtbuf_signal_fun freq;
- s_rtbuf_signal_fun amp;
- s_rtbuf_signal_sawtooth_data *data;
- unsigned int i = 0;
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_SAWTOOTH_IN_FREQUENCY, &freq);
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_SAWTOOTH_IN_AMPLITUDE, &);
- data = (s_rtbuf_signal_sawtooth_data*) rtb->data;
- while (i < RTBUF_SIGNAL_SAMPLES) {
- double f = freq.sample_fun(freq.signal, i);
- double a = amp.sample_fun(amp.signal, i);
- f = max(0.0, f);
- a = max(0.0, a);
- f /= (double) RTBUF_SIGNAL_SAMPLERATE;
- data->phase = fmod(data->phase + f, 1.0);
- data->signal[i] = a * (2.0 * data->phase - 1.0);
- i++;
- }
- return 0;
-}
diff --git a/rtbuf_signal_sinus.c b/rtbuf_signal_sinus.c
deleted file mode 100644
index d7e5a46..0000000
--- a/rtbuf_signal_sinus.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- * Copyright 2018 Judy Najnudel <judy.najnudel@gmail.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <math.h>
-#include <stdio.h>
-#include "rtbuf.h"
-#include "rtbuf_signal.h"
-
-int rtbuf_signal_sinus_start (s_rtbuf *rtb)
-{
- s_rtbuf_signal_sinus_data *data;
- assert(rtb->proc->out_bytes == sizeof(*data));
- data = (s_rtbuf_signal_sinus_data*) rtb->data;
- data->phase = 0;
- return 0;
-}
-
-int rtbuf_signal_sinus (s_rtbuf *rtb)
-{
- s_rtbuf_signal_fun freq;
- s_rtbuf_signal_fun amp;
- s_rtbuf_signal_sinus_data *data;
- unsigned int i = 0;
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_SINUS_IN_FREQUENCY, &freq);
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_SINUS_IN_AMPLITUDE, &);
- data = (s_rtbuf_signal_sinus_data*) rtb->data;
- while (i < RTBUF_SIGNAL_SAMPLES) {
- double f = freq.sample_fun(freq.signal, i);
- double a = amp.sample_fun(amp.signal, i);
- f = max(0.0, f);
- a = max(0.0, a);
- f /= (double) RTBUF_SIGNAL_SAMPLERATE;
- data->phase = fmod(data->phase + 2.0 * M_PI * f, 2.0 * M_PI);
- data->signal[i] = a * sin(data->phase);
- /* printf(" i=%u f=%f a=%f %f", i, f, a, data->samples[i]); */
- i++;
- }
- return 0;
-}
diff --git a/rtbuf_signal_square.c b/rtbuf_signal_square.c
deleted file mode 100644
index 90ea7f2..0000000
--- a/rtbuf_signal_square.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <math.h>
-#include <stdio.h>
-#include "rtbuf.h"
-#include "rtbuf_signal.h"
-
-static
-double square (double amp, double phase, double pulse)
-{
- return phase < pulse ? amp : -amp;
-}
-
-int rtbuf_signal_square (s_rtbuf *rtb)
-{
- s_rtbuf_signal_fun freq;
- s_rtbuf_signal_fun amp;
- s_rtbuf_signal_fun pulse;
- s_rtbuf_signal_square_data *data;
- unsigned int i = 0;
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_SQUARE_IN_FREQUENCY, &freq);
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_SQUARE_IN_AMPLITUDE, &);
- rtbuf_signal_fun(rtb, RTBUF_SIGNAL_SQUARE_IN_PULSE, &pulse);
- data = (s_rtbuf_signal_square_data*) rtb->data;
- while (i < RTBUF_SIGNAL_SAMPLES) {
- double f = freq.sample_fun(freq.signal, i);
- double a = amp.sample_fun(amp.signal, i);
- double p = pulse.sample_fun(pulse.signal, i);
- f = max(0.0, f);
- a = max(0.0, a);
- p = clamp(0.0, p, 1.0);
- /* printf(" i=%u freq=%f amp=%f pulse=%f", i, f, a, p); */
- f /= (double) RTBUF_SIGNAL_SAMPLERATE;
- data->phase = fmod(data->phase + f, 1.0);
- data->signal[i] = square(a, data->phase, p);
- /* printf(" f=%f a=%f p=%f square=%f", f, a, p, data->samples[i]); */
- i++;
- }
- return 0;
-}
-
-int rtbuf_signal_square_start (s_rtbuf *rtb)
-{
- s_rtbuf_signal_square_data *data;
- assert(rtb->proc->out_bytes == sizeof(*data));
- data = (s_rtbuf_signal_square_data*) rtb->data;
- data->phase = 0;
- return 0;
-}
diff --git a/rtbuf_signal_type.c b/rtbuf_signal_type.c
deleted file mode 100644
index 9697b9b..0000000
--- a/rtbuf_signal_type.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <stdio.h>
-#include "rtbuf.h"
-#include "rtbuf_signal.h"
-
-int main ()
-{
- printf("/* file generated by rtbuf_signal_type */\n");
- printf("#ifndef RTBUF_SIGNAL_TYPE_H\n"
- "#define RTBUF_SIGNAL_TYPE_H\n"
- "\n");
- printf("#define RTBUF_SIGNAL_TYPE"
- " RTBUF_SIGNAL_SAMPLE_TYPE \"[%u]\"\n",
- RTBUF_SIGNAL_SAMPLES);
- printf("#define RTBUF_SIGNAL_DELAY_TYPE"
- " RTBUF_SIGNAL_SAMPLE_TYPE \"[%u]\"\n",
- RTBUF_SIGNAL_DELAY_SAMPLES_MAX);
- printf("#define RTBUF_SIGNAL_FLANGER_TYPE"
- " RTBUF_SIGNAL_SAMPLE_TYPE \"[%u]\"\n",
- RTBUF_SIGNAL_FLANGER_SAMPLES_MAX);
- printf("\n"
- "#endif\n");
- return 0;
-}
diff --git a/rtbuf_sndio.c b/rtbuf_sndio.c
deleted file mode 100644
index be4ce7d..0000000
--- a/rtbuf_sndio.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <sndio.h>
-#include <stdio.h>
-#include <strings.h>
-#include "rtbuf.h"
-#include "rtbuf_lib.h"
-#include "rtbuf_signal.h"
-#include "rtbuf_signal_type.h"
-#include "rtbuf_sndio.h"
-#include "rtbuf_sndio_type.h"
-
-s_rtbuf_lib_proc_out g_rtbuf_sndio_input_out[] = {
- { "left", RTBUF_SIGNAL_TYPE },
- { "right", RTBUF_SIGNAL_TYPE },
- { "samples", RTBUF_SNDIO_SAMPLES_TYPE },
- { 0, 0 } };
-
-s_rtbuf_lib_proc_in g_rtbuf_sndio_output_in[] = {
- { "left", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
- { "right", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
- { 0, 0, 0.0, 0.0, 0.0 } };
-
-s_rtbuf_lib_proc_out g_rtbuf_sndio_output_out[] = {
- { "samples", RTBUF_SNDIO_SAMPLES_TYPE },
- { "reserved", RTBUF_SNDIO_OUTPUT_RESERVED_TYPE },
- { 0, 0 } };
-
-const char *rtbuf_lib_name = "sndio";
-unsigned long rtbuf_lib_ver = RTBUF_LIB_VER;
-s_rtbuf_lib_proc rtbuf_lib_proc[] = {
- { "input", rtbuf_sndio_input, rtbuf_sndio_input_start,
- rtbuf_sndio_input_stop, 0, g_rtbuf_sndio_input_out },
- { "output", rtbuf_sndio_output, rtbuf_sndio_output_start,
- rtbuf_sndio_output_stop, g_rtbuf_sndio_output_in,
- g_rtbuf_sndio_output_out },
- { 0, 0, 0, 0, 0, 0 } };
-
-void print_sio_par (struct sio_par *par)
-{
- printf("#<sio_par bits=%i sig=%i rchan=%i pchan=%i rate=%i>",
- par->bits, par->sig, par->rchan, par->pchan, par->rate);
-}
diff --git a/rtbuf_sndio.h b/rtbuf_sndio.h
deleted file mode 100644
index f8f7da2..0000000
--- a/rtbuf_sndio.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-#ifndef RTBUF_SNDIO_H
-#define RTBUF_SNDIO_H
-
-#include <sndio.h>
-#include "rtbuf_signal.h"
-
-void print_sio_par (struct sio_par *par);
-
-enum {
- RTBUF_SNDIO_LEFT = 0,
- RTBUF_SNDIO_RIGHT,
- RTBUF_SNDIO_CHANNELS
-};
-
-#define RTBUF_SNDIO_SAMPLE_TYPE "short"
-#define RTBUF_SNDIO_SAMPLES \
- (RTBUF_SNDIO_CHANNELS * RTBUF_SIGNAL_SAMPLES)
-
-typedef short t_rtbuf_sndio_sample;
-typedef t_rtbuf_sndio_sample t_rtbuf_sndio_samples[RTBUF_SNDIO_SAMPLES];
-
-typedef struct rtbuf_sndio_input_data {
- t_rtbuf_signal signal[RTBUF_SNDIO_CHANNELS];
- t_rtbuf_sndio_samples samples;
-} s_rtbuf_sndio_input_data;
-
-int rtbuf_sndio_input (s_rtbuf *rtb);
-int rtbuf_sndio_input_start (s_rtbuf *rtb);
-int rtbuf_sndio_input_stop (s_rtbuf *rtb);
-
-typedef struct rtbuf_sndio_output_reserved {
- struct sio_hdl *sio_hdl;
- struct sio_par want;
- struct sio_par have;
-} s_rtbuf_sndio_output_reserved;
-
-typedef struct rtbuf_sndio_output_data {
- t_rtbuf_sndio_samples samples;
- s_rtbuf_sndio_output_reserved reserved;
-} s_rtbuf_sndio_output_data;
-
-#define RTBUF_SNDIO_OUTPUT_RESERVED_SIZE \
- sizeof(s_rtbuf_sndio_output_reserved)
-
-int rtbuf_sndio_output (s_rtbuf *rtb);
-int rtbuf_sndio_output_start (s_rtbuf *rtb);
-int rtbuf_sndio_output_stop (s_rtbuf *rtb);
-
-#endif
diff --git a/rtbuf_sndio_input.c b/rtbuf_sndio_input.c
deleted file mode 100644
index 86a9598..0000000
--- a/rtbuf_sndio_input.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <sndio.h>
-#include <stdio.h>
-#include <strings.h>
-#include "rtbuf.h"
-#include "rtbuf_signal.h"
-#include "rtbuf_sndio.h"
-
-int rtbuf_sndio_input (s_rtbuf *rtb)
-{
- /*
- s_sndio_input_data *data = (s_sndio_input_data*) rtb->data;
- */
- (void) rtb;
- return 0;
-}
-
-int rtbuf_sndio_input_start (s_rtbuf *rtb)
-{
- s_rtbuf_sndio_input_data *data;
- assert(rtb->proc->out_bytes == sizeof(*data));
- data = (s_rtbuf_sndio_input_data*) rtb->data;
- return 0;
-}
-
-int rtbuf_sndio_input_stop (s_rtbuf *rtb)
-{
- (void) rtb;
- return 0;
-}
diff --git a/rtbuf_sndio_output.c b/rtbuf_sndio_output.c
deleted file mode 100644
index 72f0653..0000000
--- a/rtbuf_sndio_output.c
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <limits.h>
-#include <sndio.h>
-#include <stdio.h>
-#include <strings.h>
-#include "rtbuf.h"
-#include "rtbuf_sndio.h"
-
-void rtbuf_sndio_output_parameters (struct sio_par *want)
-{
- bzero(want, sizeof(struct sio_par));
- sio_initpar(want);
- want->bits = 16;
- want->sig = 1;
- want->rchan = 0;
- want->pchan = RTBUF_SNDIO_CHANNELS;
- want->rate = RTBUF_SIGNAL_SAMPLERATE;
- want->appbufsz = RTBUF_SIGNAL_SAMPLES;
- want->xrun = SIO_IGNORE;
- print_sio_par(want); printf("\n");
-}
-
-int rtbuf_sndio_output_check_parameters (struct sio_par *have)
-{
- int ok;
- print_sio_par(have);
- printf("\n");
- ok = (have->bits == 16 &&
- have->sig == 1 &&
- have->rchan == 0 &&
- have->pchan == RTBUF_SNDIO_CHANNELS &&
- have->rate == RTBUF_SIGNAL_SAMPLERATE);
- return ok;
-}
-
-int rtbuf_sndio_output_start (s_rtbuf *rtb)
-{
- s_rtbuf_sndio_output_data *data;
- s_rtbuf_sndio_output_reserved *res;
- int err = 0;
- assert(rtb->proc->out_bytes == sizeof(*data));
- data = (s_rtbuf_sndio_output_data*) rtb->data;
- res = &data->reserved;
- if (!res->sio_hdl) {
- res->sio_hdl = sio_open(SIO_DEVANY, SIO_PLAY, 0);
- if (!res->sio_hdl)
- err = rtbuf_err("sndio_output_start: sio_open failed");
- else {
- rtbuf_sndio_output_parameters(&res->want);
- if (sio_setpar(res->sio_hdl,
- &res->want) != 1)
- err = rtbuf_err("sndio_output_start: sio_setpar failed");
- else if (sio_getpar(res->sio_hdl,
- &res->have) != 1)
- err = rtbuf_err("sndio_output_start: sio_getpar failed");
- else if (!rtbuf_sndio_output_check_parameters(&res->have))
- err = rtbuf_err("sndio_output_start: check_parameters failed");
- else if (sio_start(res->sio_hdl) != 1)
- err = rtbuf_err("sndio_output_start: sio_start failed");
- }
- }
- return err;
-}
-
-int rtbuf_sndio_output_stop (s_rtbuf *rtb)
-{
- s_rtbuf_sndio_output_data *data;
- data = (s_rtbuf_sndio_output_data*) rtb->data;
- if (data->reserved.sio_hdl) {
- sio_close(data->reserved.sio_hdl);
- data->reserved.sio_hdl = 0;
- }
- return 0;
-}
-
-int rtbuf_sndio_output (s_rtbuf *rtb)
-{
- s_rtbuf_signal_fun in[RTBUF_SNDIO_CHANNELS];
- s_rtbuf_sndio_output_data *data;
- short *sample;
- unsigned int i = 0;
- unsigned int j = 0;
- assert(rtb);
- assert(rtb->data);
- assert(rtb->proc);
- while (j < RTBUF_SNDIO_CHANNELS) {
- rtbuf_signal_fun(rtb, j, &in[j]);
- j++;
- }
- data = (s_rtbuf_sndio_output_data*) rtb->data;
- sample = data->samples;
- /* printf("sndio_output"); */
- while (i < RTBUF_SIGNAL_SAMPLES) {
- j = 0;
- while (j < RTBUF_SNDIO_CHANNELS) {
- double in_ = in[j].sample_fun(in[j].signal, i);
- in_ = clamp(-1.0, in_, 1.0);
- if (in_ < 0.0)
- in_ *= -SHRT_MIN;
- else
- in_ *= SHRT_MAX;
- *sample = (short) in_;
- sample++;
- j++;
- }
- i++;
- }
- sio_write(data->reserved.sio_hdl, data->samples,
- sizeof(t_rtbuf_sndio_samples));
- /* printf("\n"); */
- return 0;
-}
diff --git a/rtbuf_sndio_type.c b/rtbuf_sndio_type.c
deleted file mode 100644
index a616900..0000000
--- a/rtbuf_sndio_type.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <stdio.h>
-#include "rtbuf.h"
-#include "rtbuf_sndio.h"
-
-int main ()
-{
- printf("/* file generated by rtbuf_sndio_type */\n");
- printf("#ifndef RTBUF_SNDIO_TYPE_H\n"
- "#define RTBUF_SNDIO_TYPE_H\n"
- "\n");
- printf("#define RTBUF_SNDIO_SAMPLES_TYPE RTBUF_SNDIO_SAMPLE_TYPE"
- " \"[%u]\"\n",
- RTBUF_SNDIO_SAMPLES);
- printf("#define RTBUF_SNDIO_OUTPUT_RESERVED_TYPE"
- " \"char[%u]\"\n",
- (unsigned int) RTBUF_SNDIO_OUTPUT_RESERVED_SIZE);
- printf("\n"
- "#endif\n");
- return 0;
-}
diff --git a/rtbuf_synth.c b/rtbuf_synth.c
deleted file mode 100644
index 8fd9cef..0000000
--- a/rtbuf_synth.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <float.h>
-#include <stdio.h>
-#include "rtbuf.h"
-#include "rtbuf_lib.h"
-#include "rtbuf_signal.h"
-#include "rtbuf_signal_type.h"
-#include "rtbuf_music.h"
-#include "rtbuf_music_type.h"
-#include "rtbuf_synth.h"
-
-s_rtbuf_lib_proc_in g_rtbuf_synth_adsr_in[] = {
- RTBUF_MUSIC_NOTE_IN(),
- { "attack", RTBUF_SIGNAL_TYPE, 0.02, 0.0, 2.0 },
- { "decay", RTBUF_SIGNAL_TYPE, 0.01, 0.0, 2.0 },
- { "sustain", RTBUF_SIGNAL_TYPE, 0.4, 0.0, 1.0 },
- { "release", RTBUF_SIGNAL_TYPE, 0.3, 0.0, 10.0 },
- { 0, 0, 0.0, 0.0, 0.0 } };
-
-s_rtbuf_lib_proc_out g_rtbuf_synth_adsr_out[] = {
- { "signal", RTBUF_SIGNAL_TYPE },
- { "state", "int" },
- { 0, 0 } };
-
-s_rtbuf_lib_proc_in g_rtbuf_synth_synth_in[] = {
- { "envelope", RTBUF_SIGNAL_TYPE, 1.0, 0.0, 1.0 },
- { "oscillator", RTBUF_SIGNAL_TYPE, 0.0, -1.0, 1.0 },
- RTBUF_MUSIC_NOTES_IN("note"),
- { 0, 0, 0.0, 0.0, 0.0 } };
-
-s_rtbuf_lib_proc_out g_rtbuf_synth_synth_out[] = {
- { "signal", RTBUF_SIGNAL_TYPE },
- { "note_n", "unsigned int" },
- { 0, 0 } };
-
-const char *rtbuf_lib_name = "synth";
-unsigned long rtbuf_lib_ver = RTBUF_LIB_VER;
-s_rtbuf_lib_proc rtbuf_lib_proc[] = {
- { "adsr", rtbuf_synth_adsr, rtbuf_synth_adsr_start, 0,
- g_rtbuf_synth_adsr_in, g_rtbuf_synth_adsr_out },
- { "synth", rtbuf_synth_synth, rtbuf_synth_synth_start, 0,
- g_rtbuf_synth_synth_in, g_rtbuf_synth_synth_out },
- { 0, 0, 0, 0, 0, 0 } };
-
-int rtbuf_lib_init (s_rtbuf_lib *lib)
-{
- (void) lib;
- rtbuf_music_init();
- return 0;
-}
diff --git a/rtbuf_synth.h b/rtbuf_synth.h
deleted file mode 100644
index a1124b1..0000000
--- a/rtbuf_synth.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-#ifndef RTBUF_SYNTH_H
-#define RTBUF_SYNTH_H
-
-#include "rtbuf.h"
-#include "rtbuf_music.h"
-#include "rtbuf_music_type.h"
-#include "rtbuf_signal.h"
-#include "rtbuf_synth_type.h"
-
-/* adsr */
-
-enum {
- RTBUF_MUSIC_NOTE_IN_ENUM(RTBUF_SYNTH_ADSR_IN),
- RTBUF_SYNTH_ADSR_IN_ATTACK,
- RTBUF_SYNTH_ADSR_IN_DECAY,
- RTBUF_SYNTH_ADSR_IN_SUSTAIN,
- RTBUF_SYNTH_ADSR_IN_RELEASE,
- RTBUF_SYNTH_ADSR_IN_N
-};
-
-enum {
- RTBUF_SYNTH_ENVELOPE_STATE_NOT_STARTED = 0,
- RTBUF_SYNTH_ENVELOPE_STATE_STARTED,
- RTBUF_SYNTH_ENVELOPE_STATE_ENDED
-};
-
-#pragma pack(push,1)
-typedef struct rtbuf_synth_adsr_data {
- t_rtbuf_signal signal;
- int state;
-} s_rtbuf_synth_adsr_data;
-#pragma pack(pop)
-
-int rtbuf_synth_adsr (s_rtbuf *rtb);
-int rtbuf_synth_adsr_start (s_rtbuf *rtb);
-
-/* synth */
-
-enum {
- RTBUF_SYNTH_SYNTH_IN_ENVELOPE = 0,
- RTBUF_SYNTH_SYNTH_IN_OSCILLATOR,
- RTBUF_SYNTH_SYNTH_IN_NOTES,
- RTBUF_SYNTH_NOTES_IN_ENUM(RTBUF_SYNTH_SYNTH_IN_NOTE),
- RTBUF_SYNTH_SYNTH_IN_N
-};
-
-#define RTBUF_SYNTH_SYNTH_IN_NOTE_ENVELOPE(i) \
- (RTBUF_SYNTH_SYNTH_IN_NOTE_0_ENVELOPE + 2 * i)
-
-#define RTBUF_SYNTH_SYNTH_IN_NOTE_OSCILLATOR(i) \
- (RTBUF_SYNTH_SYNTH_IN_NOTE_0_OSCILLATOR + 2 * i)
-
-#pragma pack(push,1)
-typedef struct rtbuf_synth_synth_data
-{
- t_rtbuf_signal signal;
- unsigned int note_n;
-} s_rtbuf_synth_synth_data;
-#pragma pack(pop)
-
-int rtbuf_synth_synth (s_rtbuf *rtb);
-int rtbuf_synth_synth_start (s_rtbuf *rtb);
-
-#endif /* RTBUF_SYNTH_H */
diff --git a/rtbuf_synth_adsr.c b/rtbuf_synth_adsr.c
deleted file mode 100644
index 3fbcf51..0000000
--- a/rtbuf_synth_adsr.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- * Copyright 2018 Judy Najnudel <judy.najnudel@gmail.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <stdio.h>
-#include <strings.h>
-#include "rtbuf.h"
-#include "rtbuf_synth.h"
-
-static
-double adsr (double attack, double decay, double sustain,
- double release, double start, double stop)
-{
- double t = start;
- double x;
- if (stop >= 0.0)
- t = start - stop;
- if (t < attack)
- x = t / attack;
- else if (t - attack < decay)
- x = 1.0 + (sustain - 1.0) * (t - attack) / decay;
- else
- x = sustain;
- if (stop < 0.0)
- return x;
- if (stop < release)
- return x * (1.0 - stop / release);
- return 0.0;
-}
-
-void rtbuf_synth_adsr_signal (s_rtbuf *rtb, double *signal,
- double velocity, double start,
- double stop, double r)
-{
- double a =
- rtbuf_signal_sample(rtb, RTBUF_SYNTH_ADSR_IN_ATTACK, 0.02);
- double d =
- rtbuf_signal_sample(rtb, RTBUF_SYNTH_ADSR_IN_DECAY, 0.01);
- double s =
- rtbuf_signal_sample(rtb, RTBUF_SYNTH_ADSR_IN_SUSTAIN, 0.4);
- unsigned int i = 0;
- (void) velocity;
- (void) start;
- (void) stop;
- while (i < RTBUF_SIGNAL_SAMPLES) {
- double dt = (double) i / RTBUF_SIGNAL_SAMPLERATE;
- double start_i = start + dt;
- double stop_i = stop < 0 ? stop : stop + dt;
- a = max(0.0, a);
- d = max(0.0, d);
- s = max(0.0, s);
- r = max(0.0, r);
- *signal = velocity * adsr(a, d, s, r, start_i, stop_i);
- signal++;
- i++;
- }
-}
-
-int rtbuf_synth_adsr (s_rtbuf *rtb)
-{
- double vel;
- double start;
- s_rtbuf_synth_adsr_data *data;
- assert(rtb);
- assert(rtb->data);
- vel = rtbuf_signal_sample(rtb, RTBUF_SYNTH_ADSR_IN_VELOCITY, 0.0);
- start = rtbuf_signal_sample(rtb, RTBUF_SYNTH_ADSR_IN_START, -1.0);
- data = (s_rtbuf_synth_adsr_data*) rtb->data;
- if (data->state == RTBUF_SYNTH_ENVELOPE_STATE_NOT_STARTED) {
- if (vel > 0.0 && start >= 0.0)
- data->state = RTBUF_SYNTH_ENVELOPE_STATE_STARTED;
- else
- return 0;
- }
- if (data->state == RTBUF_SYNTH_ENVELOPE_STATE_ENDED)
- return 0;
- if (data->state == RTBUF_SYNTH_ENVELOPE_STATE_STARTED) {
- double stop =
- rtbuf_signal_sample(rtb, RTBUF_SYNTH_ADSR_IN_STOP, -1.0);
- double rel =
- rtbuf_signal_sample(rtb, RTBUF_SYNTH_ADSR_IN_RELEASE, 0.3);
- if (stop > rel) {
- rtbuf_signal_zero(data->signal);
- data->state = RTBUF_SYNTH_ENVELOPE_STATE_ENDED;
- return 0;
- }
- rtbuf_synth_adsr_signal(rtb, data->signal, vel, start, stop, rel);
- return 0;
- }
- assert(data->state != data->state);
- return 0;
-}
-
-int rtbuf_synth_adsr_start (s_rtbuf *rtb)
-{
- s_rtbuf_synth_adsr_data *data;
- assert(rtb->data);
- assert(rtb->proc);
- assert(rtb->proc->out_bytes == sizeof(*data));
- data = (s_rtbuf_synth_adsr_data*) rtb->data;
- data->state = RTBUF_SYNTH_ENVELOPE_STATE_NOT_STARTED;
- bzero(data->signal, sizeof(t_rtbuf_signal));
- return 0;
-}
diff --git a/rtbuf_synth_synth.c b/rtbuf_synth_synth.c
deleted file mode 100644
index a165606..0000000
--- a/rtbuf_synth_synth.c
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <assert.h>
-#include <stdio.h>
-#include <strings.h>
-#include "rtbuf.h"
-#include "rtbuf_synth.h"
-#include "rtbuf_synth_type.h"
-
-s_rtbuf * rtbuf_in_rtbuf (s_rtbuf *rtb, unsigned int in)
-{
- int i;
- assert(in < rtb->proc->in_n);
- if ((i = rtb->in[in].rtb) < 0)
- return 0;
- return &g_rtbuf[i];
-}
-
-s_rtbuf * rtbuf_synth_synth_note_envelope (s_rtbuf *rtb, unsigned int i)
-{
- unsigned int j;
- assert(i < RTBUF_MUSIC_NOTE_MAX);
- j = RTBUF_SYNTH_SYNTH_IN_NOTE_ENVELOPE(i);
- return rtbuf_in_rtbuf(rtb, j);
-}
-
-s_rtbuf * rtbuf_synth_synth_note_oscillator (s_rtbuf *rtb,
- unsigned int i)
-{
- unsigned int j;
- assert(i < RTBUF_MUSIC_NOTE_MAX);
- j = RTBUF_SYNTH_SYNTH_IN_NOTE_OSCILLATOR(i);
- return rtbuf_in_rtbuf(rtb, j);
-}
-
-void rtbuf_synth_synth_delete_note (s_rtbuf *rtb,
- unsigned int i)
-{
- s_rtbuf *env = rtbuf_synth_synth_note_envelope(rtb, i);
- s_rtbuf *osc = rtbuf_synth_synth_note_oscillator(rtb, i);
- s_rtbuf_synth_synth_data *data;
- data = (s_rtbuf_synth_synth_data*) rtb->data;
- if (env || osc) {
- printf("synth_synth_delete_note %u\n", i);
- if (env)
- rtbuf_delete(env);
- if (osc)
- rtbuf_delete(osc);
- data->note_n--;
- }
-}
-
-void rtbuf_synth_synth_delete_notes (s_rtbuf *rtb)
-{
- s_rtbuf_synth_synth_data *data;
- unsigned int i = 0;
- data = (s_rtbuf_synth_synth_data*) rtb->data;
- while (i < RTBUF_MUSIC_NOTE_MAX && data->note_n > 0) {
- rtbuf_synth_synth_delete_note(rtb, i);
- i++;
- }
-}
-
-s_rtbuf * rtbuf_synth_synth_new_envelope (s_rtbuf *rtb,
- unsigned int i)
-{
- s_rtbuf *ref = rtbuf_in_rtbuf(rtb, RTBUF_SYNTH_SYNTH_IN_ENVELOPE);
- int env_i;
- s_rtbuf *env;
- unsigned int env_vel;
- unsigned int env_freq;
- unsigned int env_start;
- unsigned int env_stop;
- s_rtbuf_binding *v = &rtb->in[RTBUF_SYNTH_SYNTH_IN_NOTES];
- unsigned int kbd_i = v->rtb;
- unsigned int kbd_notes = v->out;
- unsigned int note_vel = RTBUF_MUSIC_NOTE_IN_VELOCITY(kbd_notes, i);
- unsigned int note_freq = RTBUF_MUSIC_NOTE_IN_FREQUENCY(kbd_notes, i);
- unsigned int note_start = RTBUF_MUSIC_NOTE_IN_START(kbd_notes, i);
- unsigned int note_stop = RTBUF_MUSIC_NOTE_IN_STOP(kbd_notes, i);
- assert(rtb > g_rtbuf);
- if (!ref)
- return 0;
- if((env_i = rtbuf_clone(ref)) < 0)
- return 0;
- env = &g_rtbuf[env_i];
- env_vel = rtbuf_in_find(env, "velocity");
- env_freq = rtbuf_in_find(env, "frequency");
- env_start = rtbuf_in_find(env, "start");
- env_stop = rtbuf_in_find(env, "stop");
- rtbuf_bind(kbd_i, note_vel , env, env_vel);
- rtbuf_bind(kbd_i, note_freq , env, env_freq);
- rtbuf_bind(kbd_i, note_start, env, env_start);
- rtbuf_bind(kbd_i, note_stop , env, env_stop);
- rtbuf_bind(env_i, 0, rtb, RTBUF_SYNTH_SYNTH_IN_NOTE_ENVELOPE(i));
- if (env->proc->start)
- env->proc->start(env);
- if (env->proc->f)
- env->proc->f(env);
- /* rtbuf_print_long(env_i); */
- printf("synth_synth_new_envelope %u\n", i);
- return env;
-}
-
-s_rtbuf * rtbuf_synth_synth_new_oscillator (s_rtbuf *rtb,
- unsigned int i)
-{
- s_rtbuf *ref =
- rtbuf_in_rtbuf(rtb, RTBUF_SYNTH_SYNTH_IN_OSCILLATOR);
- int osc_i;
- s_rtbuf *osc;
- unsigned int osc_freq;
- s_rtbuf_binding *v = &rtb->in[RTBUF_SYNTH_SYNTH_IN_NOTES];
- unsigned int kbd_i = v->rtb;
- unsigned int kbd_notes = v->out;
- unsigned int note_freq = RTBUF_MUSIC_NOTE_IN_FREQUENCY(kbd_notes, i);
- assert(rtb > g_rtbuf);
- if (!ref)
- return 0;
- if ((osc_i = rtbuf_clone(ref)) < 0)
- return 0;
- osc = &g_rtbuf[osc_i];
- osc_freq = rtbuf_in_find(osc, "frequency");
- rtbuf_bind(kbd_i, note_freq, osc, osc_freq);
- rtbuf_bind(osc_i, 0, rtb, RTBUF_SYNTH_SYNTH_IN_NOTE_OSCILLATOR(i));
- if (osc->proc->start)
- osc->proc->start(osc);
- if (osc->proc->f)
- osc->proc->f(osc);
- /* rtbuf_print_long(osc_i); */
- return osc;
-}
-
-void rtbuf_synth_synth_update_note_signal (s_rtbuf *rtb,
- unsigned int i)
-{
- s_rtbuf_synth_synth_data *data;
- s_rtbuf_signal_fun env;
- s_rtbuf_signal_fun osc;
- unsigned int j = 0;
- double *signal;
- assert(rtb);
- assert(rtb->data);
- assert(i < RTBUF_MUSIC_NOTE_MAX);
- rtbuf_signal_fun(rtb, RTBUF_SYNTH_SYNTH_IN_NOTE_ENVELOPE(i), &env);
- rtbuf_signal_fun(rtb, RTBUF_SYNTH_SYNTH_IN_NOTE_OSCILLATOR(i), &osc);
- data = (s_rtbuf_synth_synth_data *) rtb->data;
- signal = data->signal;
- while (j < RTBUF_SIGNAL_SAMPLES) {
- double e = env.sample_fun(env.signal, j);
- double o = osc.sample_fun(osc.signal, j);
- e = max(0.0, e);
- *signal += e * o;
- /* printf(" e=%f o=%f s=%f", e, o, *signal); */
- signal++;
- j++;
- }
-}
-
-void rtbuf_synth_synth_update_note (s_rtbuf *rtb,
- unsigned int i)
-{
- s_rtbuf_synth_synth_data *data;
- s_rtbuf_music_notes *notes =
- rtbuf_music_notes(rtb, RTBUF_SYNTH_SYNTH_IN_NOTES);
- s_rtbuf_music_note *note;
- assert(notes);
- assert(i < RTBUF_MUSIC_NOTE_MAX);
- assert(rtb->data);
- data = (s_rtbuf_synth_synth_data*) rtb->data;
- note = ¬es->note[i];
- if (note->velocity > 0.0 && note->start >= 0.0) {
- s_rtbuf *env = rtbuf_synth_synth_note_envelope(rtb, i);
- s_rtbuf *osc = rtbuf_synth_synth_note_oscillator(rtb, i);
- if (!env || !osc) {
- if (!env)
- env = rtbuf_synth_synth_new_envelope(rtb, i);
- if (!osc)
- osc = rtbuf_synth_synth_new_oscillator(rtb, i);
- data->note_n++;
- }
- if (env && osc) {
- unsigned int env_state_out = rtbuf_proc_out_find(env->proc,
- "state");
- int env_state = rtbuf_out_int(env, env_state_out,
- RTBUF_SYNTH_ENVELOPE_STATE_STARTED);
- if (env_state == RTBUF_SYNTH_ENVELOPE_STATE_STARTED)
- rtbuf_synth_synth_update_note_signal(rtb, i);
- }
- }
- else
- rtbuf_synth_synth_delete_note(rtb, i);
-}
-
-int rtbuf_synth_synth (s_rtbuf *rtb)
-{
- s_rtbuf_music_notes *notes =
- rtbuf_music_notes(rtb, RTBUF_SYNTH_SYNTH_IN_NOTES);
- s_rtbuf_synth_synth_data *data;
- unsigned int i = 0;
- unsigned int notes_n = notes ? notes->note_n : 0;
- unsigned int n;
- data = (s_rtbuf_synth_synth_data*) rtb->data;
- n = data->note_n;
- rtbuf_signal_zero(data->signal);
- while (i < RTBUF_MUSIC_NOTE_MAX && (n > 0 || notes_n > 0)) {
- s_rtbuf_music_note *note = notes ? ¬es->note[i] : 0;
- if (rtbuf_music_note_p(note))
- notes_n--;
- if (rtbuf_synth_synth_note_envelope(rtb, i))
- n--;
- rtbuf_synth_synth_update_note(rtb, i);
- i++;
- }
- return 0;
-}
-
-int rtbuf_synth_synth_start (s_rtbuf *rtb)
-{
- s_rtbuf_synth_synth_data *data;
- assert(rtb->proc->out_bytes == sizeof(*data));
- data = (s_rtbuf_synth_synth_data*) rtb->data;
- return 0;
-}
-
-int rtbuf_synth_synth_stop (s_rtbuf *rtb)
-{
- rtbuf_synth_synth_delete_notes(rtb);
- return 0;
-}
diff --git a/rtbuf_synth_type.c b/rtbuf_synth_type.c
deleted file mode 100644
index c127198..0000000
--- a/rtbuf_synth_type.c
+++ /dev/null
@@ -1,45 +0,0 @@
-
-#include <stdio.h>
-#include "rtbuf.h"
-#include "rtbuf_music.h"
-#include "rtbuf_music_type.h"
-
-void notes_in ()
-{
- unsigned int i = 0;
- const char *st = "RTBUF_SIGNAL_TYPE";
- printf("\n"
- "#define RTBUF_SYNTH_NOTES_IN(note) \\\n");
- while (i < RTBUF_MUSIC_NOTE_MAX) {
- printf(" { note \"[%u].envelope\" , %s }, \\\n", i, st);
- printf(" { note \"[%u].oscillator\", %s }", i, st);
- if (i < RTBUF_MUSIC_NOTE_MAX - 1)
- printf(", \\");
- printf("\n");
- i++;
- }
- i = 0;
- printf("\n"
- "#define RTBUF_SYNTH_NOTES_IN_ENUM(note) \\\n");
- while (i < RTBUF_MUSIC_NOTE_MAX) {
- printf(" note ## _%u_ENVELOPE , \\\n", i);
- printf(" note ## _%u_OSCILLATOR", i);
- if (i < RTBUF_MUSIC_NOTE_MAX - 1)
- printf(", \\");
- printf("\n");
- i++;
- }
-}
-
-int main ()
-{
- printf("/* file generated by rtbuf_synth_type */\n");
- printf("#ifndef RTBUF_SYNTH_TYPE_H\n"
- "#define RTBUF_SYNTH_TYPE_H\n"
- "\n"
- "#include \"rtbuf_signal_type.h\"\n");
- notes_in();
- printf("\n"
- "#endif\n");
- return 0;
-}
diff --git a/rtbuf_type.c b/rtbuf_type.c
deleted file mode 100644
index 567dc1d..0000000
--- a/rtbuf_type.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <strings.h>
-#include "rtbuf_type.h"
-#include "symbol.h"
-
-s_data_type g_rtbuf_data_type_type = {
- sizeof(s_rtbuf_type) * 8,
- DATA_TYPE_BITS
-};
-s_data_alloc g_rtbuf_data_type_alloc;
-s_rtbuf_type *g_rtbuf_data_type;
-
-void rtbuf_type_init ()
-{
- data_alloc_init(&g_rtbuf_data_type_alloc, &g_rtbuf_data_type_type,
- RTBUF_TYPE_MAX, 0, 0);
- g_rtbuf_data_type = g_rtbuf_data_type_alloc.mem;
- assert(g_rtbuf_data_type);
- rtbuf_type_define("char" , sizeof(char));
- rtbuf_type_define("unsigned char" , sizeof(unsigned char));
- rtbuf_type_define("short" , sizeof(short));
- rtbuf_type_define("unsigned short", sizeof(unsigned short));
- rtbuf_type_define("int" , sizeof(int));
- rtbuf_type_define("unsigned int" , sizeof(unsigned int));
- rtbuf_type_define("long" , sizeof(long));
- rtbuf_type_define("unsigned long" , sizeof(unsigned long));
- rtbuf_type_define("float" , sizeof(float));
- rtbuf_type_define("double" , sizeof(double));
-}
-
-s_rtbuf_type * rtbuf_type_new (const char *name, unsigned int size)
-{
- s_rtbuf_type *rt = data_new(&g_rtbuf_data_type_alloc);
- if (!rt)
- return 0;
- rt->name = symbol_intern(name);
- rt->t.bits = size * 8;
- rt->t.type = DATA_TYPE_BITS;
- return rt;
-}
-
-void rtbuf_type_delete (s_rtbuf_type *rt)
-{
- assert(rt);
- data_delete(&g_rtbuf_data_type_alloc, rt);
-}
-
-s_rtbuf_type * rtbuf_type_find (symbol name)
-{
- unsigned int i = 0;
- unsigned int n =
- g_rtbuf_data_type_alloc.n - g_rtbuf_data_type_alloc.free_n;
- while (i < g_rtbuf_data_type_alloc.n && n > 0) {
- if (g_rtbuf_data_type[i].name) {
- if (name == g_rtbuf_data_type[i].name)
- return &g_rtbuf_data_type[i];
- n--;
- }
- i++;
- }
- return 0;
-}
-
-s_rtbuf_type * rtbuf_type_define (const char *name, unsigned int size)
-{
- s_rtbuf_type *found = rtbuf_type_find(name);
- if (found && found->t.bits == size * 8)
- return found;
- return rtbuf_type_new(name, size);
-}
-
-s_rtbuf_type * rtbuf_type_parse_array (const char *name)
-{
- char *bracket = strchr(name, '[');
- char *right_bracket = bracket ? strchr(bracket, ']') : 0;
- if (right_bracket) {
- char buf[1024];
- unsigned int lb = bracket - name;
- unsigned int rb = right_bracket - name;
- s_rtbuf_type *element_type;
- unsigned int size;
- strlcpy(buf, name, sizeof(buf));
- buf[lb] = 0;
- if ((element_type = rtbuf_type(buf)) == 0)
- return 0;
- buf[rb] = 0;
- size = atoi(&buf[lb + 1]);
- return rtbuf_type_new(name, element_type->t.bits / 8 * size);
- }
- return 0;
-}
-
-s_rtbuf_type * rtbuf_type_parse_pointer (const char *name)
-{
- char *star = strchr(name, '*');
- if (star && star[1] == 0)
- return rtbuf_type_new(name, sizeof(void*));
- return 0;
-}
-
-s_rtbuf_type * rtbuf_type (const char *name)
-{
- const char *sym = symbol_find(name);
- s_rtbuf_type *rt;
- if (!(rt = sym ? rtbuf_type_find(sym) : 0) &&
- !(rt = rtbuf_type_parse_array(name)) &&
- !(rt = rtbuf_type_parse_pointer(name)))
- printf("type not found: %s\n", name);
- return rt;
-}
-
-s_rtbuf_type * rtbuf_type_array (const char *element_type,
- unsigned int size)
-{
- char buf[1024];
- snprintf(buf, sizeof(buf), "%s[%u]", element_type, size);
- return rtbuf_type(buf);
-}
diff --git a/rtbuf_type.h b/rtbuf_type.h
deleted file mode 100644
index 86c131a..0000000
--- a/rtbuf_type.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-#ifndef RTBUF_TYPE_H
-#define RTBUF_TYPE_H
-
-#include "data.h"
-#include "rtbuf_defs.h"
-#include "symbol.h"
-
-struct rtbuf_type {
- symbol name;
- s_data_type t;
- s_data_alloc alloc;
-};
-
-#define RTBUF_TYPE_MAX 1024
-
-void rtbuf_type_init ();
-s_rtbuf_type * rtbuf_type_new (const char *name,
- unsigned int size);
-void rtbuf_type_delete (s_rtbuf_type *rt);
-s_rtbuf_type * rtbuf_type_find (symbol name);
-s_rtbuf_type * rtbuf_type_define (const char *name,
- unsigned int size);
-s_rtbuf_type * rtbuf_type (const char *name);
-s_rtbuf_type * rtbuf_type_array (const char *element_type,
- unsigned int size);
-
-#define RTBUF_TYPE_CHAR_ARRAY(size) ("char[" #size "]")
-#define RTBUF_TYPE_SHORT_ARRAY(size) ("short[" #size "]")
-#define RTBUF_TYPE_DOUBLE_ARRAY(size) ("double[" #size "]")
-
-#endif
diff --git a/rtbuf_var.c b/rtbuf_var.c
deleted file mode 100644
index fadc3f8..0000000
--- a/rtbuf_var.c
+++ /dev/null
@@ -1,71 +0,0 @@
-#include <assert.h>
-#include <stdio.h>
-#include "data.h"
-#include "rtbuf_var.h"
-#include "rtbuf.h"
-
-s_data_type g_rtbuf_var_type = {
- sizeof(s_rtbuf_var) * 8,
- DATA_TYPE_BITS
-};
-s_data_alloc g_rtbuf_var_alloc;
-s_rtbuf_var *g_rtbuf_var;
-
-void rtbuf_var_init (void)
-{
- data_alloc_init(&g_rtbuf_var_alloc, &g_rtbuf_var_type, RTBUF_VAR_MAX, NULL, NULL);
- g_rtbuf_var = g_rtbuf_var_alloc.mem;
- assert(g_rtbuf_var);
-}
-
-s_rtbuf_var * rtbuf_var_new (const char *name)
-{
- s_rtbuf_var *v = data_new(&g_rtbuf_var_alloc);
- if (v)
- v->name = symbol_intern(name);
- return v;
-}
-
-s_rtbuf_var * rtbuf_var_find (const char *name)
-{
- s_rtbuf_var *v = g_rtbuf_var + g_rtbuf_var_alloc.n;
- unsigned i = g_rtbuf_var_alloc.n;
- const char *sym = symbol_find(name);
- if (sym)
- while (v--, i--) {
- assert(v >= g_rtbuf_var);
- if (v->name == sym)
- return v;
- }
- return NULL;
-}
-
-s_rtbuf_var * rtbuf_var_rtbuf_set (const char *name, unsigned i)
-{
- s_rtbuf_var *v = rtbuf_var_find(name);
- if (!v)
- v = rtbuf_var_new(name);
- if (v) {
- v->type = RTBUF_VAR_RTBUF;
- v->index = i;
- }
- return v;
-}
-
-void rtbuf_var_print (const s_rtbuf_var *v)
-{
- if (v) {
- printf("%s = ", v->name);
- switch (v->type) {
- case RTBUF_VAR_NULL:
- printf("NULL");
- fflush(stdout);
- break;
- case RTBUF_VAR_RTBUF:
- rtbuf_print_long(v->index);
- break;
- default:
- assert(0);
- }
- }
-}
diff --git a/rtbuf_var.h b/rtbuf_var.h
deleted file mode 100644
index 714012f..0000000
--- a/rtbuf_var.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef RTBUF_VAR_H
-#define RTBUF_VAR_H
-
-#include "rtbuf_defs.h"
-
-#define RTBUF_VAR_MAX 1000
-
-struct rtbuf_var {
- e_rtbuf_var_type type;
- const char *name;
- unsigned index;
-};
-
-void rtbuf_var_init (void);
-s_rtbuf_var * rtbuf_var_find (const char *name);
-s_rtbuf_var * rtbuf_var_rtbuf_set (const char *name, unsigned i);
-void rtbuf_var_print (const s_rtbuf_var *v);
-
-#endif
diff --git a/rtbuf_widget.c b/rtbuf_widget.c
deleted file mode 100644
index 9b2629d..0000000
--- a/rtbuf_widget.c
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <assert.h>
-#include <gtk/gtk.h>
-#include "rtbuf_gtk.h"
-#include "rtbuf_input_widget.h"
-#include "rtbuf_output_widget.h"
-#include "rtbuf_widget.h"
-#include "rtbuf.h"
-
-struct _RtbufWidgetPrivate {
- s_rtbuf *rtbuf;
- GtkWidget *event_box;
- GtkWidget *label;
- GtkWidget *inputs;
- GtkWidget *outputs;
-};
-
-enum {
- PROP_0,
- PROP_RTBUF,
- PROP_LABEL,
- LAST_PROP
-};
-
-static GParamSpec *rtbuf_widget_props[LAST_PROP];
-
-static void rtbuf_widget_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec);
-static void rtbuf_widget_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec);
-static void rtbuf_widget_finalize (GObject *object);
-static gboolean rtbuf_widget_draw (GtkWidget *widget, cairo_t *cr,
- gpointer data);
-
-G_DEFINE_TYPE_WITH_PRIVATE (RtbufWidget, rtbuf_widget, GTK_TYPE_BOX)
-
-static void
-rtbuf_widget_class_init (RtbufWidgetClass *klass)
-{
- GObjectClass *gobject_class = (GObjectClass*) klass;
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
- printf("rtbuf_widget class init\n");
- gobject_class->finalize = rtbuf_widget_finalize;
- gobject_class->set_property = rtbuf_widget_set_property;
- gobject_class->get_property = rtbuf_widget_get_property;
- rtbuf_widget_props[PROP_LABEL] =
- g_param_spec_string("label",
- "Label",
- "Text of the frame's label",
- NULL,
- G_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
- rtbuf_widget_props[PROP_RTBUF] =
- g_param_spec_pointer("rtbuf",
- "Rtbuf",
- "Pointer to a s_rtbuf",
- G_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
- g_object_class_install_properties(gobject_class, LAST_PROP, rtbuf_widget_props);
- gtk_widget_class_set_template_from_resource(widget_class,
- "/rtbuf/rtbuf_widget.ui");
- gtk_widget_class_bind_template_child_private(widget_class,
- RtbufWidget, event_box);
- gtk_widget_class_bind_template_child_private(widget_class,
- RtbufWidget, label);
- gtk_widget_class_bind_template_child_private(widget_class,
- RtbufWidget, inputs);
- gtk_widget_class_bind_template_child_private(widget_class,
- RtbufWidget, outputs);
-}
-
-static void
-rtbuf_widget_init (RtbufWidget *widget)
-{
- RtbufWidgetPrivate *priv;
- s_rtbuf_proc *proc;
- unsigned int i = 0;
- printf("rtbuf_widget init\n");
- priv = rtbuf_widget_get_instance_private(widget);
- gtk_widget_init_template(GTK_WIDGET(widget));
- g_signal_connect(G_OBJECT(widget), "draw",
- G_CALLBACK(rtbuf_widget_draw), priv);
-}
-
-static void
-rtbuf_widget_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- RtbufWidget *widget = RTBUF_WIDGET(object);
- RtbufWidgetPrivate *priv = rtbuf_widget_get_instance_private(widget);
- switch (prop_id) {
- case PROP_LABEL:
- rtbuf_widget_set_label(widget, g_value_get_string(value));
- break;
- case PROP_RTBUF:
- rtbuf_widget_set_rtbuf(widget, g_value_get_pointer(value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
- break;
- }
-}
-
-static void
-rtbuf_widget_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- RtbufWidget *widget = RTBUF_WIDGET(object);
- RtbufWidgetPrivate *priv = rtbuf_widget_get_instance_private(widget);
- switch (prop_id) {
- case PROP_LABEL:
- g_value_set_string(value, rtbuf_widget_get_label(widget));
- break;
- case PROP_RTBUF:
- g_value_set_pointer(value, priv->rtbuf);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
- break;
- }
-}
-
-static void
-rtbuf_widget_finalize (GObject *object)
-{
- RtbufWidget *widget = RTBUF_WIDGET(object);
- RtbufWidgetPrivate *priv = rtbuf_widget_get_instance_private(widget);
- g_clear_object(&priv->label);
- g_clear_object(&priv->inputs);
- g_clear_object(&priv->outputs);
- G_OBJECT_CLASS(rtbuf_widget_parent_class)->finalize(object);
-}
-
-static gboolean
-rtbuf_widget_draw (GtkWidget *widget, cairo_t *cr, gpointer data)
-{
- GtkAllocation alloc;
- gtk_widget_get_allocation(widget, &alloc);
- cairo_new_path(cr);
- cairo_rectangle(cr, 0, 0, alloc.width, alloc.height);
- cairo_set_source_rgb(cr, 1.0, 1.0, 0.7);
- cairo_fill(cr);
- (void) data;
- return FALSE;
-}
-
-RtbufWidget *
-rtbuf_widget_new (s_rtbuf *rtb, const gchar *label)
-{
- return (RtbufWidget*) g_object_new(RTBUF_WIDGET_TYPE,
- "label", label,
- "rtbuf", rtb,
- NULL);
-}
-
-void gtk_container_clear_widget (GtkWidget *widget,
- gpointer data)
-{
- GtkContainer *container = (GtkContainer*) data;
- gtk_container_remove(container, widget);
-}
-
-void gtk_container_clear (GtkContainer *container)
-{
- gtk_container_foreach(container,
- gtk_container_clear_widget,
- container);
-}
-
-void rtbuf_widget_set_rtbuf (RtbufWidget *widget, s_rtbuf *rtbuf)
-{
-
- RtbufWidgetPrivate *priv = rtbuf_widget_get_instance_private(widget);
- GtkContainer *inputs;
- GtkContainer *outputs;
- s_rtbuf_proc *proc;
- unsigned int i;
- printf("rtbuf_widget set rtbuf\n");
- priv->rtbuf = rtbuf;
- proc = rtbuf->proc;
- inputs = GTK_CONTAINER(priv->inputs);
- outputs = GTK_CONTAINER(priv->outputs);
- gtk_container_clear(inputs);
- for (i = 0; i < proc->in_n; i++) {
- RtbufInputWidget *input_widget =
- rtbuf_input_widget_new(priv->rtbuf, i);
- gtk_container_add(inputs, GTK_WIDGET(input_widget));
- }
- gtk_container_clear(outputs);
- for (i = 0; i < proc->out_n; i++) {
- RtbufOutputWidget *output_widget =
- rtbuf_output_widget_new(priv->rtbuf, i);
- gtk_container_add(outputs, GTK_WIDGET(output_widget));
- }
-}
-
-void rtbuf_widget_set_label (RtbufWidget *widget,
- const gchar *label)
-{
- g_return_if_fail(IS_RTBUF_WIDGET(widget));
- if (label) {
- RtbufWidgetPrivate *priv = rtbuf_widget_get_instance_private(widget);
- if (GTK_IS_LABEL(priv->label))
- gtk_label_set_text(GTK_LABEL(priv->label), label);
- }
-}
-
-const gchar *
-rtbuf_widget_get_label (RtbufWidget *widget)
-{
- RtbufWidgetPrivate *priv =
- rtbuf_widget_get_instance_private(widget);
- if (priv && priv->label)
- return gtk_label_get_text(GTK_LABEL(priv->label));
- return NULL;
-}
-
-GtkWidget *
-rtbuf_widget_get_event_box (RtbufWidget *widget)
-{
- RtbufWidgetPrivate *priv =
- rtbuf_widget_get_instance_private(widget);
- if (priv)
- return priv->event_box;
- return NULL;
-}
-
-s_rtbuf *
-rtbuf_widget_get_rtbuf (RtbufWidget *widget)
-{
- RtbufWidgetPrivate *priv =
- rtbuf_widget_get_instance_private(widget);
- if (priv)
- return priv->rtbuf;
- return NULL;
-}
-
-void rtbuf_widget_connect_inputs (RtbufWidget *widget,
- const char *signal,
- GCallback callback)
-{
- RtbufWidgetPrivate *priv =
- rtbuf_widget_get_instance_private(widget);
- s_signal_binding sb = { signal, callback };
- gtk_container_foreach(GTK_CONTAINER(priv->inputs),
- rtbuf_input_widget_connect,
- &sb);
-}
-
-void rtbuf_widget_connect_input_checks (RtbufWidget *widget,
- const char *signal,
- GCallback callback)
-{
- RtbufWidgetPrivate *priv =
- rtbuf_widget_get_instance_private(widget);
- s_signal_binding sb = { signal, callback };
- gtk_container_foreach(GTK_CONTAINER(priv->inputs),
- rtbuf_input_widget_connect_check,
- &sb);
-}
-
-void rtbuf_widget_connect_output_checks (RtbufWidget *widget,
- const char *signal,
- GCallback callback)
-{
- RtbufWidgetPrivate *priv =
- rtbuf_widget_get_instance_private(widget);
- s_signal_binding sb = { signal, callback };
- gtk_container_foreach(GTK_CONTAINER(priv->outputs),
- rtbuf_output_widget_connect_check,
- &sb);
-}
diff --git a/rtbuf_widget.h b/rtbuf_widget.h
deleted file mode 100644
index 2e36a7d..0000000
--- a/rtbuf_widget.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2020 Thomas de Grivel <thoxdg@gmail.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef RTBUF_WIDGET_H
-#define RTBUF_WIDGET_H
-
-#include "rtbuf.h"
-
-#define RTBUF_WIDGET_TYPE \
- (rtbuf_widget_get_type())
-
-#define RTBUF_WIDGET(object) \
- (G_TYPE_CHECK_INSTANCE_CAST((object), RTBUF_WIDGET_TYPE, \
- RtbufWidget))
-
-#define RTBUF_WIDGET_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), RTBUF_WIDGET_TYPE, \
- RtbufWidgetClass))
-
-#define IS_RTBUF_WIDGET(object) \
- (G_TYPE_CHECK_INSTANCE_TYPE((object), RTBUF_WIDGET_TYPE))
-
-#define IS_RTBUF_WIDGET_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass), RTBUF_WIDGET_TYPE))
-
-#define RTBUF_WIDGET_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS((obj), RTBUF_WIDGET_TYPE, \
- RtbufWidgetClass))
-
-typedef struct _RtbufWidget RtbufWidget;
-typedef struct _RtbufWidgetClass RtbufWidgetClass;
-typedef struct _RtbufWidgetPrivate RtbufWidgetPrivate;
-
-struct _RtbufWidget {
- GtkBox box;
-};
-
-struct _RtbufWidgetClass {
- GtkBoxClass parent_class;
-};
-
-GType rtbuf_widget_get_type (void) G_GNUC_CONST;
-RtbufWidget * rtbuf_widget_new (s_rtbuf *rtbuf, const gchar *label);
-void rtbuf_widget_set_rtbuf (RtbufWidget *widget,
- s_rtbuf *rtbuf);
-void rtbuf_widget_set_label (RtbufWidget *widget,
- const gchar *label);
-const gchar * rtbuf_widget_get_label (RtbufWidget *widget);
-GtkWidget * rtbuf_widget_get_event_box (RtbufWidget *widget);
-s_rtbuf * rtbuf_widget_get_rtbuf (RtbufWidget *widget);
-void rtbuf_widget_connect_inputs (RtbufWidget *widget,
- const char *signal,
- GCallback callback);
-void rtbuf_widget_connect_input_checks (RtbufWidget *widget,
- const char *signal,
- GCallback callback);
-void rtbuf_widget_connect_output_checks (RtbufWidget *widget,
- const char *signal,
- GCallback callback);
-
-#endif
diff --git a/rtbuf_widget.ui b/rtbuf_widget.ui
deleted file mode 100644
index d9ce4b3..0000000
--- a/rtbuf_widget.ui
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.22.1 -->
-<interface>
- <requires lib="gtk+" version="3.20"/>
- <template class="RtbufWidget" parent="GtkBox">
- <property name="visible">True</property>
- <property name="app_paintable">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkEventBox" id="event_box">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkLabel" id="label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">rtbuf</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox" id="inputs">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox" id="outputs">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- </template>
-</interface>
diff --git a/symbol.c b/symbol.c
deleted file mode 100644
index 2069d42..0000000
--- a/symbol.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <strings.h>
-#include "symbol.h"
-
-char g_string[STRING_MAX];
-unsigned int g_string_n = 0;
-
-const char *g_symbols[SYMBOL_MAX];
-unsigned int g_symbols_n = 0;
-
-void symbols_init () {
- bzero(g_string, sizeof(g_string));
- bzero(g_symbols, sizeof(g_symbols));
-}
-
-symbol symbol_new (const char *name)
-{
- unsigned int i = 0;
- if (g_symbols_n == SYMBOL_MAX) {
- fprintf(stderr, "maximum number of symbols exceeded\n");
- return 0;
- }
- while (i < SYMBOL_MAX) {
- if (g_symbols[i] == 0) {
- const char *in = name;
- char *out = &g_string[g_string_n];
- g_symbols[i] = out;
- while (*in) {
- *out++ = *in++;
- g_string_n++;
- }
- *out = 0;
- g_string_n++;
- g_symbols_n++;
- return g_symbols[i];
- }
- i++;
- }
- return 0;
-}
-
-symbol symbol_find (const char *name)
-{
- unsigned int i = 0;
- unsigned int n = g_symbols_n;
- while (i < SYMBOL_MAX && n > 0) {
- if (g_symbols[i]) {
- if (name == g_symbols[i] ||
- strcmp(name, g_symbols[i]) == 0)
- return g_symbols[i];
- n--;
- }
- i++;
- }
- return 0;
-}
-
-symbol symbol_intern (const char *name)
-{
- symbol sym = symbol_find(name);
- if (sym == 0)
- sym = symbol_new(name);
- return sym;
-}
diff --git a/symbol.h b/symbol.h
deleted file mode 100644
index 02271dd..0000000
--- a/symbol.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2018 Thomas de Grivel <thoxdg@gmail.com> +33614550127
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-#ifndef SYMBOL_H
-#define SYMBOL_H
-
-typedef const char *symbol;
-
-#define STRING_MAX 65536
-extern char g_string[STRING_MAX];
-extern unsigned int g_string_n;
-
-#define SYMBOL_MAX 32768
-extern symbol g_symbols[SYMBOL_MAX];
-extern unsigned int g_symbols_n;
-
-void symbols_init ();
-symbol symbol_new (symbol name);
-void symbol_delete (symbol sym);
-symbol symbol_find (symbol name);
-symbol symbol_intern (const char *name);
-
-#endif