Compare commits

...

8 Commits

Author SHA1 Message Date
9310b08670 necessary cleaning of single comment 2025-07-25 08:20:00 +02:00
Stefano D'Angelo
59838dda25 made lv2 template and test plugin c++ friendly 2025-07-18 17:33:23 +02:00
1e5d2b49da add extra fields to product.json for external templates 2025-07-18 11:39:44 +02:00
69cff1ebab vst3 typo bug fix 2025-07-08 15:15:23 +02:00
Stefano D'Angelo
50118f66a4 fix ios issues 2025-06-08 08:57:35 +02:00
Stefano D'Angelo
6695731d09 update copyright headers 2025-06-05 08:22:52 +02:00
Stefano D'Angelo
9a86ef2de8 use shell pipefail in makefiles 2025-06-05 08:21:03 +02:00
bb9d68c633 extended file copy/generation api to allow chmod 2025-06-04 11:33:36 +02:00
14 changed files with 116 additions and 60 deletions

View File

@ -1,7 +1,7 @@
#
# Tibia
#
# Copyright (C) 2023, 2024 Orastron Srl unipersonale
# Copyright (C) 2023-2025 Orastron Srl unipersonale
#
# Tibia is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -18,6 +18,8 @@
# File author: Stefano D'Angelo
#
SHELL := bash -o pipefail
TEMPLATE := android
include vars.mk

View File

@ -18,6 +18,8 @@
# File author: Stefano D'Angelo
#
SHELL := bash -o pipefail
TEMPLATE := cmd
include vars.mk

View File

@ -1,7 +1,7 @@
#
# Tibia
#
# Copyright (C) 2023, 2024 Orastron Srl unipersonale
# Copyright (C) 2023-2025 Orastron Srl unipersonale
#
# Tibia is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -18,6 +18,8 @@
# File author: Stefano D'Angelo
#
SHELL := bash -o pipefail
TEMPLATE := daisy-seed
include vars.mk

View File

@ -1,7 +1,7 @@
#
# Tibia
#
# Copyright (C) 2024 Orastron Srl unipersonale
# Copyright (C) 2024, 2025 Orastron Srl unipersonale
#
# Tibia is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -18,6 +18,8 @@
# File author: Stefano D'Angelo
#
SHELL := bash -o pipefail
TEMPLATE := ios
include vars.mk
@ -34,7 +36,7 @@ BUILD_DATA_DIR := build/gen/res
-include $(MKINC_DIR)/vars-pre.mk
CFLAGS := -O3 -Wall -Wpedantic -Wextra
CFLAGS_ALL := -I$(DATA_DIR)/src -I$(PLUGIN_DIR) -I$(API_DIR) -fvisiblity=hidden $(CFLAGS_EXTRA) $(CFLAGS)
CFLAGS_ALL := -I$(DATA_DIR)/src -I$(PLUGIN_DIR) -I$(API_DIR) -fvisibility=hidden $(CFLAGS_EXTRA) $(CFLAGS)
CXXFLAGS := $(CFLAGS)
CXXFLAGS_ALL := -I$(DATA_DIR)/src -I$(PLUGIN_DIR) -I$(API_DIR) -fvisibility=hidden $(CXXFLAGS_EXTRA) $(CXXFLAGS)

View File

