Compare commits
20 Commits
Author | SHA1 | Date | |
---|---|---|---|
a5727492cd | |||
402df416f8 | |||
a437e54408 | |||
![]() |
261db0e579 | ||
![]() |
fc7b20a956 | ||
0417448cbd | |||
1f620b46fd | |||
786a999c5e | |||
7311d47b9a | |||
![]() |
429543e7af | ||
bdfcf19fdf | |||
44b21010f3 | |||
1a4d158bc0 | |||
b3da04681d | |||
33e4dc39ce | |||
5ddc28440c | |||
5211cf5a3e | |||
35f9c0c091 | |||
f5c9ebab6a | |||
c81cc828aa |
@ -20,7 +20,7 @@ Feel free to try it out anyway and perhaps give us some feedback (we'd appreciat
|
|||||||
|
|
||||||
## Legal
|
## Legal
|
||||||
|
|
||||||
Copyright (C) 2021-2024 Orastron Srl unipersonale.
|
Copyright (C) 2021-2025 Orastron Srl unipersonale.
|
||||||
|
|
||||||
Authors: Stefano D'Angelo, Paolo Marrone.
|
Authors: Stefano D'Angelo, Paolo Marrone.
|
||||||
|
|
||||||
|
@ -50,8 +50,19 @@ KOTLIN_STDLIB_FILE := $(KOTLIN_DIR)/kotlin-stdlib-$(KOTLIN_STDLIB_VERSION).jar
|
|||||||
KOTLINX_COROUTINES_CORE_FILE := $(KOTLIN_DIR)/kotlinx-coroutines-core-$(KOTLINX_COROUTINES_CORE_VERSION).jar
|
KOTLINX_COROUTINES_CORE_FILE := $(KOTLIN_DIR)/kotlinx-coroutines-core-$(KOTLINX_COROUTINES_CORE_VERSION).jar
|
||||||
KOTLINX_COROUTINES_CORE_JVM_FILE := $(KOTLIN_DIR)/kotlinx-coroutines-core-jvm-$(KOTLINX_COROUTINES_CORE_JVM_VERSION).jar
|
KOTLINX_COROUTINES_CORE_JVM_FILE := $(KOTLIN_DIR)/kotlinx-coroutines-core-jvm-$(KOTLINX_COROUTINES_CORE_JVM_VERSION).jar
|
||||||
|
|
||||||
CC := $(NDK_DIR)/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi$(MIN_API)-clang
|
ifeq ($(OS), Windows_NT)
|
||||||
CXX := $(NDK_DIR)/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi$(MIN_API)-clang++
|
NDK_BIN_DIR ?= $(NDK_DIR)/toolchains/llvm/prebuilt/windows-x86_64/bin/
|
||||||
|
else
|
||||||
|
UNAME_S := $(shell uname -s)
|
||||||
|
ifeq ($(UNAME_S), Darwin)
|
||||||
|
NDK_BIN_DIR ?= $(NDK_DIR)/toolchains/llvm/prebuilt/darwin-x86_64/bin/
|
||||||
|
else
|
||||||
|
NDK_BIN_DIR ?= $(NDK_DIR)/toolchains/llvm/prebuilt/linux-x86_64/bin/
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
CC := $(NDK_BIN_DIR)/armv7a-linux-androideabi$(MIN_API)-clang
|
||||||
|
CXX := $(NDK_BIN_DIR)/armv7a-linux-androideabi$(MIN_API)-clang++
|
||||||
JC := javac
|
JC := javac
|
||||||
|
|
||||||
APKSIGNER := $(BUILD_TOOLS_DIR)/apksigner
|
APKSIGNER := $(BUILD_TOOLS_DIR)/apksigner
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
BUNDLE_NAME := {{=it.product.bundleName}}
|
BUNDLE_NAME := {{=it.product.bundleName}}
|
||||||
JAVA_PACKAGE_NAME := {{=it.android.javaPackageName}}
|
JAVA_PACKAGE_NAME := {{=it.android.javaPackageName}}
|
||||||
|
ANDROID_VERSION := {{=it.android.androidVersion}}
|
||||||
|
|
||||||
{{?(it.android_make?.commonDir || it.make?.commonDir)}}
|
{{?(it.android_make?.commonDir || it.make?.commonDir)}}
|
||||||
COMMON_DIR := {{=it.android_make?.commonDir ?? (it.make?.commonDir ?? "")}}
|
COMMON_DIR := {{=it.android_make?.commonDir ?? (it.make?.commonDir ?? "")}}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
{{??}}
|
{{??}}
|
||||||
<uses-sdk android:minSdkVersion="26" /> <!-- for androidx core and AAudio -->
|
<uses-sdk android:minSdkVersion="26" /> <!-- for androidx core and AAudio -->
|
||||||
{{?}}
|
{{?}}
|
||||||
<uses-sdk android:targetSdkVersion="34" />
|
<uses-sdk android:targetSdkVersion="{{=it.android.androidVersion}}" />
|
||||||
<application android:label="{{=it.product.name}}">
|
<application android:label="{{=it.product.name}}">
|
||||||
<activity android:name=".MainActivity" android:label="{{=it.product.name}}" android:exported="true">
|
<activity android:name=".MainActivity" android:label="{{=it.product.name}}" android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
@ -38,8 +38,8 @@ BUILD_DATA_DIR := build/$(BUNDLE_DIR)
|
|||||||
ifeq ($(OS), Windows_NT)
|
ifeq ($(OS), Windows_NT)
|
||||||
DLL_SUFFIX := .dll
|
DLL_SUFFIX := .dll
|
||||||
UI_TYPE := WindowsUI
|
UI_TYPE := WindowsUI
|
||||||
LV2DIR := $(shell echo '$(COMMONPROGRAMFILES)' | sed 's:\\:/:g')/LV2
|
LV2DIR := $(subst \,/,$(COMMONPROGRAMFILES))/LV2
|
||||||
LV2DIR_USER := $(shell echo '$(APPDATA)' | sed 's:\\:/:g')/LV2
|
LV2DIR_USER := $(subst \,/,$(APPDATA))/LV2
|
||||||
CC := gcc
|
CC := gcc
|
||||||
CXX := g++
|
CXX := g++
|
||||||
else
|
else
|
||||||
@ -123,6 +123,8 @@ strip: $(STRIP_PREREQS)
|
|||||||
#rdfproc lv2_store parse build/$(BUNDLE_DIR)/manifest.ttl turtle || (rm lv2_store* && exit 1)
|
#rdfproc lv2_store parse build/$(BUNDLE_DIR)/manifest.ttl turtle || (rm lv2_store* && exit 1)
|
||||||
#rdfproc lv2_store serialize ntriples > build/$(BUNDLE_DIR)/manifest.ttl || (rm lv2_store* && exit 1)
|
#rdfproc lv2_store serialize ntriples > build/$(BUNDLE_DIR)/manifest.ttl || (rm lv2_store* && exit 1)
|
||||||
#rm lv2_store*
|
#rm lv2_store*
|
||||||
|
#f=`cat build/$(BUNDLE_DIR)/manifest.ttl` && echo "$f" | sed '/^[[:space:]]**$/d' > build/$(BUNDLE_DIR)/manifest.ttl
|
||||||
|
f=`sed '/^[[:space:]]*$$/d' build/$(BUNDLE_DIR)/manifest.ttl` && echo "$$f" > build/$(BUNDLE_DIR)/manifest.ttl
|
||||||
|
|
||||||
install: all
|
install: all
|
||||||
@for d in `find build/$(BUNDLE_DIR) -type d`; do \
|
@for d in `find build/$(BUNDLE_DIR) -type d`; do \
|
||||||
|
@ -93,6 +93,7 @@ static float adjust_param(size_t index, float value) {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
plugin p;
|
plugin p;
|
||||||
|
float sample_rate;
|
||||||
#if DATA_PRODUCT_AUDIO_INPUT_CHANNELS_N > 0
|
#if DATA_PRODUCT_AUDIO_INPUT_CHANNELS_N > 0
|
||||||
const float * x[DATA_PRODUCT_AUDIO_INPUT_CHANNELS_N];
|
const float * x[DATA_PRODUCT_AUDIO_INPUT_CHANNELS_N];
|
||||||
#endif
|
#endif
|
||||||
@ -212,7 +213,8 @@ static LV2_Handle instantiate(const struct LV2_Descriptor * descriptor, double s
|
|||||||
};
|
};
|
||||||
plugin_init(&instance->p, &cbs);
|
plugin_init(&instance->p, &cbs);
|
||||||
|
|
||||||
plugin_set_sample_rate(&instance->p, sample_rate);
|
instance->sample_rate = (float)sample_rate;
|
||||||
|
plugin_set_sample_rate(&instance->p, instance->sample_rate);
|
||||||
size_t req = plugin_mem_req(&instance->p);
|
size_t req = plugin_mem_req(&instance->p);
|
||||||
if (req != 0) {
|
if (req != 0) {
|
||||||
instance->mem = malloc(req);
|
instance->mem = malloc(req);
|
||||||
@ -451,7 +453,7 @@ static LV2_State_Status state_save(LV2_Handle instance, LV2_State_Store_Function
|
|||||||
/* .set_parameter = */ NULL
|
/* .set_parameter = */ NULL
|
||||||
# endif
|
# endif
|
||||||
};
|
};
|
||||||
return plugin_state_save(&i->p, &cbs) == 0 ? LV2_STATE_SUCCESS : LV2_STATE_ERR_UNKNOWN;
|
return plugin_state_save(&i->p, &cbs, i->sample_rate) == 0 ? LV2_STATE_SUCCESS : LV2_STATE_ERR_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
static LV2_State_Status state_restore(LV2_Handle instance, LV2_State_Retrieve_Function retrieve, LV2_State_Handle handle, uint32_t flags, const LV2_Feature * const * features) {
|
static LV2_State_Status state_restore(LV2_Handle instance, LV2_State_Retrieve_Function retrieve, LV2_State_Handle handle, uint32_t flags, const LV2_Feature * const * features) {
|
||||||
@ -479,7 +481,7 @@ static LV2_State_Status state_restore(LV2_Handle instance, LV2_State_Retrieve_Fu
|
|||||||
/* .set_parameter = */ state_set_parameter_cb
|
/* .set_parameter = */ state_set_parameter_cb
|
||||||
# endif
|
# endif
|
||||||
};
|
};
|
||||||
return plugin_state_load(&cbs, data, length) == 0 ? LV2_STATE_SUCCESS : LV2_STATE_ERR_UNKNOWN;
|
return plugin_state_load(&cbs, i->sample_rate, data, length) == 0 ? LV2_STATE_SUCCESS : LV2_STATE_ERR_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const void * extension_data(const char * uri) {
|
static const void * extension_data(const char * uri) {
|
||||||
|
@ -31,12 +31,33 @@ MKINC_DIR ?= $(COMMON_DIR)
|
|||||||
BUNDLE_DIR := $(BUNDLE_NAME).vst3
|
BUNDLE_DIR := $(BUNDLE_NAME).vst3
|
||||||
|
|
||||||
ifeq ($(OS), Windows_NT)
|
ifeq ($(OS), Windows_NT)
|
||||||
|
DLL_SUFFIX := .vst3
|
||||||
|
VST3DIR := $(subst \,/,$(COMMONPROGRAMFILES))/VST3
|
||||||
|
VST3DIR_USER := $(subst \,/,$(LOCALAPPDATA))/Programs/Common/VST3
|
||||||
|
CC := gcc
|
||||||
|
CXX := g++
|
||||||
|
MACHINE := $(shell $(CC) -dumpmachine | sed 's:-.*::g')
|
||||||
|
ifeq ($(MACHINE), x86_64)
|
||||||
VST3_PLATFORM := x86_64-win
|
VST3_PLATFORM := x86_64-win
|
||||||
|
endif
|
||||||
|
ifeq ($(MACHINE), aarch64)
|
||||||
|
VST3_PLATFORM := arm64-win
|
||||||
|
endif
|
||||||
else
|
else
|
||||||
UNAME_S := $(shell uname -s)
|
UNAME_S := $(shell uname -s)
|
||||||
ifeq ($(UNAME_S), Darwin)
|
ifeq ($(UNAME_S), Darwin)
|
||||||
|
DLL_SUFFIX :=
|
||||||
|
VST3DIR := /Library/Audio/Plug-Ins/VST3
|
||||||
|
VST3DIR_USER := $(HOME)/Library/Audio/Plug-Ins/VST3
|
||||||
|
CC := clang
|
||||||
|
CXX := clang++
|
||||||
VST3_PLATFORM := MacOS
|
VST3_PLATFORM := MacOS
|
||||||
else
|
else
|
||||||
|
DLL_SUFFIX := .so
|
||||||
|
VST3DIR := /usr/local/lib/vst3
|
||||||
|
VST3DIR_USER := $(HOME)/.vst3
|
||||||
|
CC := gcc
|
||||||
|
CXX := g++
|
||||||
VST3_PLATFORM := $(shell uname -m)-linux
|
VST3_PLATFORM := $(shell uname -m)-linux
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@ -47,29 +68,6 @@ BUILD_DATA_DIR := build/$(BUNDLE_DIR)/Contents/Resources
|
|||||||
|
|
||||||
-include $(MKINC_DIR)/vars-pre.mk
|
-include $(MKINC_DIR)/vars-pre.mk
|
||||||
|
|
||||||
ifeq ($(OS), Windows_NT)
|
|
||||||
DLL_SUFFIX := .vst3
|
|
||||||
VST3DIR := $(shell echo '$(COMMONPROGRAMFILES)' | sed 's:\\:/:g')/VST3
|
|
||||||
VST3DIR_USER := $(shell echo '$(LOCALAPPDATA)' | sed 's:\\:/:g')/Programs/Common/VST3
|
|
||||||
CC := gcc
|
|
||||||
CXX := g++
|
|
||||||
else
|
|
||||||
UNAME_S := $(shell uname -s)
|
|
||||||
ifeq ($(UNAME_S), Darwin)
|
|
||||||
DLL_SUFFIX :=
|
|
||||||
VST3DIR := /Library/Audio/Plug-Ins/VST3
|
|
||||||
VST3DIR_USER := $(HOME)/Library/Audio/Plug-Ins/VST3
|
|
||||||
CC := clang
|
|
||||||
CXX := clang++
|
|
||||||
else
|
|
||||||
DLL_SUFFIX := .so
|
|
||||||
VST3DIR := /usr/local/lib/vst3
|
|
||||||
VST3DIR_USER := $(HOME)/.vst3
|
|
||||||
CC := gcc
|
|
||||||
CXX := g++
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
CFLAGS := -O3 -Wall -Wpedantic -Wextra
|
CFLAGS := -O3 -Wall -Wpedantic -Wextra
|
||||||
CFLAGS_ALL := -I$(DATA_DIR)/src -I$(PLUGIN_DIR) -I$(API_DIR) -fPIC $(CFLAGS_EXTRA) $(CFLAGS)
|
CFLAGS_ALL := -I$(DATA_DIR)/src -I$(PLUGIN_DIR) -I$(API_DIR) -fPIC $(CFLAGS_EXTRA) $(CFLAGS)
|
||||||
|
|
||||||
|
@ -271,7 +271,9 @@ typedef struct pluginInstance {
|
|||||||
Steinberg_uint32 refs;
|
Steinberg_uint32 refs;
|
||||||
Steinberg_FUnknown * context;
|
Steinberg_FUnknown * context;
|
||||||
plugin p;
|
plugin p;
|
||||||
float sampleRate;
|
float lastSampleRate;
|
||||||
|
float curSampleRate;
|
||||||
|
float nextSampleRate;
|
||||||
#if DATA_PRODUCT_PARAMETERS_IN_N > 0
|
#if DATA_PRODUCT_PARAMETERS_IN_N > 0
|
||||||
float parametersIn[DATA_PRODUCT_PARAMETERS_IN_N];
|
float parametersIn[DATA_PRODUCT_PARAMETERS_IN_N];
|
||||||
float parametersInSync[DATA_PRODUCT_PARAMETERS_IN_N];
|
float parametersInSync[DATA_PRODUCT_PARAMETERS_IN_N];
|
||||||
@ -412,6 +414,9 @@ static Steinberg_tresult pluginInitialize(void *thisInterface, struct Steinberg_
|
|||||||
if (p->context != NULL)
|
if (p->context != NULL)
|
||||||
return Steinberg_kResultFalse;
|
return Steinberg_kResultFalse;
|
||||||
p->context = context;
|
p->context = context;
|
||||||
|
p->lastSampleRate = 0.f;
|
||||||
|
p->curSampleRate = 0.f;
|
||||||
|
p->nextSampleRate = 0.f;
|
||||||
|
|
||||||
plugin_callbacks cbs = {
|
plugin_callbacks cbs = {
|
||||||
/* .handle = */ (void *)p,
|
/* .handle = */ (void *)p,
|
||||||
@ -628,7 +633,7 @@ static Steinberg_tresult pluginSetActive(void* thisInterface, Steinberg_TBool st
|
|||||||
p->neededBusesActive = 0;
|
p->neededBusesActive = 0;
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
plugin_set_sample_rate(&p->p, p->sampleRate);
|
plugin_set_sample_rate(&p->p, p->nextSampleRate);
|
||||||
size_t req = plugin_mem_req(&p->p);
|
size_t req = plugin_mem_req(&p->p);
|
||||||
if (req != 0) {
|
if (req != 0) {
|
||||||
p->mem = malloc(req);
|
p->mem = malloc(req);
|
||||||
@ -636,8 +641,11 @@ static Steinberg_tresult pluginSetActive(void* thisInterface, Steinberg_TBool st
|
|||||||
return Steinberg_kOutOfMemory;
|
return Steinberg_kOutOfMemory;
|
||||||
plugin_mem_set(&p->p, p->mem);
|
plugin_mem_set(&p->p, p->mem);
|
||||||
}
|
}
|
||||||
|
p->curSampleRate = p->nextSampleRate;
|
||||||
|
p->lastSampleRate = p->nextSampleRate;
|
||||||
plugin_reset(&p->p);
|
plugin_reset(&p->p);
|
||||||
}
|
} else
|
||||||
|
p->curSampleRate = 0.f;
|
||||||
return Steinberg_kResultOk;
|
return Steinberg_kResultOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -667,7 +675,7 @@ static Steinberg_tresult pluginSetState(void* thisInterface, struct Steinberg_IB
|
|||||||
/* .set_parameter = */ pluginStateSetParameterCb
|
/* .set_parameter = */ pluginStateSetParameterCb
|
||||||
# endif
|
# endif
|
||||||
};
|
};
|
||||||
int err = plugin_state_load(&cbs, data, length);
|
int err = plugin_state_load(&cbs, p->curSampleRate, data, length);
|
||||||
#else
|
#else
|
||||||
// we need to provide a default implementation because of certain hosts (e.g. Ardour)
|
// we need to provide a default implementation because of certain hosts (e.g. Ardour)
|
||||||
int err = 0;
|
int err = 0;
|
||||||
@ -701,7 +709,7 @@ static Steinberg_tresult pluginSetState(void* thisInterface, struct Steinberg_IB
|
|||||||
|
|
||||||
if (data)
|
if (data)
|
||||||
free(data);
|
free(data);
|
||||||
TRACE(err == 0 ? " ok" : " err");
|
TRACE(err == 0 ? " ok\n" : " err\n");
|
||||||
return err == 0 ? Steinberg_kResultOk : Steinberg_kResultFalse;
|
return err == 0 ? Steinberg_kResultOk : Steinberg_kResultFalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -723,7 +731,7 @@ static Steinberg_tresult pluginGetState(void* thisInterface, struct Steinberg_IB
|
|||||||
/* .set_parameter = */ NULL
|
/* .set_parameter = */ NULL
|
||||||
# endif
|
# endif
|
||||||
};
|
};
|
||||||
int err = plugin_state_save(&p->p, &cbs);
|
int err = plugin_state_save(&p->p, &cbs, p->lastSampleRate);
|
||||||
#else
|
#else
|
||||||
// we need to provide a default implementation because of certain hosts (e.g. Ardour)
|
// we need to provide a default implementation because of certain hosts (e.g. Ardour)
|
||||||
int err = 0;
|
int err = 0;
|
||||||
@ -855,7 +863,7 @@ static Steinberg_uint32 pluginGetLatencySamples(void* thisInterface) {
|
|||||||
static Steinberg_tresult pluginSetupProcessing(void* thisInterface, struct Steinberg_Vst_ProcessSetup* setup) {
|
static Steinberg_tresult pluginSetupProcessing(void* thisInterface, struct Steinberg_Vst_ProcessSetup* setup) {
|
||||||
TRACE("plugin IAudioProcessor setup processing\n");
|
TRACE("plugin IAudioProcessor setup processing\n");
|
||||||
pluginInstance *p = (pluginInstance *)((char *)thisInterface - offsetof(pluginInstance, vtblIAudioProcessor));
|
pluginInstance *p = (pluginInstance *)((char *)thisInterface - offsetof(pluginInstance, vtblIAudioProcessor));
|
||||||
p->sampleRate = (float)setup->sampleRate;
|
p->nextSampleRate = (float)setup->sampleRate;
|
||||||
return Steinberg_kResultOk;
|
return Steinberg_kResultOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1372,20 +1380,20 @@ static Steinberg_tresult plugViewIsPlatformTypeSupported(void* thisInterface, St
|
|||||||
# if DATA_PRODUCT_PARAMETERS_N > 0
|
# if DATA_PRODUCT_PARAMETERS_N > 0
|
||||||
# if DATA_PRODUCT_PARAMETERS_IN_N > 0
|
# if DATA_PRODUCT_PARAMETERS_IN_N > 0
|
||||||
static void plugViewUpdateParameterIn(plugView *view, size_t index) {
|
static void plugViewUpdateParameterIn(plugView *view, size_t index) {
|
||||||
if (view->ui)
|
if (view && view->ui)
|
||||||
plugin_ui_set_parameter(view->ui, parameterInData[index].index, view->ctrl->parametersIn[index]);
|
plugin_ui_set_parameter(view->ui, parameterInData[index].index, view->ctrl->parametersIn[index]);
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if DATA_PRODUCT_PARAMETERS_OUT_N > 0
|
# if DATA_PRODUCT_PARAMETERS_OUT_N > 0
|
||||||
static void plugViewUpdateParameterOut(plugView *view, size_t index) {
|
static void plugViewUpdateParameterOut(plugView *view, size_t index) {
|
||||||
if (view->ui)
|
if (view && view->ui)
|
||||||
plugin_ui_set_parameter(view->ui, parameterOutData[index].index, view->ctrl->parametersOut[index]);
|
plugin_ui_set_parameter(view->ui, parameterOutData[index].index, view->ctrl->parametersOut[index]);
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
static void plugViewUpdateAllParameters(plugView *view) {
|
static void plugViewUpdateAllParameters(plugView *view) {
|
||||||
if (view->ui == NULL)
|
if (view == NULL || view->ui == NULL)
|
||||||
return;
|
return;
|
||||||
# if DATA_PRODUCT_PARAMETERS_IN_N > 0
|
# if DATA_PRODUCT_PARAMETERS_IN_N > 0
|
||||||
for (size_t i = 0; i < DATA_PRODUCT_PARAMETERS_IN_N; i++)
|
for (size_t i = 0; i < DATA_PRODUCT_PARAMETERS_IN_N; i++)
|
||||||
@ -1858,7 +1866,7 @@ static Steinberg_tresult controllerSetComponentState(void* thisInterface, struct
|
|||||||
/* .set_parameter = */ controllerStateSetParameterCb
|
/* .set_parameter = */ controllerStateSetParameterCb
|
||||||
# endif
|
# endif
|
||||||
};
|
};
|
||||||
int err = plugin_state_load(&cbs, data, length);
|
int err = plugin_state_load(&cbs, -1.f, data, length); // -1.f means "does not apply"
|
||||||
#else
|
#else
|
||||||
// we need to provide a default implementation because of certain hosts (e.g. Reaper)
|
// we need to provide a default implementation because of certain hosts (e.g. Reaper)
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"android": {
|
"android": {
|
||||||
"javaPackageName": "com.example.tibia_test"
|
"javaPackageName": "com.example.tibia_test",
|
||||||
|
"androidVersion": "36"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"ios_make": {
|
"ios_make": {
|
||||||
"headerSearchPaths": [ "../../../../../miniaudio" ],
|
"headerSearchPaths": [ "../../../../../miniaudio" ],
|
||||||
"deploymentTarget": 16.6
|
"deploymentTarget": "16.6"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,8 @@ static float parse_float(const uint8_t *data) {
|
|||||||
return v.f;
|
return v.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int plugin_state_save(plugin *instance, const plugin_state_callbacks *cbs) {
|
static int plugin_state_save(plugin *instance, const plugin_state_callbacks *cbs, float last_sample_rate) {
|
||||||
|
(void)last_sample_rate;
|
||||||
uint8_t data[13];
|
uint8_t data[13];
|
||||||
cbs->lock(cbs->handle);
|
cbs->lock(cbs->handle);
|
||||||
const float gain = instance->gain;
|
const float gain = instance->gain;
|
||||||
@ -159,7 +160,8 @@ static char x_isnan(float x) {
|
|||||||
return ((v.u & 0x7f800000) == 0x7f800000) && (v.u & 0x7fffff);
|
return ((v.u & 0x7f800000) == 0x7f800000) && (v.u & 0x7fffff);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int plugin_state_load(const plugin_state_callbacks *cbs, const char *data, size_t length) {
|
static int plugin_state_load(const plugin_state_callbacks *cbs, float cur_sample_rate, const char *data, size_t length) {
|
||||||
|
(void)cur_sample_rate;
|
||||||
if (length != 13)
|
if (length != 13)
|
||||||
return -1;
|
return -1;
|
||||||
const uint8_t *d = (const uint8_t *)data;
|
const uint8_t *d = (const uint8_t *)data;
|
||||||
|
357
test/plugin_ui.h
357
test/plugin_ui.h
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Tibia
|
* 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
|
* Tibia is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -18,21 +18,16 @@
|
|||||||
* File author: Stefano D'Angelo, Paolo Marrone
|
* File author: Stefano D'Angelo, Paolo Marrone
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pugl/pugl.h>
|
#include "vinci.h"
|
||||||
#include <pugl/cairo.h>
|
#include <stdio.h>
|
||||||
#include <cairo.h>
|
#include <string.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
void *widget;
|
void *widget;
|
||||||
PuglWorld * world;
|
|
||||||
PuglView * view;
|
|
||||||
|
|
||||||
double fw;
|
vinci *vinci;
|
||||||
double fh;
|
window *window;
|
||||||
double x;
|
int param_down;
|
||||||
double y;
|
|
||||||
double w;
|
|
||||||
double h;
|
|
||||||
|
|
||||||
float gain;
|
float gain;
|
||||||
float delay;
|
float delay;
|
||||||
@ -40,281 +35,213 @@ typedef struct {
|
|||||||
char bypass;
|
char bypass;
|
||||||
float y_z1;
|
float y_z1;
|
||||||
|
|
||||||
int param_down;
|
|
||||||
|
|
||||||
plugin_ui_callbacks cbs;
|
plugin_ui_callbacks cbs;
|
||||||
} plugin_ui;
|
} plugin_ui;
|
||||||
|
|
||||||
#define WIDTH 600.0
|
#define WIDTH 600.0
|
||||||
#define HEIGHT 400.0
|
#define HEIGHT 400.0
|
||||||
#define RATIO (WIDTH / HEIGHT)
|
|
||||||
#define INV_RATIO (HEIGHT / WIDTH)
|
|
||||||
|
|
||||||
static void plugin_ui_get_default_size(uint32_t *width, uint32_t *height) {
|
static void plugin_ui_get_default_size(uint32_t *width, uint32_t *height) {
|
||||||
*width = WIDTH;
|
*width = WIDTH;
|
||||||
*height = HEIGHT;
|
*height = HEIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void plugin_ui_update_geometry(plugin_ui *instance) {
|
static void draw_rect(window *w, uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint32_t color) {
|
||||||
PuglRect frame = puglGetFrame(instance->view);
|
uint32_t *data = (uint32_t*) malloc(width * height * 4);
|
||||||
instance->fw = frame.width;
|
uint32_t p = 0;
|
||||||
instance->fh = frame.height;
|
for (uint32_t i = 0; i < height; i++)
|
||||||
if (frame.width == 0 || frame.height == 0)
|
for (uint32_t j = 0; j < width; j++, p++)
|
||||||
return;
|
data[p] = color;
|
||||||
|
window_draw(w, (unsigned char*)data, 0, 0, width, height, x, y, width, height);
|
||||||
|
free(data);
|
||||||
|
}
|
||||||
|
|
||||||
if (instance->fw / instance->fh > RATIO) {
|
static void draw_slider(plugin_ui *pui, int id, float value) {
|
||||||
instance->w = RATIO * instance->fh;
|
const int w = window_get_width(pui->window);
|
||||||
instance->h = instance->fh;
|
const int h = window_get_height(pui->window);
|
||||||
instance->x = 0.5 * (instance->fw - instance->w);
|
draw_rect(pui->window, 0.1 * w, 0.15 * (id + 1) * h, 0.8 * w * value, 0.1 * h, 0x6789ab);
|
||||||
instance->y = 0.0;
|
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);
|
||||||
} else {
|
}
|
||||||
instance->w = instance->fw;
|
|
||||||
instance->h = INV_RATIO * instance->fw;
|
static void draw_button(plugin_ui *pui, int id, char value) {
|
||||||
instance->x = 0.0;
|
const int w = window_get_width(pui->window);
|
||||||
instance->y = 0.5 * (instance->fh - instance->h);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void on_close(window *w) {
|
||||||
|
printf("on_close %p \n", (void*)w); fflush(stdout);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void on_mouse_press (window *win, int32_t x, int32_t y, uint32_t state) {
|
||||||
|
(void) state;
|
||||||
|
|
||||||
|
plugin_ui *pui = (plugin_ui*) window_get_data(win);
|
||||||
|
const int w = window_get_width(win);
|
||||||
|
const int h = window_get_height(win);
|
||||||
|
|
||||||
|
if (x >= 0.1 * w && x <= 0.9 * w && y >= 0.15 * h && y <= 0.25 * h) {
|
||||||
|
pui->param_down = 0;
|
||||||
|
pui->gain = (float)((x - (0.1 * w)) / (0.8 * w));
|
||||||
|
pui->cbs.set_parameter_begin(pui->cbs.handle, 0, -60.f + 80.f * pui->gain);
|
||||||
|
draw_slider(pui, 0, pui->gain);
|
||||||
|
} else if (x >= 0.1 * w && x <= 0.9 * w && y >= 0.3 * h && y <= 0.4 * h) {
|
||||||
|
pui->param_down = 1;
|
||||||
|
pui->delay = (float)((x - (0.1 * w)) / (0.8 * w));
|
||||||
|
pui->cbs.set_parameter_begin(pui->cbs.handle, 1, 1000.f * pui->delay);
|
||||||
|
draw_slider(pui, 1, pui->delay);
|
||||||
|
} else if (x >= 0.1 * w && x <= 0.9 * w && y >= 0.45 * h && y <= 0.55 * h) {
|
||||||
|
pui->param_down = 2;
|
||||||
|
pui->cutoff = (float)((x - (0.1 * w)) / (0.8 * w));
|
||||||
|
pui->cbs.set_parameter_begin(pui->cbs.handle, 2, (632.4555320336746f * pui->cutoff + 20.653108640674372f) / (1.0326554320337158f - pui->cutoff));
|
||||||
|
draw_slider(pui, 2, pui->cutoff);
|
||||||
|
} else if (x >= 0.4 * w && x <= 0.6 * w && y >= 0.6 * h && y <= 0.7 * h) {
|
||||||
|
pui->param_down = 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void plugin_ui_draw(plugin_ui *instance) {
|
static void on_mouse_release (window *win, int32_t x, int32_t y, uint32_t state) {
|
||||||
cairo_t *cr = (cairo_t *)puglGetContext(instance->view);
|
(void) state;
|
||||||
double x = instance->x;
|
|
||||||
double y = instance->y;
|
|
||||||
double w = instance->w;
|
|
||||||
double h = instance->h;
|
|
||||||
|
|
||||||
cairo_set_line_width(cr, 0.005 * h);
|
plugin_ui *pui = (plugin_ui*) window_get_data(win);
|
||||||
|
const int w = window_get_width(win);
|
||||||
|
const int h = window_get_height(win);
|
||||||
|
|
||||||
cairo_set_source_rgb(cr, 0, 0, 0);
|
if (pui->param_down == 4)
|
||||||
cairo_paint(cr);
|
if (x >= 0.4 * w && x <= 0.6 * w && y >= 0.6 * h && y <= 0.7 * h) {
|
||||||
|
pui->bypass = !pui->bypass;
|
||||||
cairo_set_source_rgb(cr, 0.2, 0.2, 0.2);
|
pui->cbs.set_parameter(pui->cbs.handle, 3, pui->bypass ? 1.f : 0.f);
|
||||||
cairo_rectangle(cr, x, y, w, h);
|
draw_button(pui, 3, pui->bypass);
|
||||||
cairo_fill(cr);
|
|
||||||
|
|
||||||
cairo_set_source_rgb(cr, 0.1, 0.1, 0.1);
|
|
||||||
cairo_rectangle(cr, x + 0.1 * w, y + 0.15 * h, 0.8 * w, 0.1 * h);
|
|
||||||
cairo_fill(cr);
|
|
||||||
cairo_set_source_rgb(cr, 0.5, 0.5, 0.5);
|
|
||||||
cairo_rectangle(cr, x + 0.1 * w, y + 0.15 * h, 0.8 * w * instance->gain, 0.1 * h);
|
|
||||||
cairo_fill(cr);
|
|
||||||
cairo_set_source_rgb(cr, 0.7, 0.7, 0.7);
|
|
||||||
cairo_rectangle(cr, x + 0.1 * w, y + 0.15 * h, 0.8 * w, 0.1 * h);
|
|
||||||
cairo_stroke(cr);
|
|
||||||
|
|
||||||
cairo_set_source_rgb(cr, 0.1, 0.1, 0.1);
|
|
||||||
cairo_rectangle(cr, x + 0.1 * w, y + 0.3 * h, 0.8 * w, 0.1 * h);
|
|
||||||
cairo_fill(cr);
|
|
||||||
cairo_set_source_rgb(cr, 0.5, 0.5, 0.5);
|
|
||||||
cairo_rectangle(cr, x + 0.1 * w, y + 0.3 * h, 0.8 * w * instance->delay, 0.1 * h);
|
|
||||||
cairo_fill(cr);
|
|
||||||
cairo_set_source_rgb(cr, 0.7, 0.7, 0.7);
|
|
||||||
cairo_rectangle(cr, x + 0.1 * w, y + 0.3 * h, 0.8 * w, 0.1 * h);
|
|
||||||
cairo_stroke(cr);
|
|
||||||
|
|
||||||
cairo_set_source_rgb(cr, 0.1, 0.1, 0.1);
|
|
||||||
cairo_rectangle(cr, x + 0.1 * w, y + 0.45 * h, 0.8 * w, 0.1 * h);
|
|
||||||
cairo_fill(cr);
|
|
||||||
cairo_set_source_rgb(cr, 0.5, 0.5, 0.5);
|
|
||||||
cairo_rectangle(cr, x + 0.1 * w, y + 0.45 * h, 0.8 * w * instance->cutoff, 0.1 * h);
|
|
||||||
cairo_fill(cr);
|
|
||||||
cairo_set_source_rgb(cr, 0.7, 0.7, 0.7);
|
|
||||||
cairo_rectangle(cr, x + 0.1 * w, y + 0.45 * h, 0.8 * w, 0.1 * h);
|
|
||||||
cairo_stroke(cr);
|
|
||||||
|
|
||||||
if (instance->bypass)
|
|
||||||
cairo_set_source_rgb(cr, 1.0, 0, 0);
|
|
||||||
else
|
|
||||||
cairo_set_source_rgb(cr, 0.7, 0.7, 0.7);
|
|
||||||
cairo_rectangle(cr, x + 0.4 * w, y + 0.6 * h, 0.2 * w, 0.1 * h);
|
|
||||||
cairo_fill(cr);
|
|
||||||
|
|
||||||
cairo_set_source_rgb(cr, 0.1, 0.1, 0.1);
|
|
||||||
cairo_rectangle(cr, x + 0.1 * w, y + 0.75 * h, 0.8 * w, 0.1 * h);
|
|
||||||
cairo_fill(cr);
|
|
||||||
|
|
||||||
cairo_set_source_rgb(cr, 0.5, 0.5, 0.5);
|
|
||||||
cairo_rectangle(cr, x + 0.1 * w, y + 0.75 * h, 0.8 * w * instance->y_z1, 0.1 * h);
|
|
||||||
cairo_fill(cr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PuglStatus plugin_ui_on_event(PuglView *view, const PuglEvent *event) {
|
if (pui->param_down != -1) {
|
||||||
switch (event->type) {
|
float v = x < 0.1 * w ? 0.f : (x > 0.9 * w ? 1.f : (float)((x - (0.1 * w)) / (0.8 * w)));
|
||||||
case PUGL_CONFIGURE:
|
switch (pui->param_down) {
|
||||||
{
|
|
||||||
plugin_ui *instance = (plugin_ui *)puglGetHandle(view);
|
|
||||||
plugin_ui_update_geometry(instance);
|
|
||||||
puglPostRedisplay(instance->view);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case PUGL_BUTTON_PRESS:
|
|
||||||
{
|
|
||||||
plugin_ui *instance = (plugin_ui *)puglGetHandle(view);
|
|
||||||
const PuglButtonEvent *ev = (const PuglButtonEvent *)event;
|
|
||||||
double x = instance->x;
|
|
||||||
double y = instance->y;
|
|
||||||
double w = instance->w;
|
|
||||||
double h = instance->h;
|
|
||||||
|
|
||||||
if (ev->x >= x + 0.1 * w && ev->x <= x + 0.9 * w
|
|
||||||
&& ev->y >= y + 0.15 * h && ev->y <= y + 0.25 * h) {
|
|
||||||
instance->param_down = 0;
|
|
||||||
instance->gain = (float)((ev->x - (x + 0.1 * w)) / (0.8 * w));
|
|
||||||
instance->cbs.set_parameter_begin(instance->cbs.handle, 0, -60.f + 80.f * instance->gain);
|
|
||||||
puglPostRedisplay(instance->view);
|
|
||||||
} else if (ev->x >= x + 0.1 * w && ev->x <= x + 0.9 * w
|
|
||||||
&& ev->y >= y + 0.3 * h && ev->y <= y + 0.4 * h) {
|
|
||||||
instance->param_down = 1;
|
|
||||||
instance->delay = (float)((ev->x - (x + 0.1 * w)) / (0.8 * w));
|
|
||||||
instance->cbs.set_parameter_begin(instance->cbs.handle, 1, 1000.f * instance->delay);
|
|
||||||
puglPostRedisplay(instance->view);
|
|
||||||
} else if (ev->x >= x + 0.1 * w && ev->x <= x + 0.9 * w
|
|
||||||
&& ev->y >= y + 0.45 * h && ev->y <= y + 0.55 * h) {
|
|
||||||
instance->param_down = 2;
|
|
||||||
instance->cutoff = (float)((ev->x - (x + 0.1 * w)) / (0.8 * w));
|
|
||||||
instance->cbs.set_parameter_begin(instance->cbs.handle, 2, (632.4555320336746f * instance->cutoff + 20.653108640674372f) / (1.0326554320337158f - instance->cutoff));
|
|
||||||
puglPostRedisplay(instance->view);
|
|
||||||
} else if (ev->x >= x + 0.4 * w && ev->x <= x + 0.6 * w
|
|
||||||
&& ev->y >= y + 0.6 * h && ev->y <= y + 0.7 * h) {
|
|
||||||
instance->param_down = 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case PUGL_MOTION:
|
|
||||||
{
|
|
||||||
plugin_ui *instance = (plugin_ui *)puglGetHandle(view);
|
|
||||||
const PuglMotionEvent *ev = (const PuglMotionEvent *)event;
|
|
||||||
double x = instance->x;
|
|
||||||
double w = instance->w;
|
|
||||||
float v = ev->x < x + 0.1 * w ? 0.f : (ev->x > x + 0.9 * w ? 1.f : (float)((ev->x - (x + 0.1 * w)) / (0.8 * w)));
|
|
||||||
|
|
||||||
switch (instance->param_down) {
|
|
||||||
case 0:
|
case 0:
|
||||||
instance->gain = v;
|
pui->gain = v;
|
||||||
instance->cbs.set_parameter(instance->cbs.handle, 0, -60.f + 80.f * instance->gain);
|
pui->cbs.set_parameter_end(pui->cbs.handle, 0, -60.f + 80.f * pui->gain);
|
||||||
puglPostRedisplay(instance->view);
|
draw_slider(pui, 0, pui->gain);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
instance->delay = v;
|
pui->delay = v;
|
||||||
instance->cbs.set_parameter(instance->cbs.handle, 1, 1000.f * instance->delay);
|
pui->cbs.set_parameter_end(pui->cbs.handle, 1, 1000.f * pui->delay);
|
||||||
puglPostRedisplay(instance->view);
|
draw_slider(pui, 1, pui->delay);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
instance->cutoff = v;
|
pui->cutoff = v;
|
||||||
instance->cbs.set_parameter(instance->cbs.handle, 2, (632.4555320336746f * instance->cutoff + 20.653108640674372f) / (1.0326554320337158f - instance->cutoff));
|
pui->cbs.set_parameter_end(pui->cbs.handle, 2, (632.4555320336746f * pui->cutoff + 20.653108640674372f) / (1.0326554320337158f - pui->cutoff));
|
||||||
puglPostRedisplay(instance->view);
|
draw_slider(pui, 2, pui->cutoff);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
pui->param_down = -1;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case PUGL_BUTTON_RELEASE:
|
|
||||||
{
|
|
||||||
plugin_ui *instance = (plugin_ui *)puglGetHandle(view);
|
|
||||||
const PuglButtonEvent *ev = (const PuglButtonEvent *)event;
|
|
||||||
double x = instance->x;
|
|
||||||
double y = instance->y;
|
|
||||||
double w = instance->w;
|
|
||||||
double h = instance->h;
|
|
||||||
|
|
||||||
if (instance->param_down == 3)
|
|
||||||
if (ev->x >= x + 0.4 * w && ev->x <= x + 0.6 * w
|
|
||||||
&& ev->y >= y + 0.6 * h && ev->y <= y + 0.7 * h) {
|
|
||||||
instance->bypass = !instance->bypass;
|
|
||||||
instance->cbs.set_parameter(instance->cbs.handle, 3, instance->bypass ? 1.f : 0.f);
|
|
||||||
puglPostRedisplay(instance->view);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (instance->param_down != -1) {
|
static void on_mouse_move (window *win, int32_t x, int32_t y, uint32_t state) {
|
||||||
float v = ev->x < x + 0.1 * w ? 0.f : (ev->x > x + 0.9 * w ? 1.f : (float)((ev->x - (x + 0.1 * w)) / (0.8 * w)));
|
(void) y;
|
||||||
switch (instance->param_down) {
|
(void) state;
|
||||||
|
|
||||||
|
plugin_ui *pui = (plugin_ui*) window_get_data(win);
|
||||||
|
const int w = window_get_width(win);
|
||||||
|
|
||||||
|
float v = x < 0.1 * w ? 0.f : (x > 0.9 * w ? 1.f : (float)((x - (0.1 * w)) / (0.8 * w)));
|
||||||
|
|
||||||
|
switch (pui->param_down) {
|
||||||
case 0:
|
case 0:
|
||||||
instance->gain = v;
|
pui->gain = v;
|
||||||
instance->cbs.set_parameter_end(instance->cbs.handle, 0, -60.f + 80.f * instance->gain);
|
pui->cbs.set_parameter(pui->cbs.handle, 0, -60.f + 80.f * pui->gain);
|
||||||
puglPostRedisplay(instance->view);
|
draw_slider(pui, 0, pui->gain);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
instance->delay = v;
|
pui->delay = v;
|
||||||
instance->cbs.set_parameter_end(instance->cbs.handle, 1, 1000.f * instance->delay);
|
pui->cbs.set_parameter(pui->cbs.handle, 1, 1000.f * pui->delay);
|
||||||
puglPostRedisplay(instance->view);
|
draw_slider(pui, 1, pui->delay);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
instance->cutoff = v;
|
pui->cutoff = v;
|
||||||
instance->cbs.set_parameter_end(instance->cbs.handle, 2, (632.4555320336746f * instance->cutoff + 20.653108640674372f) / (1.0326554320337158f - instance->cutoff));
|
pui->cbs.set_parameter(pui->cbs.handle, 2, (632.4555320336746f * pui->cutoff + 20.653108640674372f) / (1.0326554320337158f - pui->cutoff));
|
||||||
puglPostRedisplay(instance->view);
|
draw_slider(pui, 2, pui->cutoff);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
instance->param_down = -1;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
static void on_window_resize (window *w, int32_t width, int32_t height) {
|
||||||
case PUGL_EXPOSE:
|
draw_rect(w, 0, 0, width, height, 0xff9999);
|
||||||
{
|
|
||||||
plugin_ui *instance = (plugin_ui *)puglGetHandle(view);
|
plugin_ui *pui = (plugin_ui*) window_get_data(w);
|
||||||
plugin_ui_update_geometry(instance); // I didn't expect this was needed here for X11 to work decently when resizing
|
|
||||||
plugin_ui_draw(instance);
|
draw_slider(pui, 0, pui->gain);
|
||||||
}
|
draw_slider(pui, 1, pui->delay);
|
||||||
break;
|
draw_slider(pui, 2, pui->cutoff);
|
||||||
default:
|
draw_button(pui, 3, pui->bypass);
|
||||||
break;
|
draw_slider(pui, 4, pui->y_z1);
|
||||||
}
|
|
||||||
return PUGL_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static plugin_ui *plugin_ui_create(char has_parent, void *parent, plugin_ui_callbacks *cbs) {
|
static plugin_ui *plugin_ui_create(char has_parent, void *parent, plugin_ui_callbacks *cbs) {
|
||||||
plugin_ui *instance = malloc(sizeof(plugin_ui));
|
plugin_ui *instance = malloc(sizeof(plugin_ui));
|
||||||
if (instance == NULL)
|
if (instance == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
struct window_cbs wcbs;
|
||||||
|
memset(&wcbs, 0, sizeof(window_cbs));
|
||||||
|
wcbs.on_window_close = on_close;
|
||||||
|
wcbs.on_mouse_press = on_mouse_press;
|
||||||
|
wcbs.on_mouse_release = on_mouse_release;
|
||||||
|
wcbs.on_mouse_move = on_mouse_move;
|
||||||
|
wcbs.on_window_resize = on_window_resize;
|
||||||
|
|
||||||
instance->param_down = -1;
|
instance->param_down = -1;
|
||||||
instance->world = puglNewWorld(PUGL_MODULE, 0);
|
instance->vinci = vinci_new();
|
||||||
instance->view = puglNewView(instance->world);
|
instance->window = window_new(instance->vinci, has_parent ? parent : NULL, WIDTH, HEIGHT, &wcbs);
|
||||||
puglSetSizeHint(instance->view, PUGL_DEFAULT_SIZE, WIDTH, HEIGHT);
|
instance->widget = window_get_handle(instance->window);
|
||||||
puglSetViewHint(instance->view, PUGL_RESIZABLE, PUGL_TRUE);
|
window_set_data(instance->window, (void*) instance);
|
||||||
puglSetHandle(instance->view, instance);
|
window_show(instance->window);
|
||||||
puglSetBackend(instance->view, puglCairoBackend());
|
|
||||||
PuglRect frame = { 0, 0, WIDTH, HEIGHT };
|
// just some valid values to allow drawing
|
||||||
puglSetFrame(instance->view, frame);
|
instance->gain = 0.f;
|
||||||
puglSetEventFunc(instance->view, plugin_ui_on_event);
|
instance->delay = 0.f;
|
||||||
if (has_parent)
|
instance->cutoff = 0.f;
|
||||||
puglSetParentWindow(instance->view, (PuglNativeView)parent);
|
instance->bypass = 0;
|
||||||
if (puglRealize(instance->view)) {
|
instance->y_z1 = 0.f;
|
||||||
puglFreeView(instance->view);
|
|
||||||
puglFreeWorld(instance->world);
|
on_window_resize(instance->window, window_get_width(instance->window), window_get_height(instance->window));
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
instance->widget = (void *)puglGetNativeView(instance->view);
|
|
||||||
instance->cbs = *cbs;
|
instance->cbs = *cbs;
|
||||||
puglSetFrame(instance->view, frame); // Intentionally duplicated because of ardour/lv2/mac strange event order call
|
|
||||||
puglShow(instance->view, PUGL_SHOW_RAISE); // Cocoa calls events at this so it's better this happens late
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void plugin_ui_free(plugin_ui *instance) {
|
static void plugin_ui_free(plugin_ui *instance) {
|
||||||
puglFreeView(instance->view);
|
window_free(instance->window);
|
||||||
puglFreeWorld(instance->world);
|
vinci_destroy(instance->vinci);
|
||||||
free(instance);
|
free(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void plugin_ui_idle(plugin_ui *instance) {
|
static void plugin_ui_idle(plugin_ui *instance) {
|
||||||
puglUpdate(instance->world, 0);
|
vinci_idle(instance->vinci);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void plugin_ui_set_parameter(plugin_ui *instance, size_t index, float value) {
|
static void plugin_ui_set_parameter(plugin_ui *instance, size_t index, float value) {
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0:
|
case 0:
|
||||||
instance->gain = 0.0125f * value + 0.75f;
|
instance->gain = 0.0125f * value + 0.75f;
|
||||||
|
draw_slider(instance, 0, instance->gain);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
instance->delay = 0.001f * value;
|
instance->delay = 0.001f * value;
|
||||||
|
draw_slider(instance, 1, instance->delay);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
// (bad) approx log unmap
|
// (bad) approx log unmap
|
||||||
instance->cutoff = (1.0326554320337176f * value - 20.65310864067435f) / (value + 632.4555320336754f);
|
instance->cutoff = (1.0326554320337176f * value - 20.65310864067435f) / (value + 632.4555320336754f);
|
||||||
|
draw_slider(instance, 2, instance->cutoff);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
instance->bypass = value >= 0.5f;
|
instance->bypass = value >= 0.5f;
|
||||||
|
draw_button(instance, 3, instance->bypass);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
instance->y_z1 = 0.5f * value + 0.5f;
|
instance->y_z1 = 0.5f * value + 0.5f;
|
||||||
|
draw_slider(instance, 4, instance->y_z1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
puglPostRedisplay(instance->view);
|
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,45 @@
|
|||||||
API_DIR := ../api
|
API_DIR := ../api
|
||||||
|
|
||||||
|
VINCI_DIR := ../../../vinci
|
||||||
|
|
||||||
ifeq ($(TEMPLATE), cmd)
|
ifeq ($(TEMPLATE), cmd)
|
||||||
TINYWAV_DIR := ../../../tinywav
|
TINYWAV_DIR := ../../../tinywav
|
||||||
MIDI_PARSER_DIR := ../../../midi-parser
|
MIDI_PARSER_DIR := ../../../midi-parser
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(TEMPLATE), lv2)
|
ifeq ($(TEMPLATE), lv2)
|
||||||
CFLAGS_EXTRA := $(shell pkg-config --cflags pugl-cairo-0 pugl-0 cairo)
|
ifeq ($(OS), Windows_NT)
|
||||||
LDFLAGS_EXTRA := $(shell pkg-config --libs pugl-cairo-0 pugl-0 cairo) -Wl,-rpath,$(shell pkg-config --variable=libdir pugl-cairo-0),-rpath,$(shell pkg-config --variable=libdir pugl-0),-rpath,$(shell pkg-config --variable=libdir cairo)
|
C_SRCS_EXTRA := $(VINCI_DIR)/vinci-win32.c
|
||||||
|
LDFLAGS_EXTRA := -mwindows
|
||||||
|
else
|
||||||
|
UNAME_S := $(shell uname -s)
|
||||||
|
ifeq ($(UNAME_S), Darwin)
|
||||||
|
M_SRCS_EXTRA := $(VINCI_DIR)/vinci-cocoa.m
|
||||||
|
LDFLAGS_EXTRA := -framework Cocoa -lobjc
|
||||||
|
else
|
||||||
|
C_SRCS_EXTRA := $(VINCI_DIR)/vinci-xcb.c
|
||||||
|
LDFLAGS_EXTRA := -lxcb
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
CFLAGS_EXTRA := $(CFLAGS_EXTRA) -I${VINCI_DIR}
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(TEMPLATE), vst3)
|
ifeq ($(TEMPLATE), vst3)
|
||||||
RUTEX_DIR := ../../../rutex
|
ifeq ($(OS), Windows_NT)
|
||||||
CFLAGS_EXTRA := -I../../../vst3_c_api $(shell pkg-config --cflags pugl-cairo-0)
|
C_SRCS_EXTRA := $(VINCI_DIR)/vinci-win32.c
|
||||||
LDFLAGS_EXTRA := $(shell pkg-config --libs pugl-cairo-0 pugl-0 cairo) -Wl,-rpath,$(shell pkg-config --variable=libdir pugl-cairo-0),-rpath,$(shell pkg-config --variable=libdir pugl-0),-rpath,$(shell pkg-config --variable=libdir cairo)
|
LDFLAGS_EXTRA := -mwindows
|
||||||
|
else
|
||||||
|
UNAME_S := $(shell uname -s)
|
||||||
|
ifeq ($(UNAME_S), Darwin)
|
||||||
|
M_SRCS_EXTRA := $(VINCI_DIR)/vinci-cocoa.m
|
||||||
|
LDFLAGS_EXTRA := -framework Cocoa -lobjc
|
||||||
|
else
|
||||||
|
C_SRCS_EXTRA := $(VINCI_DIR)/vinci-xcb.c
|
||||||
|
LDFLAGS_EXTRA := -lxcb
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
CFLAGS_EXTRA := $(CFLAGS_EXTRA) -I../../../vst3_c_api
|
||||||
|
CFLAGS_EXTRA := $(CFLAGS_EXTRA) -I${VINCI_DIR}
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(TEMPLATE), daisy-seed)
|
ifeq ($(TEMPLATE), daisy-seed)
|
||||||
@ -29,13 +55,12 @@ ifeq ($(TEMPLATE), android)
|
|||||||
SDK_DIR := $(HOME)/Android/Sdk
|
SDK_DIR := $(HOME)/Android/Sdk
|
||||||
ANDROIDX_DIR := $(HOME)/Android/androidx
|
ANDROIDX_DIR := $(HOME)/Android/androidx
|
||||||
KOTLIN_DIR := $(HOME)/Android/kotlin
|
KOTLIN_DIR := $(HOME)/Android/kotlin
|
||||||
NDK_VERSION := 28.0.12674087
|
NDK_VERSION := 28.0.13004108
|
||||||
BUILD_TOOLS_VERSION := 35.0.0
|
BUILD_TOOLS_VERSION := 36.0.0
|
||||||
ANDROID_VERSION := 35
|
ANDROIDX_CORE_VERSION := 1.16.0
|
||||||
ANDROIDX_CORE_VERSION := 1.15.0
|
|
||||||
ANDROIDX_LIFECYCLE_COMMON_VERSION := 2.8.7
|
ANDROIDX_LIFECYCLE_COMMON_VERSION := 2.8.7
|
||||||
ANDROIDX_VERSIONEDPARCELABLE_VERSION := 1.2.1
|
ANDROIDX_VERSIONEDPARCELABLE_VERSION := 1.2.1
|
||||||
KOTLIN_STDLIB_VERSION := 2.1.10
|
KOTLIN_STDLIB_VERSION := 2.1.20
|
||||||
KOTLINX_COROUTINES_CORE_VERSION := 1.10.1
|
KOTLINX_COROUTINES_CORE_VERSION := 1.10.2
|
||||||
KOTLINX_COROUTINES_CORE_JVM_VERSION := 1.10.1
|
KOTLINX_COROUTINES_CORE_JVM_VERSION := 1.10.2
|
||||||
endif
|
endif
|
||||||
|
Loading…
Reference in New Issue
Block a user