| @@ -14,7 +14,7 @@ ifeq ($(ARCH), lin) | |||
| LDFLAGS += -rdynamic \ | |||
| -lpthread -lGL -ldl \ | |||
| $(shell pkg-config --libs gtk+-2.0) \ | |||
| -Ldep/lib -lGLEW -lglfw -ljansson -lspeexdsp -lcurl -lzip -lrtaudio -lrtmidi -lcrypto -lssl | |||
| -Ldep/lib -lGLEW -lglfw -ljansson -lspeexdsp -lcurl -lzip -lrtaudio -lrtmidi -lcrypto -lssl -lossia | |||
| TARGET = Rack | |||
| endif | |||
| @@ -23,7 +23,7 @@ ifeq ($(ARCH), mac) | |||
| CXXFLAGS += -DAPPLE -stdlib=libc++ | |||
| LDFLAGS += -stdlib=libc++ -lpthread -ldl \ | |||
| -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo \ | |||
| -Ldep/lib -lGLEW -lglfw -ljansson -lspeexdsp -lcurl -lzip -lrtaudio -lrtmidi -lcrypto -lssl | |||
| -Ldep/lib -lGLEW -lglfw -ljansson -lspeexdsp -lcurl -lzip -lrtaudio -lrtmidi -lcrypto -lssl -lossia | |||
| TARGET = Rack | |||
| BUNDLE = dist/$(TARGET).app | |||
| endif | |||
| @@ -34,7 +34,7 @@ ifeq ($(ARCH), win) | |||
| -Wl,--export-all-symbols,--out-implib,libRack.a -mwindows \ | |||
| -lgdi32 -lopengl32 -lcomdlg32 -lole32 \ | |||
| -Ldep/lib -lglew32 -lglfw3dll -lcurl -lzip -lrtaudio -lrtmidi -lcrypto -lssl \ | |||
| -Wl,-Bstatic -ljansson -lspeexdsp | |||
| -Wl,-Bstatic -ljansson -lspeexdsp -lossia | |||
| TARGET = Rack.exe | |||
| OBJECTS = Rack.res | |||
| endif | |||
| @@ -11,7 +11,7 @@ FLAGS += -Wall -Wextra -Wno-unused-parameter | |||
| ifneq ($(ARCH), mac) | |||
| CXXFLAGS += -Wsuggest-override | |||
| endif | |||
| CXXFLAGS += -std=c++11 | |||
| CXXFLAGS += -std=c++14 | |||
| ifeq ($(ARCH), lin) | |||
| @@ -3,20 +3,14 @@ LOCAL = $(shell pwd) | |||
| # Arch-specifics | |||
| include ../arch.mk | |||
| FLAGS += -g -O3 -march=nocona | |||
| ifeq ($(ARCH),mac) | |||
| FLAGS += -mmacosx-version-min=10.7 -stdlib=libc++ | |||
| LDFLAGS += -mmacosx-version-min=10.7 -stdlib=libc++ | |||
| MACOS_FLAGS = -mmacosx-version-min=10.7 -stdlib=libc++ | |||
| export CFLAGS = $(MACOS_FLAGS) | |||
| export CXXFLAGS = $(MACOS_FLAGS) | |||
| export CPPFLAGS = $(MACOS_FLAGS) | |||
| export LDFLAGS = $(MACOS_FLAGS) | |||
| endif | |||
| CFLAGS += $(FLAGS) | |||
| CXXFLAGS += $(FLAGS) | |||
| export CFLAGS | |||
| export CXXFLAGS | |||
| export LDFLAGS | |||
| # Commands | |||
| WGET = wget -nc | |||
| UNTAR = tar xf | |||
| @@ -38,6 +32,7 @@ ifeq ($(ARCH),lin) | |||
| rtmidi = lib/librtmidi.so | |||
| rtaudio = lib/librtaudio.so | |||
| openssl = lib/libssl.so | |||
| ossia = lib/libossia.so | |||
| endif | |||
| ifeq ($(ARCH),mac) | |||
| @@ -50,6 +45,7 @@ ifeq ($(ARCH),mac) | |||
| rtmidi = lib/librtmidi.dylib | |||
| rtaudio = lib/librtaudio.dylib | |||
| openssl = lib/libssl.dylib | |||
| ossia = lib/libossia.so | |||
| endif | |||
| ifeq ($(ARCH),win) | |||
| @@ -62,6 +58,7 @@ ifeq ($(ARCH),win) | |||
| rtmidi = bin/librtmidi-4.dll | |||
| rtaudio = bin/librtaudio.dll | |||
| openssl = bin/libssl-1_1-x64.dll | |||
| ossia = bin/ossia.dll | |||
| endif | |||
| # Library configuration | |||
| @@ -80,7 +77,7 @@ endif | |||
| .NOTPARALLEL: | |||
| all: $(glew) $(glfw) $(jansson) $(libspeexdsp) $(libcurl) $(libzip) $(rtmidi) $(rtaudio) | |||
| all: $(glew) $(glfw) $(jansson) $(libspeexdsp) $(libcurl) $(libzip) $(rtmidi) $(rtaudio) $(ossia) | |||
| @echo "" | |||
| @echo "#######################################" | |||
| @echo "# Built all dependencies successfully #" | |||
| @@ -151,5 +148,14 @@ $(rtaudio): | |||
| $(MAKE) -C rtaudio/cmakebuild | |||
| $(MAKE) -C rtaudio/cmakebuild install | |||
| $(ossia): | |||
| git clone https://github.com/OSSIA/libossia --depth=1 | |||
| mkdir -p build-libossia && cd build-libossia && $(CMAKE) \ | |||
| -DCMAKE_INSTALL_PREFIX="$(LOCAL)" -DOSSIA_PD=OFF \ | |||
| -DOSSIA_COTIRE=OFF -DOSSIA_PROTOCOL_MIDI=OFF \ | |||
| -DOSSIA_EDITOR=OFF -DBUILD_TYPE=Release ../libossia && \ | |||
| $(MAKE) -j4 && \ | |||
| $(MAKE) install | |||
| clean: | |||
| git clean -ffdx | |||
| @@ -3,12 +3,17 @@ | |||
| #include "util.hpp" | |||
| #include <jansson.h> | |||
| #include <ossia/network/network.hpp> | |||
| #include <ossia/network/oscquery/oscquery_server.hpp> | |||
| namespace rack { | |||
| extern ossia::net::generic_device& root_dev(); | |||
| struct Param { | |||
| float value = 0.0; | |||
| std::string name = "param.1"; | |||
| ossia::net::parameter_base* ossia_param; | |||
| }; | |||
| struct Light { | |||
| @@ -41,7 +46,6 @@ struct Output { | |||
| Light plugLights[2]; | |||
| }; | |||
| struct Module { | |||
| std::vector<Param> params; | |||
| std::vector<Input> inputs; | |||
| @@ -49,6 +53,8 @@ struct Module { | |||
| std::vector<Light> lights; | |||
| /** For CPU usage meter */ | |||
| float cpuTime = 0.0; | |||
| ossia::net::node_base* node{}; | |||
| /** Deprecated, use constructor below this one */ | |||
| Module() DEPRECATED {} | |||
| @@ -58,6 +64,8 @@ struct Module { | |||
| inputs.resize(numInputs); | |||
| outputs.resize(numOutputs); | |||
| lights.resize(numLights); | |||
| node = &ossia::net::create_node(rack::root_dev(),"module"); | |||
| } | |||
| virtual ~Module() {} | |||
| @@ -3,6 +3,7 @@ | |||
| #include <list> | |||
| #include "tags.hpp" | |||
| #include <ossia/network/network.hpp> | |||
| namespace rack { | |||
| @@ -55,6 +56,8 @@ struct Model { | |||
| virtual ~Model() {} | |||
| virtual ModuleWidget *createModuleWidget() { return NULL; } | |||
| ossia::net::node_base* node; | |||
| }; | |||
| void pluginInit(); | |||
| @@ -8,7 +8,8 @@ | |||
| #include "gui.hpp" | |||
| #include "app.hpp" | |||
| #include "components.hpp" | |||
| #include <iostream> | |||
| #include <sstream> | |||
| namespace rack { | |||
| @@ -24,6 +25,8 @@ Model *createModel(std::string manufacturer, std::string slug, std::string name, | |||
| ModuleWidget *createModuleWidget() override { | |||
| ModuleWidget *moduleWidget = new TModuleWidget(); | |||
| moduleWidget->model = this; | |||
| moduleWidget->module->node->set_name(name); | |||
| return moduleWidget; | |||
| } | |||
| }; | |||
| @@ -43,13 +46,38 @@ Widget *createScrew(Vec pos) { | |||
| } | |||
| template <class TParamWidget> | |||
| ParamWidget *createParam(Vec pos, Module *module, int paramId, float minValue, float maxValue, float defaultValue) { | |||
| ParamWidget *createParam(Vec pos, Module *module, int paramId, float minValue, float maxValue, float defaultValue, std::string name = std::string("")) { | |||
| ParamWidget *param = new TParamWidget(); | |||
| param->box.pos = pos; | |||
| param->module = module; | |||
| param->paramId = paramId; | |||
| param->setLimits(minValue, maxValue); | |||
| auto& p = module->params[paramId]; | |||
| if (name == "") | |||
| { | |||
| std::stringstream ss; | |||
| ss << "param." << paramId; | |||
| name = ss.str(); | |||
| } | |||
| auto& p_node = ossia::net::create_node(*module->node, name); | |||
| p.ossia_param = p_node.create_parameter(ossia::val_type::FLOAT); | |||
| p.ossia_param->set_domain(ossia::make_domain(minValue,maxValue)); | |||
| p.ossia_param->set_bounding(ossia::bounding_mode::CLIP); | |||
| p.ossia_param->push_value(defaultValue); | |||
| p.ossia_param->set_default_value(defaultValue); | |||
| p.ossia_param->add_callback([param] (const ossia::value& v) { | |||
| auto& p = param->module->params[param->paramId]; | |||
| param->value = v.get<float>(); | |||
| p.value = param->value; | |||
| if ( auto fbw = dynamic_cast<FramebufferWidget*>(param)) | |||
| fbw->dirty = true; | |||
| }); | |||
| param->setLimits(minValue, maxValue); | |||
| param->setDefaultValue(defaultValue); | |||
| return param; | |||
| } | |||
| @@ -1,5 +1,7 @@ | |||
| #include "app.hpp" | |||
| #include <ossia/network/network.hpp> | |||
| #include <ossia/network/oscquery/oscquery_server.hpp> | |||
| namespace rack { | |||
| @@ -28,5 +30,12 @@ void sceneDestroy() { | |||
| gScene = NULL; | |||
| } | |||
| ossia::net::generic_device& root_dev(){ | |||
| static ossia::net::generic_device dev{ | |||
| std::make_unique<ossia::oscquery::oscquery_server_protocol>(1234, 5678), | |||
| "VCV-Rack"}; | |||
| return dev; | |||
| } | |||
| } // namespace rack | |||
| @@ -11,7 +11,6 @@ | |||
| #include "engine.hpp" | |||
| #include "util.hpp" | |||
| namespace rack { | |||
| float sampleRate; | |||
| @@ -33,7 +32,6 @@ static Module *smoothModule = NULL; | |||
| static int smoothParamId; | |||
| static float smoothValue; | |||
| float Light::getBrightness() { | |||
| return sqrtf(fmaxf(0.0, value)); | |||
| } | |||
| @@ -76,11 +74,13 @@ static void engineStep() { | |||
| float delta = smoothValue - value; | |||
| if (fabsf(delta) < snap) { | |||
| smoothModule->params[smoothParamId].value = smoothValue; | |||
| smoothModule->params[smoothParamId].ossia_param->push_value(smoothValue); | |||
| smoothModule = NULL; | |||
| } | |||
| else { | |||
| value += delta * lambda * sampleTime; | |||
| smoothModule->params[smoothParamId].value = value; | |||
| smoothModule->params[smoothParamId].ossia_param->push_value(value); | |||
| } | |||
| } | |||
| @@ -240,6 +240,7 @@ void engineRemoveWire(Wire *wire) { | |||
| void engineSetParam(Module *module, int paramId, float value) { | |||
| module->params[paramId].value = value; | |||
| module->params[paramId].ossia_param->push_value(value); | |||
| } | |||
| void engineSetParamSmooth(Module *module, int paramId, float value) { | |||
| @@ -248,10 +249,12 @@ void engineSetParamSmooth(Module *module, int paramId, float value) { | |||
| // Since only one param can be smoothed at a time, if another param is currently being smoothed, skip to its final state | |||
| if (smoothModule && !(smoothModule == module && smoothParamId == paramId)) { | |||
| smoothModule->params[smoothParamId].value = smoothValue; | |||
| smoothModule->params[smoothParamId].ossia_param->push_value(smoothValue); | |||
| } | |||
| smoothModule = module; | |||
| smoothParamId = paramId; | |||
| smoothValue = value; | |||
| module->params[paramId].ossia_param->push_value(smoothValue); | |||
| } | |||
| void engineSetSampleRate(float newSampleRate) { | |||