@ -164,6 +164,7 @@ void (^midiNotifyBlock)(const MIDINotification *message) = ^(const MIDINotificat
};
void (^midiReceiveBlock)(const MIDIEventList *evtlist, void *srcConnRefCon) = ^(const MIDIEventList *evtlist, void *srcConnRefCon) {
(void)srcConnRefCon;
const MIDIEventPacket *p = evtlist->packet;
for (UInt32 i = 0; i < evtlist->numPackets; i++) {
for (UInt32 j = 0; j < p->wordCount; j++) {

View File

@ -26,5 +26,5 @@ module.exports = function (data, api) {
api.generateFileFromTemplateFile(`src${sep}index.html`, `src${sep}index.html`, data);
api.copyFile(`src${sep}native.mm`, `src${sep}native.mm`);
api.copyFile(`src${sep}app-Bridging-Header.h`, `src${sep}app-Bridging-Header.h`);
api.copyFile(`src${sep}app.swift`, `src${sep}app.swift`, data);
api.copyFile(`src${sep}app.swift`, `src${sep}app.swift`);
};

View File

@ -18,6 +18,8 @@
# File author: Stefano D'Angelo
#
SHELL := bash -o pipefail
TEMPLATE := lv2
include vars.mk
@ -69,7 +71,7 @@ LDFLAGS :=
LDFLAGS_ALL := -shared $(shell pkg-config --libs lv2) $(LDFLAGS_EXTRA) $(LDFLAGS)
CXXFLAGS := $(CFLAGS)
CXXFLAGS_ALL := -I$(DATA_DIR)/src -I$(PLUGIN_DIR) -I$(API_DIR) -fPIC $(CXXFLAGS_EXTRA) $(CXXFLAGS)
CXXFLAGS_ALL := -I$(DATA_DIR)/src -I$(PLUGIN_DIR) -I$(API_DIR) $(shell pkg-config --cflags lv2) -fPIC -fvisibility=hidden $(CXXFLAGS_EXTRA) $(CXXFLAGS)
ifeq ($(UNAME_S), Darwin)
CFLAGS_ALL := $(CFLAGS_ALL) -arch arm64 -arch x86_64

View File

@ -58,7 +58,11 @@
#endif
#if (DATA_PRODUCT_CONTROL_INPUTS_N > 0) && defined(DATA_STATE_DSP_CUSTOM)
# include <stdatomic.h>
# ifdef __cplusplus
# include <atomic>
# else
# include <stdatomic.h>
# endif
# if defined(_WIN32) || defined(__CYGWIN__)
# include <processthreadsapi.h>
# define yield SwitchToThread
@ -113,7 +117,11 @@ typedef struct {
float params[DATA_PRODUCT_CONTROL_INPUTS_N];
# ifdef DATA_STATE_DSP_CUSTOM
float params_sync[DATA_PRODUCT_CONTROL_INPUTS_N];
# ifdef __cplusplus
std::atomic_flag sync_lock_flag;
# else
atomic_flag sync_lock_flag;
# endif
char synced;
char loaded;
# endif
@ -142,14 +150,22 @@ static const char * get_bundle_path_cb(void *handle) {
#ifdef DATA_STATE_DSP_CUSTOM
static void state_lock_cb(void *handle) {
plugin_instance * i = (plugin_instance *)handle;
# ifdef __cplusplus
while (i->sync_lock_flag.test_and_set())
# else
while (atomic_flag_test_and_set(&i->sync_lock_flag))
# endif
yield();
i->synced = 0;
}
static void state_unlock_cb(void *handle) {
plugin_instance * i = (plugin_instance *)handle;
# ifdef __cplusplus
i->sync_lock_flag.clear();
# else
atomic_flag_clear(&i->sync_lock_flag);
# endif
}
static int state_write_cb(void *handle, const char *data, size_t length) {
@ -172,7 +188,12 @@ static LV2_Handle instantiate(const struct LV2_Descriptor * descriptor, double s
(void)descriptor;
(void)bundle_path;
plugin_instance *instance = malloc(sizeof(plugin_instance));
// make C++ compilers happy
const char * missing;
plugin_callbacks cbs;
size_t req;
plugin_instance *instance = (plugin_instance *)malloc(sizeof(plugin_instance));
if (instance == NULL)
goto err_instance;
@ -181,7 +202,7 @@ static LV2_Handle instantiate(const struct LV2_Descriptor * descriptor, double s
goto err_bundle_path;
// from https://lv2plug.in/book
const char * missing = lv2_features_query(features,
missing = lv2_features_query(features,
LV2_LOG__log, &instance->logger.log, false,
LV2_URID__map, &instance->map, true,
NULL);
@ -205,17 +226,15 @@ static LV2_Handle instantiate(const struct LV2_Descriptor * descriptor, double s
}
#endif
plugin_callbacks cbs = {
/* .handle = */ (void *)instance,
/* .format = */ "lv2",
/* .get_bindir = */ get_bundle_path_cb,
/* .get_datadir = */ get_bundle_path_cb
};
cbs.handle = (void *)instance;
cbs.format = "lv2";
cbs.get_bindir = get_bundle_path_cb;
cbs.get_datadir = get_bundle_path_cb;
plugin_init(&instance->p, &cbs);
instance->sample_rate = (float)sample_rate;
plugin_set_sample_rate(&instance->p, instance->sample_rate);
size_t req = plugin_mem_req(&instance->p);
req = plugin_mem_req(&instance->p);
if (req != 0) {
instance->mem = malloc(req);
if (instance->mem == NULL) {
@ -265,34 +284,34 @@ static void connect_port(LV2_Handle instance, uint32_t port, void * data_locatio
plugin_instance * i = (plugin_instance *)instance;
#if DATA_PRODUCT_AUDIO_INPUT_CHANNELS_N > 0
if (port < DATA_PRODUCT_AUDIO_INPUT_CHANNELS_N) {
i->x[port] = data_location;
i->x[port] = (const float *)data_location;
return;
}
port -= DATA_PRODUCT_AUDIO_INPUT_CHANNELS_N;
#endif
#if DATA_PRODUCT_AUDIO_OUTPUT_CHANNELS_N > 0
if (port < DATA_PRODUCT_AUDIO_OUTPUT_CHANNELS_N) {
i->y[port] = data_location;
i->y[port] = (float *)data_location;
return;
}
port -= DATA_PRODUCT_AUDIO_OUTPUT_CHANNELS_N;
#endif
#if DATA_PRODUCT_MIDI_INPUTS_N > 0
if (port < DATA_PRODUCT_MIDI_INPUTS_N) {
i->x_midi[port] = data_location;
i->x_midi[port] = (const LV2_Atom_Sequence *)data_location;
return;
}
port -= DATA_PRODUCT_MIDI_INPUTS_N;
#endif
#if DATA_PRODUCT_MIDI_OUTPUTS_N > 0
if (port < DATA_PRODUCT_MIDI_OUTPUTS_N) {
i->y_midi[port] = data_location;
i->y_midi[port] = (LV2_Atom_Sequence *)data_location;
return;
}
port -= DATA_PRODUCT_MIDI_OUTPUTS_N;
#endif
#if (DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N) > 0
i->c[port] = data_location;
i->c[port] = (float *)data_location;
#endif
}
@ -306,9 +325,13 @@ static void activate(LV2_Handle instance) {
# ifdef DATA_STATE_DSP_CUSTOM
for (uint32_t j = 0; j < DATA_PRODUCT_CONTROL_INPUTS_N; j++)
i->params_sync[j] = i->params[j];
# ifdef __cplusplus
i->sync_lock_flag.clear();
# else
// why is this not correct?
// i->sync_lock_flag = ATOMIC_FLAG_INIT;
atomic_flag_clear(&i->sync_lock_flag);
# endif
i->synced = 1;
i->loaded = 0;
# endif
@ -333,7 +356,11 @@ static void run(LV2_Handle instance, uint32_t sample_count) {
#if DATA_PRODUCT_CONTROL_INPUTS_N > 0
# ifdef DATA_STATE_DSP_CUSTOM
# ifdef __cplusplus
_Bool locked = !i->sync_lock_flag.test_and_set();
# else
_Bool locked = !atomic_flag_test_and_set(&i->sync_lock_flag);
# endif
if (locked) {
if (!i->synced) {
if (i->loaded) {
@ -373,7 +400,11 @@ static void run(LV2_Handle instance, uint32_t sample_count) {
# ifdef DATA_STATE_DSP_CUSTOM
if (locked)
# ifdef __cplusplus
i->sync_lock_flag.clear();
# else
atomic_flag_clear(&i->sync_lock_flag);
# endif
# endif
#endif
@ -467,7 +498,7 @@ static LV2_State_Status state_restore(LV2_Handle instance, LV2_State_Retrieve_Fu
}
size_t length;
uint32_t type, xflags; // jalv 1.6.6 crashes using NULL as per spec, so we have these two
const char * data = retrieve(handle, i->uri_state_data, &length, &type, &xflags);
const char * data = (const char *)retrieve(handle, i->uri_state_data, &length, &type, &xflags);
if (data == NULL) {
lv2_log_error(&i->logger, "Cannot restore state since property <%s> could not be retrieved\n", DATA_LV2_URI "#state_data");
return LV2_STATE_ERR_NO_PROPERTY;
@ -561,7 +592,12 @@ static LV2UI_Handle ui_instantiate(const LV2UI_Descriptor * descriptor, const ch
(void)descriptor;
(void)plugin_uri;
ui_instance *instance = malloc(sizeof(ui_instance));
// make C++ compilers happy
char has_parent;
void *parent;
plugin_ui_callbacks cbs;
ui_instance *instance = (ui_instance *)malloc(sizeof(ui_instance));
if (instance == NULL)
goto err_instance;
@ -569,8 +605,8 @@ static LV2UI_Handle ui_instantiate(const LV2UI_Descriptor * descriptor, const ch
if (instance->bundle_path == NULL)
goto err_bundle_path;
char has_parent = 0;
void *parent = NULL;
has_parent = 0;
parent = NULL;
# if DATA_PRODUCT_CONTROL_INPUTS_N > 0
instance->has_touch = 0;
# endif
@ -587,17 +623,15 @@ static LV2UI_Handle ui_instantiate(const LV2UI_Descriptor * descriptor, const ch
# endif
}
plugin_ui_callbacks cbs = {
/* .handle = */ (void *)instance,
/* .format = */ "lv2",
/* .get_bindir = */ ui_get_bundle_path_cb,
/* .get_datadir = */ ui_get_bundle_path_cb,
cbs.handle = (void *)instance;
cbs.format = "lv2";
cbs.get_bindir = ui_get_bundle_path_cb;
cbs.get_datadir = ui_get_bundle_path_cb;
# if DATA_PRODUCT_CONTROL_INPUTS_N > 0
/* .set_parameter_begin = */ ui_set_parameter_begin_cb,
/* .set_parameter = */ ui_set_parameter_cb,
/* .set_parameter_end = */ ui_set_parameter_end_cb,
cbs.set_parameter_begin = ui_set_parameter_begin_cb;
cbs.set_parameter = ui_set_parameter_cb;
cbs.set_parameter_end = ui_set_parameter_end_cb;
# endif
};
# if DATA_PRODUCT_CONTROL_INPUTS_N > 0
instance->write = write_function;
instance->controller = controller;

View File

@ -2177,7 +2177,7 @@ static struct Steinberg_IPlugView* controllerCreateView(void* thisInterface, Ste
controller *c = (controller *)((char *)thisInterface - offsetof(controller, vtblIEditController));
size_t i;
for (i = 0; i < c->viewsCount; c++)
for (i = 0; i < c->viewsCount; i++)
if (c->views[i] == NULL)
break;
if (i == c->viewsCount) {

View File

@ -24,7 +24,7 @@ build/web/index.html: $(DATA_DIR)/src/index.html | build/web
build/web/key.pem: build/web/cert.pem
build/web/cert.pem: | build
yes "" | openssl req -x509 -newkey rsa:2048 -keyout build/web/key.pem -out build/web/cert.pem -days 365 -nodes 2>/dev/null
openssl req -x509 -newkey rsa:2048 -keyout build/web/key.pem -out build/web/cert.pem -days 365 -nodes -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" 2>/dev/null
strip-web-demo: build/web/index.html
$(eval TMP := $(shell mktemp /tmp/index.XXXXXX))

View File

@ -18,6 +18,8 @@
# File author: Stefano D'Angelo
#
SHELL := bash -o pipefail
TEMPLATE := web
include vars.mk

View File

@ -25,8 +25,8 @@
typedef struct {
void *widget;
vinci *vinci;
window *window;
vinci *ui;
window *w;
int param_down;
float gain;
@ -57,16 +57,16 @@ static void draw_rect(window *w, uint32_t x, uint32_t y, uint32_t width, uint32_
}
static void draw_slider(plugin_ui *pui, int id, float value) {
const int w = window_get_width(pui->window);
const int h = window_get_height(pui->window);
draw_rect(pui->window, 0.1 * w, 0.15 * (id + 1) * h, 0.8 * w * value, 0.1 * h, 0x6789ab);
draw_rect(pui->window, 0.1 * w + 0.8 * w * value, 0.15 * (id + 1) * h, 0.8 * w * (1.f - value), 0.1 * h, 0x1223bc);
const int w = window_get_width(pui->w);
const int h = window_get_height(pui->w);
draw_rect(pui->w, 0.1 * w, 0.15 * (id + 1) * h, 0.8 * w * value, 0.1 * h, 0x6789ab);
draw_rect(pui->w, 0.1 * w + 0.8 * w * value, 0.15 * (id + 1) * h, 0.8 * w * (1.f - value), 0.1 * h, 0x1223bc);
}
static void draw_button(plugin_ui *pui, int id, char value) {
const int w = window_get_width(pui->window);
const int h = window_get_height(pui->window);
draw_rect(pui->window, 0.4 * w, 0.15 * (id + 1) * h, 0.2 * w, 0.1 * h, value ? 0x6789ab : 0x1223bc);
const int w = window_get_width(pui->w);
const int h = window_get_height(pui->w);
draw_rect(pui->w, 0.4 * w, 0.15 * (id + 1) * h, 0.2 * w, 0.1 * h, value ? 0x6789ab : 0x1223bc);
}
static void on_close(window *w) {
@ -191,11 +191,11 @@ static plugin_ui *plugin_ui_create(char has_parent, void *parent, plugin_ui_call
wcbs.on_window_resize = on_window_resize;
instance->param_down = -1;
instance->vinci = vinci_new();
instance->window = window_new(instance->vinci, has_parent ? parent : NULL, WIDTH, HEIGHT, &wcbs);
instance->widget = window_get_handle(instance->window);
window_set_data(instance->window, (void*) instance);
window_show(instance->window);
instance->ui = vinci_new();
instance->w = window_new(instance->ui, has_parent ? parent : NULL, WIDTH, HEIGHT, &wcbs);
instance->widget = window_get_handle(instance->w);
window_set_data(instance->w, (void*) instance);
window_show(instance->w);
// just some valid values to allow drawing
instance->gain = 0.f;
@ -204,20 +204,20 @@ static plugin_ui *plugin_ui_create(char has_parent, void *parent, plugin_ui_call
instance->bypass = 0;
instance->y_z1 = 0.f;
on_window_resize(instance->window, window_get_width(instance->window), window_get_height(instance->window));
on_window_resize(instance->w, window_get_width(instance->w), window_get_height(instance->w));
instance->cbs = *cbs;
return instance;
}
static void plugin_ui_free(plugin_ui *instance) {
window_free(instance->window);
vinci_destroy(instance->vinci);
window_free(instance->w);
vinci_destroy(instance->ui);
free(instance);
}
static void plugin_ui_idle(plugin_ui *instance) {
vinci_idle(instance->vinci);
vinci_idle(instance->ui);
}
static void plugin_ui_set_parameter(plugin_ui *instance, size_t index, float value) {

View File

@ -2,7 +2,9 @@
"product": {
"name": "Tibia test product",
"version": "1.0.0",
"buildVersion": "0",
"buildVersion": 0,
"description": "A toy plugin to test Tibia",
"copyright": "Copyright © 2021-2025 Orastron Srl unipersonale",
"bundleName": "tibia-test",
"buses": [
{
@ -136,7 +138,8 @@
],
"ui": {
"userResizable": true,
"selfResizable": false
"selfResizable": false,
"highResolution": true
},
"state": {
"dspCustom": true

14
tibia
View File

@ -115,21 +115,27 @@ var doT = require("dot");
doT.templateSettings.strip = false;
var api = {
generateFileFromTemplateFile: function (templateFile, outFile, data) {
generateFileFromTemplateFile: function (templateFile, outFile, data, mode) {
if (!outputData)
return;
var dir = outputDir + path.sep + path.dirname(outFile);
fs.mkdirSync(dir, { recursive: true });
var t = doT.template(fs.readFileSync(template + path.sep + templateFile, { encoding: "utf-8" }));
fs.writeFileSync(outputDir + path.sep + outFile, t(data), { encoding: "utf-8" });
var outputFile = outputDir + path.sep + outFile;
fs.writeFileSync(outputFile, t(data), { encoding: "utf-8" });
if (mode !== undefined)
fs.chmodSync(outputFile, mode);
},
copyFile: function (inFile, outFile) {
copyFile: function (inFile, outFile, mode) {
if (!outputCommon)
return;
var dir = outputDir + path.sep + path.dirname(outFile);
fs.mkdirSync(dir, { recursive: true });
fs.copyFileSync(template + path.sep + inFile, outputDir + path.sep + outFile);
var outputFile = outputDir + path.sep + outFile;
fs.copyFileSync(template + path.sep + inFile, outputFile);
if (mode !== undefined)
fs.chmodSync(outputFile, mode);
},
templateDir: template