Signed-off-by: falkTX <falktx@falktx.com>tags/22.02
@@ -22,7 +22,7 @@ include ../dpf/Makefile.base.mk | |||
BUILD_DIR = ../build/lv2export | |||
# BASE_FLAGS += -DHEADLESS | |||
BASE_FLAGS += -DHEADLESS | |||
BASE_FLAGS += -DPRIVATE= | |||
ifeq ($(MACOS),true) | |||
@@ -34,6 +34,7 @@ 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 | |||
@@ -100,8 +101,10 @@ endif | |||
# Build files | |||
# BUILD_FILES += test.cpp | |||
BUILD_FILES = dep.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 | |||
@@ -115,9 +118,15 @@ 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 | |||
# EXTRA_LIBS = ../plugins/plugins.a | |||
ifneq ($(SYSDEPS),true) | |||
EXTRA_LIBS += ../src/Rack/dep/lib/libjansson.a | |||
@@ -139,6 +148,9 @@ TARGETS += ../bin/CardinalModules.lv2/plugins$(LIB_EXT) | |||
all: $(TARGETS) | |||
clean: | |||
rm -f $(TARGETS) $(BUILD_OBJS) | |||
# -------------------------------------------------------------- | |||
# Build commands | |||
@@ -162,10 +174,18 @@ $(BUILD_DIR)/%.cpp.o: %.cpp | |||
@echo "Compiling $<" | |||
$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) -c -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='"modelChowChorus"' | |||
-DPLUGIN_URI='"urn:cardinal:chow:chorus"' | |||
$(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 |
@@ -15,8 +15,11 @@ | |||
* For a full copy of the GNU General Public License see the LICENSE file. | |||
*/ | |||
#define PRIVATE | |||
#include <common.hpp> | |||
#undef PRIVATE | |||
#include <rack.hpp> | |||
#include <context.hpp> | |||
using namespace rack; | |||
@@ -24,21 +27,6 @@ namespace rack { | |||
namespace settings { | |||
bool cpuMeter = false; | |||
} | |||
Context::~Context() { | |||
} | |||
static thread_local Context* threadContext; | |||
Context* contextGet() { | |||
DISTRHO_SAFE_ASSERT(threadContext != nullptr); | |||
return threadContext; | |||
} | |||
// Apple's clang incorrectly compiles this function when -O2 or higher is enabled. | |||
#ifdef ARCH_MAC | |||
__attribute__((optnone)) | |||
#endif | |||
void contextSet(Context* const context) { | |||
// DISTRHO_SAFE_ASSERT(threadContext == nullptr); | |||
threadContext = context; | |||
} | |||
Exception::Exception(const char* format, ...) | |||
{ | |||
va_list args; | |||
@@ -27,8 +27,11 @@ | |||
# error PLUGIN_URI undefined | |||
#endif | |||
#define PRIVATE | |||
#include <common.hpp> | |||
#include <engine/Engine.hpp> | |||
#undef PRIVATE | |||
// #include <common.hpp> | |||
#include <rack.hpp> | |||
#include "src/lv2/buf-size.h" | |||
@@ -39,10 +42,34 @@ | |||
using namespace rack; | |||
extern Model* PLUGIN_MODEL; | |||
Plugin* PLUGIN_INSTANCE; | |||
extern Plugin* PLUGIN_INSTANCE; | |||
namespace rack { | |||
namespace engine { | |||
struct Engine::Internal { | |||
float sampleRate; | |||
}; | |||
Engine::Engine() | |||
{ | |||
internal = new Internal; | |||
} | |||
Engine::~Engine() | |||
{ | |||
delete internal; | |||
} | |||
float Engine::getSampleRate() | |||
{ | |||
return internal->sampleRate; | |||
} | |||
} | |||
namespace plugin { | |||
void Plugin::addModel(Model* model) | |||
{ | |||
// Check that the model is not added to a plugin already | |||
@@ -55,6 +82,7 @@ Model* modelFromJson(json_t* moduleJ) { | |||
return nullptr; | |||
} | |||
std::vector<Plugin*> plugins; | |||
} // namespace plugin | |||
} // namespace rack | |||
@@ -69,6 +97,10 @@ struct PluginLv2 { | |||
PluginLv2(double sr) | |||
{ | |||
// FIXME shared instance for these 2 | |||
Context* const context = new Context; | |||
context->engine = new Engine; | |||
context->engine->internal->sampleRate = sr; | |||
contextSet(context); | |||
plugin = new Plugin; | |||
PLUGIN_INSTANCE = plugin; | |||
@@ -87,6 +119,9 @@ struct PluginLv2 { | |||
module->inputs[i].channels = 1; | |||
for (int i=numOutputs; --i >=0;) | |||
module->outputs[i].channels = 1; | |||
d_stdout("Loaded %s :: %i inputs, %i outputs, %i params and %i lights", | |||
PLUGIN_URI, numInputs, numOutputs, numParams, numLights); | |||
} | |||
PluginLv2() | |||
@@ -96,6 +131,7 @@ struct PluginLv2 { | |||
// FIXME shared instance for this | |||
delete plugin; | |||
delete contextGet(); | |||
} | |||
void lv2_connect_port(const uint32_t port, void* const dataLocation) | |||
@@ -120,17 +156,17 @@ struct PluginLv2 { | |||
}; | |||
for (int i=numParams; --i >=0;) | |||
module->params[i].setValue(*static_cast<float*>(ports[numInputs+numOutputs+i])); | |||
module->params[i].setValue(*static_cast<float*>(ports[numInputs+numOutputs+i]) * 0.1f); // FIXME? | |||
for (uint32_t s=0; s<sampleCount; ++s) | |||
{ | |||
for (int i=numInputs; --i >=0;) | |||
module->inputs[i].setVoltage(static_cast<float*>(ports[i])[s] * 10.0f); | |||
module->inputs[i].setVoltage(static_cast<const float*>(ports[i])[s] * 5.0f); | |||
module->doProcess(args); | |||
for (int i=numOutputs; --i >=0;) | |||
static_cast<float*>(ports[numInputs+i])[s] = module->outputs[i].getVoltage() * 0.1f; | |||
static_cast<float*>(ports[numInputs+i])[s] = module->outputs[i].getVoltage() * 0.2f; | |||
++args.frame; | |||
} | |||
@@ -3,5 +3,5 @@ | |||
<urn:cardinal:chow:chorus> | |||
a lv2:Plugin ; | |||
lv2:binary <plugins.dylib> ; | |||
lv2:binary <plugins@LIB_EXT@> ; | |||
rdfs:seeAlso <chow-chorus.ttl> . |