From cc6a97929407231798a70335e9b29254d235bc85 Mon Sep 17 00:00:00 2001 From: Minecon724 Date: Fri, 8 Nov 2024 17:48:30 +0100 Subject: [PATCH] WIP --- .gitignore | 2 ++ Makefile | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ include/easy.h | 7 +++++++ src/easy.c | 17 +++++++++++++++++ src/main.c | 29 +++++++++++++++++++++++++++++ 5 files changed, 104 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 include/easy.h create mode 100644 src/easy.c create mode 100644 src/main.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..01f9cb9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +build/ +.vscode/ \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ce06b42 --- /dev/null +++ b/Makefile @@ -0,0 +1,49 @@ +# Compiler to use +CC ?= gcc + +CFLAGS = -Wall -Wextra -std=gnu17 -I include $(shell pkg-config --cflags lilv-0) +LDFLAGS = -llilv-0 + +# Directory for build outputs +BUILD_DIR := build + +# Name of the output program +PROGRAM_NAME ?= easyexport + +# Find all .c files in the source directory +SRCS := $(wildcard src/*.c) + +# Generate corresponding .o file names in the build/obj directory +OBJS := $(patsubst src/%.c,$(BUILD_DIR)/obj/%.o,$(SRCS)) + +# Name of the final executable +TARGET := $(BUILD_DIR)/$(PROGRAM_NAME) + + +# Default target: build the executable +all: CFLAGS += -O3 +all: $(TARGET) + +# Debug target +debug: CFLAGS += -O0 -g +debug: $(TARGET) + +# Declare 'all' and 'clean' as phony targets (not files) +.PHONY: all debug clean + +# Rule to link object files into the final executable +$(TARGET): $(OBJS) | $(BUILD_DIR) + $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) + du -b $(TARGET) # Size of the executable in bytes + +# Rule to compile source files into object files +$(BUILD_DIR)/obj/%.o: src/%.c | $(BUILD_DIR)/obj + $(CC) $(CFLAGS) -c $< -o $@ + +# Create build directories if they don't exist +$(BUILD_DIR) $(BUILD_DIR)/obj: + mkdir -p $@ + +# Clean target: remove the build directory +clean: + rm -rf $(BUILD_DIR) \ No newline at end of file diff --git a/include/easy.h b/include/easy.h new file mode 100644 index 0000000..bf15334 --- /dev/null +++ b/include/easy.h @@ -0,0 +1,7 @@ +#ifndef EASY_H +#define EASY_H + +#include +const LilvPlugin* easy_load_plugin(LilvWorld* world, const char* uri); + +#endif \ No newline at end of file diff --git a/src/easy.c b/src/easy.c new file mode 100644 index 0000000..093b0f1 --- /dev/null +++ b/src/easy.c @@ -0,0 +1,17 @@ +#include + +const LilvPlugin* easy_load_plugin(LilvWorld* world, const char* uri) { + const LilvPlugins* plugin_list = lilv_world_get_all_plugins(world); + + LilvNode* plugin_uri = lilv_new_uri(world, uri); + const LilvPlugin* plugin = lilv_plugins_get_by_uri(plugin_list, plugin_uri); + lilv_node_free(plugin_uri); + + if (plugin != NULL) { + LilvNode *plugin_name = lilv_plugin_get_name(plugin); + printf("Loaded plugin \"%s\"\n", lilv_node_as_string(plugin_name)); + lilv_node_free(plugin_name); + } + + return plugin; +} \ No newline at end of file diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..d84925e --- /dev/null +++ b/src/main.c @@ -0,0 +1,29 @@ +#include +#include +#include + +/* +http://lsp-plug.in/plugins/lv2/comp_delay_x2_stereo +http://lsp-plug.in/plugins/lv2/para_equalizer_x32_lr +http://calf.sourceforge.net/plugins/BassEnhancer +*/ + +const LilvPlugin* easy_load_plugin(LilvWorld* world, const char* uri); + +int main() { + LilvWorld* world = lilv_world_new(); + lilv_world_load_all(world); + + // + + const LilvPlugin* plugin = easy_load_plugin(world, "http://lsp-plug.in/plugins/lv2/comp_delay_x2_stereo"); + if (plugin == NULL) { + fprintf(stderr, "Plugin not found: comp_delay_x2_stereo (from lsp-plug.in)\n"); + return 1; + } + + // + + LilvInstance* instance = lilv_plugin_instantiate(plugin, 48000.0, NULL); +} +