summaryrefslogtreecommitdiffstats
path: root/src/libs/engine
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-09-19 23:54:39 +0000
committerDavid Robillard <d@drobilla.net>2007-09-19 23:54:39 +0000
commitad558bdafde7e40b5de79b47d8586aec53cf3f7e (patch)
treea4431ddd696eb66eceb3119a9f7da933f3585ea4 /src/libs/engine
parent0b8415c61e321d032d62b5b1cbda65bab6f178d7 (diff)
downloadingen-ad558bdafde7e40b5de79b47d8586aec53cf3f7e.tar.gz
ingen-ad558bdafde7e40b5de79b47d8586aec53cf3f7e.tar.bz2
ingen-ad558bdafde7e40b5de79b47d8586aec53cf3f7e.zip
Toggling of individual node polyphonic state.
git-svn-id: http://svn.drobilla.net/lad/ingen@733 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/engine')
-rw-r--r--src/libs/engine/ClientBroadcaster.cpp9
-rw-r--r--src/libs/engine/ClientBroadcaster.hpp1
-rw-r--r--src/libs/engine/GraphObject.hpp16
-rw-r--r--src/libs/engine/Node.hpp8
-rw-r--r--src/libs/engine/NodeBase.cpp3
-rw-r--r--src/libs/engine/NodeBase.hpp2
-rw-r--r--src/libs/engine/OSCClientSender.cpp24
-rw-r--r--src/libs/engine/OSCClientSender.hpp3
-rw-r--r--src/libs/engine/OSCEngineReceiver.cpp25
-rw-r--r--src/libs/engine/OSCEngineReceiver.hpp1
-rw-r--r--src/libs/engine/Patch.cpp2
-rw-r--r--src/libs/engine/events/SetPolyphonicEvent.cpp33
-rw-r--r--src/libs/engine/events/SetPolyphonicEvent.hpp10
13 files changed, 92 insertions, 45 deletions
diff --git a/src/libs/engine/ClientBroadcaster.cpp b/src/libs/engine/ClientBroadcaster.cpp
index 0a98c05c..6193b586 100644
--- a/src/libs/engine/ClientBroadcaster.cpp
+++ b/src/libs/engine/ClientBroadcaster.cpp
@@ -190,6 +190,15 @@ ClientBroadcaster::send_destroyed(const string& path)
(*i).second->object_destroyed(path);
}
+
+void
+ClientBroadcaster::send_polyphonic(const string& path, bool polyphonic)
+{
+ for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i)
+ (*i).second->polyphonic(path, polyphonic);
+}
+
+
void
ClientBroadcaster::send_patch_cleared(const string& patch_path)
{
diff --git a/src/libs/engine/ClientBroadcaster.hpp b/src/libs/engine/ClientBroadcaster.hpp
index 1c1217bc..42bd817b 100644
--- a/src/libs/engine/ClientBroadcaster.hpp
+++ b/src/libs/engine/ClientBroadcaster.hpp
@@ -74,6 +74,7 @@ public:
void send_node(const Node* const node, bool recursive);
void send_port(const Port* port);
void send_destroyed(const string& path);
+ void send_polyphonic(const string& path, bool polyphonic);
void send_patch_cleared(const string& patch_path);
void send_connection(const Connection* const connection);
void send_disconnection(const string& src_port_path, const string& dst_port_path);
diff --git a/src/libs/engine/GraphObject.hpp b/src/libs/engine/GraphObject.hpp
index 1a6f0d7e..a2cfd5f0 100644
--- a/src/libs/engine/GraphObject.hpp
+++ b/src/libs/engine/GraphObject.hpp
@@ -31,13 +31,12 @@ using std::string;
using Raul::Atom;
using Raul::Path;
+
+namespace Raul { class Maid; }
+
namespace Ingen {
class Patch;
-class Node;
-class Port;
-class ObjectStore;
-
/** An object on the audio graph - Patch, Node, Port, etc.
*
@@ -52,8 +51,8 @@ class GraphObject : public Raul::Deletable
public:
typedef std::map<string, Atom> MetadataMap;
- GraphObject(GraphObject* parent, const string& name)
- : _store(NULL), _parent(parent), _name(name)
+ GraphObject(GraphObject* parent, const string& name, bool polyphonic=false)
+ : _parent(parent), _name(name), _polyphonic(polyphonic)
{
assert(parent == NULL || _name.length() > 0);
assert(_name.find("/") == string::npos);
@@ -62,6 +61,9 @@ public:
virtual ~GraphObject() {}
+ bool polyphonic() const { return _polyphonic; }
+ virtual void set_polyphonic(Raul::Maid& maid, bool p) { _polyphonic = p; }
+
inline GraphObject* parent() const { return _parent; }
inline const string& name() const { return _name; }
@@ -99,9 +101,9 @@ public:
}
protected:
- ObjectStore* _store;
GraphObject* _parent;
string _name;
+ bool _polyphonic;
private:
MetadataMap _metadata;
diff --git a/src/libs/engine/Node.hpp b/src/libs/engine/Node.hpp
index 470075a6..83a31c67 100644
--- a/src/libs/engine/Node.hpp
+++ b/src/libs/engine/Node.hpp
@@ -49,7 +49,10 @@ namespace Shared { class ClientInterface; }
class Node : public GraphObject
{
public:
- Node(GraphObject* parent, const std::string& name) : GraphObject(parent, name) {}
+ Node(GraphObject* parent, const std::string& name, bool poly)
+ : GraphObject(parent, name, poly)
+ {}
+
virtual ~Node() {}
/** Activate this Node.
@@ -122,9 +125,6 @@ public:
virtual const Raul::Array<Port*>& ports() const = 0;
virtual uint32_t num_ports() const = 0;
-
- virtual bool polyphonic() const = 0;
- virtual uint32_t polyphony() const = 0;
/** Used by the process order finding algorithm (ie during connections) */
virtual bool traversed() const = 0;
diff --git a/src/libs/engine/NodeBase.cpp b/src/libs/engine/NodeBase.cpp
index faef4a32..e8df05d6 100644
--- a/src/libs/engine/NodeBase.cpp
+++ b/src/libs/engine/NodeBase.cpp
@@ -34,9 +34,8 @@ namespace Ingen {
NodeBase::NodeBase(const Plugin* plugin, const string& name, bool poly, Patch* parent, SampleRate srate, size_t buffer_size)
-: Node(parent, name),
+: Node(parent, name, poly),
_plugin(plugin),
- _polyphonic(poly),
_polyphony(parent ? parent->internal_poly() : 1),
_srate(srate),
_buffer_size(buffer_size),
diff --git a/src/libs/engine/NodeBase.hpp b/src/libs/engine/NodeBase.hpp
index 8e1bb7f3..9f12c95f 100644
--- a/src/libs/engine/NodeBase.hpp
+++ b/src/libs/engine/NodeBase.hpp
@@ -80,7 +80,6 @@ public:
SampleRate sample_rate() const { return _srate; }
size_t buffer_size() const { return _buffer_size; }
uint32_t num_ports() const { return _ports ? _ports->size() : 0; }
- bool polyphonic() const { return _polyphonic; }
uint32_t polyphony() const { return _polyphony; }
bool traversed() const { return _traversed; }
void traversed(bool b) { _traversed = b; }
@@ -107,7 +106,6 @@ protected:
const Plugin* _plugin;
- bool _polyphonic;
uint32_t _polyphony;
SampleRate _srate;
size_t _buffer_size;
diff --git a/src/libs/engine/OSCClientSender.cpp b/src/libs/engine/OSCClientSender.cpp
index 75353981..a2034cda 100644
--- a/src/libs/engine/OSCClientSender.cpp
+++ b/src/libs/engine/OSCClientSender.cpp
@@ -382,6 +382,30 @@ OSCClientSender::new_port(const std::string& path,
/** \page client_osc_namespace
+ * <p> \b /ingen/polyphonic - Notification an object's polyphonic property has changed.
+ * \arg \b path (string) - Path of object
+ * \arg \b polyphonic (bool) - Whether or not object is polyphonic (from it's parent's perspective).
+ *
+ * \li This is a notification that the object is <em>externally</em> polyphonic,
+ * i.e. its parent sees several independent buffers for a single port, one for each voice.
+ * An object can be internally polyphonic but externally not if the voices are mixed down;
+ * this is true of DSSI plugins and subpatches with mismatched polyphony. </p> \n \n
+ */
+void
+OSCClientSender::polyphonic(const std::string& path,
+ bool polyphonic)
+{
+ if (!_enabled)
+ return;
+
+ if (polyphonic)
+ lo_send(_address, "/ingen/polyphonic", "sT", path.c_str());
+ else
+ lo_send(_address, "/ingen/polyphonic", "sF", path.c_str());
+}
+
+
+/** \page client_osc_namespace
* <p> \b /ingen/destroyed - Notification an object has been destroyed
* \arg \b path (const std::string&) - Path of object (which no longer exists) </p> \n \n
*/
diff --git a/src/libs/engine/OSCClientSender.hpp b/src/libs/engine/OSCClientSender.hpp
index ac45bef4..b1fcc0f4 100644
--- a/src/libs/engine/OSCClientSender.hpp
+++ b/src/libs/engine/OSCClientSender.hpp
@@ -90,6 +90,9 @@ public:
const std::string& data_type,
bool is_output);
+ virtual void polyphonic(const std::string& path,
+ bool polyphonic);
+
virtual void patch_enabled(const std::string& path);
virtual void patch_disabled(const std::string& path);
diff --git a/src/libs/engine/OSCEngineReceiver.cpp b/src/libs/engine/OSCEngineReceiver.cpp
index 68790300..d750118e 100644
--- a/src/libs/engine/OSCEngineReceiver.cpp
+++ b/src/libs/engine/OSCEngineReceiver.cpp
@@ -84,6 +84,8 @@ OSCEngineReceiver::OSCEngineReceiver(Engine& engine, size_t queue_size, uint16_t
lo_server_add_method(_server, "/ingen/disable_patch", "is", disable_patch_cb, this);
lo_server_add_method(_server, "/ingen/clear_patch", "is", clear_patch_cb, this);
lo_server_add_method(_server, "/ingen/set_polyphony", "isi", set_polyphony_cb, this);
+ lo_server_add_method(_server, "/ingen/set_polyphonic", "isT", set_polyphonic_cb, this);
+ lo_server_add_method(_server, "/ingen/set_polyphonic", "isF", set_polyphonic_cb, this);
lo_server_add_method(_server, "/ingen/create_port", "issi", create_port_cb, this);
lo_server_add_method(_server, "/ingen/create_node", "issssT", create_node_cb, this);
lo_server_add_method(_server, "/ingen/create_node", "issssF", create_node_cb, this);
@@ -458,6 +460,23 @@ OSCEngineReceiver::_set_polyphony_cb(const char* path, const char* types, lo_arg
/** \page engine_osc_namespace
+ * <p> \b /ingen/set_polyphonic - Toggle a node's or port's polyphonic mode
+ * \arg \b response-id (integer)
+ * \arg \b path - Object's path
+ * \arg \b polyphonic (bool) </p> \n \n
+ */
+int
+OSCEngineReceiver::_set_polyphonic_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+{
+ const char* object_path = &argv[1]->s;
+ bool polyphonic = (types[2] == 'T');
+
+ set_polyphonic(object_path, polyphonic);
+ return 0;
+}
+
+
+/** \page engine_osc_namespace
* <p> \b /ingen/create_port - Add a port into a given patch (load a plugin by URI)
* \arg \b response-id (integer)
* \arg \b path (string) - Full path of the new port (ie. /patch2/subpatch/newport)
@@ -490,7 +509,6 @@ OSCEngineReceiver::_create_node_by_uri_cb(const char* path, const char* types, l
bool polyphonic = (types[3] == 'T');
create_node(node_path, plug_uri, polyphonic);
-
return 0;
}
@@ -719,7 +737,6 @@ OSCEngineReceiver::_midi_learn_cb(const char* path, const char* types, lo_arg**
const char* patch_path = &argv[1]->s;
midi_learn(patch_path);
-
return 0;
}
@@ -743,7 +760,6 @@ OSCEngineReceiver::_metadata_set_cb(const char* path, const char* types, lo_arg*
Raul::Atom value = Raul::AtomLiblo::lo_arg_to_atom(types[3], argv[3]);
set_metadata(object_path, key, value);
-
return 0;
}
@@ -763,7 +779,6 @@ OSCEngineReceiver::_metadata_get_cb(const char* path, const char* types, lo_arg*
const char* key = &argv[2]->s;
request_metadata(object_path, key);
-
return 0;
}
@@ -780,7 +795,6 @@ OSCEngineReceiver::_request_plugin_cb(const char* path, const char* types, lo_ar
const char* uri = &argv[1]->s;
request_plugin(uri);
-
return 0;
}
@@ -797,7 +811,6 @@ OSCEngineReceiver::_request_object_cb(const char* path, const char* types, lo_ar
const char* object_path = &argv[1]->s;
request_object(object_path);
-
return 0;
}
diff --git a/src/libs/engine/OSCEngineReceiver.hpp b/src/libs/engine/OSCEngineReceiver.hpp
index 559a56b2..264b66c1 100644
--- a/src/libs/engine/OSCEngineReceiver.hpp
+++ b/src/libs/engine/OSCEngineReceiver.hpp
@@ -93,6 +93,7 @@ private:
LO_HANDLER(disable_patch);
LO_HANDLER(clear_patch);
LO_HANDLER(set_polyphony);
+ LO_HANDLER(set_polyphonic);
LO_HANDLER(destroy);
LO_HANDLER(connect);
LO_HANDLER(disconnect);
diff --git a/src/libs/engine/Patch.cpp b/src/libs/engine/Patch.cpp
index 08d15c69..77b043eb 100644
--- a/src/libs/engine/Patch.cpp
+++ b/src/libs/engine/Patch.cpp
@@ -261,7 +261,7 @@ Patch::add_node(Raul::ListNode<Node*>* ln)
assert(ln != NULL);
assert(ln->elem() != NULL);
assert(ln->elem()->parent_patch() == this);
- assert(ln->elem()->polyphony() == _internal_poly);
+ //assert(ln->elem()->polyphony() == _internal_poly);
_nodes.push_back(ln);
}
diff --git a/src/libs/engine/events/SetPolyphonicEvent.cpp b/src/libs/engine/events/SetPolyphonicEvent.cpp
index 369abbd2..17313f96 100644
--- a/src/libs/engine/events/SetPolyphonicEvent.cpp
+++ b/src/libs/engine/events/SetPolyphonicEvent.cpp
@@ -31,10 +31,10 @@
namespace Ingen {
-SetPolyphonicEvent::SetPolyphonicEvent(Engine& engine, SharedPtr<Responder> responder, FrameTime time, QueuedEventSource* source, const string& patch_path, bool poly)
+SetPolyphonicEvent::SetPolyphonicEvent(Engine& engine, SharedPtr<Responder> responder, FrameTime time, QueuedEventSource* source, const string& path, bool poly)
: QueuedEvent(engine, responder, time, true, source),
- _patch_path(patch_path),
- _patch(NULL),
+ _path(path),
+ _object(NULL),
_poly(poly)
{
}
@@ -43,12 +43,9 @@ SetPolyphonicEvent::SetPolyphonicEvent(Engine& engine, SharedPtr<Responder> resp
void
SetPolyphonicEvent::pre_process()
{
- /*
- _patch = _engine.object_store()->find_patch(_patch_path);
- if (_patch && _poly > _patch->internal_poly())
- _patch->prepare_internal_poly(_poly);
-*/
- QueuedEvent::pre_process();
+ _object = _engine.object_store()->find_object(_path);
+
+ QueuedEvent::pre_process();
}
@@ -56,10 +53,10 @@ void
SetPolyphonicEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
QueuedEvent::execute(nframes, start, end);
-/*
- if (_patch)
- _patch->apply_internal_poly(*_engine.maid(), _poly);
-*/
+
+ if (_object)
+ _object->set_polyphonic(*_engine.maid(), _poly);
+
_source->unblock();
}
@@ -67,12 +64,12 @@ SetPolyphonicEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
void
SetPolyphonicEvent::post_process()
{
- /*
- if (_patch)
+ if (_object) {
_responder->respond_ok();
- else
- _responder->respond_error("Unable to find patch");
- */
+ _engine.broadcaster()->send_polyphonic(_path, _poly);
+ } else {
+ _responder->respond_error("Unable to find object");
+ }
}
diff --git a/src/libs/engine/events/SetPolyphonicEvent.hpp b/src/libs/engine/events/SetPolyphonicEvent.hpp
index 42988f72..3e3aa81e 100644
--- a/src/libs/engine/events/SetPolyphonicEvent.hpp
+++ b/src/libs/engine/events/SetPolyphonicEvent.hpp
@@ -26,7 +26,7 @@ using std::string;
namespace Ingen {
-class Patch;
+class GraphObject;
/** Delete all nodes from a patch.
@@ -36,16 +36,16 @@ class Patch;
class SetPolyphonicEvent : public QueuedEvent
{
public:
- SetPolyphonicEvent(Engine& engine, SharedPtr<Responder> responder, FrameTime time, QueuedEventSource* source, const string& patch_path, bool poly);
+ SetPolyphonicEvent(Engine& engine, SharedPtr<Responder> responder, FrameTime time, QueuedEventSource* source, const string& path, bool poly);
void pre_process();
void execute(SampleCount nframes, FrameTime start, FrameTime end);
void post_process();
private:
- string _patch_path;
- Patch* _patch;
- bool _poly;
+ string _path;
+ GraphObject* _object;
+ bool _poly;
};