Browse Source

change createParam fingerprint to add human readeable name

pull/574/head
Antoine Villeret 7 years ago
parent
commit
03a434ba1a
4 changed files with 27 additions and 27 deletions
  1. +6
    -3
      include/engine.hpp
  2. +12
    -6
      include/rack.hpp
  3. +9
    -0
      src/app.cpp
  4. +0
    -18
      src/engine.cpp

+ 6
- 3
include/engine.hpp View File

@@ -3,11 +3,12 @@
#include "util.hpp"
#include <jansson.h>

#include <ossia/ossia.hpp>
#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;
@@ -45,8 +46,6 @@ struct Output {
Light plugLights[2];
};

static ossia::net::generic_device& root_dev();

struct Module {
std::vector<Param> params;
std::vector<Input> inputs;
@@ -54,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 {}
@@ -63,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() {}



+ 12
- 6
include/rack.hpp View File

@@ -9,6 +9,7 @@
#include "app.hpp"
#include "components.hpp"
#include <iostream>
#include <sstream>

namespace rack {

@@ -24,10 +25,8 @@ Model *createModel(std::string manufacturer, std::string slug, std::string name,
ModuleWidget *createModuleWidget() override {
ModuleWidget *moduleWidget = new TModuleWidget();
moduleWidget->model = this;
// TODO move node creation here
node = &ossia::net::create_node(rack::root_dev(),name);
moduleWidget->module->node->set_name(name);
return moduleWidget;
}
};
@@ -47,14 +46,21 @@ 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;
auto& p = module->params[paramId];
auto& p_node = ossia::net::create_node(*module->node,p.name);

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);


+ 9
- 0
src/app.cpp View File

@@ -1,5 +1,7 @@
#include "app.hpp"

#include <ossia/network/network.hpp>
#include <ossia/network/oscquery/oscquery_server.hpp>

namespace rack {

@@ -27,5 +29,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

+ 0
- 18
src/engine.cpp View File

@@ -276,22 +276,4 @@ float engineGetSampleTime() {
return sampleTime;
}

Module::Module(){}

Module::Module(int numParams, int numInputs, int numOutputs, int numLights) {
params.resize(numParams);
inputs.resize(numInputs);
outputs.resize(numOutputs);
lights.resize(numLights);
}

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

Loading…
Cancel
Save