From bb64f80bb139314a06e0b22fddbea7a330b6e149 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 18 Sep 2016 21:36:48 -0400 Subject: Preliminary parameter support work --- src/server/Parameter.hpp | 82 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 src/server/Parameter.hpp (limited to 'src/server/Parameter.hpp') diff --git a/src/server/Parameter.hpp b/src/server/Parameter.hpp new file mode 100644 index 00000000..d7c0e42a --- /dev/null +++ b/src/server/Parameter.hpp @@ -0,0 +1,82 @@ +/* + This file is part of Ingen. + Copyright 2016 David Robillard + + Ingen is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or any later version. + + Ingen 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 Affero General Public License for details. + + You should have received a copy of the GNU Affero General Public License + along with Ingen. If not, see . +*/ + +#ifndef INGEN_ENGINE_PARAMETER_HPP +#define INGEN_ENGINE_PARAMETER_HPP + +#include "ingen/World.hpp" + +namespace Ingen { +namespace Server { + +class BlockImpl; + +/** A parameter (message-based control) on a Block. + * + * \ingroup engine + */ +class Parameter : public NodeImpl +{ +public: + static Atom node_to_atom(Forge& forge, const LilvNode* node) { + if (lilv_node_is_float(node)) { + return forge.make(lilv_node_as_float(node)); + } else if (lilv_node_is_uri(node)) { + return forge.make_urid(Raul::URI(lilv_node_as_uri(node))); + } + return Atom(); + } + + Parameter(Ingen::World* world, + const Ingen::URIs& uris, + NodeImpl* parent, + const Raul::URI& uri, + const Raul::Symbol& symbol, + const Atom& value) + : NodeImpl(uris, parent, symbol) + , _value(value) + { + set_property(uris.rdf_type, uris.ingen_Parameter); + set_property(uris.lv2_symbol, uris.forge.alloc(symbol)); + LilvWorld* lworld = world->lilv_world(); + LilvNode* prop = lilv_new_uri(lworld, uri.c_str()); + LilvNode* range = lilv_world_get(lworld, prop, uris.rdfs_range, NULL); + set_property(uris.rdfs_range, node_to_atom(world->forge(), range)); + LilvNode* min = lilv_world_get(lworld, prop, uris.lv2_minimum, NULL); + LilvNode* max = lilv_world_get(lworld, prop, uris.lv2_maximum, NULL); + LilvNode* def = lilv_world_get(lworld, prop, uris.lv2_default, NULL); + set_property(uris.ingen_value, node_to_atom(world->forge(), def)); + set_property(uris.lv2_minimum, node_to_atom(world->forge(), min)); + set_property(uris.lv2_maximum, node_to_atom(world->forge(), max)); + } + + virtual GraphType graph_type() const { return GraphType::PARAMETER; } + + /** A parameter's parent is always a block. */ + BlockImpl* parent_block() const { return (BlockImpl*)_parent; } + + // n/a + virtual bool prepare_poly(BufferFactory&, uint32_t) { return false; } + virtual bool apply_poly(RunContext&, Raul::Maid&, uint32_t) { return false; } + +protected: + Atom _value; +}; + +} // namespace Server +} // namespace Ingen + +#endif // INGEN_ENGINE_PARAMETER_HPP -- cgit v1.2.1