diff --git a/lv2export/Makefile b/lv2export/Makefile index 0549e88..c5b8ce2 100644 --- a/lv2export/Makefile +++ b/lv2export/Makefile @@ -14,6 +14,7 @@ SYSDEPS ?= false # -------------------------------------------------------------- # Import base definitions +USE_NANOVG_FBO = true include ../dpf/Makefile.base.mk # -------------------------------------------------------------- @@ -21,9 +22,6 @@ include ../dpf/Makefile.base.mk BUILD_DIR = ../build/lv2export -BASE_FLAGS += -DHEADLESS -BASE_FLAGS += -DPRIVATE= - ifeq ($(MACOS),true) BASE_FLAGS += -DARCH_MAC else ifeq ($(WINDOWS),true) @@ -32,120 +30,77 @@ else BASE_FLAGS += -DARCH_LIN endif -BASE_FLAGS += -fno-finite-math-only -# BASE_FLAGS += -I../dpf/dgl -BASE_FLAGS += -I../dpf/dgl/src/nanovg -BASE_FLAGS += -I../dpf/distrho -BASE_FLAGS += -I../include -BASE_FLAGS += -I../include/neon-compat -BASE_FLAGS += -I../src/Rack/include -ifeq ($(SYSDEPS),true) -BASE_FLAGS += -DCARDINAL_SYSDEPS -BASE_FLAGS += $(shell pkg-config --cflags jansson libarchive samplerate speexdsp) -else -BASE_FLAGS += -DZSTDLIB_VISIBILITY= -BASE_FLAGS += -I../src/Rack/dep/include -endif -BASE_FLAGS += -I../src/Rack/dep/filesystem/include -BASE_FLAGS += -I../src/Rack/dep/fuzzysearchdatabase/src -BASE_FLAGS += -I../src/Rack/dep/glfw/include -BASE_FLAGS += -I../src/Rack/dep/nanosvg/src -# BASE_FLAGS += -IRack/dep/osdialog -BASE_FLAGS += -I../src/Rack/dep/oui-blendish -BASE_FLAGS += -I../src/Rack/dep/pffft -BASE_FLAGS += -pthread - -ifeq ($(WINDOWS),true) -BASE_FLAGS += -D_USE_MATH_DEFINES -BASE_FLAGS += -DWIN32_LEAN_AND_MEAN -BASE_FLAGS += -I../include/mingw-compat -BASE_FLAGS += -I../include/mingw-std-threads +ifeq ($(DEBUG),true) +BASE_FLAGS += -UDEBUG endif +# BASE_FLAGS += -DHEADLESS +# BASE_FLAGS += -DPRIVATE= +# +# BASE_FLAGS += -fno-finite-math-only +# # BASE_FLAGS += -I../dpf/dgl +# BASE_FLAGS += -I../dpf/dgl/src/nanovg +# BASE_FLAGS += -I../dpf/distrho +# BASE_FLAGS += -I../include +# BASE_FLAGS += -I../include/neon-compat +# BASE_FLAGS += -I../src/Rack/include +# ifeq ($(SYSDEPS),true) +# BASE_FLAGS += -DCARDINAL_SYSDEPS +# BASE_FLAGS += $(shell pkg-config --cflags jansson libarchive samplerate speexdsp) +# else +# BASE_FLAGS += -DZSTDLIB_VISIBILITY= +# BASE_FLAGS += -I../src/Rack/dep/include +# endif +# BASE_FLAGS += -I../src/Rack/dep/filesystem/include +# BASE_FLAGS += -I../src/Rack/dep/fuzzysearchdatabase/src +# BASE_FLAGS += -I../src/Rack/dep/glfw/include +# BASE_FLAGS += -I../src/Rack/dep/nanosvg/src +# # BASE_FLAGS += -IRack/dep/osdialog +# BASE_FLAGS += -I../src/Rack/dep/oui-blendish +# BASE_FLAGS += -I../src/Rack/dep/pffft +# BASE_FLAGS += -pthread +# +# ifeq ($(WINDOWS),true) +# BASE_FLAGS += -D_USE_MATH_DEFINES +# BASE_FLAGS += -DWIN32_LEAN_AND_MEAN +# BASE_FLAGS += -I../include/mingw-compat +# BASE_FLAGS += -I../include/mingw-std-threads +# endif + # -------------------------------------------------------------- # lots of warnings from VCV side -BASE_FLAGS += -Wno-unused-but-set-variable BASE_FLAGS += -Wno-unused-parameter -BASE_FLAGS += -Wno-unused-result BASE_FLAGS += -Wno-unused-variable -ifeq ($(MACOS),true) -BASE_FLAGS += -Wno-unknown-warning-option -endif - # -------------------------------------------------------------- -# extra linker flags - -LINK_FLAGS += -pthread +# also from plugins -ifneq ($(HAIKU_OR_MACOS_OR_WINDOWS),true) -LINK_FLAGS += -ldl -endif +BASE_FLAGS += -Wno-deprecated-declarations +BASE_FLAGS += -Wno-implicit-fallthrough ifeq ($(MACOS),true) -LINK_FLAGS += -framework IOKit -else ifeq ($(WINDOWS),true) -# needed by VCVRack -EXTRA_LIBS += -ldbghelp -lshlwapi -# needed by JW-Modules -EXTRA_LIBS += -lws2_32 -lwinmm -endif - -ifeq ($(SYSDEPS),true) -EXTRA_LIBS += $(shell pkg-config --libs jansson libarchive samplerate speexdsp) +BASE_FLAGS += -Wno-unknown-warning-option endif # -------------------------------------------------------------- -# Build files - -# BUILD_FILES += test.cpp -# BUILD_FILES = dep.cpp -BUILD_FILES += dep2.cpp -BUILD_FILES += ../src/override/context.cpp -BUILD_FILES += ../src/override/RemoteNanoVG.cpp -BUILD_FILES += ../src/Rack/src/logger.cpp -BUILD_FILES += ../src/Rack/src/random.cpp -BUILD_FILES += ../src/Rack/src/string.cpp -BUILD_FILES += ../src/Rack/src/system.cpp -BUILD_FILES += ../src/Rack/src/tinyexpr.c -BUILD_FILES += ../src/Rack/src/Quantity.cpp -BUILD_FILES += ../src/Rack/src/engine/Module.cpp -BUILD_FILES += ../src/Rack/src/engine/ParamQuantity.cpp -BUILD_FILES += ../src/Rack/src/engine/PortInfo.cpp -BUILD_FILES += ../src/Rack/dep/pffft/pffft.c -BUILD_FILES += ../src/Rack/dep/pffft/fftpack.c - -BUILD_OBJS = $(BUILD_FILES:%=$(BUILD_DIR)/%.o) - -# ChowDSP Chorus -BUILD_OBJS += $(BUILD_DIR)/lv2plugin/chowdsp-chorus.o -BUILD_OBJS += $(BUILD_DIR)/plugin/ChowDSP/ChowChorus/ChowChorus.cpp.o -BUILD_OBJS += $(BUILD_DIR)/plugin/ChowDSP/ChowChorus/BBDDelayLine.cpp.o -BUILD_OBJS += $(BUILD_DIR)/plugin/ChowDSP/shared/SineWave.cpp.o -BUILD_OBJS += $(BUILD_DIR)/plugin/ChowDSP/plugin.cpp.o - -# EXTRA_LIBS = ../plugins/plugins.a - -ifneq ($(SYSDEPS),true) -EXTRA_LIBS += ../src/Rack/dep/lib/libjansson.a -EXTRA_LIBS += ../src/Rack/dep/lib/libsamplerate.a -EXTRA_LIBS += ../src/Rack/dep/lib/libspeexdsp.a -ifeq ($(WINDOWS),true) -EXTRA_LIBS += ../src/Rack/dep/lib/libarchive_static.a -else -EXTRA_LIBS += ../src/Rack/dep/lib/libarchive.a -endif -EXTRA_LIBS += ../src/Rack/dep/lib/libzstd.a -endif +# stuff to include + +BUILD_CXX_FLAGS += -I. +BUILD_CXX_FLAGS += -Iincludes +BUILD_CXX_FLAGS += -I../dpf/distrho +BUILD_CXX_FLAGS += -I../plugins # -------------------------------------------------------------- # Build targets -TARGETS = ../bin/CardinalModules.lv2/manifest.ttl -TARGETS += ../bin/CardinalModules.lv2/plugins$(LIB_EXT) +PLUGINS = $(subst plugins/,,$(subst .cpp,,$(wildcard plugins/*.cpp))) -all: $(TARGETS) +BINARIES = $(PLUGINS:%=../bin/cardinal-%.lv2/plugin$(LIB_EXT)) +RESOURCES = $(PLUGINS:%=../bin/cardinal-%.lv2/manifest.ttl) +RESOURCES += $(PLUGINS:%=../bin/cardinal-%.lv2/plugin.ttl) + +all: $(BINARIES) $(RESOURCES) clean: rm -f $(TARGETS) $(BUILD_OBJS) @@ -153,44 +108,31 @@ clean: # -------------------------------------------------------------- # Build commands -../bin/CardinalModules.lv2/manifest.ttl: manifest.ttl.in - -@mkdir -p $(shell dirname $@) - sed -e "s/@LIB_EXT@/$(LIB_EXT)/" $< > $@ - # FIXME wildcard install - install -m 644 lv2ttl/* ../bin/CardinalModules.lv2/ - -../bin/CardinalModules.lv2/plugins$(LIB_EXT): $(BUILD_OBJS) +../bin/cardinal-%.lv2/manifest.ttl: manifest.ttl.in -@mkdir -p $(shell dirname $@) - $(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(EXTRA_LIBS) $(SHARED) -o $@ + sed -e "s/@LIB_EXT@/$(LIB_EXT)/" -e "s/@SLUG@/$*/" $< > $@ -$(BUILD_DIR)/%.c.o: %.c - -@mkdir -p "$(shell dirname $(BUILD_DIR)/$<)" - @echo "Compiling $<" - $(SILENT)$(CC) $< $(BUILD_C_FLAGS) -c -o $@ +../bin/cardinal-%.lv2/plugin.ttl: ../bin/cardinal-%.lv2/plugin$(LIB_EXT) + ../dpf/utils/lv2_ttl_generator$(APP_EXT) $^ | tail -n +2 > $@ -$(BUILD_DIR)/%.cpp.o: %.cpp - -@mkdir -p "$(shell dirname $(BUILD_DIR)/$<)" - @echo "Compiling $<" - $(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ +../bin/cardinal-%.lv2/plugin$(LIB_EXT): $(BUILD_DIR)/%.cpp.o + -@mkdir -p $(shell dirname $@) + $(SILENT)$(CXX) $< $(LINK_FLAGS) $(SHARED) -o $@ # -------------------------------------------------------------- -$(BUILD_DIR)/lv2plugin/chowdsp-chorus.o: lv2plugin.cpp - -@mkdir -p "$(shell dirname $@)" - @echo "Compiling $< (ChowDSP Chorus)" - $(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) -UPRIVATE -c -o $@ \ - -DPLUGIN_INSTANCE=pluginInstance__ChowDSP \ - -DPLUGIN_MODEL=modelChowChorus \ - -DPLUGIN_URI='"urn:cardinal:chow:chorus"' +# $(BUILD_DIR)/valleyaudio-plateau.cpp.o: plugins/valleyaudio-plateau.cpp +# -@mkdir -p "$(shell dirname $(BUILD_DIR)/$<)" +# @echo "Compiling $<" +# $(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) -DSLUG='"$*"' -c -o $@ -$(BUILD_DIR)/plugin/ChowDSP/%.o: ../plugins/ChowDSP/src/% - -@mkdir -p "$(shell dirname $@)" - @echo "Compiling $< (ChowDSP Chorus)" - $(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) -UPRIVATE -c -o $@ \ - -DpluginInstance=pluginInstance__ChowDSP +$(BUILD_DIR)/%.cpp.o: plugins/%.cpp + -@mkdir -p "$(shell dirname $(BUILD_DIR)/$<)" + @echo "Compiling $<" + $(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) -DSLUG='"$*"' -c -o $@ # -------------------------------------------------------------- --include $(BUILD_OBJS:%.o=%.d) +-include $(PLUGINS:%=$(BUILD_DIR)/%.cpp.d) # -------------------------------------------------------------- diff --git a/lv2export/dep2.cpp b/lv2export/dep2.cpp deleted file mode 100644 index ecf7cfb..0000000 --- a/lv2export/dep2.cpp +++ /dev/null @@ -1,272 +0,0 @@ -/* - * DISTRHO Cardinal Plugin - * Copyright (C) 2021 Filipe Coelho - * - * This program 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; either version 3 of - * the License, or any later version. - * - * This program 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. - * - * For a full copy of the GNU General Public License see the LICENSE file. - */ - -#define PRIVATE -#include - -#undef PRIVATE -#include - -using namespace rack; - -namespace rack { -namespace settings { -bool cpuMeter = false; -} -Exception::Exception(const char* format, ...) -{ - va_list args; - va_start(args, format); - msg = string::fV(format, args); - va_end(args); -} -namespace asset { -std::string plugin(plugin::Plugin* plugin, std::string filename) { return {}; } -std::string system(std::string filename) { return {}; } -} -namespace engine { -float Engine::getParamValue(Module* module, int paramId) { return 0.0f; } -float Engine::getParamSmoothValue(Module* module, int paramId) { return 0.0f; } -void Engine::setParamValue(Module* module, int paramId, float value) {} -void Engine::setParamSmoothValue(Module* module, int paramId, float value) {} -} -} - -namespace rack { -namespace app { - -Knob::Knob() {} -Knob::~Knob() {} -void Knob::initParamQuantity() {} -void Knob::onHover(const HoverEvent& e) {} -void Knob::onButton(const ButtonEvent& e) {} -void Knob::onDragStart(const DragStartEvent& e) {} -void Knob::onDragEnd(const DragEndEvent& e) {} -void Knob::onDragMove(const DragMoveEvent& e) {} -void Knob::onDragLeave(const DragLeaveEvent& e) {} -void Knob::onHoverScroll(const HoverScrollEvent& e) {} -void Knob::onLeave(const LeaveEvent& e) {} - -void LightWidget::draw(const DrawArgs& args) {} -void LightWidget::drawLayer(const DrawArgs& args, int layer) {} -void LightWidget::drawBackground(const DrawArgs& args) {} -void LightWidget::drawLight(const DrawArgs& args) {} -void LightWidget::drawHalo(const DrawArgs& args) {} - -ModuleLightWidget::~ModuleLightWidget() {} -engine::Light* ModuleLightWidget::getLight(int colorId) { return nullptr; } -engine::LightInfo* ModuleLightWidget::getLightInfo() { return nullptr; } -void ModuleLightWidget::createTooltip() {} -void ModuleLightWidget::destroyTooltip() {} -void ModuleLightWidget::step() {} -void ModuleLightWidget::onHover(const HoverEvent& e) {} -void ModuleLightWidget::onEnter(const EnterEvent& e) {} -void ModuleLightWidget::onLeave(const LeaveEvent& e) {} - -ModuleWidget::ModuleWidget() {} -ModuleWidget::~ModuleWidget() {} -plugin::Model* ModuleWidget::getModel() { return nullptr; } -void ModuleWidget::setModel(plugin::Model* model) {} -engine::Module* ModuleWidget::getModule() { return nullptr; } -void ModuleWidget::setModule(engine::Module* module) {} -widget::Widget* ModuleWidget::getPanel() { return nullptr; } -void ModuleWidget::setPanel(widget::Widget* panel) {} -void ModuleWidget::setPanel(std::shared_ptr svg) {} -void ModuleWidget::addParam(ParamWidget* param) {} -void ModuleWidget::addInput(PortWidget* input) {} -void ModuleWidget::addOutput(PortWidget* output) {} -ParamWidget* ModuleWidget::getParam(int paramId) { return nullptr; } -PortWidget* ModuleWidget::getInput(int portId) { return nullptr; } -PortWidget* ModuleWidget::getOutput(int portId) { return nullptr; } -std::vector ModuleWidget::getParams() { return {}; } -std::vector ModuleWidget::getPorts() { return {}; } -std::vector ModuleWidget::getInputs() { return {}; } -std::vector ModuleWidget::getOutputs() { return {}; } -void ModuleWidget::draw(const DrawArgs& args) {} -void ModuleWidget::drawLayer(const DrawArgs& args, int layer) {} -void ModuleWidget::onHover(const HoverEvent& e) {} -void ModuleWidget::onHoverKey(const HoverKeyEvent& e) {} -void ModuleWidget::onButton(const ButtonEvent& e) {} -void ModuleWidget::onDragStart(const DragStartEvent& e) {} -void ModuleWidget::onDragEnd(const DragEndEvent& e) {} -void ModuleWidget::onDragMove(const DragMoveEvent& e) {} -void ModuleWidget::onDragHover(const DragHoverEvent& e) {} -json_t* ModuleWidget::toJson() { return nullptr; } -void ModuleWidget::fromJson(json_t* rootJ) {} -bool ModuleWidget::pasteJsonAction(json_t* rootJ) { return false; } -void ModuleWidget::copyClipboard() {} -bool ModuleWidget::pasteClipboardAction() { return false; } -void ModuleWidget::load(std::string filename) {} -void ModuleWidget::loadAction(std::string filename) {} -void ModuleWidget::loadTemplate() {} -void ModuleWidget::loadDialog() {} -void ModuleWidget::save(std::string filename) {} -void ModuleWidget::saveTemplate() {} -void ModuleWidget::saveTemplateDialog() {} -bool ModuleWidget::hasTemplate() { return false; } -void ModuleWidget::clearTemplate() {} -void ModuleWidget::clearTemplateDialog() {} -void ModuleWidget::saveDialog() {} -void ModuleWidget::disconnect() {} -void ModuleWidget::resetAction() {} -void ModuleWidget::randomizeAction() {} -void ModuleWidget::appendDisconnectActions(history::ComplexAction* complexAction) {} -void ModuleWidget::disconnectAction() {} -void ModuleWidget::cloneAction(bool cloneCables) {} -void ModuleWidget::bypassAction(bool bypassed) {} -void ModuleWidget::removeAction() {} -void ModuleWidget::createContextMenu() {} -math::Vec& ModuleWidget::dragOffset() { static math::Vec r; return r; } -bool& ModuleWidget::dragEnabled() { static bool r; return r; } -math::Vec& ModuleWidget::oldPos() { static math::Vec r; return r; } -engine::Module* ModuleWidget::releaseModule() { return nullptr; } - -int MultiLightWidget::getNumColors() { return 0; } -void MultiLightWidget::addBaseColor(NVGcolor baseColor) {} -void MultiLightWidget::setBrightnesses(const std::vector& brightnesses) {} - -ParamWidget::ParamWidget() {} -ParamWidget::~ParamWidget() {} -engine::ParamQuantity* ParamWidget::getParamQuantity() { return nullptr; } -void ParamWidget::createTooltip() {} -void ParamWidget::destroyTooltip() {} -void ParamWidget::step() {} -void ParamWidget::draw(const DrawArgs& args) {} -void ParamWidget::onButton(const ButtonEvent& e) {} -void ParamWidget::onDoubleClick(const DoubleClickEvent& e) {} -void ParamWidget::onEnter(const EnterEvent& e) {} -void ParamWidget::onLeave(const LeaveEvent& e) {} -void ParamWidget::createContextMenu() {} -void ParamWidget::resetAction() {} - -PortWidget::PortWidget() {} -PortWidget::~PortWidget() {} -engine::Port* PortWidget::getPort() { return nullptr; } -engine::PortInfo* PortWidget::getPortInfo() { return nullptr; } -void PortWidget::createTooltip() {} -void PortWidget::destroyTooltip() {} -void PortWidget::createContextMenu() {} -void PortWidget::deleteTopCableAction() {} -void PortWidget::step() {} -void PortWidget::draw(const DrawArgs& args) {} -void PortWidget::onButton(const ButtonEvent& e) {} -void PortWidget::onEnter(const EnterEvent& e) {} -void PortWidget::onLeave(const LeaveEvent& e) {} -void PortWidget::onDragStart(const DragStartEvent& e) {} -void PortWidget::onDragEnd(const DragEndEvent& e) {} -void PortWidget::onDragDrop(const DragDropEvent& e) {} -void PortWidget::onDragEnter(const DragEnterEvent& e) {} -void PortWidget::onDragLeave(const DragLeaveEvent& e) {} - -SliderKnob::SliderKnob() {} -void SliderKnob::onHover(const HoverEvent& e) {} -void SliderKnob::onButton(const ButtonEvent& e) {} - -SvgKnob::SvgKnob() {} -void SvgKnob::setSvg(std::shared_ptr svg) {} -void SvgKnob::onChange(const ChangeEvent& e) {} - -SvgPort::SvgPort() {} -void SvgPort::setSvg(std::shared_ptr svg) {} - -SvgScrew::SvgScrew() {} -void SvgScrew::setSvg(std::shared_ptr svg) {} - -SvgSlider::SvgSlider() {} -void SvgSlider::setBackgroundSvg(std::shared_ptr svg) {} -void SvgSlider::setHandleSvg(std::shared_ptr svg) {} -void SvgSlider::setHandlePos(math::Vec minHandlePos, math::Vec maxHandlePos) {} -void SvgSlider::setHandlePosCentered(math::Vec minHandlePosCentered, math::Vec maxHandlePosCentered) {} -void SvgSlider::onChange(const ChangeEvent& e) {} - -} - -namespace engine { - -std::string LightInfo::getName() { return name; } -std::string LightInfo::getDescription() { return description; } - -} - -namespace widget { - -FramebufferWidget::FramebufferWidget() {} -FramebufferWidget::~FramebufferWidget() {} -void FramebufferWidget::setDirty(bool dirty) {} -int FramebufferWidget::getImageHandle() { return 0; } -NVGLUframebuffer* FramebufferWidget::getFramebuffer() { return nullptr; } -math::Vec FramebufferWidget::getFramebufferSize() { return {}; } -void FramebufferWidget::deleteFramebuffer() {} -void FramebufferWidget::step() {} -void FramebufferWidget::draw(const DrawArgs& args) {} -void FramebufferWidget::render(math::Vec scale, math::Vec offsetF, math::Rect clipBox) {} -void FramebufferWidget::drawFramebuffer() {} -void FramebufferWidget::onDirty(const DirtyEvent& e) {} -void FramebufferWidget::onContextCreate(const ContextCreateEvent& e) {} -void FramebufferWidget::onContextDestroy(const ContextDestroyEvent& e) {} - -SvgWidget::SvgWidget() {} -void SvgWidget::wrap() {} -void SvgWidget::setSvg(std::shared_ptr svg) {} -void SvgWidget::draw(const DrawArgs& args) {} - -Widget::~Widget() {} -math::Rect Widget::getBox() { return {}; } -void Widget::setBox(math::Rect box) {} -math::Vec Widget::getPosition() { return {}; } -void Widget::setPosition(math::Vec pos) {} -math::Vec Widget::getSize() { return {}; } -void Widget::setSize(math::Vec size) {} -widget::Widget* Widget::getParent() { return nullptr; } -bool Widget::isVisible() { return false; } -void Widget::setVisible(bool visible) {} -void Widget::requestDelete() {} -math::Rect Widget::getChildrenBoundingBox() { return {}; } -math::Rect Widget::getVisibleChildrenBoundingBox() { return {}; } -bool Widget::isDescendantOf(Widget* ancestor) { return false; } -math::Vec Widget::getRelativeOffset(math::Vec v, Widget* ancestor) { return {}; } -float Widget::getRelativeZoom(Widget* ancestor) { return 0.0f; } -math::Rect Widget::getViewport(math::Rect r) { return {}; } -bool Widget::hasChild(Widget* child) { return false; } -void Widget::addChild(Widget* child) {} -void Widget::addChildBottom(Widget* child) {} -void Widget::addChildBelow(Widget* child, Widget* sibling) {} -void Widget::addChildAbove(Widget* child, Widget* sibling) {} -void Widget::removeChild(Widget* child) {} -void Widget::clearChildren() {} -void Widget::step() {} -void Widget::draw(const DrawArgs& args) {} -void Widget::drawLayer(const DrawArgs& args, int layer) {} -void Widget::drawChild(Widget* child, const DrawArgs& args, int layer) {} - -} - -namespace window { - -Svg::~Svg() {} -void Svg::loadFile(const std::string& filename) {} -void Svg::loadString(const std::string& str) {} -math::Vec Svg::getSize() { return {}; } -int Svg::getNumShapes() { return 0; } -int Svg::getNumPaths() { return 0; } -int Svg::getNumPoints() { return 0; } -void Svg::draw(NVGcontext* vg) {} -std::shared_ptr Svg::load(const std::string& filename) { return {}; } - -} - -} diff --git a/lv2export/export.cpp b/lv2export/export.cpp new file mode 100644 index 0000000..cf8210d --- /dev/null +++ b/lv2export/export.cpp @@ -0,0 +1,115 @@ +/* + * DISTRHO Cardinal Plugin + * Copyright (C) 2021-2022 Filipe Coelho + * + * This program 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; either version 3 of + * the License, or any later version. + * + * This program 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. + * + * For a full copy of the GNU General Public License see the LICENSE file. + */ + +#ifndef PLUGIN_MODEL +# error PLUGIN_MODEL undefined +#endif + +#ifndef PLUGIN_CV_INPUTS +# error PLUGIN_CV_INPUTS undefined +#endif + +#ifndef PLUGIN_CV_OUTPUTS +# error PLUGIN_CV_OUTPUTS undefined +#endif + +#include + +// ----------------------------------------------------------------------- + +DISTRHO_PLUGIN_EXPORT +void lv2_generate_ttl() +{ + Context context; + context._engine.sampleRate = 48000.f; + contextSet(&context); + + engine::Module* module = PLUGIN_MODEL->createModule(); + + d_stdout("@prefix doap: ."); + d_stdout("@prefix foaf: ."); + d_stdout("@prefix lv2: ."); + d_stdout(""); + + d_stdout(""); + d_stdout(" a lv2:Plugin, doap:Project ;"); + d_stdout(" doap:name \"" SLUG "\" ;"); + d_stdout(""); + + int index = 0; + + for (int i=0, numAudio=0, numCV=0; igetNumInputs(); ++i) + { + d_stdout(" lv2:port ["); + if (kCvInputs[i]) + { + d_stdout(" a lv2:InputPort, lv2:CVPort ;"); + d_stdout(" lv2:symbol \"lv2_cv_in_%d\" ;", ++numCV); + } + else + { + d_stdout(" a lv2:InputPort, lv2:AudioPort ;"); + d_stdout(" lv2:symbol \"lv2_audio_in_%d\" ;", ++numAudio); + } + d_stdout(" lv2:name \"%s\" ;", module->getInputInfo(i)->getFullName().c_str()); + d_stdout(" lv2:index %d ;", index++); + d_stdout(" ] ;"); + d_stdout(""); + } + + for (int i=0, numAudio=0, numCV=0; igetNumOutputs(); ++i) + { + d_stdout(" lv2:port ["); + if (kCvOutputs[i]) + { + d_stdout(" a lv2:OutputPort, lv2:CVPort ;"); + d_stdout(" lv2:symbol \"lv2_cv_out_%d\" ;", ++numCV); + } + else + { + d_stdout(" a lv2:OutputPort, lv2:AudioPort ;"); + d_stdout(" lv2:symbol \"lv2_audio_out_%d\" ;", ++numAudio); + } + d_stdout(" lv2:name \"%s\" ;", module->getOutputInfo(i)->getFullName().c_str()); + d_stdout(" lv2:index %d ;", index++); + d_stdout(" ] ;"); + d_stdout(""); + } + + for (int i=0; igetNumParams(); ++i) + { + ParamQuantity* q = module->getParamQuantity(i); + d_stdout(" lv2:port ["); + d_stdout(" a lv2:InputPort, lv2:ControlPort ;"); + d_stdout(" lv2:index %d ;", index++); + d_stdout(" lv2:symbol \"lv2_param_%d\" ;", i + 1); + d_stdout(" lv2:name \"%s\" ;", q->name.c_str()); + d_stdout(" lv2:default %f ;", q->defaultValue); + d_stdout(" lv2:minimum %f ;", q->minValue); + d_stdout(" lv2:maximum %f ;", q->maxValue); + d_stdout(" ] ;"); + d_stdout(""); + // q->getDescription().c_str() + // q->unit.c_str() + } + + d_stdout(" ."); + + delete module; +} + +// ----------------------------------------------------------------------- diff --git a/lv2export/includes/asset.hpp b/lv2export/includes/asset.hpp new file mode 100644 index 0000000..e69de29 diff --git a/lv2export/includes/rack.hpp b/lv2export/includes/rack.hpp new file mode 100644 index 0000000..ab7dd73 --- /dev/null +++ b/lv2export/includes/rack.hpp @@ -0,0 +1,1103 @@ +/* + * DISTRHO Cardinal Plugin + * Copyright (C) 2021-2022 Filipe Coelho + * + * This program 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; either version 3 of + * the License, or any later version. + * + * This program 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. + * + * For a full copy of the GNU General Public License see the LICENSE file. + */ + +/** + * This file contains a substantial amount of code from VCVRack, adjusted for inline use + * Copyright (C) 2016-2021 VCV. + * + * This program 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; either version 3 of + * the License, or (at your option) any later version. + */ + +#pragma once + +#include +#include +#include + +#include +#include +#include +#include +#include + +struct NVGcolor { float a; }; +struct NVGpaint {}; + +inline NVGcolor nvgRGB(int r, int g, int b) { return {}; } +inline NVGcolor nvgRGBA(int r, int g, int b, int a) { return {}; } +inline NVGcolor nvgRGBf(float r, float g, float b) { return {}; } +inline NVGcolor nvgRGBAf(float r, float g, float b, float a) { return {}; } +inline void nvgBeginPath(void* vg) {} +inline void nvgFillColor(void* vg, NVGcolor) {} +inline void nvgFillPaint(void* vg, NVGpaint) {} +inline void nvgFill(void* vg) {} +inline void nvgStrokeColor(void* vg, NVGcolor) {} +inline void nvgStrokeWidth(void* vg, float) {} +inline void nvgStroke(void* vg) {} +inline void nvgRect(void* vg, float a, float b, float c, float d) {} +inline void nvgImageSize(void*, int, void*, void*) {} +inline NVGpaint nvgImagePattern(void*, float, float, float, float, float, int handle, float) { return {}; } + +struct json_t {}; +json_t* json_integer(int) { return NULL; } +json_t* json_object() { return NULL; } +json_t* json_object_get(json_t*, const char*) { return NULL; } +int json_integer_value(json_t*) { return 0; } +void json_object_set_new(json_t*, const char*, json_t*) {} + +namespace rack { + +struct Quantity { + virtual ~Quantity() {} + virtual void setValue(float value) {} + virtual float getValue() { return 0.f; } + virtual float getMinValue() { return 0.f; } + virtual float getMaxValue() { return 1.f; } + virtual float getDefaultValue() { return 0.f; } +// virtual float getDisplayValue(); +// virtual void setDisplayValue(float displayValue); +// virtual int getDisplayPrecision(); +// virtual std::string getDisplayValueString(); +// virtual void setDisplayValueString(std::string s); + virtual std::string getLabel() { return ""; } + virtual std::string getUnit() { return ""; } +// virtual std::string getString(); +// virtual void reset(); +// virtual void randomize(); +// bool isMin(); +// bool isMax(); +// void setMin(); +// void setMax(); +// void toggle(); +// void moveValue(float deltaValue); +// float getRange(); +// bool isBounded(); +// float toScaled(float value); +// float fromScaled(float scaledValue); +// void setScaledValue(float scaledValue); +// float getScaledValue(); +// void moveScaledValue(float deltaScaledValue); +}; + +namespace ui { +struct Menu; +} + +namespace math { + +inline int clamp(int x, int a, int b) { + return std::max(std::min(x, b), a); +} + +inline float clamp(float x, float a = 0.f, float b = 1.f) { + return std::fmax(std::fmin(x, b), a); +} + +struct Vec { + float x = 0.f; + float y = 0.f; + Vec() {} + Vec(float xy) : x(xy), y(xy) {} + Vec(float x, float y) : x(x), y(y) {} + Vec neg() const { return Vec(-x, -y); } + Vec plus(Vec b) const { return Vec(x + b.x, y + b.y); } + Vec minus(Vec b) const { return Vec(x - b.x, y - b.y); } + Vec mult(float s) const { return Vec(x * s, y * s); } + Vec mult(Vec b) const { return Vec(x * b.x, y * b.y); } +}; + +struct Rect { + Vec pos; + Vec size; +}; + +} // namespace math + +namespace engine { + +static constexpr const int PORT_MAX_CHANNELS = 16; + +struct Module; + +struct Engine { + float getSampleRate() { return sampleRate; } + // custom + float sampleRate = 0.f; +}; + +struct Light { + float value = 0.f; + void setBrightness(float brightness) { + value = brightness; + } + float getBrightness() { + return value; + } + void setBrightnessSmooth(float brightness, float deltaTime, float lambda = 30.f) { + if (brightness < value) { + // Fade out light + value += (brightness - value) * lambda * deltaTime; + } + else { + // Immediately illuminate light + value = brightness; + } + } + void setSmoothBrightness(float brightness, float deltaTime) { + setBrightnessSmooth(brightness, deltaTime); + } + void setBrightnessSmooth(float brightness, int frames = 1) { + setBrightnessSmooth(brightness, frames / 44100.f); + } +}; + +struct Param { + float value = 0.f; + float getValue() { return value; } + void setValue(float value) { this->value = value; } +}; + +struct Port { + union { + float voltages[PORT_MAX_CHANNELS] = {}; + float value; + }; + union { + uint8_t channels = 0; + uint8_t active; + }; + Light plugLights[3]; + enum Type { + INPUT, + OUTPUT, + }; + + void setVoltage(float voltage, int channel = 0) { voltages[channel] = voltage; } + float getVoltage(int channel = 0) { return voltages[channel]; } + float getPolyVoltage(int channel) { return isMonophonic() ? getVoltage(0) : getVoltage(channel); } + + float getNormalVoltage(float normalVoltage, int channel = 0) { return isConnected() ? getVoltage(channel) : normalVoltage; } + + float getNormalPolyVoltage(float normalVoltage, int channel) { return isConnected() ? getPolyVoltage(channel) : normalVoltage; } + + float* getVoltages(int firstChannel = 0) { return &voltages[firstChannel]; } + + void readVoltages(float* v) { + for (int c = 0; c < channels; c++) { + v[c] = voltages[c]; + } + } + + void writeVoltages(const float* v) { + for (int c = 0; c < channels; c++) { + voltages[c] = v[c]; + } + } + + void clearVoltages() { + for (int c = 0; c < channels; c++) { + voltages[c] = 0.f; + } + } + + float getVoltageSum() { + float sum = 0.f; + for (int c = 0; c < channels; c++) { + sum += voltages[c]; + } + return sum; + } + + float getVoltageRMS() { + if (channels == 0) { + return 0.f; + } + else if (channels == 1) { + return std::fabs(voltages[0]); + } + else { + float sum = 0.f; + for (int c = 0; c < channels; c++) { + sum += std::pow(voltages[c], 2); + } + return std::sqrt(sum); + } + } + +// template +// T getVoltageSimd(int firstChannel) { +// return T::load(&voltages[firstChannel]); +// } +// +// template +// T getPolyVoltageSimd(int firstChannel) { +// return isMonophonic() ? getVoltage(0) : getVoltageSimd(firstChannel); +// } +// +// template +// T getNormalVoltageSimd(T normalVoltage, int firstChannel) { +// return isConnected() ? getVoltageSimd(firstChannel) : normalVoltage; +// } +// +// template +// T getNormalPolyVoltageSimd(T normalVoltage, int firstChannel) { +// return isConnected() ? getPolyVoltageSimd(firstChannel) : normalVoltage; +// } +// +// template +// void setVoltageSimd(T voltage, int firstChannel) { +// voltage.store(&voltages[firstChannel]); +// } + + void setChannels(int channels) { + if (this->channels == 0) { + return; + } + for (int c = channels; c < this->channels; c++) { + voltages[c] = 0.f; + } + if (channels == 0) { + channels = 1; + } + this->channels = channels; + } + + int getChannels() { return channels; } + bool isConnected() { return channels > 0; } + bool isMonophonic() { return channels == 1; } + bool isPolyphonic() { return channels > 1; } + float normalize(float normalVoltage) { return getNormalVoltage(normalVoltage); } +}; + +struct Output : Port {}; + +struct Input : Port {}; + +struct PortInfo { + Module* module = NULL; + Port::Type type = Port::INPUT; + int portId = -1; + std::string name; + std::string description; + virtual ~PortInfo() {} + virtual std::string getName() { + if (name == "") + return std::string("#") + std::to_string(portId + 1); + return name; + } + std::string getFullName() { + std::string name = getName(); + name += " "; + name += (type == Port::INPUT) ? "input" : "output"; + return name; + } + virtual std::string getDescription() { return description; } +}; + +struct ParamQuantity : Quantity { + Module* module = NULL; + int paramId = -1; + float minValue = 0.f; + float maxValue = 1.f; + float defaultValue = 0.f; + std::string name; + std::string unit; + float displayBase = 0.f; + float displayMultiplier = 1.f; + float displayOffset = 0.f; + int displayPrecision = 5; + std::string description; + bool resetEnabled = true; + bool randomizeEnabled = true; + bool smoothEnabled = false; + bool snapEnabled = false; + +// Param* getParam(); +// /** If smoothEnabled is true, requests to the engine to smoothly move to a target value each sample. */ +// void setSmoothValue(float value); +// float getSmoothValue(); + +// void setValue(float value) override; +// float getValue() override; + float getMinValue() override { return minValue; } + float getMaxValue() override { return maxValue; } + float getDefaultValue() override { return defaultValue; } +// float getDisplayValue() override; +// void setDisplayValue(float displayValue) override; +// std::string getDisplayValueString() override; +// void setDisplayValueString(std::string s) override; +// int getDisplayPrecision() override; +// std::string getLabel() override; +// std::string getUnit() override; +// void reset() override; +// void randomize() override; + + virtual std::string getDescription() { return description; } + +// virtual json_t* toJson(); +// virtual void fromJson(json_t* rootJ); +}; + +struct SwitchQuantity : ParamQuantity { +// std::vector labels; +// std::string getDisplayValueString() override; +// void setDisplayValueString(std::string s) override; +}; + +struct Module { + std::vector params; + std::vector