Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
8ddf42ea33 | ||
![]() |
2d66e616cd |
@ -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-2025 Orastron Srl unipersonale.
|
Copyright (C) 2021-2024 Orastron Srl unipersonale.
|
||||||
|
|
||||||
Authors: Stefano D'Angelo, Paolo Marrone.
|
Authors: Stefano D'Angelo, Paolo Marrone.
|
||||||
|
|
||||||
|
9
notes
9
notes
@ -268,12 +268,3 @@ product {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
makefile dirs:
|
|
||||||
- make always executed from Makefile directory
|
|
||||||
- COMMON_DIR: static common sources (e.g., src/lv2.c)
|
|
||||||
- DATA_DIR: generated sources/data (e.g., src/data.h, data/manifest.ttl.in)
|
|
||||||
- PLUGIN_DIR: plugin sources (e.g., plugin.h)
|
|
||||||
- API_DIR: generated Tibia-related API sources (e.g., plugin_api.h)
|
|
||||||
- MKINC_DIR: Makefile includes (e.g., vars-pre.mk)
|
|
||||||
- build: build files
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# Tibia
|
# Tibia
|
||||||
#
|
#
|
||||||
# Copyright (C) 2023-2025 Orastron Srl unipersonale
|
# Copyright (C) 2023, 2024 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,8 +18,6 @@
|
|||||||
# File author: Stefano D'Angelo
|
# File author: Stefano D'Angelo
|
||||||
#
|
#
|
||||||
|
|
||||||
SHELL := bash -o pipefail
|
|
||||||
|
|
||||||
TEMPLATE := android
|
TEMPLATE := android
|
||||||
|
|
||||||
include vars.mk
|
include vars.mk
|
||||||
@ -52,19 +50,8 @@ 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
|
||||||
|
|
||||||
ifeq ($(OS), Windows_NT)
|
CC := $(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/
|
CXX := $(NDK_DIR)/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi$(MIN_API)-clang++
|
||||||
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
|
||||||
@ -92,10 +79,10 @@ ifeq ($(HAS_MIDI_IN), yes)
|
|||||||
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 -fvisibility=hidden $(CFLAGS_EXTRA) $(CFLAGS)
|
CFLAGS_ALL := -I$(DATA_DIR)/src -I$(PLUGIN_DIR) -I$(API_DIR) -fPIC $(CFLAGS_EXTRA) $(CFLAGS)
|
||||||
|
|
||||||
CXXFLAGS := $(CFLAGS)
|
CXXFLAGS := $(CFLAGS)
|
||||||
CXXFLAGS_ALL := -I$(DATA_DIR)/src -I$(PLUGIN_DIR) -I$(API_DIR) -fPIC -fvisibility=hidden -std=c++11 $(CXXFLAGS_EXTRA) $(CXXFLAGS)
|
CXXFLAGS_ALL := -I$(DATA_DIR)/src -I$(PLUGIN_DIR) -I$(API_DIR) -fPIC -std=c++11 $(CXXFLAGS_EXTRA) $(CXXFLAGS)
|
||||||
|
|
||||||
LDFLAGS :=
|
LDFLAGS :=
|
||||||
LDFLAGS_ALL := -shared -static-libstdc++ -landroid
|
LDFLAGS_ALL := -shared -static-libstdc++ -landroid
|
||||||
@ -117,8 +104,6 @@ DIRS := build build/gen build/apk build/obj build/apk/lib build/apk/lib/armeabi-
|
|||||||
|
|
||||||
ALL := build/$(BUNDLE_NAME).apk
|
ALL := build/$(BUNDLE_NAME).apk
|
||||||
|
|
||||||
PHONY := all clean install
|
|
||||||
|
|
||||||
-include $(MKINC_DIR)/vars-extra.mk
|
-include $(MKINC_DIR)/vars-extra.mk
|
||||||
|
|
||||||
all: $(ALL)
|
all: $(ALL)
|
||||||
@ -160,7 +145,7 @@ install: build/$(BUNDLE_NAME).apk
|
|||||||
|
|
||||||
-include $(MKINC_DIR)/rules-extra.mk
|
-include $(MKINC_DIR)/rules-extra.mk
|
||||||
|
|
||||||
.PHONY: $(PHONY)
|
.PHONY: all clean install
|
||||||
|
|
||||||
.SECONDEXPANSION:
|
.SECONDEXPANSION:
|
||||||
|
|
||||||
@ -173,5 +158,3 @@ $(CXX_OBJS): build/obj/%.o: $$(filter $$(PERCENT)/$$(basename $$(notdir $$@)).cp
|
|||||||
$(CXX) $^ -o $@ -c $(CXXFLAGS_ALL)
|
$(CXX) $^ -o $@ -c $(CXXFLAGS_ALL)
|
||||||
|
|
||||||
-include $(MKINC_DIR)/rules-secondexp-extra.mk
|
-include $(MKINC_DIR)/rules-secondexp-extra.mk
|
||||||
|
|
||||||
.DELETE_ON_ERROR:
|
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
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="{{=it.android.androidVersion}}" />
|
<uses-sdk android:targetSdkVersion="34" />
|
||||||
<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>
|
||||||
|
@ -18,8 +18,6 @@
|
|||||||
# File author: Stefano D'Angelo
|
# File author: Stefano D'Angelo
|
||||||
#
|
#
|
||||||
|
|
||||||
SHELL := bash -o pipefail
|
|
||||||
|
|
||||||
TEMPLATE := cmd
|
TEMPLATE := cmd
|
||||||
|
|
||||||
include vars.mk
|
include vars.mk
|
||||||
@ -51,7 +49,7 @@ CC := gcc
|
|||||||
CXX := g++
|
CXX := g++
|
||||||
|
|
||||||
CFLAGS := -O3 -Wall -Wpedantic -Wextra
|
CFLAGS := -O3 -Wall -Wpedantic -Wextra
|
||||||
CFLAGS_ALL := -I$(DATA_DIR)/src -I$(PLUGIN_DIR) -I$(API_DIR) -I$(TINYWAV_DIR) -I$(MIDI_PARSER_DIR)/include -fvisibility=hidden $(CFLAGS_EXTRA) $(CFLAGS)
|
CFLAGS_ALL := -I$(DATA_DIR)/src -I$(PLUGIN_DIR) -I$(API_DIR) -I$(TINYWAV_DIR) -I$(MIDI_PARSER_DIR)/include $(CFLAGS_EXTRA) $(CFLAGS)
|
||||||
|
|
||||||
LDFLAGS :=
|
LDFLAGS :=
|
||||||
LDFLAGS_ALL := $(LDFLAGS_EXTRA) $(LDFLAGS)
|
LDFLAGS_ALL := $(LDFLAGS_EXTRA) $(LDFLAGS)
|
||||||
@ -81,12 +79,8 @@ DIRS := build build/obj
|
|||||||
ALL := build/$(PROGRAM)
|
ALL := build/$(PROGRAM)
|
||||||
|
|
||||||
STRIP_ALL := build/$(PROGRAM)
|
STRIP_ALL := build/$(PROGRAM)
|
||||||
STRIP_PREREQS := $(STRIP_ALL)
|
STRIP_PHONY :=
|
||||||
|
STRIP_PREREQS := $(STRIP_ALL) $(STRIP_PHONY)
|
||||||
PHONY := all clean strip
|
|
||||||
ifneq ($(OS), Windows_NT)
|
|
||||||
PHONY := $(PHONY) install
|
|
||||||
endif
|
|
||||||
|
|
||||||
-include $(MKINC_DIR)/vars-extra.mk
|
-include $(MKINC_DIR)/vars-extra.mk
|
||||||
|
|
||||||
@ -109,13 +103,15 @@ clean:
|
|||||||
strip: $(STRIP_PREREQS)
|
strip: $(STRIP_PREREQS)
|
||||||
strip build/$(PROGRAM)
|
strip build/$(PROGRAM)
|
||||||
|
|
||||||
ifneq ($(OS), Windows_NT)
|
ifeq ($(OS), Windows_NT)
|
||||||
|
.PHONY: all clean strip $(STRIP_PHONY)
|
||||||
|
else
|
||||||
install: all
|
install: all
|
||||||
mkdir -m 0755 -p $(BINDIR)
|
mkdir -m 0755 -p $(BINDIR)
|
||||||
install -m 0755 build/$(PROGRAM) $(BINDIR)
|
install -m 0755 build/$(PROGRAM) $(BINDIR)
|
||||||
endif
|
|
||||||
|
|
||||||
.PHONY: $(PHONY)
|
.PHONY: all clean strip $(STRIP_PHONY) install
|
||||||
|
endif
|
||||||
|
|
||||||
-include $(MKINC_DIR)/rules-extra.mk
|
-include $(MKINC_DIR)/rules-extra.mk
|
||||||
|
|
||||||
@ -133,5 +129,3 @@ $(CXX_OBJS): build/obj/%.o: $$(filter $$(PERCENT)/$$(basename $$(notdir $$@)).cp
|
|||||||
$(CXX) $^ -o $@ -c $(CXXFLAGS_ALL)
|
$(CXX) $^ -o $@ -c $(CXXFLAGS_ALL)
|
||||||
|
|
||||||
-include $(MKINC_DIR)/rules-secondexp-extra.mk
|
-include $(MKINC_DIR)/rules-secondexp-extra.mk
|
||||||
|
|
||||||
.DELETE_ON_ERROR:
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# Tibia
|
# Tibia
|
||||||
#
|
#
|
||||||
# Copyright (C) 2023-2025 Orastron Srl unipersonale
|
# Copyright (C) 2023, 2024 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,8 +18,6 @@
|
|||||||
# File author: Stefano D'Angelo
|
# File author: Stefano D'Angelo
|
||||||
#
|
#
|
||||||
|
|
||||||
SHELL := bash -o pipefail
|
|
||||||
|
|
||||||
TEMPLATE := daisy-seed
|
TEMPLATE := daisy-seed
|
||||||
|
|
||||||
include vars.mk
|
include vars.mk
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# Tibia
|
# Tibia
|
||||||
#
|
#
|
||||||
# Copyright (C) 2024, 2025 Orastron Srl unipersonale
|
# Copyright (C) 2024 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,8 +18,6 @@
|
|||||||
# File author: Stefano D'Angelo
|
# File author: Stefano D'Angelo
|
||||||
#
|
#
|
||||||
|
|
||||||
SHELL := bash -o pipefail
|
|
||||||
|
|
||||||
TEMPLATE := ios
|
TEMPLATE := ios
|
||||||
|
|
||||||
include vars.mk
|
include vars.mk
|
||||||
@ -36,10 +34,10 @@ BUILD_DATA_DIR := build/gen/res
|
|||||||
-include $(MKINC_DIR)/vars-pre.mk
|
-include $(MKINC_DIR)/vars-pre.mk
|
||||||
|
|
||||||
CFLAGS := -O3 -Wall -Wpedantic -Wextra
|
CFLAGS := -O3 -Wall -Wpedantic -Wextra
|
||||||
CFLAGS_ALL := -I$(DATA_DIR)/src -I$(PLUGIN_DIR) -I$(API_DIR) -fvisibility=hidden $(CFLAGS_EXTRA) $(CFLAGS)
|
CFLAGS_ALL := -I$(DATA_DIR)/src -I$(PLUGIN_DIR) -I$(API_DIR) $(CFLAGS_EXTRA) $(CFLAGS)
|
||||||
|
|
||||||
CXXFLAGS := $(CFLAGS)
|
CXXFLAGS := $(CFLAGS)
|
||||||
CXXFLAGS_ALL := -I$(DATA_DIR)/src -I$(PLUGIN_DIR) -I$(API_DIR) -fvisibility=hidden $(CXXFLAGS_EXTRA) $(CXXFLAGS)
|
CXXFLAGS_ALL := -I$(DATA_DIR)/src -I$(PLUGIN_DIR) -I$(API_DIR) $(CXXFLAGS_EXTRA) $(CXXFLAGS)
|
||||||
|
|
||||||
LDFLAGS :=
|
LDFLAGS :=
|
||||||
LDFLAGS_ALL := $(LDFLAGS_EXTRA) $(LDFLAGS)
|
LDFLAGS_ALL := $(LDFLAGS_EXTRA) $(LDFLAGS)
|
||||||
@ -97,5 +95,3 @@ $(RESOURCES_OUT): build/gen/res/%: $$(filter $$(PERCENT)/%,$$(RESOURCES)) | buil
|
|||||||
cp -R $^ $@
|
cp -R $^ $@
|
||||||
|
|
||||||
-include $(MKINC_DIR)/rules-secondexp-extra.mk
|
-include $(MKINC_DIR)/rules-secondexp-extra.mk
|
||||||
|
|
||||||
.DELETE_ON_ERROR:
|
|
||||||
|
@ -164,7 +164,6 @@ void (^midiNotifyBlock)(const MIDINotification *message) = ^(const MIDINotificat
|
|||||||
};
|
};
|
||||||
|
|
||||||
void (^midiReceiveBlock)(const MIDIEventList *evtlist, void *srcConnRefCon) = ^(const MIDIEventList *evtlist, void *srcConnRefCon) {
|
void (^midiReceiveBlock)(const MIDIEventList *evtlist, void *srcConnRefCon) = ^(const MIDIEventList *evtlist, void *srcConnRefCon) {
|
||||||
(void)srcConnRefCon;
|
|
||||||
const MIDIEventPacket *p = evtlist->packet;
|
const MIDIEventPacket *p = evtlist->packet;
|
||||||
for (UInt32 i = 0; i < evtlist->numPackets; i++) {
|
for (UInt32 i = 0; i < evtlist->numPackets; i++) {
|
||||||
for (UInt32 j = 0; j < p->wordCount; j++) {
|
for (UInt32 j = 0; j < p->wordCount; j++) {
|
||||||
|
@ -26,5 +26,5 @@ module.exports = function (data, api) {
|
|||||||
api.generateFileFromTemplateFile(`src${sep}index.html`, `src${sep}index.html`, data);
|
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}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-Bridging-Header.h`, `src${sep}app-Bridging-Header.h`);
|
||||||
api.copyFile(`src${sep}app.swift`, `src${sep}app.swift`);
|
api.copyFile(`src${sep}app.swift`, `src${sep}app.swift`, data);
|
||||||
};
|
};
|
||||||
|
@ -18,8 +18,6 @@
|
|||||||
# File author: Stefano D'Angelo
|
# File author: Stefano D'Angelo
|
||||||
#
|
#
|
||||||
|
|
||||||
SHELL := bash -o pipefail
|
|
||||||
|
|
||||||
TEMPLATE := lv2
|
TEMPLATE := lv2
|
||||||
|
|
||||||
include vars.mk
|
include vars.mk
|
||||||
@ -40,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 := $(subst \,/,$(COMMONPROGRAMFILES))/LV2
|
LV2DIR := $(shell echo '$(COMMONPROGRAMFILES)' | sed 's:\\:/:g')/LV2
|
||||||
LV2DIR_USER := $(subst \,/,$(APPDATA))/LV2
|
LV2DIR_USER := $(shell echo '$(APPDATA)' | sed 's:\\:/:g')/LV2
|
||||||
CC := gcc
|
CC := gcc
|
||||||
CXX := g++
|
CXX := g++
|
||||||
else
|
else
|
||||||
@ -64,14 +62,14 @@ else
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CFLAGS := -O3 -Wall -Wpedantic -Wextra
|
CFLAGS := -O0 -g -Wall -Wpedantic -Wextra
|
||||||
CFLAGS_ALL := -I$(DATA_DIR)/src -I$(PLUGIN_DIR) -I$(API_DIR) $(shell pkg-config --cflags lv2) -fPIC -fvisibility=hidden $(CFLAGS_EXTRA) $(CFLAGS)
|
CFLAGS_ALL := -I$(DATA_DIR)/src -I$(PLUGIN_DIR) -I$(API_DIR) $(shell pkg-config --cflags lv2) -fPIC $(CFLAGS_EXTRA) $(CFLAGS)
|
||||||
|
|
||||||
LDFLAGS :=
|
LDFLAGS :=
|
||||||
LDFLAGS_ALL := -shared $(shell pkg-config --libs lv2) $(LDFLAGS_EXTRA) $(LDFLAGS)
|
LDFLAGS_ALL := -shared $(shell pkg-config --libs lv2) $(LDFLAGS_EXTRA) $(LDFLAGS)
|
||||||
|
|
||||||
CXXFLAGS := $(CFLAGS)
|
CXXFLAGS := $(CFLAGS)
|
||||||
CXXFLAGS_ALL := -I$(DATA_DIR)/src -I$(PLUGIN_DIR) -I$(API_DIR) $(shell pkg-config --cflags lv2) -fPIC -fvisibility=hidden $(CXXFLAGS_EXTRA) $(CXXFLAGS)
|
CXXFLAGS_ALL := -I$(DATA_DIR)/src -I$(PLUGIN_DIR) -I$(API_DIR) -fPIC $(CXXFLAGS_EXTRA) $(CXXFLAGS)
|
||||||
|
|
||||||
ifeq ($(UNAME_S), Darwin)
|
ifeq ($(UNAME_S), Darwin)
|
||||||
CFLAGS_ALL := $(CFLAGS_ALL) -arch arm64 -arch x86_64
|
CFLAGS_ALL := $(CFLAGS_ALL) -arch arm64 -arch x86_64
|
||||||
@ -95,9 +93,8 @@ DIRS := build build/$(BUNDLE_DIR) build/obj
|
|||||||
ALL := build/$(BUNDLE_DIR)/manifest.ttl build/$(BUNDLE_DIR)/$(DLL_FILE)
|
ALL := build/$(BUNDLE_DIR)/manifest.ttl build/$(BUNDLE_DIR)/$(DLL_FILE)
|
||||||
|
|
||||||
STRIP_ALL := build/$(BUNDLE_DIR)/$(DLL_FILE) build/$(BUNDLE_DIR)/manifest.ttl
|
STRIP_ALL := build/$(BUNDLE_DIR)/$(DLL_FILE) build/$(BUNDLE_DIR)/manifest.ttl
|
||||||
STRIP_PREREQS := $(STRIP_ALL)
|
STRIP_PHONY :=
|
||||||
|
STRIP_PREREQS := $(STRIP_ALL) $(STRIP_PHONY)
|
||||||
.PHONY: all clean strip install install-user
|
|
||||||
|
|
||||||
-include $(MKINC_DIR)/vars-extra.mk
|
-include $(MKINC_DIR)/vars-extra.mk
|
||||||
|
|
||||||
@ -121,48 +118,43 @@ clean:
|
|||||||
rm -fr build
|
rm -fr build
|
||||||
|
|
||||||
strip: $(STRIP_PREREQS)
|
strip: $(STRIP_PREREQS)
|
||||||
strip -Sx build/$(BUNDLE_DIR)/$(DLL_FILE)
|
strip build/$(BUNDLE_DIR)/$(DLL_FILE)
|
||||||
#Reaper can't handle this
|
#Reaper can't handle this
|
||||||
#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
|
|
||||||
$(eval TMP := $(shell mktemp /tmp/index.XXXXXX))
|
|
||||||
sed '/^[[:space:]]*$$/d' build/$(BUNDLE_DIR)/manifest.ttl > $(TMP) || (rm $(TMP) && exit 1)
|
|
||||||
cp $(TMP) build/$(BUNDLE_DIR)/manifest.ttl || (rm $(TMP) && exit 1)
|
|
||||||
rm $(TMP)
|
|
||||||
|
|
||||||
install: all
|
install: all
|
||||||
@for d in `find build/$(BUNDLE_DIR) -type d`; do \
|
@for d in `find build/$(BUNDLE_DIR) -type d`; do \
|
||||||
d=`echo $$d | sed 's:^build/::'` ; \
|
d=`echo $$d | sed 's:^build/::'` ; \
|
||||||
echo mkdir -m 0755 -p "$(LV2DIR)/$$d"; \
|
echo mkdir -m 0755 -p "$(LV2DIR)/$$d"; \
|
||||||
mkdir -m 0755 -p "$(LV2DIR)/$$d" || exit 1; \
|
mkdir -m 0755 -p "$(LV2DIR)/$$d"; \
|
||||||
done
|
done
|
||||||
@for f in `find build/$(BUNDLE_DIR) -type f`; do \
|
@for f in `find build/$(BUNDLE_DIR) -type f`; do \
|
||||||
m=`[ -x $$f ] && echo 0755 || echo 0644`; \
|
m=`[ -x $$f ] && echo 0755 || echo 0644`; \
|
||||||
d=`echo $$f | sed 's:^build/::'` ; \
|
d=`echo $$f | sed 's:^build/::'` ; \
|
||||||
d=`dirname $$d`; \
|
d=`dirname $$d`; \
|
||||||
echo install -m $$m $$f "$(LV2DIR)/$$d"; \
|
echo install -m $$m $$f "$(LV2DIR)/$$d"; \
|
||||||
install -m $$m $$f "$(LV2DIR)/$$d" || exit 1; \
|
install -m $$m $$f "$(LV2DIR)/$$d"; \
|
||||||
done
|
done
|
||||||
|
|
||||||
install-user: all
|
install-user: all
|
||||||
@for d in `find build/$(BUNDLE_DIR) -type d`; do \
|
@for d in `find build/$(BUNDLE_DIR) -type d`; do \
|
||||||
d=`echo $$d | sed 's:^build/::'` ; \
|
d=`echo $$d | sed 's:^build/::'` ; \
|
||||||
echo mkdir -m 0755 -p "$(LV2DIR_USER)/$$d"; \
|
echo mkdir -m 0755 -p "$(LV2DIR_USER)/$$d"; \
|
||||||
mkdir -m 0755 -p "$(LV2DIR_USER)/$$d" || exit 1; \
|
mkdir -m 0755 -p "$(LV2DIR_USER)/$$d"; \
|
||||||
done
|
done
|
||||||
@for f in `find build/$(BUNDLE_DIR) -type f`; do \
|
@for f in `find build/$(BUNDLE_DIR) -type f`; do \
|
||||||
m=`[ -x $$f ] && echo 0755 || echo 0644`; \
|
m=`[ -x $$f ] && echo 0755 || echo 0644`; \
|
||||||
d=`echo $$f | sed 's:^build/::'` ; \
|
d=`echo $$f | sed 's:^build/::'` ; \
|
||||||
d=`dirname $$d`; \
|
d=`dirname $$d`; \
|
||||||
echo install -m $$m $$f "$(LV2DIR_USER)/$$d"; \
|
echo install -m $$m $$f "$(LV2DIR_USER)/$$d"; \
|
||||||
install -m $$m $$f "$(LV2DIR_USER)/$$d" || exit 1; \
|
install -m $$m $$f "$(LV2DIR_USER)/$$d"; \
|
||||||
done
|
done
|
||||||
|
|
||||||
-include $(MKINC_DIR)/rules-extra.mk
|
-include $(MKINC_DIR)/rules-extra.mk
|
||||||
|
|
||||||
.PHONY: $(PHONY)
|
.PHONY: all clean strip $(STRIP_PHONY) install install-user
|
||||||
|
|
||||||
.SECONDEXPANSION:
|
.SECONDEXPANSION:
|
||||||
|
|
||||||
@ -178,5 +170,3 @@ $(CXX_OBJS): build/obj/%.o: $$(filter $$(PERCENT)/$$(basename $$(notdir $$@)).cp
|
|||||||
$(CXX) $^ -o $@ -c $(CXXFLAGS_ALL)
|
$(CXX) $^ -o $@ -c $(CXXFLAGS_ALL)
|
||||||
|
|
||||||
-include $(MKINC_DIR)/rules-secondexp-extra.mk
|
-include $(MKINC_DIR)/rules-secondexp-extra.mk
|
||||||
|
|
||||||
.DELETE_ON_ERROR:
|
|
||||||
|
1
templates/lv2-next/README.md
Normal file
1
templates/lv2-next/README.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
This is experimental and broken, do not use this.
|
95
templates/lv2-next/data/manifest.ttl.in
Normal file
95
templates/lv2-next/data/manifest.ttl.in
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
{{~it.tibia.lv2.prefixes :p}}
|
||||||
|
@prefix {{=p.id}}: <{{=p.uri}}> .
|
||||||
|
{{~}}
|
||||||
|
|
||||||
|
{{~it.product.parameters :p}}
|
||||||
|
plugin:{{=p.id}}
|
||||||
|
a lv2:Parameter ;
|
||||||
|
rdfs:label "{{=p.name}}" ;
|
||||||
|
lv2:name "{{=p.name}}" ;
|
||||||
|
{{?"shortName" in p}}
|
||||||
|
lv2:shortName "{{=p.shortName.substring(0, 16)}}" ;
|
||||||
|
{{?}}
|
||||||
|
lv2:symbol "{{=p.id}}" ;
|
||||||
|
rdfs:range atom:Float .
|
||||||
|
{{~}}
|
||||||
|
|
||||||
|
{{=it.tibia.lv2.ttlURI(it.lv2.uri)}}
|
||||||
|
a lv2:Plugin ;
|
||||||
|
{{~it.lv2.types :t}}
|
||||||
|
a {{=it.tibia.lv2.ttlURI(t)}} ;
|
||||||
|
{{~}}
|
||||||
|
{{?it.lv2.project}}
|
||||||
|
lv2:project {{=it.tibia.lv2.ttlURI(it.lv2.project)}} ;
|
||||||
|
{{?}}
|
||||||
|
lv2:binary <{{=it.product.bundleName}}@DLL_SUFFIX@> ;
|
||||||
|
doap:name "{{=it.product.name}}" ;
|
||||||
|
doap:maintainer [
|
||||||
|
a foaf:Organization ;
|
||||||
|
foaf:name "{{=it.company.name}}" ;
|
||||||
|
foaf:mbox <mailto:{{=it.company.email}}> ;
|
||||||
|
rdfs:seeAlso {{=it.tibia.lv2.ttlURI(it.company.url)}}
|
||||||
|
] ;
|
||||||
|
lv2:minorVersion {{=/^([0-9]+)\./.exec(it.lv2.version)[1]}} ;
|
||||||
|
lv2:microVersion {{=/^[0-9]+\.([0-9]+)/.exec(it.lv2.version)[1]}} ;
|
||||||
|
{{?it.tibia.lv2.ports.find(p => p.type == "midi" || p.type == "param")}}
|
||||||
|
lv2:requiredFeature urid:map ;
|
||||||
|
lv2:optionalFeature log:log ;
|
||||||
|
{{?}}
|
||||||
|
{{?it.product.parameters.find(p => p.direction == "input")}}
|
||||||
|
patch:writable {{=it.product.parameters.filter(p => p.direction == "input").map(p => "plugin:" + p.id).join(" , ")}} ;
|
||||||
|
{{?}}
|
||||||
|
{{?it.product.parameters.find(p => p.direction == "output")}}
|
||||||
|
patch:readable {{=it.product.parameters.filter(p => p.direction == "output").map(p => "plugin:" + p.id).join(" , ")}} ;
|
||||||
|
{{?}}
|
||||||
|
lv2:optionalFeature lv2:hardRTCapable ;
|
||||||
|
{{?it.product.ui}}
|
||||||
|
ui:ui plugin:ui ;
|
||||||
|
{{?}}
|
||||||
|
lv2:port [
|
||||||
|
{{~it.tibia.lv2.ports :p:i}}
|
||||||
|
a {{?p.type == "control"}}lv2:ControlPort{{??(p.type == "midi" || p.type == "param")}}atom:AtomPort{{??}}{{?p.cv}}lv2:CVPort{{??}}lv2:AudioPort{{?}}{{?}} ,
|
||||||
|
{{?p.direction == "input"}}lv2:InputPort{{??}}lv2:OutputPort{{?}} ;
|
||||||
|
lv2:name "{{=p.name}}" ;
|
||||||
|
{{?"shortName" in p}}
|
||||||
|
lv2:shortName "{{=p.shortName.substring(0, 16)}}" ;
|
||||||
|
{{?}}
|
||||||
|
lv2:symbol "{{=p.id}}" ;
|
||||||
|
{{?p.type == "param"}}
|
||||||
|
atom:bufferType atom:Sequence ;
|
||||||
|
atom:supports atom:Object ;
|
||||||
|
atom:supports patch:Message ;
|
||||||
|
{{??p.type == "midi"}}
|
||||||
|
atom:bufferType atom:Sequence ;
|
||||||
|
atom:supports midi:MidiEvent ;
|
||||||
|
{{?}}
|
||||||
|
{{?p.sidechain}}
|
||||||
|
lv2:portProperty lv2:isSideChain ;
|
||||||
|
{{?}}
|
||||||
|
{{?p.control}}
|
||||||
|
lv2:designation lv2:control ;
|
||||||
|
{{?}}
|
||||||
|
{{?p.optional}}
|
||||||
|
lv2:portProperty lv2:connectionOptional ;
|
||||||
|
{{?}}
|
||||||
|
lv2:index {{=i}}
|
||||||
|
{{?i < it.tibia.lv2.ports.length - 1}}
|
||||||
|
] , [
|
||||||
|
{{??}}
|
||||||
|
] .
|
||||||
|
{{?}}
|
||||||
|
{{~}}
|
||||||
|
|
||||||
|
{{?it.product.ui}}
|
||||||
|
plugin:ui
|
||||||
|
a ui:@UI_TYPE@ ;
|
||||||
|
ui:binary <{{=it.product.bundleName}}@DLL_SUFFIX@> ;
|
||||||
|
{{?!it.product.ui.userResizable}}
|
||||||
|
lv2:optionalFeature ui:noUserResize ; # doesn't work as lv2:requiredFeature, don't ask me why
|
||||||
|
{{?!it.product.ui.selfResizable}}
|
||||||
|
lv2:optionalFeature ui:fixedSize ;
|
||||||
|
{{?}}
|
||||||
|
{{?}}
|
||||||
|
lv2:requiredFeature ui:idleInterface ;
|
||||||
|
lv2:extensionData ui:idleInterface .
|
||||||
|
{{?}}
|
78
templates/lv2-next/src/data.h
Normal file
78
templates/lv2-next/src/data.h
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
* Tibia
|
||||||
|
*
|
||||||
|
* Copyright (C) 2024 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
|
||||||
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* Tibia is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Tibia. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* File author: Stefano D'Angelo
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define DATA_LV2_URI "{{=it.tibia.CGetUTF8StringLiteral(it.tibia.lv2.expandURI(it.lv2.uri))}}"
|
||||||
|
|
||||||
|
#define DATA_PRODUCT_AUDIO_INPUT_CHANNELS_N {{=it.product.buses.filter(x => x.type == "audio" && x.direction == "input").reduce((s, x) => s += x.channels == "mono" ? 1 : 2, 0)}}
|
||||||
|
#define DATA_PRODUCT_AUDIO_OUTPUT_CHANNELS_N {{=it.product.buses.filter(x => x.type == "audio" && x.direction == "output").reduce((s, x) => s += x.channels == "mono" ? 1 : 2, 0)}}
|
||||||
|
#define DATA_PRODUCT_MIDI_INPUTS_N {{=it.product.buses.filter(x => x.type == "midi" && x.direction == "input").length}}
|
||||||
|
#define DATA_PRODUCT_MIDI_OUTPUTS_N {{=it.product.buses.filter(x => x.type == "midi" && x.direction == "output").length}}
|
||||||
|
#define DATA_PRODUCT_CONTROL_INPUTS_N {{=it.product.parameters.filter(x => x.direction == "input").length}}
|
||||||
|
#define DATA_PRODUCT_CONTROL_OUTPUTS_N {{=it.product.parameters.filter(x => x.direction == "output").length}}
|
||||||
|
|
||||||
|
#if DATA_PRODUCT_MIDI_INPUTS_N > 0
|
||||||
|
static uint32_t midi_in_index[DATA_PRODUCT_MIDI_INPUTS_N] = {
|
||||||
|
{{~it.tibia.lv2.ports.filter(x => x.type == "midi" && x.direction == "input") :p}}{{=p.busIndex}}, {{~}}
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
||||||
|
|
||||||
|
# define DATA_PARAM_BYPASS 1
|
||||||
|
# define DATA_PARAM_TOGGLED (1<<1)
|
||||||
|
# define DATA_PARAM_INTEGER (1<<2)
|
||||||
|
|
||||||
|
static struct {
|
||||||
|
uint32_t index;
|
||||||
|
float min;
|
||||||
|
float max;
|
||||||
|
float def;
|
||||||
|
uint32_t flags;
|
||||||
|
} param_data[DATA_PRODUCT_CONTROL_INPUTS_N] = {
|
||||||
|
{{~it.tibia.lv2.ports.filter(x => x.type == "control" && x.direction == "input") :p}}
|
||||||
|
{
|
||||||
|
/* .index = */ {{=p.paramIndex}},
|
||||||
|
/* .min = */ {{=p.minimum.toExponential()}}f,
|
||||||
|
/* .max = */ {{=p.maximum.toExponential()}}f,
|
||||||
|
/* .def = */ {{=p.defaultValue.toExponential()}}f,
|
||||||
|
/* .flags = */ {{?p.isBypass}}DATA_PARAM_BYPASS{{??p.isLatency}}DATA_PARAM_INTEGER{{??}}0{{?p.toggled}} | DATA_PARAM_TOGGLED{{?}}{{?p.integer}} | DATA_PARAM_INTEGER{{?}}{{?}}
|
||||||
|
},
|
||||||
|
{{~}}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if DATA_PRODUCT_CONTROL_OUTPUTS_N > 0
|
||||||
|
static uint32_t param_out_index[DATA_PRODUCT_CONTROL_OUTPUTS_N] = {
|
||||||
|
{{~it.tibia.lv2.ports.filter(x => x.type == "control" && x.direction == "output") :p}}{{=p.paramIndex}}, {{~}}
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
{{?it.lv2.ui}}
|
||||||
|
#define DATA_UI
|
||||||
|
#define DATA_LV2_UI_URI "{{=it.tibia.CGetUTF8StringLiteral(it.tibia.lv2.expandURI(it.lv2.ui.uri))}}"
|
||||||
|
#define DATA_UI_USER_RESIZABLE {{=it.product.ui.userResizable ? 1 : 0}}
|
||||||
|
|
||||||
|
#if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
||||||
|
static uint32_t index_to_param[DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N] = {
|
||||||
|
{{~it.tibia.lv2.ports.filter(x => x.type == "control").map((e, i) => ({ i: i, pi: e.paramIndex })).sort((a, b) => a.pi - b.pi) :p}}{{=p.i + it.tibia.lv2.ports.filter(x => x.type != "control").length}}, {{~}}
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
{{?}}
|
499
templates/lv2-next/src/lv2.c
Normal file
499
templates/lv2-next/src/lv2.c
Normal file
@ -0,0 +1,499 @@
|
|||||||
|
/*
|
||||||
|
* Tibia
|
||||||
|
*
|
||||||
|
* Copyright (C) 2024 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
|
||||||
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* Tibia is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Tibia. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* File author: Stefano D'Angelo
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "data.h"
|
||||||
|
#include "plugin_api.h"
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||||
|
#include "plugin.h"
|
||||||
|
#ifdef DATA_UI
|
||||||
|
# include "plugin_ui.h"
|
||||||
|
#endif
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
|
#include "lv2/core/lv2.h"
|
||||||
|
#include "lv2/core/lv2_util.h"
|
||||||
|
#include "lv2/log/log.h"
|
||||||
|
#include "lv2/log/logger.h"
|
||||||
|
#include "lv2/urid/urid.h"
|
||||||
|
#if DATA_PRODUCT_MIDI_INPUTS_N + DATA_PRODUCT_MIDI_OUTPUTS_N > 0
|
||||||
|
# include "lv2/atom/util.h"
|
||||||
|
# include "lv2/atom/atom.h"
|
||||||
|
# include "lv2/midi/midi.h"
|
||||||
|
#endif
|
||||||
|
#ifdef DATA_UI
|
||||||
|
# include "lv2/ui/ui.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#if defined(__i386__) || defined(__x86_64__)
|
||||||
|
# include <xmmintrin.h>
|
||||||
|
# include <pmmintrin.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static inline float clampf(float x, float m, float M) {
|
||||||
|
return x < m ? m : (x > M ? M : x);
|
||||||
|
}
|
||||||
|
|
||||||
|
static float adjust_param(size_t index, float value) {
|
||||||
|
if (param_data[index].flags & DATA_PARAM_BYPASS)
|
||||||
|
value = value > 0.f ? 0.f : 1.f;
|
||||||
|
else if (param_data[index].flags & DATA_PARAM_TOGGLED)
|
||||||
|
value = value > 0.f ? 1.f : 0.f;
|
||||||
|
else if (param_data[index].flags & DATA_PARAM_INTEGER)
|
||||||
|
value = (int32_t)(value + (value >= 0.f ? 0.5f : -0.5f));
|
||||||
|
return clampf(value, param_data[index].min, param_data[index].max);
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
plugin p;
|
||||||
|
#if DATA_PRODUCT_AUDIO_INPUT_CHANNELS_N > 0
|
||||||
|
const float * x[DATA_PRODUCT_AUDIO_INPUT_CHANNELS_N];
|
||||||
|
#endif
|
||||||
|
#if DATA_PRODUCT_AUDIO_OUTPUT_CHANNELS_N > 0
|
||||||
|
float * y[DATA_PRODUCT_AUDIO_OUTPUT_CHANNELS_N];
|
||||||
|
#endif
|
||||||
|
#if DATA_PRODUCT_MIDI_INPUTS_N > 0
|
||||||
|
const LV2_Atom_Sequence * x_midi[DATA_PRODUCT_MIDI_INPUTS_N];
|
||||||
|
#endif
|
||||||
|
#if DATA_PRODUCT_MIDI_OUTPUTS_N > 0
|
||||||
|
LV2_Atom_Sequence * y_midi[DATA_PRODUCT_MIDI_OUTPUTS_N];
|
||||||
|
#endif
|
||||||
|
#if (DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N) > 0
|
||||||
|
float * c[DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N];
|
||||||
|
#endif
|
||||||
|
#if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
||||||
|
float params[DATA_PRODUCT_CONTROL_INPUTS_N];
|
||||||
|
#endif
|
||||||
|
void * mem;
|
||||||
|
char * bundle_path;
|
||||||
|
LV2_Log_Logger logger;
|
||||||
|
LV2_URID_Map * map;
|
||||||
|
#if DATA_PRODUCT_MIDI_INPUTS_N + DATA_PRODUCT_MIDI_OUTPUTS_N > 0
|
||||||
|
LV2_URID uri_midi_MidiEvent;
|
||||||
|
#endif
|
||||||
|
} plugin_instance;
|
||||||
|
|
||||||
|
static const char * get_bundle_path_cb(void *handle) {
|
||||||
|
plugin_instance *instance = (plugin_instance *)handle;
|
||||||
|
return instance->bundle_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
static LV2_Handle instantiate(const struct LV2_Descriptor * descriptor, double sample_rate, const char * bundle_path, const LV2_Feature * const * features) {
|
||||||
|
(void)descriptor;
|
||||||
|
(void)bundle_path;
|
||||||
|
|
||||||
|
plugin_instance *instance = malloc(sizeof(plugin_instance));
|
||||||
|
if (instance == NULL)
|
||||||
|
goto err_instance;
|
||||||
|
|
||||||
|
instance->bundle_path = strdup(bundle_path);
|
||||||
|
if (instance->bundle_path == NULL)
|
||||||
|
goto err_bundle_path;
|
||||||
|
|
||||||
|
// from https://lv2plug.in/book
|
||||||
|
const char* missing = lv2_features_query(features,
|
||||||
|
LV2_LOG__log, &instance->logger.log, false,
|
||||||
|
LV2_URID__map, &instance->map, true,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
lv2_log_logger_set_map(&instance->logger, instance->map);
|
||||||
|
if (missing) {
|
||||||
|
lv2_log_error(&instance->logger, "Missing feature <%s>\n", missing);
|
||||||
|
goto err_urid;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if DATA_PRODUCT_MIDI_INPUTS_N + DATA_PRODUCT_MIDI_OUTPUTS_N > 0
|
||||||
|
instance->uri_midi_MidiEvent = instance->map->map(instance->map->handle, LV2_MIDI__MidiEvent);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
plugin_callbacks cbs = {
|
||||||
|
/* .handle = */ (void *)instance,
|
||||||
|
/* .format = */ "lv2",
|
||||||
|
/* .get_bindir = */ get_bundle_path_cb,
|
||||||
|
/* .get_datadir = */ get_bundle_path_cb
|
||||||
|
};
|
||||||
|
plugin_init(&instance->p, &cbs);
|
||||||
|
|
||||||
|
plugin_set_sample_rate(&instance->p, sample_rate);
|
||||||
|
size_t req = plugin_mem_req(&instance->p);
|
||||||
|
if (req != 0) {
|
||||||
|
instance->mem = malloc(req);
|
||||||
|
if (instance->mem == NULL) {
|
||||||
|
lv2_log_error(&instance->logger, "Not enough memory\n");
|
||||||
|
goto err_mem;
|
||||||
|
}
|
||||||
|
plugin_mem_set(&instance->p, instance->mem);
|
||||||
|
} else
|
||||||
|
instance->mem = NULL;
|
||||||
|
|
||||||
|
#if DATA_PRODUCT_AUDIO_INPUT_CHANNELS_N > 0
|
||||||
|
for (uint32_t i = 0; i < DATA_PRODUCT_AUDIO_INPUT_CHANNELS_N; i++)
|
||||||
|
instance->x[i] = NULL;
|
||||||
|
#endif
|
||||||
|
#if DATA_PRODUCT_AUDIO_OUTPUT_CHANNELS_N > 0
|
||||||
|
for (uint32_t i = 0; i < DATA_PRODUCT_AUDIO_OUTPUT_CHANNELS_N; i++)
|
||||||
|
instance->y[i] = NULL;
|
||||||
|
#endif
|
||||||
|
#if DATA_PRODUCT_MIDI_INPUTS_N > 0
|
||||||
|
for (uint32_t i = 0; i < DATA_PRODUCT_MIDI_INPUTS_N; i++)
|
||||||
|
instance->x_midi[i] = NULL;
|
||||||
|
#endif
|
||||||
|
#if DATA_PRODUCT_MIDI_OUTPUTS_N > 0
|
||||||
|
for (uint32_t i = 0; i < DATA_PRODUCT_MIDI_OUTPUTS_N; i++)
|
||||||
|
instance->y_midi[i] = NULL;
|
||||||
|
#endif
|
||||||
|
#if (DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N) > 0
|
||||||
|
for (uint32_t i = 0; i < DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N; i++)
|
||||||
|
instance->c[i] = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
|
||||||
|
err_mem:
|
||||||
|
plugin_fini(&instance->p);
|
||||||
|
err_urid:
|
||||||
|
free(instance->bundle_path);
|
||||||
|
err_bundle_path:
|
||||||
|
free(instance);
|
||||||
|
err_instance:
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void connect_port(LV2_Handle instance, uint32_t port, void * data_location) {
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void activate(LV2_Handle instance) {
|
||||||
|
plugin_instance * i = (plugin_instance *)instance;
|
||||||
|
#if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
||||||
|
for (uint32_t j = 0; j < DATA_PRODUCT_CONTROL_INPUTS_N; j++) {
|
||||||
|
i->params[j] = i->c[j] != NULL ? *i->c[j] : param_data[j].def;
|
||||||
|
plugin_set_parameter(&i->p, param_data[j].index, i->params[j]);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
plugin_reset(&i->p);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void run(LV2_Handle instance, uint32_t sample_count) {
|
||||||
|
plugin_instance * i = (plugin_instance *)instance;
|
||||||
|
|
||||||
|
#if defined(__aarch64__)
|
||||||
|
uint64_t fpcr;
|
||||||
|
__asm__ __volatile__ ("mrs %0, fpcr" : "=r"(fpcr));
|
||||||
|
__asm__ __volatile__ ("msr fpcr, %0" :: "r"(fpcr | 0x1000000)); // enable FZ
|
||||||
|
#elif defined(__i386__) || defined(__x86_64__)
|
||||||
|
const unsigned int flush_zero_mode = _MM_GET_FLUSH_ZERO_MODE();
|
||||||
|
const unsigned int denormals_zero_mode = _MM_GET_DENORMALS_ZERO_MODE();
|
||||||
|
|
||||||
|
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
|
||||||
|
_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
||||||
|
for (uint32_t j = 0; j < DATA_PRODUCT_CONTROL_INPUTS_N; j++) {
|
||||||
|
if (i->c[j] == NULL)
|
||||||
|
continue;
|
||||||
|
float v = adjust_param(j, *i->c[j]);
|
||||||
|
if (v != i->params[j]) {
|
||||||
|
i->params[j] = v;
|
||||||
|
plugin_set_parameter(&i->p, param_data[j].index, v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// from https://lv2plug.in/book
|
||||||
|
#if DATA_PRODUCT_MIDI_INPUTS_N > 0
|
||||||
|
for (size_t j = 0; j < DATA_PRODUCT_MIDI_INPUTS_N; j++) {
|
||||||
|
if (i->x_midi[j] == NULL)
|
||||||
|
continue;
|
||||||
|
LV2_ATOM_SEQUENCE_FOREACH(i->x_midi[j], ev) {
|
||||||
|
if (ev->body.type == i->uri_midi_MidiEvent) {
|
||||||
|
const uint8_t * data = (const uint8_t *)(ev + 1);
|
||||||
|
if ((data[0] & 0xf0) != 0xf0)
|
||||||
|
plugin_midi_msg_in(&i->p, midi_in_index[j], data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if DATA_PRODUCT_AUDIO_INPUT_CHANNELS_N > 0
|
||||||
|
const float ** x = i->x;
|
||||||
|
#else
|
||||||
|
const float ** x = NULL;
|
||||||
|
#endif
|
||||||
|
#if DATA_PRODUCT_AUDIO_OUTPUT_CHANNELS_N > 0
|
||||||
|
float ** y = i-> y;
|
||||||
|
#else
|
||||||
|
float ** y = NULL;
|
||||||
|
#endif
|
||||||
|
plugin_process(&i->p, x, y, sample_count);
|
||||||
|
|
||||||
|
#if DATA_PRODUCT_CONTROL_OUTPUTS_N > 0
|
||||||
|
for (uint32_t j = 0; j < DATA_PRODUCT_CONTROL_OUTPUTS_N; j++) {
|
||||||
|
uint32_t k = param_out_index[j];
|
||||||
|
if (i->c[k] != NULL)
|
||||||
|
*i->c[k] = plugin_get_parameter(&i->p, k);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
(void)plugin_get_parameter;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__aarch64__)
|
||||||
|
__asm__ __volatile__ ("msr fpcr, %0" : : "r"(fpcr));
|
||||||
|
#elif defined(__i386__) || defined(__x86_64__)
|
||||||
|
_MM_SET_FLUSH_ZERO_MODE(flush_zero_mode);
|
||||||
|
_MM_SET_DENORMALS_ZERO_MODE(denormals_zero_mode);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void cleanup(LV2_Handle instance) {
|
||||||
|
plugin_instance * i = (plugin_instance *)instance;
|
||||||
|
plugin_fini(&i->p);
|
||||||
|
if (i->mem)
|
||||||
|
free(i->mem);
|
||||||
|
free(i->bundle_path);
|
||||||
|
free(instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const LV2_Descriptor descriptor = {
|
||||||
|
/* .URI = */ DATA_LV2_URI,
|
||||||
|
/* .instantiate = */ instantiate,
|
||||||
|
/* .connect_port = */ connect_port,
|
||||||
|
/* .activate = */ activate,
|
||||||
|
/* .run = */ run,
|
||||||
|
/* .deactivate = */ NULL,
|
||||||
|
/* .cleanup = */ cleanup,
|
||||||
|
/* .extension_data = */ NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
LV2_SYMBOL_EXPORT const LV2_Descriptor * lv2_descriptor(uint32_t index) {
|
||||||
|
return index == 0 ? &descriptor : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef DATA_UI
|
||||||
|
typedef struct {
|
||||||
|
plugin_ui * ui;
|
||||||
|
char * bundle_path;
|
||||||
|
# if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
||||||
|
LV2UI_Write_Function write;
|
||||||
|
LV2UI_Controller controller;
|
||||||
|
char has_touch;
|
||||||
|
LV2UI_Touch touch;
|
||||||
|
# endif
|
||||||
|
} ui_instance;
|
||||||
|
|
||||||
|
# define CONTROL_INPUT_INDEX_OFFSET ( \
|
||||||
|
DATA_PRODUCT_AUDIO_INPUT_CHANNELS_N \
|
||||||
|
+ DATA_PRODUCT_AUDIO_OUTPUT_CHANNELS_N \
|
||||||
|
+ DATA_PRODUCT_MIDI_INPUTS_N \
|
||||||
|
+ DATA_PRODUCT_MIDI_OUTPUTS_N )
|
||||||
|
# define CONTROL_OUTPUT_INDEX_OFFSET (CONTROL_INPUT_INDEX_OFFSET + DATA_PRODUCT_CONTROL_INPUTS_N)
|
||||||
|
|
||||||
|
static const char * ui_get_bundle_path_cb(void *handle) {
|
||||||
|
ui_instance *instance = (ui_instance *)handle;
|
||||||
|
return instance->bundle_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
# if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
||||||
|
static void ui_set_parameter_begin_cb(void *handle, size_t index, float value) {
|
||||||
|
ui_instance *instance = (ui_instance *)handle;
|
||||||
|
if (instance->has_touch) {
|
||||||
|
index = index_to_param[index];
|
||||||
|
instance->touch.touch(instance->touch.handle, index, true);
|
||||||
|
value = adjust_param(index - CONTROL_INPUT_INDEX_OFFSET, value);
|
||||||
|
instance->write(instance->controller, index, sizeof(float), 0, &value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ui_set_parameter_cb(void *handle, size_t index, float value) {
|
||||||
|
ui_instance *instance = (ui_instance *)handle;
|
||||||
|
index = index_to_param[index];
|
||||||
|
value = adjust_param(index - CONTROL_INPUT_INDEX_OFFSET, value);
|
||||||
|
instance->write(instance->controller, index, sizeof(float), 0, &value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ui_set_parameter_end_cb(void *handle, size_t index, float value) {
|
||||||
|
ui_instance *instance = (ui_instance *)handle;
|
||||||
|
if (instance->has_touch) {
|
||||||
|
index = index_to_param[index];
|
||||||
|
value = adjust_param(index - CONTROL_INPUT_INDEX_OFFSET, value);
|
||||||
|
instance->write(instance->controller, index, sizeof(float), 0, &value);
|
||||||
|
instance->touch.touch(instance->touch.handle, index, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
|
static LV2UI_Handle ui_instantiate(const LV2UI_Descriptor * descriptor, const char * plugin_uri, const char * bundle_path, LV2UI_Write_Function write_function, LV2UI_Controller controller, LV2UI_Widget * widget, const LV2_Feature * const * features) {
|
||||||
|
(void)descriptor;
|
||||||
|
(void)plugin_uri;
|
||||||
|
|
||||||
|
ui_instance *instance = malloc(sizeof(ui_instance));
|
||||||
|
if (instance == NULL)
|
||||||
|
goto err_instance;
|
||||||
|
|
||||||
|
instance->bundle_path = strdup(bundle_path);
|
||||||
|
if (instance->bundle_path == NULL)
|
||||||
|
goto err_bundle_path;
|
||||||
|
|
||||||
|
char has_parent = 0;
|
||||||
|
void *parent = NULL;
|
||||||
|
instance->has_touch = 0;
|
||||||
|
for (size_t i = 0; features[i] != NULL; i++) {
|
||||||
|
if (!strcmp(features[i]->URI, LV2_UI__parent)) {
|
||||||
|
has_parent = 1;
|
||||||
|
parent = features[i]->data;
|
||||||
|
}
|
||||||
|
if (!strcmp(features[i]->URI, LV2_UI__touch)) {
|
||||||
|
instance->has_touch = 1;
|
||||||
|
instance->touch = *((LV2UI_Touch *)features[i]->data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin_ui_callbacks cbs = {
|
||||||
|
/* .handle = */ (void *)instance,
|
||||||
|
/* .format = */ "lv2",
|
||||||
|
/* .get_bindir = */ ui_get_bundle_path_cb,
|
||||||
|
/* .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
|
||||||
|
# else
|
||||||
|
/* .set_parameter_begin = */ NULL,
|
||||||
|
/* .set_parameter = */ NULL,
|
||||||
|
/* .set_parameter_end = */ NULL
|
||||||
|
# endif
|
||||||
|
};
|
||||||
|
# if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
||||||
|
instance->write = write_function;
|
||||||
|
instance->controller = controller;
|
||||||
|
# else
|
||||||
|
(void)write_function;
|
||||||
|
(void)controller;
|
||||||
|
# endif
|
||||||
|
instance->ui = plugin_ui_create(has_parent, parent, &cbs);
|
||||||
|
if (instance->ui == NULL)
|
||||||
|
goto err_create;
|
||||||
|
|
||||||
|
*widget = instance->ui->widget;
|
||||||
|
return instance;
|
||||||
|
|
||||||
|
err_create:
|
||||||
|
free(instance->bundle_path);
|
||||||
|
err_bundle_path:
|
||||||
|
free(instance);
|
||||||
|
err_instance:
|
||||||
|
*widget = NULL;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ui_cleanup(LV2UI_Handle handle) {
|
||||||
|
ui_instance *instance = (ui_instance *)handle;
|
||||||
|
plugin_ui_free(instance->ui);
|
||||||
|
free(instance->bundle_path);
|
||||||
|
free(instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
# if DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N > 0
|
||||||
|
static void ui_port_event(LV2UI_Handle handle, uint32_t port_index, uint32_t buffer_size, uint32_t format, const void * buffer) {
|
||||||
|
(void)buffer_size;
|
||||||
|
(void)format;
|
||||||
|
|
||||||
|
ui_instance *instance = (ui_instance *)handle;
|
||||||
|
# if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
||||||
|
if (port_index < CONTROL_OUTPUT_INDEX_OFFSET) {
|
||||||
|
size_t index = port_index - CONTROL_INPUT_INDEX_OFFSET;
|
||||||
|
plugin_ui_set_parameter(instance->ui, param_data[index].index, adjust_param(index, *((float *)buffer)));
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
# if DATA_PRODUCT_CONTROL_OUTPUTS_N > 0
|
||||||
|
# if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
||||||
|
else
|
||||||
|
# endif
|
||||||
|
plugin_ui_set_parameter(instance->ui, param_out_index[port_index - CONTROL_OUTPUT_INDEX_OFFSET], *((float *)buffer));
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
|
static int ui_idle(LV2UI_Handle handle) {
|
||||||
|
ui_instance *instance = (ui_instance *)handle;
|
||||||
|
plugin_ui_idle(instance->ui);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const void * ui_extension_data(const char * uri) {
|
||||||
|
static const LV2UI_Idle_Interface idle = { ui_idle };
|
||||||
|
if (!strcmp(uri, LV2_UI__idleInterface))
|
||||||
|
return &idle;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const LV2UI_Descriptor ui_descriptor = {
|
||||||
|
/* .URI = */ DATA_LV2_UI_URI,
|
||||||
|
/* .instantiate = */ ui_instantiate,
|
||||||
|
/* .cleanup = */ ui_cleanup,
|
||||||
|
# if DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N > 0
|
||||||
|
/* .port_event = */ ui_port_event,
|
||||||
|
# else
|
||||||
|
/* .port_event = */ NULL,
|
||||||
|
# endif
|
||||||
|
/* .extension_data = */ ui_extension_data
|
||||||
|
};
|
||||||
|
|
||||||
|
LV2_SYMBOL_EXPORT const LV2UI_Descriptor * lv2ui_descriptor(uint32_t index) {
|
||||||
|
return index == 0 ? &ui_descriptor : NULL;
|
||||||
|
}
|
||||||
|
#endif
|
136
templates/lv2-next/tibia-index.js
Normal file
136
templates/lv2-next/tibia-index.js
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
/*
|
||||||
|
* Tibia
|
||||||
|
*
|
||||||
|
* Copyright (C) 2024 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
|
||||||
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* Tibia is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Tibia. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* File author: Stefano D'Angelo
|
||||||
|
*/
|
||||||
|
|
||||||
|
var path = require("path");
|
||||||
|
var sep = path.sep;
|
||||||
|
|
||||||
|
module.exports = function (data, api, outputCommon, outputData) {
|
||||||
|
if (outputData) {
|
||||||
|
data.tibia.lv2 = {
|
||||||
|
prefixes: [
|
||||||
|
{ id: "atom", uri: "http://lv2plug.in/ns/ext/atom#" },
|
||||||
|
{ id: "doap", uri: "http://usefulinc.com/ns/doap#" },
|
||||||
|
{ id: "foaf", uri: "http://xmlns.com/foaf/0.1/" },
|
||||||
|
{ id: "log", uri: "http://lv2plug.in/ns/ext/log#" },
|
||||||
|
{ id: "lv2", uri: "http://lv2plug.in/ns/lv2core#" },
|
||||||
|
{ id: "midi", uri: "http://lv2plug.in/ns/ext/midi#" },
|
||||||
|
{ id: "patch", uri: "http://lv2plug.in/ns/ext/patch#" },
|
||||||
|
{ id: "pprops", uri: "http://lv2plug.in/ns/ext/port-props#" },
|
||||||
|
{ id: "rdf", uri: "http://www.w3.org/1999/02/22-rdf-syntax-ns#" },
|
||||||
|
{ id: "rdfs", uri: "http://www.w3.org/2000/01/rdf-schema#" },
|
||||||
|
{ id: "ui", uri: "http://lv2plug.in/ns/extensions/ui#" },
|
||||||
|
{ id: "units", uri: "http://lv2plug.in/ns/extensions/units#" },
|
||||||
|
{ id: "urid", uri: "http://lv2plug.in/ns/ext/urid#" }
|
||||||
|
],
|
||||||
|
units: {
|
||||||
|
"bar": "@units:bar",
|
||||||
|
"beat": "@units:beat",
|
||||||
|
"bpm": "@units:bpm",
|
||||||
|
"cent": "@units:cent",
|
||||||
|
"cm": "@units:cm",
|
||||||
|
"coef": "@units:coef",
|
||||||
|
"db": "@units:db",
|
||||||
|
"degree": "@units:degree",
|
||||||
|
"frame": "@units:frame",
|
||||||
|
"hz": "@units:hz",
|
||||||
|
"inch": "@units:inch",
|
||||||
|
"khz": "@units:khz",
|
||||||
|
"km": "@units:km",
|
||||||
|
"m": "@units:m",
|
||||||
|
"mhz": "@units:mhz",
|
||||||
|
"midiNote": "@units:midiNote",
|
||||||
|
"mile": "@units:mile",
|
||||||
|
"min": "@units:min",
|
||||||
|
"mm": "@units:mm",
|
||||||
|
"ms": "@units:ms",
|
||||||
|
"oct": "@units:oct",
|
||||||
|
"pc": "@units:pc",
|
||||||
|
"s": "@units:s",
|
||||||
|
"semitone12TET": "@units:semitone12TET"
|
||||||
|
},
|
||||||
|
ports: [],
|
||||||
|
|
||||||
|
ttlURI: function (uri) {
|
||||||
|
if (uri.charAt(0) == "@") {
|
||||||
|
if (uri.indexOf("#") == -1)
|
||||||
|
return uri.substring(1);
|
||||||
|
uri = data.tibia.lv2.expandURI(uri);
|
||||||
|
}
|
||||||
|
return "<" + uri + ">";
|
||||||
|
},
|
||||||
|
|
||||||
|
expandURI: function (uri) {
|
||||||
|
if (uri.charAt(0) != "@")
|
||||||
|
return uri;
|
||||||
|
var i = uri.indexOf(":");
|
||||||
|
var p = uri.substring(1, uri.indexOf(":"));
|
||||||
|
return data.tibia.lv2.prefixes.find(x => x.id == p).uri + uri.substring(i + 1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
for (var id in data.lv2.prefixes)
|
||||||
|
data.tibia.lv2.prefixes.push({ id: id, uri: data.lv2.prefixes[id] });
|
||||||
|
|
||||||
|
data.tibia.lv2.prefixes.push({ id: "plugin", uri: data.tibia.lv2.expandURI(data.lv2.uri) + "#" });
|
||||||
|
|
||||||
|
var buses = data.product.buses;
|
||||||
|
var audioPorts = [];
|
||||||
|
var midiPorts = [];
|
||||||
|
for (var bi = 0; bi < buses.length; bi++) {
|
||||||
|
var b = buses[bi];
|
||||||
|
if (b.type == "audio") {
|
||||||
|
if (b.channels == "mono") {
|
||||||
|
var e = { type: "audio", direction: b.direction, name: b.name, sidechain: b.sidechain, cv: b.cv, optional: b.optional, busIndex: bi, id: b.id };
|
||||||
|
audioPorts.push(e);
|
||||||
|
} else {
|
||||||
|
var e = { type: "audio", direction: b.direction, name: b.name + " Left", shortName: b.shortName + " L", sidechain: b.sidechain, cv: b.cv, busIndex: bi, id: b.id + "_l" };
|
||||||
|
audioPorts.push(e);
|
||||||
|
var e = { type: "audio", direction: b.direction, name: b.name + " Right", shortName: b.shortName + " R", sidechain: b.sidechain, cv: b.cv, busIndex: bi, id: b.id + "_r" };
|
||||||
|
audioPorts.push(e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var e = { type: "midi", direction: b.direction, name: b.name, sidechain: b.sidechain, control: b.control, optional: b.optional, busIndex: bi, id: b.id };
|
||||||
|
midiPorts.push(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
audioPorts.sort((a, b) => a.direction != b.direction ? (a.direction == "input" ? -1 : 1) : 0);
|
||||||
|
midiPorts.sort((a, b) => a.direction != b.direction ? (a.direction == "input" ? -1 : 1) : 0);
|
||||||
|
data.tibia.lv2.ports.push.apply(data.tibia.lv2.ports, audioPorts);
|
||||||
|
data.tibia.lv2.ports.push.apply(data.tibia.lv2.ports, midiPorts);
|
||||||
|
|
||||||
|
var hasCtrlIn = false;
|
||||||
|
var hasCtrlOut = false;
|
||||||
|
for (var i = 0; i < data.product.parameters.length && !(hasCtrlIn && hasCtrlOut); i++) {
|
||||||
|
var p = data.product.parameters[i];
|
||||||
|
if (p.direction == "input")
|
||||||
|
hasCtrlIn = true;
|
||||||
|
else
|
||||||
|
hasCtrlOut = true;
|
||||||
|
}
|
||||||
|
if (hasCtrlIn)
|
||||||
|
data.tibia.lv2.ports.push({ type: "param", direction: "input", name: "Control in", id: "control_in", control: true });
|
||||||
|
if (hasCtrlOut)
|
||||||
|
data.tibia.lv2.ports.push({ type: "param", direction: "output", name: "Control out", id: "control_out", control: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
api.generateFileFromTemplateFile(`data${sep}manifest.ttl.in`, `data${sep}manifest.ttl.in`, data);
|
||||||
|
api.copyFile(`src${sep}lv2.c`, `src${sep}lv2.c`);
|
||||||
|
api.generateFileFromTemplateFile(`src${sep}data.h`, `src${sep}data.h`, data);
|
||||||
|
};
|
@ -31,11 +31,20 @@
|
|||||||
lv2:optionalFeature state:threadSafeRestore ;
|
lv2:optionalFeature state:threadSafeRestore ;
|
||||||
{{?}}
|
{{?}}
|
||||||
{{?it.product.ui}}
|
{{?it.product.ui}}
|
||||||
ui:ui {{=it.tibia.lv2.ttlURI(it.lv2.ui.uri)}} ;
|
ui:ui plugin:ui ;
|
||||||
{{?}}
|
{{?}}
|
||||||
{{?(it.product.state && it.product.state.dspCustom)}}
|
{{?(it.product.state && it.product.state.dspCustom)}}
|
||||||
lv2:extensionData state:interface ;
|
lv2:extensionData state:interface ;
|
||||||
{{?}}
|
{{?}}
|
||||||
|
|
||||||
|
{{~it.tibia.lv2.parameters:p:i}}
|
||||||
|
{{?p.direction == "input"}}
|
||||||
|
patch:writable plugin:{{=p.id}};
|
||||||
|
{{??}}
|
||||||
|
patch:readable plugin:{{=p.id}};
|
||||||
|
{{?}}
|
||||||
|
{{~}}
|
||||||
|
|
||||||
lv2:port [
|
lv2:port [
|
||||||
{{~it.tibia.lv2.ports :p:i}}
|
{{~it.tibia.lv2.ports :p:i}}
|
||||||
{{?p.isBypass}}
|
{{?p.isBypass}}
|
||||||
@ -68,6 +77,22 @@
|
|||||||
lv2:portProperty lv2:connectionOptional ;
|
lv2:portProperty lv2:connectionOptional ;
|
||||||
lv2:portProperty lv2:integer ;
|
lv2:portProperty lv2:integer ;
|
||||||
lv2:portProperty lv2:reportsLatency ;
|
lv2:portProperty lv2:reportsLatency ;
|
||||||
|
{{??p.isInputParameterMessage}}
|
||||||
|
a lv2:InputPort ,
|
||||||
|
atom:AtomPort ;
|
||||||
|
atom:bufferType atom:Sequence ;
|
||||||
|
atom:supports patch:Message ;
|
||||||
|
lv2:designation lv2:control ;
|
||||||
|
lv2:symbol "InputParameterMessage" ;
|
||||||
|
lv2:name "InputParameterMessage" ;
|
||||||
|
{{??p.isOutputParameterMessage}}
|
||||||
|
a lv2:OutputPort ,
|
||||||
|
atom:AtomPort ;
|
||||||
|
atom:bufferType atom:Sequence ;
|
||||||
|
atom:supports patch:Message ;
|
||||||
|
lv2:designation lv2:control ;
|
||||||
|
lv2:symbol "OutputParameterMessage" ;
|
||||||
|
lv2:name "OutputParameterMessage" ;
|
||||||
{{??}}
|
{{??}}
|
||||||
a {{?p.type == "control"}}lv2:ControlPort{{??p.type == "midi"}}atom:AtomPort{{??}}{{?p.cv}}lv2:CVPort{{??}}lv2:AudioPort{{?}}{{?}} ,
|
a {{?p.type == "control"}}lv2:ControlPort{{??p.type == "midi"}}atom:AtomPort{{??}}{{?p.cv}}lv2:CVPort{{??}}lv2:AudioPort{{?}}{{?}} ,
|
||||||
{{?p.direction == "input"}}lv2:InputPort{{??}}lv2:OutputPort{{?}} ;
|
{{?p.direction == "input"}}lv2:InputPort{{??}}lv2:OutputPort{{?}} ;
|
||||||
@ -129,8 +154,22 @@
|
|||||||
{{?}}
|
{{?}}
|
||||||
{{~}}
|
{{~}}
|
||||||
|
|
||||||
|
{{~it.tibia.lv2.parameters:p:i}}
|
||||||
|
|
||||||
|
plugin:{{=p.id}}
|
||||||
|
a lv2:Parameter ;
|
||||||
|
rdfs:label "{{=p.name}}" ;
|
||||||
|
rdfs:range {{?p.toggled}}atom:Bool{{??p.integer}}atom:Int{{??}}atom:Float{{?}} ;
|
||||||
|
{{?p.unit && p.unit in it.tibia.lv2.units}}
|
||||||
|
units:unit {{=it.tibia.lv2.ttlURI(it.tibia.lv2.units[p.unit])}} ;
|
||||||
|
{{?}}
|
||||||
|
lv2:minimum {{=p.minimum.toExponential()}} ;
|
||||||
|
lv2:maximum {{=p.maximum.toExponential()}} ;
|
||||||
|
lv2:default {{=p.defaultValue.toExponential()}} .
|
||||||
|
{{~}}
|
||||||
|
|
||||||
{{?it.product.ui}}
|
{{?it.product.ui}}
|
||||||
{{=it.tibia.lv2.ttlURI(it.lv2.ui.uri)}}
|
plugin:ui
|
||||||
a ui:@UI_TYPE@ ;
|
a ui:@UI_TYPE@ ;
|
||||||
ui:binary <{{=it.product.bundleName}}@DLL_SUFFIX@> ;
|
ui:binary <{{=it.product.bundleName}}@DLL_SUFFIX@> ;
|
||||||
{{?!it.product.ui.userResizable}}
|
{{?!it.product.ui.userResizable}}
|
||||||
|
@ -37,12 +37,56 @@ static uint32_t midi_in_index[DATA_PRODUCT_MIDI_INPUTS_N] = {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
|
||||||
|
|
||||||
# define DATA_PARAM_BYPASS 1
|
# define DATA_PARAM_BYPASS 1
|
||||||
# define DATA_PARAM_TOGGLED (1<<1)
|
# define DATA_PARAM_TOGGLED (1<<1)
|
||||||
# define DATA_PARAM_INTEGER (1<<2)
|
# define DATA_PARAM_INTEGER (1<<2)
|
||||||
|
|
||||||
|
{{?it.lv2.use_parameters}}
|
||||||
|
#define DATA_PRODUCT_USE_PARAMETERS 1
|
||||||
|
|
||||||
|
{{?it.tibia.lv2.ports.find(p => p.isInputParameterMessage)}}
|
||||||
|
#define DATA_PRODUCT_IPM {{=it.tibia.lv2.ports.indexOf(it.tibia.lv2.ports.find(p => p.isInputParameterMessage))}}
|
||||||
|
{{?}}
|
||||||
|
{{?it.tibia.lv2.ports.find(p => p.isOutputParameterMessage)}}
|
||||||
|
#define DATA_PRODUCT_OPM {{=it.tibia.lv2.ports.indexOf(it.tibia.lv2.ports.find(p => p.isOutputParameterMessage))}}
|
||||||
|
{{?}}
|
||||||
|
|
||||||
|
|
||||||
|
#if DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N > 0
|
||||||
|
|
||||||
|
static struct {
|
||||||
|
uint32_t index;
|
||||||
|
float min;
|
||||||
|
float max;
|
||||||
|
float def;
|
||||||
|
uint32_t flags;
|
||||||
|
const char *id;
|
||||||
|
} param_data[DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N] = {
|
||||||
|
{{~it.tibia.lv2.parameters :p}}
|
||||||
|
{
|
||||||
|
/* .index = */ {{=p.paramIndex}},
|
||||||
|
/* .min = */ {{=p.minimum.toExponential()}}f,
|
||||||
|
/* .max = */ {{=p.maximum.toExponential()}}f,
|
||||||
|
/* .def = */ {{=p.defaultValue.toExponential()}}f,
|
||||||
|
/* .flags = */ {{?p.isBypass}}DATA_PARAM_BYPASS{{??p.isLatency}}DATA_PARAM_INTEGER{{??}}0{{?p.toggled}} | DATA_PARAM_TOGGLED{{?}}{{?p.integer}} | DATA_PARAM_INTEGER{{?}}{{?}},
|
||||||
|
/* .id = */ DATA_LV2_URI"#{{=p.id}}"
|
||||||
|
},
|
||||||
|
{{~}}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if DATA_PRODUCT_CONTROL_OUTPUTS_N > 0
|
||||||
|
static uint32_t param_out_index[DATA_PRODUCT_CONTROL_OUTPUTS_N] = {
|
||||||
|
{{~it.tibia.lv2.parameters.filter(x => x.direction == "output") :p}}{{=p.paramIndex}}, {{~}}
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
{{??}}
|
||||||
|
|
||||||
|
#if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
uint32_t index;
|
uint32_t index;
|
||||||
float min;
|
float min;
|
||||||
@ -69,9 +113,11 @@ static uint32_t param_out_index[DATA_PRODUCT_CONTROL_OUTPUTS_N] = {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
{{?}}
|
||||||
|
|
||||||
{{?it.product.ui}}
|
{{?it.product.ui}}
|
||||||
#define DATA_UI
|
#define DATA_UI
|
||||||
#define DATA_LV2_UI_URI "{{=it.tibia.CGetUTF8StringLiteral(it.tibia.lv2.expandURI(it.lv2.ui.uri))}}"
|
#define DATA_LV2_UI_URI "{{=it.tibia.CGetUTF8StringLiteral(it.tibia.lv2.expandURI(it.lv2.uri + '#ui'))}}"
|
||||||
#define DATA_UI_USER_RESIZABLE {{=it.product.ui.userResizable ? 1 : 0}}
|
#define DATA_UI_USER_RESIZABLE {{=it.product.ui.userResizable ? 1 : 0}}
|
||||||
{{?}}
|
{{?}}
|
||||||
|
|
||||||
|
@ -49,6 +49,10 @@
|
|||||||
#ifdef DATA_STATE_DSP_CUSTOM
|
#ifdef DATA_STATE_DSP_CUSTOM
|
||||||
# include <lv2/state/state.h>
|
# include <lv2/state/state.h>
|
||||||
#endif
|
#endif
|
||||||
|
#if DATA_PRODUCT_USE_PARAMETERS
|
||||||
|
# include "lv2/lv2plug.in/ns/ext/patch/patch.h"
|
||||||
|
# include <lv2/lv2plug.in/ns/ext/atom/forge.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@ -58,11 +62,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (DATA_PRODUCT_CONTROL_INPUTS_N > 0) && defined(DATA_STATE_DSP_CUSTOM)
|
#if (DATA_PRODUCT_CONTROL_INPUTS_N > 0) && defined(DATA_STATE_DSP_CUSTOM)
|
||||||
# ifdef __cplusplus
|
|
||||||
# include <atomic>
|
|
||||||
# else
|
|
||||||
# include <stdatomic.h>
|
# include <stdatomic.h>
|
||||||
# endif
|
|
||||||
# if defined(_WIN32) || defined(__CYGWIN__)
|
# if defined(_WIN32) || defined(__CYGWIN__)
|
||||||
# include <processthreadsapi.h>
|
# include <processthreadsapi.h>
|
||||||
# define yield SwitchToThread
|
# define yield SwitchToThread
|
||||||
@ -97,7 +97,6 @@ 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
|
||||||
@ -110,18 +109,11 @@ typedef struct {
|
|||||||
#if DATA_PRODUCT_MIDI_OUTPUTS_N > 0
|
#if DATA_PRODUCT_MIDI_OUTPUTS_N > 0
|
||||||
LV2_Atom_Sequence * y_midi[DATA_PRODUCT_MIDI_OUTPUTS_N];
|
LV2_Atom_Sequence * y_midi[DATA_PRODUCT_MIDI_OUTPUTS_N];
|
||||||
#endif
|
#endif
|
||||||
#if (DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N) > 0
|
|
||||||
float * c[DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N];
|
|
||||||
#endif
|
|
||||||
#if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
#if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
||||||
float params[DATA_PRODUCT_CONTROL_INPUTS_N];
|
float params[DATA_PRODUCT_CONTROL_INPUTS_N];
|
||||||
# ifdef DATA_STATE_DSP_CUSTOM
|
# ifdef DATA_STATE_DSP_CUSTOM
|
||||||
float params_sync[DATA_PRODUCT_CONTROL_INPUTS_N];
|
float params_sync[DATA_PRODUCT_CONTROL_INPUTS_N];
|
||||||
# ifdef __cplusplus
|
|
||||||
std::atomic_flag sync_lock_flag;
|
|
||||||
# else
|
|
||||||
atomic_flag sync_lock_flag;
|
atomic_flag sync_lock_flag;
|
||||||
# endif
|
|
||||||
char synced;
|
char synced;
|
||||||
char loaded;
|
char loaded;
|
||||||
# endif
|
# endif
|
||||||
@ -140,6 +132,30 @@ typedef struct {
|
|||||||
LV2_State_Store_Function state_store;
|
LV2_State_Store_Function state_store;
|
||||||
LV2_State_Handle state_handle;
|
LV2_State_Handle state_handle;
|
||||||
#endif
|
#endif
|
||||||
|
#if (DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N) > 0
|
||||||
|
# if DATA_PRODUCT_USE_PARAMETERS
|
||||||
|
LV2_URID uri_atom_Blank;
|
||||||
|
LV2_URID uri_atom_Object;
|
||||||
|
LV2_URID uri_atom_URID;
|
||||||
|
LV2_URID uri_atom_Float;
|
||||||
|
LV2_URID uri_atom_Bool;
|
||||||
|
LV2_URID uri_patch_Set;
|
||||||
|
LV2_URID uri_patch_Get;
|
||||||
|
LV2_URID uri_patch_property;
|
||||||
|
LV2_URID uri_patch_value;
|
||||||
|
LV2_URID uri_parameters[DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N]; // TODO: Fix 0 params case
|
||||||
|
# if DATA_PRODUCT_IPM
|
||||||
|
const LV2_Atom_Sequence *controlIn;
|
||||||
|
# endif
|
||||||
|
# if DATA_PRODUCT_OPM
|
||||||
|
const LV2_Atom_Sequence *controlOut;
|
||||||
|
LV2_Atom_Forge forge;
|
||||||
|
LV2_Atom_Float output_parameter_atoms[DATA_PRODUCT_CONTROL_OUTPUTS_N];
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
float *c[DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N];
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
} plugin_instance;
|
} plugin_instance;
|
||||||
|
|
||||||
static const char * get_bundle_path_cb(void *handle) {
|
static const char * get_bundle_path_cb(void *handle) {
|
||||||
@ -150,22 +166,14 @@ static const char * get_bundle_path_cb(void *handle) {
|
|||||||
#ifdef DATA_STATE_DSP_CUSTOM
|
#ifdef DATA_STATE_DSP_CUSTOM
|
||||||
static void state_lock_cb(void *handle) {
|
static void state_lock_cb(void *handle) {
|
||||||
plugin_instance * i = (plugin_instance *)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))
|
while (atomic_flag_test_and_set(&i->sync_lock_flag))
|
||||||
# endif
|
|
||||||
yield();
|
yield();
|
||||||
i->synced = 0;
|
i->synced = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void state_unlock_cb(void *handle) {
|
static void state_unlock_cb(void *handle) {
|
||||||
plugin_instance * i = (plugin_instance *)handle;
|
plugin_instance * i = (plugin_instance *)handle;
|
||||||
# ifdef __cplusplus
|
|
||||||
i->sync_lock_flag.clear();
|
|
||||||
# else
|
|
||||||
atomic_flag_clear(&i->sync_lock_flag);
|
atomic_flag_clear(&i->sync_lock_flag);
|
||||||
# endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int state_write_cb(void *handle, const char *data, size_t length) {
|
static int state_write_cb(void *handle, const char *data, size_t length) {
|
||||||
@ -188,12 +196,7 @@ static LV2_Handle instantiate(const struct LV2_Descriptor * descriptor, double s
|
|||||||
(void)descriptor;
|
(void)descriptor;
|
||||||
(void)bundle_path;
|
(void)bundle_path;
|
||||||
|
|
||||||
// make C++ compilers happy
|
plugin_instance *instance = malloc(sizeof(plugin_instance));
|
||||||
const char * missing;
|
|
||||||
plugin_callbacks cbs;
|
|
||||||
size_t req;
|
|
||||||
|
|
||||||
plugin_instance *instance = (plugin_instance *)malloc(sizeof(plugin_instance));
|
|
||||||
if (instance == NULL)
|
if (instance == NULL)
|
||||||
goto err_instance;
|
goto err_instance;
|
||||||
|
|
||||||
@ -202,7 +205,7 @@ static LV2_Handle instantiate(const struct LV2_Descriptor * descriptor, double s
|
|||||||
goto err_bundle_path;
|
goto err_bundle_path;
|
||||||
|
|
||||||
// from https://lv2plug.in/book
|
// from https://lv2plug.in/book
|
||||||
missing = lv2_features_query(features,
|
const char * missing = lv2_features_query(features,
|
||||||
LV2_LOG__log, &instance->logger.log, false,
|
LV2_LOG__log, &instance->logger.log, false,
|
||||||
LV2_URID__map, &instance->map, true,
|
LV2_URID__map, &instance->map, true,
|
||||||
NULL);
|
NULL);
|
||||||
@ -226,15 +229,16 @@ static LV2_Handle instantiate(const struct LV2_Descriptor * descriptor, double s
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cbs.handle = (void *)instance;
|
plugin_callbacks cbs = {
|
||||||
cbs.format = "lv2";
|
/* .handle = */ (void *)instance,
|
||||||
cbs.get_bindir = get_bundle_path_cb;
|
/* .format = */ "lv2",
|
||||||
cbs.get_datadir = get_bundle_path_cb;
|
/* .get_bindir = */ get_bundle_path_cb,
|
||||||
|
/* .get_datadir = */ get_bundle_path_cb
|
||||||
|
};
|
||||||
plugin_init(&instance->p, &cbs);
|
plugin_init(&instance->p, &cbs);
|
||||||
|
|
||||||
instance->sample_rate = (float)sample_rate;
|
plugin_set_sample_rate(&instance->p, 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) {
|
if (req != 0) {
|
||||||
instance->mem = malloc(req);
|
instance->mem = malloc(req);
|
||||||
if (instance->mem == NULL) {
|
if (instance->mem == NULL) {
|
||||||
@ -262,8 +266,29 @@ static LV2_Handle instantiate(const struct LV2_Descriptor * descriptor, double s
|
|||||||
instance->y_midi[i] = NULL;
|
instance->y_midi[i] = NULL;
|
||||||
#endif
|
#endif
|
||||||
#if (DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N) > 0
|
#if (DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N) > 0
|
||||||
|
# if DATA_PRODUCT_USE_PARAMETERS
|
||||||
|
instance->uri_atom_Blank = instance->map->map (instance->map->handle, LV2_ATOM__Blank);
|
||||||
|
instance->uri_atom_Object = instance->map->map (instance->map->handle, LV2_ATOM__Object);
|
||||||
|
instance->uri_atom_URID = instance->map->map (instance->map->handle, LV2_ATOM__URID);
|
||||||
|
instance->uri_atom_Float = instance->map->map (instance->map->handle, LV2_ATOM__Float);
|
||||||
|
instance->uri_atom_Bool = instance->map->map (instance->map->handle, LV2_ATOM__Bool);
|
||||||
|
instance->uri_patch_Set = instance->map->map (instance->map->handle, LV2_PATCH__Set);
|
||||||
|
instance->uri_patch_Get = instance->map->map (instance->map->handle, LV2_PATCH__Get);
|
||||||
|
instance->uri_patch_property = instance->map->map (instance->map->handle, LV2_PATCH__property);
|
||||||
|
instance->uri_patch_value = instance->map->map (instance->map->handle, LV2_PATCH__value);
|
||||||
|
for (int i = 0; i < DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N; i++) {
|
||||||
|
instance->uri_parameters[i] = instance->map->map (instance->map->handle, param_data[i].id);
|
||||||
|
}
|
||||||
|
lv2_atom_forge_init(&instance->forge, instance->map);
|
||||||
|
for (int aa = 0; aa < DATA_PRODUCT_CONTROL_OUTPUTS_N; aa++) {
|
||||||
|
instance->output_parameter_atoms[aa].atom.size = sizeof(float);
|
||||||
|
instance->output_parameter_atoms[aa].atom.type = instance->uri_atom_Float;
|
||||||
|
instance->output_parameter_atoms[aa].body = param_data[param_out_index[aa]].def;
|
||||||
|
}
|
||||||
|
# else
|
||||||
for (uint32_t i = 0; i < DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N; i++)
|
for (uint32_t i = 0; i < DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N; i++)
|
||||||
instance->c[i] = NULL;
|
instance->c[i] = NULL;
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
@ -281,37 +306,56 @@ err_instance:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void connect_port(LV2_Handle instance, uint32_t port, void * data_location) {
|
static void connect_port(LV2_Handle instance, uint32_t port, void * data_location) {
|
||||||
|
#if DATA_PRODUCT_USE_PARAMETERS
|
||||||
|
const uint32_t port0 = port;
|
||||||
|
#endif
|
||||||
plugin_instance * i = (plugin_instance *)instance;
|
plugin_instance * i = (plugin_instance *)instance;
|
||||||
#if DATA_PRODUCT_AUDIO_INPUT_CHANNELS_N > 0
|
#if DATA_PRODUCT_AUDIO_INPUT_CHANNELS_N > 0
|
||||||
if (port < DATA_PRODUCT_AUDIO_INPUT_CHANNELS_N) {
|
if (port < DATA_PRODUCT_AUDIO_INPUT_CHANNELS_N) {
|
||||||
i->x[port] = (const float *)data_location;
|
i->x[port] = data_location;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
port -= DATA_PRODUCT_AUDIO_INPUT_CHANNELS_N;
|
port -= DATA_PRODUCT_AUDIO_INPUT_CHANNELS_N;
|
||||||
#endif
|
#endif
|
||||||
#if DATA_PRODUCT_AUDIO_OUTPUT_CHANNELS_N > 0
|
#if DATA_PRODUCT_AUDIO_OUTPUT_CHANNELS_N > 0
|
||||||
if (port < DATA_PRODUCT_AUDIO_OUTPUT_CHANNELS_N) {
|
if (port < DATA_PRODUCT_AUDIO_OUTPUT_CHANNELS_N) {
|
||||||
i->y[port] = (float *)data_location;
|
i->y[port] = data_location;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
port -= DATA_PRODUCT_AUDIO_OUTPUT_CHANNELS_N;
|
port -= DATA_PRODUCT_AUDIO_OUTPUT_CHANNELS_N;
|
||||||
#endif
|
#endif
|
||||||
#if DATA_PRODUCT_MIDI_INPUTS_N > 0
|
#if DATA_PRODUCT_MIDI_INPUTS_N > 0
|
||||||
if (port < DATA_PRODUCT_MIDI_INPUTS_N) {
|
if (port < DATA_PRODUCT_MIDI_INPUTS_N) {
|
||||||
i->x_midi[port] = (const LV2_Atom_Sequence *)data_location;
|
i->x_midi[port] = data_location;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
port -= DATA_PRODUCT_MIDI_INPUTS_N;
|
port -= DATA_PRODUCT_MIDI_INPUTS_N;
|
||||||
#endif
|
#endif
|
||||||
#if DATA_PRODUCT_MIDI_OUTPUTS_N > 0
|
#if DATA_PRODUCT_MIDI_OUTPUTS_N > 0
|
||||||
if (port < DATA_PRODUCT_MIDI_OUTPUTS_N) {
|
if (port < DATA_PRODUCT_MIDI_OUTPUTS_N) {
|
||||||
i->y_midi[port] = (LV2_Atom_Sequence *)data_location;
|
i->y_midi[port] = data_location;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
port -= DATA_PRODUCT_MIDI_OUTPUTS_N;
|
port -= DATA_PRODUCT_MIDI_OUTPUTS_N;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if DATA_PRODUCT_USE_PARAMETERS
|
||||||
|
# if DATA_PRODUCT_IPM
|
||||||
|
if (port0 == DATA_PRODUCT_IPM) {
|
||||||
|
i->controlIn = (const LV2_Atom_Sequence*) data_location;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
# if DATA_PRODUCT_OPM
|
||||||
|
if (port0 == DATA_PRODUCT_OPM) {
|
||||||
|
i->controlOut = (const LV2_Atom_Sequence*) data_location;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
# if (DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N) > 0
|
# if (DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N) > 0
|
||||||
i->c[port] = (float *)data_location;
|
i->c[port] = data_location;
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,19 +363,19 @@ static void activate(LV2_Handle instance) {
|
|||||||
plugin_instance * i = (plugin_instance *)instance;
|
plugin_instance * i = (plugin_instance *)instance;
|
||||||
#if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
#if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
||||||
for (uint32_t j = 0; j < DATA_PRODUCT_CONTROL_INPUTS_N; j++) {
|
for (uint32_t j = 0; j < DATA_PRODUCT_CONTROL_INPUTS_N; j++) {
|
||||||
|
# if DATA_PRODUCT_USE_PARAMETERS
|
||||||
|
i->params[j] = param_data[j].def;
|
||||||
|
# else
|
||||||
i->params[j] = i->c[j] != NULL ? *i->c[j] : param_data[j].def;
|
i->params[j] = i->c[j] != NULL ? *i->c[j] : param_data[j].def;
|
||||||
|
# endif
|
||||||
plugin_set_parameter(&i->p, param_data[j].index, i->params[j]);
|
plugin_set_parameter(&i->p, param_data[j].index, i->params[j]);
|
||||||
}
|
}
|
||||||
# ifdef DATA_STATE_DSP_CUSTOM
|
# ifdef DATA_STATE_DSP_CUSTOM
|
||||||
for (uint32_t j = 0; j < DATA_PRODUCT_CONTROL_INPUTS_N; j++)
|
for (uint32_t j = 0; j < DATA_PRODUCT_CONTROL_INPUTS_N; j++)
|
||||||
i->params_sync[j] = i->params[j];
|
i->params_sync[j] = i->params[j];
|
||||||
# ifdef __cplusplus
|
|
||||||
i->sync_lock_flag.clear();
|
|
||||||
# else
|
|
||||||
// why is this not correct?
|
// why is this not correct?
|
||||||
// i->sync_lock_flag = ATOMIC_FLAG_INIT;
|
// i->sync_lock_flag = ATOMIC_FLAG_INIT;
|
||||||
atomic_flag_clear(&i->sync_lock_flag);
|
atomic_flag_clear(&i->sync_lock_flag);
|
||||||
# endif
|
|
||||||
i->synced = 1;
|
i->synced = 1;
|
||||||
i->loaded = 0;
|
i->loaded = 0;
|
||||||
# endif
|
# endif
|
||||||
@ -339,9 +383,32 @@ static void activate(LV2_Handle instance) {
|
|||||||
plugin_reset(&i->p);
|
plugin_reset(&i->p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if DATA_PRODUCT_USE_PARAMETERS
|
||||||
|
static inline int getParamIndexByURI(plugin_instance *instance, LV2_URID uri) {
|
||||||
|
for (int i = 0; i < DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N; i++)
|
||||||
|
if (instance->uri_parameters[i] == uri)
|
||||||
|
return i;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static LV2_State_Status write_param_to_forge(LV2_State_Handle handle, uint32_t key, const void *value, size_t size, uint32_t type) {
|
||||||
|
LV2_Atom_Forge* forge = (LV2_Atom_Forge*)handle;
|
||||||
|
if (!lv2_atom_forge_key(forge, key) || !lv2_atom_forge_atom(forge, size, type) || !lv2_atom_forge_write(forge, value, size))
|
||||||
|
return LV2_STATE_ERR_UNKNOWN;
|
||||||
|
return LV2_STATE_SUCCESS;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void run(LV2_Handle instance, uint32_t sample_count) {
|
static void run(LV2_Handle instance, uint32_t sample_count) {
|
||||||
plugin_instance * i = (plugin_instance *)instance;
|
plugin_instance * i = (plugin_instance *)instance;
|
||||||
|
|
||||||
|
#if DATA_PRODUCT_USE_PARAMETERS
|
||||||
|
const uint32_t out_capacity = i->controlOut->atom.size;
|
||||||
|
lv2_atom_forge_set_buffer(&i->forge, (uint8_t*)i->controlOut, out_capacity);
|
||||||
|
LV2_Atom_Forge_Frame out_frame;
|
||||||
|
lv2_atom_forge_sequence_head(&i->forge, &out_frame, 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__aarch64__)
|
#if defined(__aarch64__)
|
||||||
uint64_t fpcr;
|
uint64_t fpcr;
|
||||||
__asm__ __volatile__ ("mrs %0, fpcr" : "=r"(fpcr));
|
__asm__ __volatile__ ("mrs %0, fpcr" : "=r"(fpcr));
|
||||||
@ -356,11 +423,7 @@ static void run(LV2_Handle instance, uint32_t sample_count) {
|
|||||||
|
|
||||||
#if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
#if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
||||||
# ifdef DATA_STATE_DSP_CUSTOM
|
# 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);
|
_Bool locked = !atomic_flag_test_and_set(&i->sync_lock_flag);
|
||||||
# endif
|
|
||||||
if (locked) {
|
if (locked) {
|
||||||
if (!i->synced) {
|
if (!i->synced) {
|
||||||
if (i->loaded) {
|
if (i->loaded) {
|
||||||
@ -381,6 +444,74 @@ static void run(LV2_Handle instance, uint32_t sample_count) {
|
|||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
# if DATA_PRODUCT_USE_PARAMETERS
|
||||||
|
if (i->controlIn && i->map) {
|
||||||
|
LV2_ATOM_SEQUENCE_FOREACH (i->controlIn, ev) {
|
||||||
|
if (ev->body.type != i->uri_atom_Object) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const LV2_Atom_Object *obj = (LV2_Atom_Object*)&ev->body;
|
||||||
|
if (obj->body.otype == i->uri_patch_Set) {
|
||||||
|
const LV2_Atom* property = NULL;
|
||||||
|
lv2_atom_object_get (obj, i->uri_patch_property, &property, 0);
|
||||||
|
if (!property || property->type != i->uri_atom_URID)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const LV2_Atom* val = NULL;
|
||||||
|
lv2_atom_object_get (obj, i->uri_patch_value, &val, 0);
|
||||||
|
if (!val)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
int index = getParamIndexByURI(i, ((LV2_Atom_URID*)property)->body);
|
||||||
|
if (index < 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
float v = adjust_param(index, *((float*)(val + 1)));
|
||||||
|
if (v != i->params[index]) {
|
||||||
|
i->params[index] = v;
|
||||||
|
# ifdef DATA_STATE_DSP_CUSTOM
|
||||||
|
if (locked) {
|
||||||
|
i->params_sync[index] = i->params[index];
|
||||||
|
# endif
|
||||||
|
plugin_set_parameter(&i->p, param_data[index].index, v);
|
||||||
|
# ifdef DATA_STATE_DSP_CUSTOM
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (obj->body.otype == i->uri_patch_Get) {
|
||||||
|
const LV2_Atom_URID *property = NULL;
|
||||||
|
lv2_atom_object_get(obj, i->uri_patch_property, (const LV2_Atom**)&property, 0);
|
||||||
|
|
||||||
|
if (!property || property->atom.type != i->uri_atom_URID)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const LV2_URID key = property->body;
|
||||||
|
const int index = getParamIndexByURI(i, key);
|
||||||
|
if (index < 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
int outIndex = -1;
|
||||||
|
for (int p = 0; p < DATA_PRODUCT_CONTROL_OUTPUTS_N; p++) {
|
||||||
|
if (param_out_index[p] == (uint32_t) index)
|
||||||
|
outIndex = p;
|
||||||
|
}
|
||||||
|
if (outIndex == -1)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const LV2_Atom* value = &i->output_parameter_atoms[outIndex].atom;
|
||||||
|
LV2_Atom_Forge_Frame frame;
|
||||||
|
lv2_atom_forge_frame_time(&i->forge, ev->time.frames);
|
||||||
|
lv2_atom_forge_object( &i->forge, &frame, 0, i->uri_patch_Set);
|
||||||
|
lv2_atom_forge_key( &i->forge, i->uri_patch_property);
|
||||||
|
lv2_atom_forge_urid( &i->forge, property->body);
|
||||||
|
write_param_to_forge( &i->forge, i->uri_patch_value, value + 1, value->size, value->type);
|
||||||
|
lv2_atom_forge_pop( &i->forge, &frame);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# else
|
||||||
for (uint32_t j = 0; j < DATA_PRODUCT_CONTROL_INPUTS_N; j++) {
|
for (uint32_t j = 0; j < DATA_PRODUCT_CONTROL_INPUTS_N; j++) {
|
||||||
if (i->c[j] == NULL)
|
if (i->c[j] == NULL)
|
||||||
continue;
|
continue;
|
||||||
@ -398,15 +529,13 @@ static void run(LV2_Handle instance, uint32_t sample_count) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# endif
|
||||||
|
|
||||||
# ifdef DATA_STATE_DSP_CUSTOM
|
# ifdef DATA_STATE_DSP_CUSTOM
|
||||||
if (locked)
|
if (locked)
|
||||||
# ifdef __cplusplus
|
|
||||||
i->sync_lock_flag.clear();
|
|
||||||
# else
|
|
||||||
atomic_flag_clear(&i->sync_lock_flag);
|
atomic_flag_clear(&i->sync_lock_flag);
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
#if DATA_PRODUCT_MIDI_INPUTS_N > 0
|
#if DATA_PRODUCT_MIDI_INPUTS_N > 0
|
||||||
// from https://lv2plug.in/book
|
// from https://lv2plug.in/book
|
||||||
@ -437,11 +566,31 @@ static void run(LV2_Handle instance, uint32_t sample_count) {
|
|||||||
plugin_process(&i->p, x, y, sample_count);
|
plugin_process(&i->p, x, y, sample_count);
|
||||||
|
|
||||||
#if DATA_PRODUCT_CONTROL_OUTPUTS_N > 0
|
#if DATA_PRODUCT_CONTROL_OUTPUTS_N > 0
|
||||||
|
# if DATA_PRODUCT_USE_PARAMETERS
|
||||||
|
|
||||||
|
for (uint32_t j = 0; j < DATA_PRODUCT_CONTROL_OUTPUTS_N; j++) {
|
||||||
|
|
||||||
|
float v = plugin_get_parameter(&i->p, param_out_index[j]);
|
||||||
|
i->output_parameter_atoms[j].body = v;
|
||||||
|
lv2_atom_forge_frame_time(&i->forge, 0);
|
||||||
|
LV2_Atom_Forge_Frame frame;
|
||||||
|
lv2_atom_forge_object(&i->forge, &frame, 0, i->uri_patch_Set);
|
||||||
|
lv2_atom_forge_key( &i->forge, i->uri_patch_property);
|
||||||
|
lv2_atom_forge_urid( &i->forge, i->uri_parameters[param_out_index[j]]);
|
||||||
|
lv2_atom_forge_key( &i->forge, i->uri_patch_value);
|
||||||
|
lv2_atom_forge_float( &i->forge, i->output_parameter_atoms[j].body);
|
||||||
|
lv2_atom_forge_pop( &i->forge, &frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
lv2_atom_forge_pop(&i->forge, &out_frame);
|
||||||
|
|
||||||
|
# else
|
||||||
for (uint32_t j = 0; j < DATA_PRODUCT_CONTROL_OUTPUTS_N; j++) {
|
for (uint32_t j = 0; j < DATA_PRODUCT_CONTROL_OUTPUTS_N; j++) {
|
||||||
uint32_t k = param_out_index[j];
|
uint32_t k = param_out_index[j];
|
||||||
if (i->c[k] != NULL)
|
if (i->c[k] != NULL)
|
||||||
*i->c[k] = plugin_get_parameter(&i->p, k);
|
*i->c[k] = plugin_get_parameter(&i->p, k);
|
||||||
}
|
}
|
||||||
|
# endif
|
||||||
#else
|
#else
|
||||||
(void)plugin_get_parameter;
|
(void)plugin_get_parameter;
|
||||||
#endif
|
#endif
|
||||||
@ -452,6 +601,7 @@ static void run(LV2_Handle instance, uint32_t sample_count) {
|
|||||||
_MM_SET_FLUSH_ZERO_MODE(flush_zero_mode);
|
_MM_SET_FLUSH_ZERO_MODE(flush_zero_mode);
|
||||||
_MM_SET_DENORMALS_ZERO_MODE(denormals_zero_mode);
|
_MM_SET_DENORMALS_ZERO_MODE(denormals_zero_mode);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cleanup(LV2_Handle instance) {
|
static void cleanup(LV2_Handle instance) {
|
||||||
@ -484,7 +634,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, i->sample_rate) == 0 ? LV2_STATE_SUCCESS : LV2_STATE_ERR_UNKNOWN;
|
return plugin_state_save(&i->p, &cbs) == 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) {
|
||||||
@ -498,7 +648,7 @@ static LV2_State_Status state_restore(LV2_Handle instance, LV2_State_Retrieve_Fu
|
|||||||
}
|
}
|
||||||
size_t length;
|
size_t length;
|
||||||
uint32_t type, xflags; // jalv 1.6.6 crashes using NULL as per spec, so we have these two
|
uint32_t type, xflags; // jalv 1.6.6 crashes using NULL as per spec, so we have these two
|
||||||
const char * data = (const char *)retrieve(handle, i->uri_state_data, &length, &type, &xflags);
|
const char * data = retrieve(handle, i->uri_state_data, &length, &type, &xflags);
|
||||||
if (data == NULL) {
|
if (data == NULL) {
|
||||||
lv2_log_error(&i->logger, "Cannot restore state since property <%s> could not be retrieved\n", DATA_LV2_URI "#state_data");
|
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;
|
return LV2_STATE_ERR_NO_PROPERTY;
|
||||||
@ -512,7 +662,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, i->sample_rate, data, length) == 0 ? LV2_STATE_SUCCESS : LV2_STATE_ERR_UNKNOWN;
|
return plugin_state_load(&cbs, 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) {
|
||||||
@ -592,12 +742,7 @@ static LV2UI_Handle ui_instantiate(const LV2UI_Descriptor * descriptor, const ch
|
|||||||
(void)descriptor;
|
(void)descriptor;
|
||||||
(void)plugin_uri;
|
(void)plugin_uri;
|
||||||
|
|
||||||
// make C++ compilers happy
|
ui_instance *instance = malloc(sizeof(ui_instance));
|
||||||
char has_parent;
|
|
||||||
void *parent;
|
|
||||||
plugin_ui_callbacks cbs;
|
|
||||||
|
|
||||||
ui_instance *instance = (ui_instance *)malloc(sizeof(ui_instance));
|
|
||||||
if (instance == NULL)
|
if (instance == NULL)
|
||||||
goto err_instance;
|
goto err_instance;
|
||||||
|
|
||||||
@ -605,8 +750,8 @@ static LV2UI_Handle ui_instantiate(const LV2UI_Descriptor * descriptor, const ch
|
|||||||
if (instance->bundle_path == NULL)
|
if (instance->bundle_path == NULL)
|
||||||
goto err_bundle_path;
|
goto err_bundle_path;
|
||||||
|
|
||||||
has_parent = 0;
|
char has_parent = 0;
|
||||||
parent = NULL;
|
void *parent = NULL;
|
||||||
# if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
# if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
||||||
instance->has_touch = 0;
|
instance->has_touch = 0;
|
||||||
# endif
|
# endif
|
||||||
@ -623,15 +768,17 @@ static LV2UI_Handle ui_instantiate(const LV2UI_Descriptor * descriptor, const ch
|
|||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
cbs.handle = (void *)instance;
|
plugin_ui_callbacks cbs = {
|
||||||
cbs.format = "lv2";
|
/* .handle = */ (void *)instance,
|
||||||
cbs.get_bindir = ui_get_bundle_path_cb;
|
/* .format = */ "lv2",
|
||||||
cbs.get_datadir = ui_get_bundle_path_cb;
|
/* .get_bindir = */ ui_get_bundle_path_cb,
|
||||||
|
/* .get_datadir = */ ui_get_bundle_path_cb,
|
||||||
# if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
# if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
||||||
cbs.set_parameter_begin = ui_set_parameter_begin_cb;
|
/* .set_parameter_begin = */ ui_set_parameter_begin_cb,
|
||||||
cbs.set_parameter = ui_set_parameter_cb;
|
/* .set_parameter = */ ui_set_parameter_cb,
|
||||||
cbs.set_parameter_end = ui_set_parameter_end_cb;
|
/* .set_parameter_end = */ ui_set_parameter_end_cb,
|
||||||
# endif
|
# endif
|
||||||
|
};
|
||||||
# if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
# if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
||||||
instance->write = write_function;
|
instance->write = write_function;
|
||||||
instance->controller = controller;
|
instance->controller = controller;
|
||||||
|
@ -37,7 +37,8 @@ module.exports = function (data, api, outputCommon, outputData) {
|
|||||||
{ id: "state", uri: "http://lv2plug.in/ns/extensions/state#" },
|
{ id: "state", uri: "http://lv2plug.in/ns/extensions/state#" },
|
||||||
{ id: "ui", uri: "http://lv2plug.in/ns/extensions/ui#" },
|
{ id: "ui", uri: "http://lv2plug.in/ns/extensions/ui#" },
|
||||||
{ id: "units", uri: "http://lv2plug.in/ns/extensions/units#" },
|
{ id: "units", uri: "http://lv2plug.in/ns/extensions/units#" },
|
||||||
{ id: "urid", uri: "http://lv2plug.in/ns/ext/urid#" }
|
{ id: "urid", uri: "http://lv2plug.in/ns/ext/urid#" },
|
||||||
|
{ id: "patch", uri: "http://lv2plug.in/ns/ext/patch#"}
|
||||||
],
|
],
|
||||||
units: {
|
units: {
|
||||||
"bar": "@units:bar",
|
"bar": "@units:bar",
|
||||||
@ -88,6 +89,8 @@ module.exports = function (data, api, outputCommon, outputData) {
|
|||||||
for (var id in data.lv2.prefixes)
|
for (var id in data.lv2.prefixes)
|
||||||
data.tibia.lv2.prefixes.push({ id: id, uri: data.lv2.prefixes[id] });
|
data.tibia.lv2.prefixes.push({ id: id, uri: data.lv2.prefixes[id] });
|
||||||
|
|
||||||
|
data.tibia.lv2.prefixes.push({ id: "plugin", uri: data.tibia.lv2.expandURI(data.lv2.uri) + "#" });
|
||||||
|
|
||||||
var buses = data.product.buses;
|
var buses = data.product.buses;
|
||||||
var audioPorts = [];
|
var audioPorts = [];
|
||||||
var midiPorts = [];
|
var midiPorts = [];
|
||||||
@ -113,6 +116,27 @@ module.exports = function (data, api, outputCommon, outputData) {
|
|||||||
data.tibia.lv2.ports.push.apply(data.tibia.lv2.ports, audioPorts);
|
data.tibia.lv2.ports.push.apply(data.tibia.lv2.ports, audioPorts);
|
||||||
data.tibia.lv2.ports.push.apply(data.tibia.lv2.ports, midiPorts);
|
data.tibia.lv2.ports.push.apply(data.tibia.lv2.ports, midiPorts);
|
||||||
|
|
||||||
|
if (data.lv2.use_parameters) {
|
||||||
|
let parameters = [];
|
||||||
|
for (var i = 0; i < data.product.parameters.length; i++) {
|
||||||
|
let e = Object.create(data.product.parameters[i]);
|
||||||
|
e.paramIndex = i;
|
||||||
|
parameters.push(e);
|
||||||
|
}
|
||||||
|
data.tibia.lv2.parameters = parameters;
|
||||||
|
|
||||||
|
if (data.product.parameters.find(p => p.direction == "input")) {
|
||||||
|
data.tibia.lv2.ports.push({
|
||||||
|
isInputParameterMessage: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (data.product.parameters.find(p => p.direction == "output")) {
|
||||||
|
data.tibia.lv2.ports.push({
|
||||||
|
isOutputParameterMessage: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
var ports = [];
|
var ports = [];
|
||||||
for (var i = 0; i < data.product.parameters.length; i++) {
|
for (var i = 0; i < data.product.parameters.length; i++) {
|
||||||
var p = data.product.parameters[i];
|
var p = data.product.parameters[i];
|
||||||
@ -124,6 +148,7 @@ module.exports = function (data, api, outputCommon, outputData) {
|
|||||||
ports.sort((a, b) => a.direction != b.direction ? (a.direction == "input" ? -1 : 1) : 0);
|
ports.sort((a, b) => a.direction != b.direction ? (a.direction == "input" ? -1 : 1) : 0);
|
||||||
data.tibia.lv2.ports.push.apply(data.tibia.lv2.ports, ports);
|
data.tibia.lv2.ports.push.apply(data.tibia.lv2.ports, ports);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
api.generateFileFromTemplateFile(`data${sep}manifest.ttl.in`, `data${sep}manifest.ttl.in`, data);
|
api.generateFileFromTemplateFile(`data${sep}manifest.ttl.in`, `data${sep}manifest.ttl.in`, data);
|
||||||
api.copyFile(`src${sep}lv2.c`, `src${sep}lv2.c`);
|
api.copyFile(`src${sep}lv2.c`, `src${sep}lv2.c`);
|
||||||
|
@ -31,33 +31,12 @@ 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
|
||||||
@ -68,8 +47,31 @@ 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 -fvisibility=hidden $(CFLAGS_EXTRA) $(CFLAGS)
|
CFLAGS_ALL := -I$(DATA_DIR)/src -I$(PLUGIN_DIR) -I$(API_DIR) -fPIC $(CFLAGS_EXTRA) $(CFLAGS)
|
||||||
|
|
||||||
LDFLAGS :=
|
LDFLAGS :=
|
||||||
LDFLAGS_ALL := -shared -lm $(LDFLAGS_EXTRA) $(LDFLAGS)
|
LDFLAGS_ALL := -shared -lm $(LDFLAGS_EXTRA) $(LDFLAGS)
|
||||||
@ -114,9 +116,8 @@ ifeq ($(UNAME_S), Darwin)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
STRIP_ALL := build/$(BUNDLE_DIR)/$(DLL_FILE)
|
STRIP_ALL := build/$(BUNDLE_DIR)/$(DLL_FILE)
|
||||||
STRIP_PREREQS := $(STRIP_ALL)
|
STRIP_PHONY :=
|
||||||
|
STRIP_PREREQS := $(STRIP_ALL) $(STRIP_PHONY)
|
||||||
PHONY := all clean strip install install-user
|
|
||||||
|
|
||||||
-include $(MKINC_DIR)/vars-extra.mk
|
-include $(MKINC_DIR)/vars-extra.mk
|
||||||
|
|
||||||
@ -145,39 +146,39 @@ clean:
|
|||||||
rm -fr build
|
rm -fr build
|
||||||
|
|
||||||
strip: $(STRIP_PREREQS)
|
strip: $(STRIP_PREREQS)
|
||||||
strip -Sx build/$(BUNDLE_DIR)/$(DLL_FILE)
|
strip build/$(BUNDLE_DIR)/$(DLL_FILE)
|
||||||
|
|
||||||
install: all
|
install: all
|
||||||
@for d in `find build/$(BUNDLE_DIR) -type d`; do \
|
@for d in `find build/$(BUNDLE_DIR) -type d`; do \
|
||||||
d=`echo $$d | sed 's:^build/::'` ; \
|
d=`echo $$d | sed 's:^build/::'` ; \
|
||||||
echo mkdir -m 0755 -p "$(VST3DIR)/$$d"; \
|
echo mkdir -m 0755 -p "$(VST3DIR)/$$d"; \
|
||||||
mkdir -m 0755 -p "$(VST3DIR)/$$d" || exit 1; \
|
mkdir -m 0755 -p "$(VST3DIR)/$$d"; \
|
||||||
done
|
done
|
||||||
@for f in `find build/$(BUNDLE_DIR) -type f`; do \
|
@for f in `find build/$(BUNDLE_DIR) -type f`; do \
|
||||||
m=`[ -x $$f ] && echo 0755 || echo 0644`; \
|
m=`[ -x $$f ] && echo 0755 || echo 0644`; \
|
||||||
d=`echo $$f | sed 's:^build/::'` ; \
|
d=`echo $$f | sed 's:^build/::'` ; \
|
||||||
d=`dirname $$d`; \
|
d=`dirname $$d`; \
|
||||||
echo install -m $$m $$f "$(VST3DIR)/$$d"; \
|
echo install -m $$m $$f "$(VST3DIR)/$$d"; \
|
||||||
install -m $$m $$f "$(VST3DIR)/$$d" || exit 1; \
|
install -m $$m $$f "$(VST3DIR)/$$d"; \
|
||||||
done
|
done
|
||||||
|
|
||||||
install-user: all
|
install-user: all
|
||||||
@for d in `find build/$(BUNDLE_DIR) -type d`; do \
|
@for d in `find build/$(BUNDLE_DIR) -type d`; do \
|
||||||
d=`echo $$d | sed 's:^build/::'` ; \
|
d=`echo $$d | sed 's:^build/::'` ; \
|
||||||
echo mkdir -m 0755 -p "$(VST3DIR_USER)/$$d"; \
|
echo mkdir -m 0755 -p "$(VST3DIR_USER)/$$d"; \
|
||||||
mkdir -m 0755 -p "$(VST3DIR_USER)/$$d" || exit 1; \
|
mkdir -m 0755 -p "$(VST3DIR_USER)/$$d"; \
|
||||||
done
|
done
|
||||||
@for f in `find build/$(BUNDLE_DIR) -type f`; do \
|
@for f in `find build/$(BUNDLE_DIR) -type f`; do \
|
||||||
m=`[ -x $$f ] && echo 0755 || echo 0644`; \
|
m=`[ -x $$f ] && echo 0755 || echo 0644`; \
|
||||||
d=`echo $$f | sed 's:^build/::'` ; \
|
d=`echo $$f | sed 's:^build/::'` ; \
|
||||||
d=`dirname $$d`; \
|
d=`dirname $$d`; \
|
||||||
echo install -m $$m $$f "$(VST3DIR_USER)/$$d"; \
|
echo install -m $$m $$f "$(VST3DIR_USER)/$$d"; \
|
||||||
install -m $$m $$f "$(VST3DIR_USER)/$$d" || exit 1; \
|
install -m $$m $$f "$(VST3DIR_USER)/$$d"; \
|
||||||
done
|
done
|
||||||
|
|
||||||
-include $(MKINC_DIR)/rules-extra.mk
|
-include $(MKINC_DIR)/rules-extra.mk
|
||||||
|
|
||||||
.PHONY: $(PHONY)
|
.PHONY: all clean strip $(STRIP_PHONY) install install-user
|
||||||
|
|
||||||
.SECONDEXPANSION:
|
.SECONDEXPANSION:
|
||||||
|
|
||||||
@ -193,5 +194,3 @@ $(CXX_OBJS): build/obj/%.o: $$(filter $$(PERCENT)/$$(basename $$(notdir $$@)).cp
|
|||||||
$(CXX) $^ -o $@ -c $(CXXFLAGS_ALL)
|
$(CXX) $^ -o $@ -c $(CXXFLAGS_ALL)
|
||||||
|
|
||||||
-include $(MKINC_DIR)/rules-secondexp-extra.mk
|
-include $(MKINC_DIR)/rules-secondexp-extra.mk
|
||||||
|
|
||||||
.DELETE_ON_ERROR:
|
|
||||||
|
@ -28,8 +28,8 @@
|
|||||||
static Steinberg_char16 dataProductNameW[64] = { {{~Array.from(it.product.name).slice(0, 63) :c}}0x{{=c.charCodeAt(0).toString(16)}}, {{~}}0 };
|
static Steinberg_char16 dataProductNameW[64] = { {{~Array.from(it.product.name).slice(0, 63) :c}}0x{{=c.charCodeAt(0).toString(16)}}, {{~}}0 };
|
||||||
static Steinberg_char16 dataProductVersionW[64] = { {{~Array.from(it.product.version + "." + it.product.buildVersion).slice(0, 63) :c}}0x{{=c.charCodeAt(0).toString(16)}}, {{~}}0 };
|
static Steinberg_char16 dataProductVersionW[64] = { {{~Array.from(it.product.version + "." + it.product.buildVersion).slice(0, 63) :c}}0x{{=c.charCodeAt(0).toString(16)}}, {{~}}0 };
|
||||||
|
|
||||||
#define DATA_VST3_SDK_VERSION "VST 3.7.13"
|
#define DATA_VST3_SDK_VERSION "VST 3.7.12"
|
||||||
static Steinberg_char16 dataVST3SDKVersionW[64] = { {{~Array.from("VST 3.7.13") :c}}0x{{=c.charCodeAt(0).toString(16)}}, {{~}}0 };
|
static Steinberg_char16 dataVST3SDKVersionW[64] = { {{~Array.from("VST 3.7.12") :c}}0x{{=c.charCodeAt(0).toString(16)}}, {{~}}0 };
|
||||||
|
|
||||||
static Steinberg_char16 dataVST3ControllerNameW[64] = { {{~Array.from(it.product.name + " Controller").slice(0, 63) :c}}0x{{=c.charCodeAt(0).toString(16)}}, {{~}}0 };
|
static Steinberg_char16 dataVST3ControllerNameW[64] = { {{~Array.from(it.product.name + " Controller").slice(0, 63) :c}}0x{{=c.charCodeAt(0).toString(16)}}, {{~}}0 };
|
||||||
|
|
||||||
|
@ -265,15 +265,13 @@ static int stateRead(struct Steinberg_IBStream * state, char ** data, Steinberg_
|
|||||||
}
|
}
|
||||||
|
|
||||||
typedef struct pluginInstance {
|
typedef struct pluginInstance {
|
||||||
Steinberg_Vst_IComponentVtbl * vtblIComponent; // must stay first
|
Steinberg_Vst_IComponentVtbl * vtblIComponent;
|
||||||
Steinberg_Vst_IAudioProcessorVtbl * vtblIAudioProcessor;
|
Steinberg_Vst_IAudioProcessorVtbl * vtblIAudioProcessor;
|
||||||
Steinberg_Vst_IProcessContextRequirementsVtbl * vtblIProcessContextRequirements;
|
Steinberg_Vst_IProcessContextRequirementsVtbl * vtblIProcessContextRequirements;
|
||||||
Steinberg_uint32 refs;
|
Steinberg_uint32 refs;
|
||||||
Steinberg_FUnknown * context;
|
Steinberg_FUnknown * context;
|
||||||
plugin p;
|
plugin p;
|
||||||
float lastSampleRate;
|
float sampleRate;
|
||||||
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];
|
||||||
@ -414,9 +412,6 @@ 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,
|
||||||
@ -633,7 +628,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->nextSampleRate);
|
plugin_set_sample_rate(&p->p, p->sampleRate);
|
||||||
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);
|
||||||
@ -641,11 +636,8 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -675,7 +667,7 @@ static Steinberg_tresult pluginSetState(void* thisInterface, struct Steinberg_IB
|
|||||||
/* .set_parameter = */ pluginStateSetParameterCb
|
/* .set_parameter = */ pluginStateSetParameterCb
|
||||||
# endif
|
# endif
|
||||||
};
|
};
|
||||||
int err = plugin_state_load(&cbs, p->curSampleRate, data, length);
|
int err = plugin_state_load(&cbs, 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;
|
||||||
@ -709,7 +701,7 @@ static Steinberg_tresult pluginSetState(void* thisInterface, struct Steinberg_IB
|
|||||||
|
|
||||||
if (data)
|
if (data)
|
||||||
free(data);
|
free(data);
|
||||||
TRACE(err == 0 ? " ok\n" : " err\n");
|
TRACE(err == 0 ? " ok" : " err");
|
||||||
return err == 0 ? Steinberg_kResultOk : Steinberg_kResultFalse;
|
return err == 0 ? Steinberg_kResultOk : Steinberg_kResultFalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -731,7 +723,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, p->lastSampleRate);
|
int err = plugin_state_save(&p->p, &cbs);
|
||||||
#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;
|
||||||
@ -863,7 +855,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->nextSampleRate = (float)setup->sampleRate;
|
p->sampleRate = (float)setup->sampleRate;
|
||||||
return Steinberg_kResultOk;
|
return Steinberg_kResultOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1149,7 +1141,7 @@ static Steinberg_Vst_IProcessContextRequirementsVtbl pluginVtblIProcessContextRe
|
|||||||
typedef struct plugView plugView;
|
typedef struct plugView plugView;
|
||||||
|
|
||||||
typedef struct controller {
|
typedef struct controller {
|
||||||
Steinberg_Vst_IEditControllerVtbl * vtblIEditController; // must stay first
|
Steinberg_Vst_IEditControllerVtbl * vtblIEditController;
|
||||||
Steinberg_Vst_IMidiMappingVtbl * vtblIMidiMapping;
|
Steinberg_Vst_IMidiMappingVtbl * vtblIMidiMapping;
|
||||||
#ifdef DATA_UI
|
#ifdef DATA_UI
|
||||||
//Steinberg_Vst_IConnectionPointVtbl * vtblIConnectionPoint;
|
//Steinberg_Vst_IConnectionPointVtbl * vtblIConnectionPoint;
|
||||||
@ -1380,20 +1372,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 && view->ui)
|
if (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 && view->ui)
|
if (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 == NULL || view->ui == NULL)
|
if (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++)
|
||||||
@ -1866,7 +1858,7 @@ static Steinberg_tresult controllerSetComponentState(void* thisInterface, struct
|
|||||||
/* .set_parameter = */ controllerStateSetParameterCb
|
/* .set_parameter = */ controllerStateSetParameterCb
|
||||||
# endif
|
# endif
|
||||||
};
|
};
|
||||||
int err = plugin_state_load(&cbs, -1.f, data, length); // -1.f means "does not apply"
|
int err = plugin_state_load(&cbs, data, length);
|
||||||
#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;
|
||||||
@ -2177,7 +2169,7 @@ static struct Steinberg_IPlugView* controllerCreateView(void* thisInterface, Ste
|
|||||||
|
|
||||||
controller *c = (controller *)((char *)thisInterface - offsetof(controller, vtblIEditController));
|
controller *c = (controller *)((char *)thisInterface - offsetof(controller, vtblIEditController));
|
||||||
size_t i;
|
size_t i;
|
||||||
for (i = 0; i < c->viewsCount; i++)
|
for (i = 0; i < c->viewsCount; c++)
|
||||||
if (c->views[i] == NULL)
|
if (c->views[i] == NULL)
|
||||||
break;
|
break;
|
||||||
if (i == c->viewsCount) {
|
if (i == c->viewsCount) {
|
||||||
@ -2419,10 +2411,25 @@ static Steinberg_tresult factoryCreateInstance(void *thisInterface, Steinberg_FI
|
|||||||
TRACE("createInstance\n");
|
TRACE("createInstance\n");
|
||||||
if (memcmp(cid, dataPluginCID, sizeof(Steinberg_TUID)) == 0) {
|
if (memcmp(cid, dataPluginCID, sizeof(Steinberg_TUID)) == 0) {
|
||||||
TRACE(" plugin\n");
|
TRACE(" plugin\n");
|
||||||
if (memcmp(iid, Steinberg_FUnknown_iid, sizeof(Steinberg_TUID))
|
size_t offset; // does it actually work like this? or is offset always 0? this seems to be correct and works...
|
||||||
&& memcmp(iid, Steinberg_IPluginBase_iid, sizeof(Steinberg_TUID))
|
if ((memcmp(iid, Steinberg_FUnknown_iid, sizeof(Steinberg_TUID)) == 0)
|
||||||
&& memcmp(iid, Steinberg_Vst_IComponent_iid, sizeof(Steinberg_TUID)))
|
|| (memcmp(iid, Steinberg_IPluginBase_iid, sizeof(Steinberg_TUID)) != 0)
|
||||||
|
|| (memcmp(iid, Steinberg_Vst_IComponent_iid, sizeof(Steinberg_TUID)) != 0)) {
|
||||||
|
TRACE(" IComponent\n");
|
||||||
|
offset = offsetof(pluginInstance, vtblIComponent);
|
||||||
|
} else if (memcmp(iid, Steinberg_Vst_IAudioProcessor_iid, sizeof(Steinberg_TUID)) != 0) {
|
||||||
|
TRACE(" IAudioProcessor\n");
|
||||||
|
offset = offsetof(pluginInstance, vtblIAudioProcessor);
|
||||||
|
} else if (memcmp(iid, Steinberg_Vst_IProcessContextRequirements_iid, sizeof(Steinberg_TUID)) != 0) {
|
||||||
|
TRACE(" IProcessContextRequirements\n");
|
||||||
|
offset = offsetof(pluginInstance, vtblIProcessContextRequirements);
|
||||||
|
} else {
|
||||||
|
TRACE(" INothing :(\n");
|
||||||
|
for (int i = 0; i < 16; i++)
|
||||||
|
TRACE(" %x", iid[i]);
|
||||||
|
TRACE("\n");
|
||||||
return Steinberg_kNoInterface;
|
return Steinberg_kNoInterface;
|
||||||
|
}
|
||||||
pluginInstance *p = malloc(sizeof(pluginInstance));
|
pluginInstance *p = malloc(sizeof(pluginInstance));
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
return Steinberg_kOutOfMemory;
|
return Steinberg_kOutOfMemory;
|
||||||
@ -2431,7 +2438,7 @@ static Steinberg_tresult factoryCreateInstance(void *thisInterface, Steinberg_FI
|
|||||||
p->vtblIProcessContextRequirements = &pluginVtblIProcessContextRequirements;
|
p->vtblIProcessContextRequirements = &pluginVtblIProcessContextRequirements;
|
||||||
p->refs = 1;
|
p->refs = 1;
|
||||||
p->context = NULL;
|
p->context = NULL;
|
||||||
*obj = p;
|
*obj = (void *)((char *)p + offset);
|
||||||
TRACE(" instance: %p\n", (void *)p);
|
TRACE(" instance: %p\n", (void *)p);
|
||||||
} else if (memcmp(cid, dataControllerCID, sizeof(Steinberg_TUID)) == 0) {
|
} else if (memcmp(cid, dataControllerCID, sizeof(Steinberg_TUID)) == 0) {
|
||||||
TRACE(" controller\n");
|
TRACE(" controller\n");
|
||||||
@ -2594,77 +2601,36 @@ EXPORT APIENTRY BOOL
|
|||||||
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) {
|
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) {
|
||||||
(void)hInstance;
|
(void)hInstance;
|
||||||
(void)lpReserved;
|
(void)lpReserved;
|
||||||
|
|
||||||
char * path;
|
|
||||||
|
|
||||||
if (dwReason == DLL_PROCESS_ATTACH) {
|
if (dwReason == DLL_PROCESS_ATTACH) {
|
||||||
if (refs == 0) {
|
if (refs == 0) {
|
||||||
DWORD path_length;
|
int pathLength;
|
||||||
DWORD n_size;
|
char path[260];
|
||||||
char * new_path;
|
HMODULE hm = NULL;
|
||||||
char * c;
|
if (GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCSTR) &bindir, &hm) == 0) {
|
||||||
|
|
||||||
HMODULE hm;
|
|
||||||
if (GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCSTR)&bindir, &hm) == 0) {
|
|
||||||
TRACE("GetModuleHandle failed, error = %lu\n", GetLastError());
|
TRACE("GetModuleHandle failed, error = %lu\n", GetLastError());
|
||||||
goto err_handle;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if ((pathLength = GetModuleFileName(hm, path, sizeof(path))) == 0) {
|
||||||
path = NULL;
|
|
||||||
n_size = MAX_PATH;
|
|
||||||
while (1) {
|
|
||||||
new_path = (char *)realloc(path, n_size);
|
|
||||||
if (new_path == NULL) {
|
|
||||||
TRACE("GetModuleFileName failed, not enough memory (requested %lu bytes)\n", n_size);
|
|
||||||
goto err_realloc;
|
|
||||||
}
|
|
||||||
path = new_path;
|
|
||||||
|
|
||||||
path_length = GetModuleFileNameA(hm, path, n_size);
|
|
||||||
if (path_length == 0) {
|
|
||||||
TRACE("GetModuleFileName failed, error = %lu\n", GetLastError());
|
TRACE("GetModuleFileName failed, error = %lu\n", GetLastError());
|
||||||
goto err_filename;
|
return 0;
|
||||||
}
|
}
|
||||||
|
char *c = strrchr(path, '\\');
|
||||||
if (path_length < n_size)
|
*c = '\0';
|
||||||
break;
|
bindir = (char*) malloc(strlen(path) + 1);
|
||||||
n_size *= 2;
|
memcpy(bindir, path, strlen(path));
|
||||||
}
|
bindir[strlen(path)] = '\0';
|
||||||
|
|
||||||
c = strrchr(path, '\\');
|
c = strrchr(path, '\\');
|
||||||
*c = '\0';
|
*c = '\0';
|
||||||
bindir = _strdup(path);
|
static char* res = "\\Resources";
|
||||||
if (bindir == NULL) {
|
datadir = malloc(strlen(path) + strlen(res) + 1);
|
||||||
TRACE("bindir _strdup failed\n");
|
sprintf(datadir, "%s%s", path, res);
|
||||||
goto err_bindir;
|
|
||||||
}
|
|
||||||
|
|
||||||
c = strrchr(path, '\\');
|
|
||||||
*c = '\0';
|
|
||||||
datadir = (char *)malloc(strlen(path) + sizeof("\\Resources") + 1);
|
|
||||||
if (datadir == NULL) {
|
|
||||||
TRACE("datadir malloc failed\n");
|
|
||||||
goto err_datadir;
|
|
||||||
}
|
|
||||||
sprintf(datadir, "%s\\Resources", path);
|
|
||||||
|
|
||||||
TRACE("bindir = %s \ndatadir = %s\n", bindir, datadir);
|
TRACE("bindir = %s \ndatadir = %s\n", bindir, datadir);
|
||||||
}
|
}
|
||||||
refs++;
|
refs++;
|
||||||
} else if (dwReason == DLL_PROCESS_DETACH)
|
} else if (dwReason == DLL_PROCESS_DETACH) {
|
||||||
vstExit();
|
vstExit();
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
err_datadir:
|
|
||||||
free(bindir);
|
|
||||||
err_bindir:
|
|
||||||
err_filename:
|
|
||||||
err_realloc:
|
|
||||||
if (path != NULL)
|
|
||||||
free(path);
|
|
||||||
err_handle:
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(__APPLE__) || defined(__linux__)
|
#elif defined(__APPLE__) || defined(__linux__)
|
||||||
@ -2684,11 +2650,9 @@ char ModuleEntry(void *handle) {
|
|||||||
v.f = vstExit;
|
v.f = vstExit;
|
||||||
if (dladdr((void*) v.d, &info) == 0)
|
if (dladdr((void*) v.d, &info) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
file = realpath(info.dli_fname, NULL);
|
file = realpath(info.dli_fname, NULL);
|
||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
char *c = strrchr(file, '/');
|
char *c = strrchr(file, '/');
|
||||||
*c = '\0';
|
*c = '\0';
|
||||||
bindir = strdup(file);
|
bindir = strdup(file);
|
||||||
@ -2696,13 +2660,10 @@ char ModuleEntry(void *handle) {
|
|||||||
goto err_bindir;
|
goto err_bindir;
|
||||||
c = strrchr(file, '/');
|
c = strrchr(file, '/');
|
||||||
*c = '\0';
|
*c = '\0';
|
||||||
|
|
||||||
datadir = x_asprintf("%s/Resources", file);
|
datadir = x_asprintf("%s/Resources", file);
|
||||||
if (datadir == NULL)
|
if (datadir == NULL)
|
||||||
goto err_datadir;
|
goto err_datadir;
|
||||||
|
|
||||||
free(file);
|
free(file);
|
||||||
|
|
||||||
TRACE("bindir = %s \ndatadir = %s\n", bindir, datadir);
|
TRACE("bindir = %s \ndatadir = %s\n", bindir, datadir);
|
||||||
}
|
}
|
||||||
refs++;
|
refs++;
|
||||||
|
@ -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/key.pem: build/web/cert.pem
|
||||||
|
|
||||||
build/web/cert.pem: | build
|
build/web/cert.pem: | build
|
||||||
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
|
yes "" | openssl req -x509 -newkey rsa:2048 -keyout build/web/key.pem -out build/web/cert.pem -days 365 -nodes 2>/dev/null
|
||||||
|
|
||||||
strip-web-demo: build/web/index.html
|
strip-web-demo: build/web/index.html
|
||||||
$(eval TMP := $(shell mktemp /tmp/index.XXXXXX))
|
$(eval TMP := $(shell mktemp /tmp/index.XXXXXX))
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
Tibia
|
Tibia
|
||||||
|
|
||||||
Copyright (C) 2022-2025 Orastron Srl unipersonale
|
Copyright (C) 2022-2024 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
|
||||||
@ -75,12 +75,12 @@ var Player = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function map(index, value) {
|
function map(index, value) {
|
||||||
var p = demo.Module.parameters[index];
|
var p = demo.Module.data.product.parameters[index];
|
||||||
return p.map == "logarithmic" ? p.minimum * Math.exp((2.0 * Math.log(Math.sqrt(p.maximum * p.minimum) / Math.abs(p.minimum))) * value) : p.minimum + (p.maximum - p.minimum) * value;
|
return p.map == "logarithmic" ? p.minimum * Math.exp((2.0 * Math.log(Math.sqrt(p.maximum * p.minimum) / Math.abs(p.minimum))) * value) : p.minimum + (p.maximum - p.minimum) * value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function unmap(index, value) {
|
function unmap(index, value) {
|
||||||
var p = demo.Module.parameters[index];
|
var p = demo.Module.data.product.parameters[index];
|
||||||
return p.map == "logarithmic" ? Math.log(value / p.minimum) / (2.0 * Math.log(Math.sqrt(p.maximum * p.minimum) / Math.abs(p.minimum))) : (value - p.minimum) / (p.maximum - p.minimum);
|
return p.map == "logarithmic" ? Math.log(value / p.minimum) / (2.0 * Math.log(Math.sqrt(p.maximum * p.minimum) / Math.abs(p.minimum))) : (value - p.minimum) / (p.maximum - p.minimum);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ var units = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function displayValue(elem, index, value) {
|
function displayValue(elem, index, value) {
|
||||||
var param = demo.Module.parameters[index];
|
var param = demo.Module.data.product.parameters[index];
|
||||||
var unit = param.unit;
|
var unit = param.unit;
|
||||||
if (param.integer)
|
if (param.integer)
|
||||||
value = Math.round(value);
|
value = Math.round(value);
|
||||||
@ -132,9 +132,9 @@ window.addEventListener("load", function (e) {
|
|||||||
var playPause = document.getElementById("playPause");
|
var playPause = document.getElementById("playPause");
|
||||||
var controls = document.getElementById("controls");
|
var controls = document.getElementById("controls");
|
||||||
|
|
||||||
audioInputIndex = demo.Module.buses.filter(x => x.type == "audio" && x.direction == "input").findIndex(x => !x.cv && !x.sidechain);
|
audioInputIndex = demo.Module.data.product.buses.filter(x => x.type == "audio" && x.direction == "input").findIndex(x => !x.cv && !x.sidechain);
|
||||||
audioOutputIndex = demo.Module.buses.filter(x => x.type == "audio" && x.direction == "output").findIndex(x => !x.cv && !x.sidechain);
|
audioOutputIndex = demo.Module.data.product.buses.filter(x => x.type == "audio" && x.direction == "output").findIndex(x => !x.cv && !x.sidechain);
|
||||||
hasMidiInput = demo.Module.buses.filter(x => x.type == "midi" && x.direction == "input").length > 0;
|
hasMidiInput = demo.Module.data.product.buses.filter(x => x.type == "midi" && x.direction == "input").length > 0;
|
||||||
|
|
||||||
if (hasMidiInput && !navigator.requestMIDIAccess)
|
if (hasMidiInput && !navigator.requestMIDIAccess)
|
||||||
alert("Your browser doesn't support the Web MIDI API");
|
alert("Your browser doesn't support the Web MIDI API");
|
||||||
@ -145,7 +145,7 @@ window.addEventListener("load", function (e) {
|
|||||||
file.value = "";
|
file.value = "";
|
||||||
playPause.disabled = true;
|
playPause.disabled = true;
|
||||||
|
|
||||||
var parameters = demo.Module.parameters;
|
var parameters = demo.Module.data.product.parameters;
|
||||||
for (var i = 0; i < parameters.length; i++) {
|
for (var i = 0; i < parameters.length; i++) {
|
||||||
var div = document.createElement("div");
|
var div = document.createElement("div");
|
||||||
|
|
||||||
@ -241,8 +241,8 @@ window.addEventListener("load", function (e) {
|
|||||||
if ((e.data[0] & 0xf0) == 0xf0)
|
if ((e.data[0] & 0xf0) == 0xf0)
|
||||||
return;
|
return;
|
||||||
var msg = { type: "midi", data: e.data };
|
var msg = { type: "midi", data: e.data };
|
||||||
for (var i = 0; i < demo.Module.buses.length; i++) {
|
for (var i = 0; i < demo.Module.data.product.buses.length; i++) {
|
||||||
var b = demo.Module.buses[i];
|
var b = demo.Module.data.product.buses[i];
|
||||||
if (b.type != "midi" || b.direction != "input")
|
if (b.type != "midi" || b.direction != "input")
|
||||||
continue;
|
continue;
|
||||||
msg.index = i;
|
msg.index = i;
|
||||||
|
@ -21,5 +21,5 @@
|
|||||||
ALL := $(ALL) build/web/index.html build/web/cert.pem build/web/key.pem
|
ALL := $(ALL) build/web/index.html build/web/cert.pem build/web/key.pem
|
||||||
|
|
||||||
STRIP_ALL := $(STRIP_ALL) build/web/index.html
|
STRIP_ALL := $(STRIP_ALL) build/web/index.html
|
||||||
STRIP_PREREQS := $(STRIP_PREREQS) strip-web-demo
|
STRIP_PHONY := $(STRIP_PHONY) strip-web-demo
|
||||||
PHONY := $(PHONY) strip-web-demo
|
STRIP_PREREQS := $(STRIP_ALL) $(STRIP_PHONY)
|
||||||
|
@ -18,8 +18,6 @@
|
|||||||
# File author: Stefano D'Angelo
|
# File author: Stefano D'Angelo
|
||||||
#
|
#
|
||||||
|
|
||||||
SHELL := bash -o pipefail
|
|
||||||
|
|
||||||
TEMPLATE := web
|
TEMPLATE := web
|
||||||
|
|
||||||
include vars.mk
|
include vars.mk
|
||||||
@ -88,9 +86,8 @@ DIRS := build build/obj build/web build/web/$(BUNDLE_NAME)
|
|||||||
ALL := build/web/$(BUNDLE_NAME)/module.wasm build/web/$(BUNDLE_NAME)/processor.js build/web/$(BUNDLE_NAME)/module.js
|
ALL := build/web/$(BUNDLE_NAME)/module.wasm build/web/$(BUNDLE_NAME)/processor.js build/web/$(BUNDLE_NAME)/module.js
|
||||||
|
|
||||||
STRIP_ALL := build/web/$(BUNDLE_NAME)/module.wasm build/web/$(BUNDLE_NAME)/processor.js build/web/$(BUNDLE_NAME)/module.js
|
STRIP_ALL := build/web/$(BUNDLE_NAME)/module.wasm build/web/$(BUNDLE_NAME)/processor.js build/web/$(BUNDLE_NAME)/module.js
|
||||||
STRIP_PREREQS := $(STRIP_ALL)
|
STRIP_PHONY :=
|
||||||
|
STRIP_PREREQS := $(STRIP_ALL) $(STRIP_PHONY)
|
||||||
PHONY := all clean strip
|
|
||||||
|
|
||||||
-include $(MKINC_DIR)/vars-extra.mk
|
-include $(MKINC_DIR)/vars-extra.mk
|
||||||
|
|
||||||
@ -124,7 +121,7 @@ strip: $(STRIP_PREREQS)
|
|||||||
|
|
||||||
-include $(MKINC_DIR)/rules-extra.mk
|
-include $(MKINC_DIR)/rules-extra.mk
|
||||||
|
|
||||||
.PHONY: $(PHONY)
|
.PHONY: all clean strip $(STRIP_PHONY)
|
||||||
|
|
||||||
.SECONDEXPANSION:
|
.SECONDEXPANSION:
|
||||||
|
|
||||||
@ -137,5 +134,3 @@ $(CXX_OBJS): build/obj/%.o: $$(filter $$(PERCENT)/$$(basename $$(notdir $$@)).cp
|
|||||||
$(CXX) $^ -o $@ -c $(CXXFLAGS_ALL)
|
$(CXX) $^ -o $@ -c $(CXXFLAGS_ALL)
|
||||||
|
|
||||||
-include $(MKINC_DIR)/rules-secondexp-extra.mk
|
-include $(MKINC_DIR)/rules-secondexp-extra.mk
|
||||||
|
|
||||||
.DELETE_ON_ERROR:
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Tibia
|
* Tibia
|
||||||
*
|
*
|
||||||
* Copyright (C) 2022-2025 Orastron Srl unipersonale
|
* Copyright (C) 2022-2024 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,12 +18,13 @@
|
|||||||
* File author: Stefano D'Angelo
|
* File author: Stefano D'Angelo
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const buses = {{=JSON.stringify(it.product.buses, null, 2)}};
|
const data = {
|
||||||
const parameters = {{=JSON.stringify(it.product.parameters, null, 2)}};
|
company: {{=JSON.stringify(it.company, null, 2)}},
|
||||||
|
product: {{=JSON.stringify(it.product, null, 2)}}
|
||||||
|
};
|
||||||
|
|
||||||
export class Module {
|
export class Module {
|
||||||
static get buses() { return buses; }
|
static get data() { return data; }
|
||||||
static get parameters() { return parameters; }
|
|
||||||
|
|
||||||
async init(context, processorJsPath, wasmPath) {
|
async init(context, processorJsPath, wasmPath) {
|
||||||
var wasmBytes = await fetch(wasmPath)
|
var wasmBytes = await fetch(wasmPath)
|
||||||
@ -44,11 +45,11 @@ export class Module {
|
|||||||
|
|
||||||
export class Node extends AudioWorkletNode {
|
export class Node extends AudioWorkletNode {
|
||||||
constructor(module) {
|
constructor(module) {
|
||||||
super(module.context, "{{=it.product.bundleName}}",
|
super(module.context, data.product.bundleName,
|
||||||
{
|
{
|
||||||
numberOfInputs: buses.filter(b => b.type == "audio" && b.direction == "input").length,
|
numberOfInputs: data.product.buses.filter(b => b.type == "audio" && b.direction == "input").length,
|
||||||
numberOfOutputs: buses.filter(b => b.type == "audio" && b.direction == "output").length,
|
numberOfOutputs: data.product.buses.filter(b => b.type == "audio" && b.direction == "output").length,
|
||||||
outputChannelCount: buses.filter(b => b.type == "audio" && b.direction == "output").map(b => b.channels == "mono" ? 1 : 2),
|
outputChannelCount: data.product.buses.filter(b => b.type == "audio" && b.direction == "output").map(b => b.channels == "mono" ? 1 : 2),
|
||||||
processorOptions: { wasmBytes: module.wasmBytes }
|
processorOptions: { wasmBytes: module.wasmBytes }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
{
|
{
|
||||||
"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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,7 @@
|
|||||||
"project": "@example:project",
|
"project": "@example:project",
|
||||||
"types": [ "@lv2:AmplifierPlugin" ],
|
"types": [ "@lv2:AmplifierPlugin" ],
|
||||||
"version": "1.0",
|
"version": "1.0",
|
||||||
"ui": {
|
|
||||||
"uri": "@example:tibia_test#ui"
|
"use_parameters": true
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,8 +138,7 @@ 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, float last_sample_rate) {
|
static int plugin_state_save(plugin *instance, const plugin_state_callbacks *cbs) {
|
||||||
(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;
|
||||||
@ -160,8 +159,7 @@ 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, float cur_sample_rate, const char *data, size_t length) {
|
static int plugin_state_load(const plugin_state_callbacks *cbs, 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;
|
||||||
|
359
test/plugin_ui.h
359
test/plugin_ui.h
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Tibia
|
* Tibia
|
||||||
*
|
*
|
||||||
* Copyright (C) 2024, 2025 Orastron Srl unipersonale
|
* Copyright (C) 2024 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,16 +18,21 @@
|
|||||||
* File author: Stefano D'Angelo, Paolo Marrone
|
* File author: Stefano D'Angelo, Paolo Marrone
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "vinci.h"
|
#include <pugl/pugl.h>
|
||||||
#include <stdio.h>
|
#include <pugl/cairo.h>
|
||||||
#include <string.h>
|
#include <cairo.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
void * widget;
|
void * widget;
|
||||||
|
PuglWorld * world;
|
||||||
|
PuglView * view;
|
||||||
|
|
||||||
vinci *ui;
|
double fw;
|
||||||
window *w;
|
double fh;
|
||||||
int param_down;
|
double x;
|
||||||
|
double y;
|
||||||
|
double w;
|
||||||
|
double h;
|
||||||
|
|
||||||
float gain;
|
float gain;
|
||||||
float delay;
|
float delay;
|
||||||
@ -35,213 +40,281 @@ 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 draw_rect(window *w, uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint32_t color) {
|
static void plugin_ui_update_geometry(plugin_ui *instance) {
|
||||||
uint32_t *data = (uint32_t*) malloc(width * height * 4);
|
PuglRect frame = puglGetFrame(instance->view);
|
||||||
uint32_t p = 0;
|
instance->fw = frame.width;
|
||||||
for (uint32_t i = 0; i < height; i++)
|
instance->fh = frame.height;
|
||||||
for (uint32_t j = 0; j < width; j++, p++)
|
if (frame.width == 0 || frame.height == 0)
|
||||||
data[p] = color;
|
return;
|
||||||
window_draw(w, (unsigned char*)data, 0, 0, width, height, x, y, width, height);
|
|
||||||
free(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void draw_slider(plugin_ui *pui, int id, float value) {
|
if (instance->fw / instance->fh > RATIO) {
|
||||||
const int w = window_get_width(pui->w);
|
instance->w = RATIO * instance->fh;
|
||||||
const int h = window_get_height(pui->w);
|
instance->h = instance->fh;
|
||||||
draw_rect(pui->w, 0.1 * w, 0.15 * (id + 1) * h, 0.8 * w * value, 0.1 * h, 0x6789ab);
|
instance->x = 0.5 * (instance->fw - instance->w);
|
||||||
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);
|
instance->y = 0.0;
|
||||||
}
|
} else {
|
||||||
|
instance->w = instance->fw;
|
||||||
static void draw_button(plugin_ui *pui, int id, char value) {
|
instance->h = INV_RATIO * instance->fw;
|
||||||
const int w = window_get_width(pui->w);
|
instance->x = 0.0;
|
||||||
const int h = window_get_height(pui->w);
|
instance->y = 0.5 * (instance->fh - instance->h);
|
||||||
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) {
|
|
||||||
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 on_mouse_release (window *win, int32_t x, int32_t y, uint32_t state) {
|
static void plugin_ui_draw(plugin_ui *instance) {
|
||||||
(void) state;
|
cairo_t *cr = (cairo_t *)puglGetContext(instance->view);
|
||||||
|
double x = instance->x;
|
||||||
|
double y = instance->y;
|
||||||
|
double w = instance->w;
|
||||||
|
double h = instance->h;
|
||||||
|
|
||||||
plugin_ui *pui = (plugin_ui*) window_get_data(win);
|
cairo_set_line_width(cr, 0.005 * h);
|
||||||
const int w = window_get_width(win);
|
|
||||||
const int h = window_get_height(win);
|
|
||||||
|
|
||||||
if (pui->param_down == 4)
|
cairo_set_source_rgb(cr, 0, 0, 0);
|
||||||
if (x >= 0.4 * w && x <= 0.6 * w && y >= 0.6 * h && y <= 0.7 * h) {
|
cairo_paint(cr);
|
||||||
pui->bypass = !pui->bypass;
|
|
||||||
pui->cbs.set_parameter(pui->cbs.handle, 3, pui->bypass ? 1.f : 0.f);
|
cairo_set_source_rgb(cr, 0.2, 0.2, 0.2);
|
||||||
draw_button(pui, 3, pui->bypass);
|
cairo_rectangle(cr, x, y, w, h);
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pui->param_down != -1) {
|
static PuglStatus plugin_ui_on_event(PuglView *view, const PuglEvent *event) {
|
||||||
float v = x < 0.1 * w ? 0.f : (x > 0.9 * w ? 1.f : (float)((x - (0.1 * w)) / (0.8 * w)));
|
switch (event->type) {
|
||||||
switch (pui->param_down) {
|
case PUGL_CONFIGURE:
|
||||||
|
{
|
||||||
|
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:
|
||||||
pui->gain = v;
|
instance->gain = v;
|
||||||
pui->cbs.set_parameter_end(pui->cbs.handle, 0, -60.f + 80.f * pui->gain);
|
instance->cbs.set_parameter(instance->cbs.handle, 0, -60.f + 80.f * instance->gain);
|
||||||
draw_slider(pui, 0, pui->gain);
|
puglPostRedisplay(instance->view);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
pui->delay = v;
|
instance->delay = v;
|
||||||
pui->cbs.set_parameter_end(pui->cbs.handle, 1, 1000.f * pui->delay);
|
instance->cbs.set_parameter(instance->cbs.handle, 1, 1000.f * instance->delay);
|
||||||
draw_slider(pui, 1, pui->delay);
|
puglPostRedisplay(instance->view);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
pui->cutoff = v;
|
instance->cutoff = v;
|
||||||
pui->cbs.set_parameter_end(pui->cbs.handle, 2, (632.4555320336746f * pui->cutoff + 20.653108640674372f) / (1.0326554320337158f - pui->cutoff));
|
instance->cbs.set_parameter(instance->cbs.handle, 2, (632.4555320336746f * instance->cutoff + 20.653108640674372f) / (1.0326554320337158f - instance->cutoff));
|
||||||
draw_slider(pui, 2, pui->cutoff);
|
puglPostRedisplay(instance->view);
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_mouse_move (window *win, int32_t x, int32_t y, uint32_t state) {
|
if (instance->param_down != -1) {
|
||||||
(void) y;
|
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) state;
|
switch (instance->param_down) {
|
||||||
|
|
||||||
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:
|
||||||
pui->gain = v;
|
instance->gain = v;
|
||||||
pui->cbs.set_parameter(pui->cbs.handle, 0, -60.f + 80.f * pui->gain);
|
instance->cbs.set_parameter_end(instance->cbs.handle, 0, -60.f + 80.f * instance->gain);
|
||||||
draw_slider(pui, 0, pui->gain);
|
puglPostRedisplay(instance->view);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
pui->delay = v;
|
instance->delay = v;
|
||||||
pui->cbs.set_parameter(pui->cbs.handle, 1, 1000.f * pui->delay);
|
instance->cbs.set_parameter_end(instance->cbs.handle, 1, 1000.f * instance->delay);
|
||||||
draw_slider(pui, 1, pui->delay);
|
puglPostRedisplay(instance->view);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
pui->cutoff = v;
|
instance->cutoff = v;
|
||||||
pui->cbs.set_parameter(pui->cbs.handle, 2, (632.4555320336746f * pui->cutoff + 20.653108640674372f) / (1.0326554320337158f - pui->cutoff));
|
instance->cbs.set_parameter_end(instance->cbs.handle, 2, (632.4555320336746f * instance->cutoff + 20.653108640674372f) / (1.0326554320337158f - instance->cutoff));
|
||||||
draw_slider(pui, 2, pui->cutoff);
|
puglPostRedisplay(instance->view);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
instance->param_down = -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
static void on_window_resize (window *w, int32_t width, int32_t height) {
|
break;
|
||||||
draw_rect(w, 0, 0, width, height, 0xff9999);
|
case PUGL_EXPOSE:
|
||||||
|
{
|
||||||
plugin_ui *pui = (plugin_ui*) window_get_data(w);
|
plugin_ui *instance = (plugin_ui *)puglGetHandle(view);
|
||||||
|
plugin_ui_update_geometry(instance); // I didn't expect this was needed here for X11 to work decently when resizing
|
||||||
draw_slider(pui, 0, pui->gain);
|
plugin_ui_draw(instance);
|
||||||
draw_slider(pui, 1, pui->delay);
|
}
|
||||||
draw_slider(pui, 2, pui->cutoff);
|
break;
|
||||||
draw_button(pui, 3, pui->bypass);
|
default:
|
||||||
draw_slider(pui, 4, pui->y_z1);
|
break;
|
||||||
|
}
|
||||||
|
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 = (plugin_ui *) 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->ui = vinci_new();
|
instance->world = puglNewWorld(PUGL_MODULE, 0);
|
||||||
instance->w = window_new(instance->ui, has_parent ? parent : NULL, WIDTH, HEIGHT, &wcbs);
|
instance->view = puglNewView(instance->world);
|
||||||
instance->widget = window_get_handle(instance->w);
|
puglSetSizeHint(instance->view, PUGL_DEFAULT_SIZE, WIDTH, HEIGHT);
|
||||||
window_set_data(instance->w, (void*) instance);
|
puglSetViewHint(instance->view, PUGL_RESIZABLE, PUGL_TRUE);
|
||||||
window_show(instance->w);
|
puglSetHandle(instance->view, instance);
|
||||||
|
puglSetBackend(instance->view, puglCairoBackend());
|
||||||
// just some valid values to allow drawing
|
PuglRect frame = { 0, 0, WIDTH, HEIGHT };
|
||||||
instance->gain = 0.f;
|
puglSetFrame(instance->view, frame);
|
||||||
instance->delay = 0.f;
|
puglSetEventFunc(instance->view, plugin_ui_on_event);
|
||||||
instance->cutoff = 0.f;
|
if (has_parent)
|
||||||
instance->bypass = 0;
|
puglSetParentWindow(instance->view, (PuglNativeView)parent);
|
||||||
instance->y_z1 = 0.f;
|
if (puglRealize(instance->view)) {
|
||||||
|
puglFreeView(instance->view);
|
||||||
on_window_resize(instance->w, window_get_width(instance->w), window_get_height(instance->w));
|
puglFreeWorld(instance->world);
|
||||||
|
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) {
|
||||||
window_free(instance->w);
|
puglFreeView(instance->view);
|
||||||
vinci_destroy(instance->ui);
|
puglFreeWorld(instance->world);
|
||||||
free(instance);
|
free(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void plugin_ui_idle(plugin_ui *instance) {
|
static void plugin_ui_idle(plugin_ui *instance) {
|
||||||
vinci_idle(instance->ui);
|
puglUpdate(instance->world, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,8 @@
|
|||||||
"product": {
|
"product": {
|
||||||
"name": "Tibia test product",
|
"name": "Tibia test product",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"buildVersion": 0,
|
"buildVersion": "1",
|
||||||
"description": "A toy plugin to test Tibia",
|
"bundleName": "tibia_test",
|
||||||
"copyright": "Copyright © 2021-2025 Orastron Srl unipersonale",
|
|
||||||
"bundleName": "tibia-test",
|
|
||||||
"buses": [
|
"buses": [
|
||||||
{
|
{
|
||||||
"type": "audio",
|
"type": "audio",
|
||||||
@ -138,8 +136,7 @@
|
|||||||
],
|
],
|
||||||
"ui": {
|
"ui": {
|
||||||
"userResizable": true,
|
"userResizable": true,
|
||||||
"selfResizable": false,
|
"selfResizable": false
|
||||||
"highResolution": true
|
|
||||||
},
|
},
|
||||||
"state": {
|
"state": {
|
||||||
"dspCustom": true
|
"dspCustom": true
|
||||||
|
@ -1,21 +1 @@
|
|||||||
#
|
|
||||||
# Tibia
|
|
||||||
#
|
|
||||||
# Copyright (C) 2024 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
|
|
||||||
# the Free Software Foundation, version 3 of the License.
|
|
||||||
#
|
|
||||||
# Tibia is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with Tibia. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
# File author: Stefano D'Angelo
|
|
||||||
#
|
|
||||||
|
|
||||||
include rules-extra-web-demo.mk
|
include rules-extra-web-demo.mk
|
||||||
|
20
test/run.sh
20
test/run.sh
@ -1,25 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
#
|
|
||||||
# Tibia
|
|
||||||
#
|
|
||||||
# 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
|
|
||||||
# the Free Software Foundation, version 3 of the License.
|
|
||||||
#
|
|
||||||
# Tibia is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with Tibia. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
# File author: Stefano D'Angelo
|
|
||||||
#
|
|
||||||
|
|
||||||
dir=`dirname $0`
|
dir=`dirname $0`
|
||||||
|
|
||||||
$dir/../tibia $dir/product.json,$dir/company.json $dir/../templates/api $dir/../out/api
|
$dir/../tibia $dir/product.json,$dir/company.json $dir/../templates/api $dir/../out/api
|
||||||
|
@ -1,21 +1 @@
|
|||||||
#
|
|
||||||
# Tibia
|
|
||||||
#
|
|
||||||
# Copyright (C) 2024 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
|
|
||||||
# the Free Software Foundation, version 3 of the License.
|
|
||||||
#
|
|
||||||
# Tibia is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with Tibia. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
# File author: Stefano D'Angelo
|
|
||||||
#
|
|
||||||
|
|
||||||
include vars-extra-web-demo.mk
|
include vars-extra-web-demo.mk
|
||||||
|
@ -1,65 +1,19 @@
|
|||||||
#
|
|
||||||
# Tibia
|
|
||||||
#
|
|
||||||
# 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
|
|
||||||
# the Free Software Foundation, version 3 of the License.
|
|
||||||
#
|
|
||||||
# Tibia is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with Tibia. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
# File author: Stefano D'Angelo
|
|
||||||
#
|
|
||||||
|
|
||||||
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)
|
||||||
ifeq ($(OS), Windows_NT)
|
CFLAGS_EXTRA := $(shell pkg-config --cflags pugl-cairo-0 pugl-0 cairo)
|
||||||
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${VINCI_DIR}
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(TEMPLATE), vst3)
|
ifeq ($(TEMPLATE), vst3)
|
||||||
ifeq ($(OS), Windows_NT)
|
RUTEX_DIR := ../../../rutex
|
||||||
C_SRCS_EXTRA := $(VINCI_DIR)/vinci-win32.c
|
CFLAGS_EXTRA := -I../../../vst3_c_api $(shell pkg-config --cflags pugl-cairo-0)
|
||||||
LDFLAGS_EXTRA := -mwindows
|
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)
|
||||||
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)
|
||||||
@ -75,12 +29,13 @@ 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.13004108
|
NDK_VERSION := 28.0.12674087
|
||||||
BUILD_TOOLS_VERSION := 36.0.0
|
BUILD_TOOLS_VERSION := 35.0.0
|
||||||
ANDROIDX_CORE_VERSION := 1.16.0
|
ANDROID_VERSION := 35
|
||||||
|
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.20
|
KOTLIN_STDLIB_VERSION := 2.1.10
|
||||||
KOTLINX_COROUTINES_CORE_VERSION := 1.10.2
|
KOTLINX_COROUTINES_CORE_VERSION := 1.10.1
|
||||||
KOTLINX_COROUTINES_CORE_JVM_VERSION := 1.10.2
|
KOTLINX_COROUTINES_CORE_JVM_VERSION := 1.10.1
|
||||||
endif
|
endif
|
||||||
|
55
tibia
55
tibia
@ -1,25 +1,5 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
/*
|
|
||||||
* Tibia
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
* the Free Software Foundation, version 3 of the License.
|
|
||||||
*
|
|
||||||
* Tibia is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Tibia. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* File author: Stefano D'Angelo
|
|
||||||
*/
|
|
||||||
|
|
||||||
function usage() {
|
function usage() {
|
||||||
console.log("Usage:");
|
console.log("Usage:");
|
||||||
console.log(" tibia file1.json,file2.json,...filen.json template outDirectory [override1=value1] [override2=value2] ...");
|
console.log(" tibia file1.json,file2.json,...filen.json template outDirectory [override1=value1] [override2=value2] ...");
|
||||||
@ -115,30 +95,39 @@ var doT = require("dot");
|
|||||||
doT.templateSettings.strip = false;
|
doT.templateSettings.strip = false;
|
||||||
|
|
||||||
var api = {
|
var api = {
|
||||||
generateFileFromTemplateFile: function (templateFile, outFile, data, mode) {
|
// https://coderrocketfuel.com/article/recursively-list-all-the-files-in-a-directory-using-node-js
|
||||||
|
getAllFiles: function (dirPath, arrayOfFiles, relDir) {
|
||||||
|
var files = fs.readdirSync(dirPath);
|
||||||
|
|
||||||
|
var arrayOfFiles = arrayOfFiles || [];
|
||||||
|
var relDir = relDir || "";
|
||||||
|
|
||||||
|
files.forEach(function(file) {
|
||||||
|
if (fs.statSync(dirPath + path.sep + file).isDirectory())
|
||||||
|
arrayOfFiles = api.getAllFiles(dirPath + path.sep + file, arrayOfFiles, relDir + file + path.sep);
|
||||||
|
else
|
||||||
|
arrayOfFiles.push(relDir + file);
|
||||||
|
});
|
||||||
|
|
||||||
|
return arrayOfFiles
|
||||||
|
},
|
||||||
|
|
||||||
|
generateFileFromTemplateFile: function (templateFile, outFile, data) {
|
||||||
if (!outputData)
|
if (!outputData)
|
||||||
return;
|
return;
|
||||||
var dir = outputDir + path.sep + path.dirname(outFile);
|
var dir = outputDir + path.sep + path.dirname(outFile);
|
||||||
fs.mkdirSync(dir, { recursive: true });
|
fs.mkdirSync(dir, { recursive: true });
|
||||||
var t = doT.template(fs.readFileSync(template + path.sep + templateFile, { encoding: "utf-8" }));
|
var t = doT.template(fs.readFileSync(template + path.sep + templateFile, { encoding: "utf-8" }));
|
||||||
var outputFile = outputDir + path.sep + outFile;
|
fs.writeFileSync(outputDir + path.sep + outFile, t(data), { encoding: "utf-8" });
|
||||||
fs.writeFileSync(outputFile, t(data), { encoding: "utf-8" });
|
|
||||||
if (mode !== undefined)
|
|
||||||
fs.chmodSync(outputFile, mode);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
copyFile: function (inFile, outFile, mode) {
|
copyFile: function (inFile, outFile) {
|
||||||
if (!outputCommon)
|
if (!outputCommon)
|
||||||
return;
|
return;
|
||||||
var dir = outputDir + path.sep + path.dirname(outFile);
|
var dir = outputDir + path.sep + path.dirname(outFile);
|
||||||
fs.mkdirSync(dir, { recursive: true });
|
fs.mkdirSync(dir, { recursive: true });
|
||||||
var outputFile = outputDir + path.sep + outFile;
|
fs.copyFileSync(template + path.sep + inFile, outputDir + path.sep + outFile);
|
||||||
fs.copyFileSync(template + path.sep + inFile, outputFile);
|
}
|
||||||
if (mode !== undefined)
|
|
||||||
fs.chmodSync(outputFile, mode);
|
|
||||||
},
|
|
||||||
|
|
||||||
templateDir: template
|
|
||||||
};
|
};
|
||||||
|
|
||||||
data.tibia = {
|
data.tibia = {
|
||||||
|
Loading…
Reference in New Issue
Block a user