summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/util/Path.h5
-rw-r--r--src/libs/client/Store.cpp1
-rw-r--r--src/libs/client/Store.h1
-rw-r--r--src/libs/engine/Event.h7
-rw-r--r--src/libs/engine/QueuedEngineInterface.cpp5
-rw-r--r--src/libs/engine/events/AllNotesOffEvent.cpp4
-rw-r--r--src/libs/engine/events/ClearPatchEvent.cpp4
-rw-r--r--src/libs/engine/events/ConnectionEvent.cpp9
-rw-r--r--src/libs/engine/events/DSSIConfigureEvent.cpp1
-rw-r--r--src/libs/engine/events/DSSIControlEvent.cpp2
-rw-r--r--src/libs/engine/events/DSSIProgramEvent.cpp2
-rw-r--r--src/libs/engine/events/DSSIUpdateEvent.cpp4
-rw-r--r--src/libs/engine/events/DisablePatchEvent.cpp4
-rw-r--r--src/libs/engine/events/DisconnectNodeEvent.cpp4
-rw-r--r--src/libs/engine/events/DisconnectPortEvent.cpp4
-rw-r--r--src/libs/engine/events/DisconnectionEvent.cpp4
-rw-r--r--src/libs/engine/events/EnablePatchEvent.cpp4
-rw-r--r--src/libs/engine/events/NoteOffEvent.cpp1
-rw-r--r--src/libs/engine/events/NoteOnEvent.cpp1
-rw-r--r--src/libs/engine/events/RequestPortValueEvent.cpp3
-rw-r--r--src/libs/engine/events/SetMetadataEvent.cpp3
-rw-r--r--src/libs/engine/events/SetPortValueEvent.cpp1
-rw-r--r--src/libs/engine/events/SetPortValueQueuedEvent.cpp1
-rw-r--r--src/progs/ingenuity/ControlPanel.cpp5
-rw-r--r--src/progs/ingenuity/NodeControlWindow.cpp1
-rw-r--r--src/progs/ingenuity/NodeControlWindow.h4
-rw-r--r--src/progs/ingenuity/NodeController.cpp46
-rw-r--r--src/progs/ingenuity/NodeController.h1
-rw-r--r--src/progs/ingenuity/OmFlowCanvas.cpp4
-rw-r--r--src/progs/ingenuity/OmFlowCanvas.h2
-rw-r--r--src/progs/ingenuity/OmModule.h2
-rw-r--r--src/progs/ingenuity/OmPort.cpp2
-rw-r--r--src/progs/ingenuity/OmPort.h2
-rw-r--r--src/progs/ingenuity/OmPortModule.h5
-rw-r--r--src/progs/ingenuity/PatchController.cpp183
-rw-r--r--src/progs/ingenuity/PatchController.h2
-rw-r--r--src/progs/ingenuity/PatchTreeWindow.cpp17
-rw-r--r--src/progs/ingenuity/PatchTreeWindow.h9
-rw-r--r--src/progs/ingenuity/PortController.cpp69
-rw-r--r--src/progs/ingenuity/PortController.h13
-rw-r--r--src/progs/ingenuity/SubpatchModule.cpp12
-rw-r--r--src/progs/ingenuity/SubpatchModule.h2
42 files changed, 210 insertions, 246 deletions
diff --git a/src/common/util/Path.h b/src/common/util/Path.h
index 2c4d58b1..197ffd16 100644
--- a/src/common/util/Path.h
+++ b/src/common/util/Path.h
@@ -195,9 +195,10 @@ public:
/** Parent path with a "/" appended.
*
* Because of the "/" special case, append a child name to base_path()
- * to construct a path.
+ * to construct a path. This return value followed by a valid name is
+ * guaranteed to be a valid path.
*/
- inline Path base_path() const
+ inline string base_path() const
{
if ((*this) == "/")
return *this;
diff --git a/src/libs/client/Store.cpp b/src/libs/client/Store.cpp
index 71dc06a2..ef1b7283 100644
--- a/src/libs/client/Store.cpp
+++ b/src/libs/client/Store.cpp
@@ -62,6 +62,7 @@ Store::add_object(CountedPtr<ObjectModel> object)
m_objects[object->path()] = object;
+ new_object_sig.emit(object);
//cout << "[Store] Added " << object->path() << endl;
}
diff --git a/src/libs/client/Store.h b/src/libs/client/Store.h
index 8407c9fb..44ca5c70 100644
--- a/src/libs/client/Store.h
+++ b/src/libs/client/Store.h
@@ -55,6 +55,7 @@ public:
const map<string, CountedPtr<PluginModel> >& plugins() const { return m_plugins; }
+ sigc::signal<void, CountedPtr<ObjectModel> > new_object_sig;
private:
void add_object(CountedPtr<ObjectModel> object);
diff --git a/src/libs/engine/Event.h b/src/libs/engine/Event.h
index 3ea72555..dc6f8aaa 100644
--- a/src/libs/engine/Event.h
+++ b/src/libs/engine/Event.h
@@ -48,7 +48,12 @@ public:
virtual void execute(SampleCount nframes, FrameTime start, FrameTime end)
{
assert(!_executed);
- assert(_time >= start && _time <= end);
+ assert(_time <= end);
+
+ // Missed the event, jitter, damnit.
+ if (_time < start)
+ _time = start;
+
_executed = true;
}
diff --git a/src/libs/engine/QueuedEngineInterface.cpp b/src/libs/engine/QueuedEngineInterface.cpp
index 919d3054..d56b8de1 100644
--- a/src/libs/engine/QueuedEngineInterface.cpp
+++ b/src/libs/engine/QueuedEngineInterface.cpp
@@ -34,9 +34,12 @@ QueuedEngineInterface::QueuedEngineInterface(CountedPtr<Engine> engine, size_t q
SampleCount
QueuedEngineInterface::now() const
{
- return _engine->audio_driver()->frame_time();
+ // Exactly one cycle latency (some could run ASAP if we get lucky, but not always, and a slight
+ // constant latency is far better than jittery lower (average) latency
+ return _engine->audio_driver()->frame_time() + _engine->audio_driver()->buffer_size();
}
+
/** Set the Responder to send responses to commands with, once the commands
* are preprocessed and ready to be executed (or not).
*
diff --git a/src/libs/engine/events/AllNotesOffEvent.cpp b/src/libs/engine/events/AllNotesOffEvent.cpp
index b26f1315..eacebda1 100644
--- a/src/libs/engine/events/AllNotesOffEvent.cpp
+++ b/src/libs/engine/events/AllNotesOffEvent.cpp
@@ -43,7 +43,9 @@ AllNotesOffEvent::AllNotesOffEvent(Engine& engine, CountedPtr<Responder> respond
void
AllNotesOffEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
-{
+{
+ Event::execute(nframes, start, end);
+
if (m_patch == NULL && m_patch_path != "")
m_patch = _engine.object_store()->find_patch(m_patch_path);
diff --git a/src/libs/engine/events/ClearPatchEvent.cpp b/src/libs/engine/events/ClearPatchEvent.cpp
index 3518dc03..b8f31243 100644
--- a/src/libs/engine/events/ClearPatchEvent.cpp
+++ b/src/libs/engine/events/ClearPatchEvent.cpp
@@ -59,6 +59,8 @@ ClearPatchEvent::pre_process()
void
ClearPatchEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
+ QueuedEvent::execute(nframes, start, end);
+
if (m_patch != NULL) {
m_patch->disable();
@@ -70,8 +72,6 @@ ClearPatchEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
m_patch->process_order(NULL);
}
}
-
- QueuedEvent::execute(nframes, start, end);
}
diff --git a/src/libs/engine/events/ConnectionEvent.cpp b/src/libs/engine/events/ConnectionEvent.cpp
index 7c97de03..17d3c9cb 100644
--- a/src/libs/engine/events/ConnectionEvent.cpp
+++ b/src/libs/engine/events/ConnectionEvent.cpp
@@ -115,8 +115,10 @@ ConnectionEvent::pre_process()
return;
}
+ assert(m_typed_event);
m_typed_event->pre_process();
-
+ assert(m_typed_event->is_prepared());
+
QueuedEvent::pre_process();
}
@@ -223,6 +225,9 @@ TypedConnectionEvent<T>::pre_process()
if (m_patch->enabled())
m_process_order = m_patch->build_process_order();
+
+ m_succeeded = true;
+ QueuedEvent::pre_process();
}
@@ -230,6 +235,8 @@ template <typename T>
void
TypedConnectionEvent<T>::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
+ QueuedEvent::execute(nframes, start, end);
+
if (m_succeeded) {
// These must be inserted here, since they're actually used by the audio thread
m_dst_port->add_connection(m_port_listnode);
diff --git a/src/libs/engine/events/DSSIConfigureEvent.cpp b/src/libs/engine/events/DSSIConfigureEvent.cpp
index fb006444..fb9dc727 100644
--- a/src/libs/engine/events/DSSIConfigureEvent.cpp
+++ b/src/libs/engine/events/DSSIConfigureEvent.cpp
@@ -51,6 +51,7 @@ DSSIConfigureEvent::pre_process()
void
DSSIConfigureEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
+ QueuedEvent::execute(nframes, start, end);
// Nothing.
}
diff --git a/src/libs/engine/events/DSSIControlEvent.cpp b/src/libs/engine/events/DSSIControlEvent.cpp
index 9ae4274b..4ab3cd6c 100644
--- a/src/libs/engine/events/DSSIControlEvent.cpp
+++ b/src/libs/engine/events/DSSIControlEvent.cpp
@@ -50,6 +50,8 @@ DSSIControlEvent::pre_process()
void
DSSIControlEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
+ QueuedEvent::execute(nframes, start, end);
+
if (m_node != NULL)
m_node->set_control(m_port_num, m_val);
}
diff --git a/src/libs/engine/events/DSSIProgramEvent.cpp b/src/libs/engine/events/DSSIProgramEvent.cpp
index d602b57c..c6a9e0b7 100644
--- a/src/libs/engine/events/DSSIProgramEvent.cpp
+++ b/src/libs/engine/events/DSSIProgramEvent.cpp
@@ -53,6 +53,8 @@ DSSIProgramEvent::pre_process()
void
DSSIProgramEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
+ QueuedEvent::execute(nframes, start, end);
+
if (m_node != NULL)
m_node->program(m_bank, m_program);
}
diff --git a/src/libs/engine/events/DSSIUpdateEvent.cpp b/src/libs/engine/events/DSSIUpdateEvent.cpp
index d2953a9b..edfe1394 100644
--- a/src/libs/engine/events/DSSIUpdateEvent.cpp
+++ b/src/libs/engine/events/DSSIUpdateEvent.cpp
@@ -56,11 +56,11 @@ DSSIUpdateEvent::pre_process()
void
DSSIUpdateEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
+ QueuedEvent::execute(nframes, start, end);
+
if (m_node != NULL) {
m_node->set_ui_url(m_url);
}
-
- QueuedEvent::execute(nframes, start, end);
}
diff --git a/src/libs/engine/events/DisablePatchEvent.cpp b/src/libs/engine/events/DisablePatchEvent.cpp
index 064dd9fd..8e6d64a1 100644
--- a/src/libs/engine/events/DisablePatchEvent.cpp
+++ b/src/libs/engine/events/DisablePatchEvent.cpp
@@ -46,10 +46,10 @@ DisablePatchEvent::pre_process()
void
DisablePatchEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
+ QueuedEvent::execute(nframes, start, end);
+
if (m_patch != NULL)
m_patch->disable();
-
- QueuedEvent::execute(nframes, start, end);
}
diff --git a/src/libs/engine/events/DisconnectNodeEvent.cpp b/src/libs/engine/events/DisconnectNodeEvent.cpp
index df85e1db..5be1167e 100644
--- a/src/libs/engine/events/DisconnectNodeEvent.cpp
+++ b/src/libs/engine/events/DisconnectNodeEvent.cpp
@@ -114,12 +114,12 @@ DisconnectNodeEvent::pre_process()
void
DisconnectNodeEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
+ QueuedEvent::execute(nframes, start, end);
+
if (m_succeeded) {
for (List<DisconnectionEvent*>::iterator i = m_disconnection_events.begin(); i != m_disconnection_events.end(); ++i)
(*i)->execute(nframes, start, end);
}
-
- QueuedEvent::execute(nframes, start, end);
}
diff --git a/src/libs/engine/events/DisconnectPortEvent.cpp b/src/libs/engine/events/DisconnectPortEvent.cpp
index 41ceff8b..f6dfa40c 100644
--- a/src/libs/engine/events/DisconnectPortEvent.cpp
+++ b/src/libs/engine/events/DisconnectPortEvent.cpp
@@ -119,12 +119,12 @@ DisconnectPortEvent::pre_process()
void
DisconnectPortEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
+ QueuedEvent::execute(nframes, start, end);
+
if (m_succeeded) {
for (List<DisconnectionEvent*>::iterator i = m_disconnection_events.begin(); i != m_disconnection_events.end(); ++i)
(*i)->execute(nframes, start, end);
}
-
- QueuedEvent::execute(nframes, start, end);
}
diff --git a/src/libs/engine/events/DisconnectionEvent.cpp b/src/libs/engine/events/DisconnectionEvent.cpp
index 7e050369..a83e6e3f 100644
--- a/src/libs/engine/events/DisconnectionEvent.cpp
+++ b/src/libs/engine/events/DisconnectionEvent.cpp
@@ -125,6 +125,7 @@ DisconnectionEvent::pre_process()
assert(m_typed_event);
m_typed_event->pre_process();
+ assert(m_typed_event->is_prepared());
QueuedEvent::pre_process();
}
@@ -235,6 +236,8 @@ template <typename T>
void
TypedDisconnectionEvent<T>::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
+ QueuedEvent::execute(nframes, start, end);
+
if (m_succeeded) {
ListNode<TypedConnection<T>*>* const port_connection
@@ -259,7 +262,6 @@ TypedDisconnectionEvent<T>::execute(SampleCount nframes, FrameTime start, FrameT
m_succeeded = false; // Ports weren't connected
}
}
- QueuedEvent::execute(nframes, start, end);
}
diff --git a/src/libs/engine/events/EnablePatchEvent.cpp b/src/libs/engine/events/EnablePatchEvent.cpp
index 01144013..3d238372 100644
--- a/src/libs/engine/events/EnablePatchEvent.cpp
+++ b/src/libs/engine/events/EnablePatchEvent.cpp
@@ -54,14 +54,14 @@ EnablePatchEvent::pre_process()
void
EnablePatchEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
+ QueuedEvent::execute(nframes, start, end);
+
if (m_patch != NULL) {
m_patch->enable();
if (m_patch->process_order() == NULL)
m_patch->process_order(m_process_order);
}
-
- QueuedEvent::execute(nframes, start, end);
}
diff --git a/src/libs/engine/events/NoteOffEvent.cpp b/src/libs/engine/events/NoteOffEvent.cpp
index 8145c208..26f3a324 100644
--- a/src/libs/engine/events/NoteOffEvent.cpp
+++ b/src/libs/engine/events/NoteOffEvent.cpp
@@ -49,6 +49,7 @@ NoteOffEvent::NoteOffEvent(Engine& engine, CountedPtr<Responder> responder, Samp
void
NoteOffEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
+ Event::execute(nframes, start, end);
assert(_time >= start && _time <= end);
if (m_node == NULL && m_node_path != "")
diff --git a/src/libs/engine/events/NoteOnEvent.cpp b/src/libs/engine/events/NoteOnEvent.cpp
index 7a98c58d..540bc618 100644
--- a/src/libs/engine/events/NoteOnEvent.cpp
+++ b/src/libs/engine/events/NoteOnEvent.cpp
@@ -58,6 +58,7 @@ NoteOnEvent::NoteOnEvent(Engine& engine, CountedPtr<Responder> responder, Sample
void
NoteOnEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
+ Event::execute(nframes, start, end);
assert(_time >= start && _time <= end);
// Lookup if neccessary
diff --git a/src/libs/engine/events/RequestPortValueEvent.cpp b/src/libs/engine/events/RequestPortValueEvent.cpp
index 12dea975..80f55dcd 100644
--- a/src/libs/engine/events/RequestPortValueEvent.cpp
+++ b/src/libs/engine/events/RequestPortValueEvent.cpp
@@ -51,14 +51,13 @@ RequestPortValueEvent::pre_process()
void
RequestPortValueEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
+ QueuedEvent::execute(nframes, start, end);
assert(_time >= start && _time <= end);
if (m_port != NULL && m_port->type() == DataType::FLOAT)
m_value = ((TypedPort<Sample>*)m_port)->buffer(0)->value_at(_time - start);
else
m_port = NULL; // triggers error response
-
- QueuedEvent::execute(nframes, start, end);
}
diff --git a/src/libs/engine/events/SetMetadataEvent.cpp b/src/libs/engine/events/SetMetadataEvent.cpp
index 428437e3..db8e0118 100644
--- a/src/libs/engine/events/SetMetadataEvent.cpp
+++ b/src/libs/engine/events/SetMetadataEvent.cpp
@@ -55,9 +55,8 @@ SetMetadataEvent::pre_process()
void
SetMetadataEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
- // Do nothing
-
QueuedEvent::execute(nframes, start, end);
+ // Do nothing
}
diff --git a/src/libs/engine/events/SetPortValueEvent.cpp b/src/libs/engine/events/SetPortValueEvent.cpp
index efe53b37..41395feb 100644
--- a/src/libs/engine/events/SetPortValueEvent.cpp
+++ b/src/libs/engine/events/SetPortValueEvent.cpp
@@ -52,6 +52,7 @@ SetPortValueEvent::SetPortValueEvent(Engine& engine, CountedPtr<Responder> respo
void
SetPortValueEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
+ Event::execute(nframes, start, end);
assert(_time >= start && _time <= end);
if (m_port == NULL)
diff --git a/src/libs/engine/events/SetPortValueQueuedEvent.cpp b/src/libs/engine/events/SetPortValueQueuedEvent.cpp
index dcbec0be..21ccf214 100644
--- a/src/libs/engine/events/SetPortValueQueuedEvent.cpp
+++ b/src/libs/engine/events/SetPortValueQueuedEvent.cpp
@@ -70,7 +70,6 @@ void
SetPortValueQueuedEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
QueuedEvent::execute(nframes, start, end);
-
assert(_time >= start && _time <= end);
if (m_error == NO_ERROR) {
diff --git a/src/progs/ingenuity/ControlPanel.cpp b/src/progs/ingenuity/ControlPanel.cpp
index 0841a818..57ac7824 100644
--- a/src/progs/ingenuity/ControlPanel.cpp
+++ b/src/progs/ingenuity/ControlPanel.cpp
@@ -222,11 +222,6 @@ void
ControlPanel::value_changed(const Path& port_path, float val)
{
if (m_callback_enabled) {
- // Update patch control slider, if this is a control panel for a patch
- // (or vice versa)
- //if (m_mirror != NULL)
- // m_mirror->set_port_value(port_path, val);
-
if (m_all_voices_radio->get_active()) {
App::instance().engine()->set_port_value(port_path, val);
} else {
diff --git a/src/progs/ingenuity/NodeControlWindow.cpp b/src/progs/ingenuity/NodeControlWindow.cpp
index 21afd234..3af8f834 100644
--- a/src/progs/ingenuity/NodeControlWindow.cpp
+++ b/src/progs/ingenuity/NodeControlWindow.cpp
@@ -18,6 +18,7 @@
#include "GladeFactory.h"
#include "NodeController.h"
#include "ControlGroups.h"
+#include "ControlPanel.h"
#include "PatchWindow.h"
#include <iostream>
#include <cmath>
diff --git a/src/progs/ingenuity/NodeControlWindow.h b/src/progs/ingenuity/NodeControlWindow.h
index dbc1aa49..b30223d7 100644
--- a/src/progs/ingenuity/NodeControlWindow.h
+++ b/src/progs/ingenuity/NodeControlWindow.h
@@ -23,15 +23,13 @@
#include <gtkmm.h>
#include <libglademm.h>
#include <sigc++/sigc++.h>
-#include "ControlPanel.h"
using std::string; using std::vector;
-using namespace Ingen::Client;
-
namespace Ingenuity {
class ControlGroup;
class NodeController;
+class ControlPanel;
/** Window with controls (sliders) for all control-rate ports on a Node.
diff --git a/src/progs/ingenuity/NodeController.cpp b/src/progs/ingenuity/NodeController.cpp
index 331a714e..1c340516 100644
--- a/src/progs/ingenuity/NodeController.cpp
+++ b/src/progs/ingenuity/NodeController.cpp
@@ -97,31 +97,42 @@ NodeController::NodeController(CountedPtr<NodeModel> model)
NodeController::~NodeController()
{
+ destroy_module();
}
void
NodeController::create_module(OmFlowCanvas* canvas)
{
- //cerr << "Creating node module " << m_model->path() << endl;
-
- // If this is a DSSI plugin, DSSIController should be doing this
- /*assert(node_model()->plugin());
- assert(node_model()->plugin()->type() != PluginModel::DSSI);
- assert(canvas != NULL);
- assert(m_module == NULL);*/
-
- assert(canvas);
- assert(node_model());
- m_module = new OmModule(canvas, this);
-
- create_all_ports();
+ if (!m_module || m_module->canvas() != canvas) {
+ delete m_module;
+ //cerr << "Creating node module " << m_model->path() << endl;
+
+ // If this is a DSSI plugin, DSSIController should be doing this
+ /*assert(node_model()->plugin());
+ assert(node_model()->plugin()->type() != PluginModel::DSSI);
+ assert(canvas != NULL);
+ assert(m_module == NULL);*/
+
+ assert(canvas);
+ assert(node_model());
+ m_module = new OmModule(canvas, this);
+ create_all_ports();
+ }
m_module->move_to(node_model()->x(), node_model()->y());
}
void
+NodeController::destroy_module()
+{
+ delete m_module;
+ m_module = NULL;
+}
+
+
+void
NodeController::set_path(const Path& new_path)
{
cerr << "FIXME: rename\n";
@@ -214,12 +225,6 @@ NodeController::add_port(CountedPtr<PortModel> pm)
if (has_control_inputs())
enable_controls_menuitem();
}
-
- if (m_control_window != NULL) {
- assert(m_control_window->control_panel() != NULL);
- m_control_window->control_panel()->add_port(pc);
- m_control_window->resize();
- }
}
@@ -233,8 +238,7 @@ NodeController::show_control_window()
if (!m_control_window)
m_control_window = new NodeControlWindow(this, poly);
- if (m_control_window->control_panel()->num_controls() > 0)
- m_control_window->present();
+ m_control_window->present();
}
diff --git a/src/progs/ingenuity/NodeController.h b/src/progs/ingenuity/NodeController.h
index ca00087c..84ac09cd 100644
--- a/src/progs/ingenuity/NodeController.h
+++ b/src/progs/ingenuity/NodeController.h
@@ -57,6 +57,7 @@ public:
virtual void metadata_update(const string& key, const string& value);
virtual void create_module(OmFlowCanvas* canvas);
+ virtual void destroy_module();
void set_path(const Path& new_path);
diff --git a/src/progs/ingenuity/OmFlowCanvas.cpp b/src/progs/ingenuity/OmFlowCanvas.cpp
index ac5f8beb..a6e3617e 100644
--- a/src/progs/ingenuity/OmFlowCanvas.cpp
+++ b/src/progs/ingenuity/OmFlowCanvas.cpp
@@ -179,13 +179,15 @@ OmFlowCanvas::generate_port_name(const string& base) {
char num_buf[5];
for (uint i=1; i < 9999; ++i) {
- snprintf(num_buf, 5, "%d", i);
+ snprintf(num_buf, 5, "%u", i);
name = base + "_";
name += num_buf;
if (!m_patch_controller->patch_model()->get_port(name))
break;
}
+ assert(Path::is_valid(string("/") + name));
+
return name;
}
diff --git a/src/progs/ingenuity/OmFlowCanvas.h b/src/progs/ingenuity/OmFlowCanvas.h
index 310aa5b8..7db347f7 100644
--- a/src/progs/ingenuity/OmFlowCanvas.h
+++ b/src/progs/ingenuity/OmFlowCanvas.h
@@ -41,7 +41,7 @@ public:
OmFlowCanvas(PatchController* controller, int width, int height);
OmModule* find_module(const string& name)
- { return (OmModule*)FlowCanvas::find_module(name); }
+ { return (OmModule*)FlowCanvas::get_module(name); }
void connect(const Port* src_port, const Port* dst_port);
void disconnect(const Port* src_port, const Port* dst_port);
diff --git a/src/progs/ingenuity/OmModule.h b/src/progs/ingenuity/OmModule.h
index fcf94191..2a31a84f 100644
--- a/src/progs/ingenuity/OmModule.h
+++ b/src/progs/ingenuity/OmModule.h
@@ -52,7 +52,7 @@ public:
virtual ~OmModule() {}
virtual OmPort* port(const string& port_name) {
- return (OmPort*)Module::port(port_name);
+ return (OmPort*)Module::get_port(port_name);
}
virtual void store_location();
diff --git a/src/progs/ingenuity/OmPort.cpp b/src/progs/ingenuity/OmPort.cpp
index 12607f24..69406b97 100644
--- a/src/progs/ingenuity/OmPort.cpp
+++ b/src/progs/ingenuity/OmPort.cpp
@@ -28,7 +28,7 @@ using namespace Ingen::Client;
namespace Ingenuity {
-OmPort::OmPort(OmModule* module, CountedPtr<PortModel> pm)
+OmPort::OmPort(Module* module, CountedPtr<PortModel> pm)
: Port(module, pm->name(), pm->is_input(), App::instance().configuration()->get_port_color(pm.get())),
m_port_model(pm)
{
diff --git a/src/progs/ingenuity/OmPort.h b/src/progs/ingenuity/OmPort.h
index d5021d79..5ffd4e26 100644
--- a/src/progs/ingenuity/OmPort.h
+++ b/src/progs/ingenuity/OmPort.h
@@ -42,7 +42,7 @@ class OmModule;
class OmPort : public LibFlowCanvas::Port
{
public:
- OmPort(OmModule* module, CountedPtr<PortModel> pm);
+ OmPort(Module* module, CountedPtr<PortModel> pm);
virtual ~OmPort() {}
diff --git a/src/progs/ingenuity/OmPortModule.h b/src/progs/ingenuity/OmPortModule.h
index 19c72609..85bd349b 100644
--- a/src/progs/ingenuity/OmPortModule.h
+++ b/src/progs/ingenuity/OmPortModule.h
@@ -39,10 +39,9 @@ class OmFlowCanvas;
class OmPort;
-/** A module in a patch.
+/** A "module" to represent a patch's port on it's own canvas.
*
- * This base class is extended for various types of modules - SubpatchModule,
- * DSSIModule, etc.
+ * Translation: This is the nameless single port pseudo module thingy.
*
* \ingroup Ingenuity
*/
diff --git a/src/progs/ingenuity/PatchController.cpp b/src/progs/ingenuity/PatchController.cpp
index 86e548c7..84c6eb7b 100644
--- a/src/progs/ingenuity/PatchController.cpp
+++ b/src/progs/ingenuity/PatchController.cpp
@@ -188,9 +188,9 @@ PatchController::set_path(const Path& new_path)
for (NodeModelMap::const_iterator i = patch_model()->nodes().begin();
i != patch_model()->nodes().end(); ++i) {
const NodeModel* const nm = (*i).second.get();
- assert(nm != NULL);
+ assert(nm );
NodeController* const nc = ((NodeController*)nm->controller());
- assert(nc != NULL);
+ assert(nc );
nc->set_path(new_path.base_path() + nc->node_model()->name());
}
@@ -199,29 +199,26 @@ PatchController::set_path(const Path& new_path)
for (PortModelList::const_iterator i = node_model()->ports().begin();
i != node_model()->ports().end(); ++i) {
GtkObjectController* const pc = (GtkObjectController*)((*i)->controller());
- assert(pc != NULL);
+ assert(pc );
assert(pc->path().parent()== new_path);
}
#endif
App::instance().patch_tree()->patch_renamed(old_path, new_path);
- if (m_window != NULL)
+ if (m_window)
m_window->patch_renamed(new_path);
- if (m_control_window != NULL)
+ if (m_control_window)
m_control_window->set_title(new_path + " Controls");
- if (m_module != NULL) {
- assert(m_module->canvas() != NULL);
- m_module->canvas()->rename_module(old_path.name(), new_path.name());
- assert(m_module->name() == new_path.name());
- }
+ if (m_module)
+ m_module->name(new_path.name());
PatchController* parent = dynamic_cast<PatchController*>(
patch_model()->parent()->controller());
- if (parent != NULL && parent->window() != NULL)
+ if (parent && parent->window())
parent->window()->node_renamed(old_path, new_path);
//remove_from_store();
@@ -232,54 +229,33 @@ PatchController::set_path(const Path& new_path)
parent->patch_model()->rename_node(old_path, new_path);
}
-#if 0
-void
-PatchController::enable()
-{
- if (m_patch_view != NULL)
- m_patch_view->enabled(true);
-
- patch_model()->enabled(true);
-
- App::instance().patch_tree()->patch_enabled(m_model->path());
-}
-
-
-void
-PatchController::disable()
-{
- if (m_patch_view != NULL)
- m_patch_view->enabled(false);
-
- patch_model()->enabled(false);
-
- App::instance().patch_tree()->patch_disabled(m_model->path());
-}
-#endif
void
PatchController::create_module(OmFlowCanvas* canvas)
{
- //cerr << "Creating patch module " << m_model->path() << endl;
+ // Update menu if we didn't used to have a module
+ if (!m_module) {
+ /*Gtk::Menu::MenuList& items = m_menu.items();
+ m_menu.remove(items[4]);
+
+ items.push_front(Gtk::Menu_Helpers::SeparatorElem());
+ items.push_front(Gtk::Menu_Helpers::MenuElem("Browse to Patch",
+ sigc::mem_fun((SubpatchModule*)m_module, &SubpatchModule::browse_to_patch)));
+ items.push_front(Gtk::Menu_Helpers::MenuElem("Open Patch in New Window",
+ sigc::mem_fun(this, &PatchController::show_patch_window)));*/
+ }
- assert(canvas != NULL);
- assert(m_module == NULL);
- assert(!m_patch_view || canvas != m_patch_view->canvas());
-
- m_module = new SubpatchModule(canvas, this);
+ if (!m_module || m_module->canvas() != canvas) {
+ //cerr << "Creating patch module " << m_model->path() << endl;
- m_menu.remove(m_menu.items()[4]);
+ assert(canvas != NULL);
+ assert(m_module == NULL);
+ assert(!m_patch_view || canvas != m_patch_view->canvas());
- // Add navigation menu items
- Gtk::Menu::MenuList& items = m_menu.items();
- items.push_front(Gtk::Menu_Helpers::SeparatorElem());
- items.push_front(Gtk::Menu_Helpers::MenuElem("Browse to Patch",
- sigc::mem_fun((SubpatchModule*)m_module, &SubpatchModule::browse_to_patch)));
- items.push_front(Gtk::Menu_Helpers::MenuElem("Open Patch in New Window",
- sigc::mem_fun(this, &PatchController::show_patch_window)));
-
- create_all_ports();
+ m_module = new SubpatchModule(canvas, this);
+ create_all_ports();
+ }
m_module->move_to(node_model()->x(), node_model()->y());
}
@@ -325,10 +301,8 @@ PatchController::create_view()
assert(nc);
assert(nm->controller() == nc);
- if (nc->module() == NULL);
- nc->create_module(m_patch_view->canvas());
- assert(nc->module() != NULL);
- m_patch_view->canvas()->add_module(nc->module());
+ nc->create_module(m_patch_view->canvas());
+ assert(nc->module());
}
// Create pseudo modules for ports (ports on this canvas, not on our module)
@@ -336,18 +310,14 @@ PatchController::create_view()
i != patch_model()->ports().end(); ++i) {
PortController* const pc = dynamic_cast<PortController*>((*i)->controller());
assert(pc);
- if (pc->module() == NULL)
- pc->create_module(m_patch_view->canvas());
- assert(pc->module() != NULL);
- m_patch_view->canvas()->add_module(pc->module());
- pc->module()->resize();
+ pc->create_module(m_patch_view->canvas());
}
// Create connections
for (list<CountedPtr<ConnectionModel> >::const_iterator i = patch_model()->connections().begin();
i != patch_model()->connections().end(); ++i) {
- create_connection(*i);
+ connection(*i);
}
// Set run checkbox
@@ -373,24 +343,28 @@ PatchController::show_properties_window()
/** Create a connection in the view (canvas).
*/
void
-PatchController::create_connection(CountedPtr<ConnectionModel> cm)
+PatchController::connection(CountedPtr<ConnectionModel> cm)
{
- // Deal with messy anonymous nodes for this patch's own ports...
- const Path& src_parent_path = cm->src_port_path().parent();
- const Path& dst_parent_path = cm->dst_port_path().parent();
-
- const string& src_parent_name =
- (src_parent_path == path()) ? "" : src_parent_path.name();
- const string& dst_parent_name =
- (dst_parent_path == path()) ? "" : dst_parent_path.name();
-
- m_patch_view->canvas()->add_connection(
- src_parent_name,
- cm->src_port_path().name(),
- dst_parent_name,
- cm->dst_port_path().name());
+ if (m_patch_view != NULL) {
+
+ // Deal with port "anonymous nodes" for this patch's own ports...
+ const Path& src_parent_path = cm->src_port_path().parent();
+ const Path& dst_parent_path = cm->dst_port_path().parent();
+
+ const string& src_parent_name =
+ (src_parent_path == path()) ? "" : src_parent_path.name();
+ const string& dst_parent_name =
+ (dst_parent_path == path()) ? "" : dst_parent_path.name();
+
+ Port* src_port = m_patch_view->canvas()->get_port(src_parent_name, cm->src_port_path().name());
+ Port* dst_port = m_patch_view->canvas()->get_port(dst_parent_name, cm->dst_port_path().name());
+ assert(src_port && dst_port);
+
+ m_patch_view->canvas()->add_connection(src_port, dst_port);
+ }
}
+
NodeController*
PatchController::create_controller_for_node(CountedPtr<NodeModel> node)
{
@@ -435,7 +409,6 @@ PatchController::add_node(CountedPtr<NodeModel> object)
CountedPtr<NodeModel> node(object);
- assert(node == object);
if (node) {
assert(node->parent() == m_patch_model);
@@ -454,10 +427,8 @@ PatchController::add_node(CountedPtr<NodeModel> object)
if (old_zoom != 1.0)
m_patch_view->canvas()->zoom(1.0);
- if (nc->module() == NULL)
- nc->create_module(m_patch_view->canvas());
- assert(nc->module() != NULL);
- m_patch_view->canvas()->add_module(nc->module());
+ nc->create_module(m_patch_view->canvas());
+ assert(nc->module());
nc->module()->resize();
// Reset zoom
@@ -480,13 +451,8 @@ PatchController::remove_node(const string& name)
assert(!m_patch_model->get_node(name));
// Update breadcrumbs if necessary
- if (m_window != NULL)
+ if (m_window)
m_window->node_removed(name);
-
- if (m_patch_view != NULL) {
- assert(m_patch_view->canvas() != NULL);
- m_patch_view->canvas()->remove_module(name);
- }
}
@@ -534,11 +500,7 @@ PatchController::add_port(CountedPtr<PortModel> pm)
if (old_zoom != 1.0)
m_patch_view->canvas()->zoom(1.0);
- if (pc->module() == NULL)
- pc->create_module(m_patch_view->canvas());
- assert(pc->module() != NULL);
- m_patch_view->canvas()->add_module(pc->module());
- pc->module()->resize();
+ pc->create_module(m_patch_view->canvas());
// Reset zoom
if (old_zoom != 1.0) {
@@ -565,6 +527,7 @@ void
PatchController::remove_port(const Path& path, bool resize_module)
{
assert(path.parent() == m_model->path());
+ assert( ! patch_model()->get_port(path.name()));
//cerr << "[PatchController] Removing port " << path << endl;
@@ -577,16 +540,12 @@ PatchController::remove_port(const Path& path, bool resize_module)
}
}*/
- // Remove port on module
- if (m_module != NULL) {
- assert(m_module->port(path.name()) != NULL);
- m_module->remove_port(path.name(), resize_module);
- assert(m_module->port(path.name()) == NULL);
+ if (m_module) {
+ delete m_module->port(path.name());
+ if (resize_module)
+ m_module->resize();
}
- patch_model()->remove_port(path);
- assert(patch_model()->get_port(path.name()));
-
// Disable "Controls" menuitem on module and patch window, if necessary
if (!has_control_inputs())
disable_controls_menuitem();
@@ -594,19 +553,6 @@ PatchController::remove_port(const Path& path, bool resize_module)
void
-PatchController::connection(CountedPtr<ConnectionModel> cm)
-{
- assert(cm);
-
- //patch_model()->add_connection(cm);
-
- if (m_patch_view != NULL)
- create_connection(cm);
-}
-
-
-
-void
PatchController::disconnection(const Path& src_port_path, const Path& dst_port_path)
{
const string& src_node_name = src_port_path.parent().name();
@@ -614,9 +560,14 @@ PatchController::disconnection(const Path& src_port_path, const Path& dst_port_p
const string& dst_node_name = dst_port_path.parent().name();
const string& dst_port_name = dst_port_path.name();
- if (m_patch_view != NULL)
- m_patch_view->canvas()->remove_connection(
- src_node_name, src_port_name, dst_node_name, dst_port_name);
+ if (m_patch_view) {
+ Port* src_port = m_patch_view->canvas()->get_port(src_node_name, src_port_name);
+ Port* dst_port = m_patch_view->canvas()->get_port(dst_node_name, dst_port_name);
+
+ if (src_port && dst_port) {
+ m_patch_view->canvas()->remove_connection(src_port, dst_port);
+ }
+ }
//patch_model()->remove_connection(src_port_path, dst_port_path);
diff --git a/src/progs/ingenuity/PatchController.h b/src/progs/ingenuity/PatchController.h
index ef8a438e..a5370826 100644
--- a/src/progs/ingenuity/PatchController.h
+++ b/src/progs/ingenuity/PatchController.h
@@ -109,8 +109,6 @@ private:
void add_node(CountedPtr<NodeModel> object);
void remove_node(const string& name);
- void create_connection(CountedPtr<ConnectionModel> cm);
-
NodeController* create_controller_for_node(CountedPtr<NodeModel> node);
PatchPropertiesWindow* m_properties_window;
diff --git a/src/progs/ingenuity/PatchTreeWindow.cpp b/src/progs/ingenuity/PatchTreeWindow.cpp
index 47bfc485..0f8c947a 100644
--- a/src/progs/ingenuity/PatchTreeWindow.cpp
+++ b/src/progs/ingenuity/PatchTreeWindow.cpp
@@ -20,6 +20,7 @@
#include "PatchTreeWindow.h"
#include "PatchController.h"
#include "PatchWindow.h"
+#include "Store.h"
#include "SubpatchModule.h"
#include "PatchModel.h"
#include "util/Path.h"
@@ -64,6 +65,22 @@ PatchTreeWindow::PatchTreeWindow(BaseObjectType* cobject,
void
+PatchTreeWindow::init(Store& store)
+{
+ store.new_object_sig.connect(sigc::mem_fun(this, &PatchTreeWindow::new_object));
+}
+
+
+void
+PatchTreeWindow::new_object(CountedPtr<ObjectModel> object)
+{
+ CountedPtr<PatchModel> patch = object;
+ if (patch && dynamic_cast<PatchController*>(patch->controller()))
+ add_patch(dynamic_cast<PatchController*>(patch->controller()));
+}
+
+
+void
PatchTreeWindow::add_patch(PatchController* pc)
{
const CountedPtr<PatchModel> pm = pc->patch_model();
diff --git a/src/progs/ingenuity/PatchTreeWindow.h b/src/progs/ingenuity/PatchTreeWindow.h
index cdc7586a..a43703a7 100644
--- a/src/progs/ingenuity/PatchTreeWindow.h
+++ b/src/progs/ingenuity/PatchTreeWindow.h
@@ -21,6 +21,11 @@
#include <libglademm.h>
#include "util/Path.h"
+namespace Ingen { namespace Client {
+ class Store;
+} }
+using Ingen::Client::Store;
+
namespace Ingenuity {
class PatchWindow;
@@ -37,6 +42,10 @@ class PatchTreeWindow : public Gtk::Window
public:
PatchTreeWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& refGlade);
+ void init(Store& store);
+
+ void new_object(CountedPtr<ObjectModel> object);
+
void patch_enabled(const Path& path);
void patch_disabled(const Path& path);
void patch_renamed(const Path& old_path, const Path& new_path);
diff --git a/src/progs/ingenuity/PortController.cpp b/src/progs/ingenuity/PortController.cpp
index 0668a9e0..6a23169f 100644
--- a/src/progs/ingenuity/PortController.cpp
+++ b/src/progs/ingenuity/PortController.cpp
@@ -18,7 +18,7 @@
#include "OmFlowCanvas.h"
#include "OmModule.h"
#include "PortModel.h"
-#include "ControlPanel.h"
+#include "PatchModel.h"
#include "OmPort.h"
#include "OmPatchPort.h"
#include "Store.h"
@@ -28,9 +28,9 @@ namespace Ingenuity {
PortController::PortController(CountedPtr<PortModel> model)
: GtkObjectController(model),
+ m_patch_port(NULL),
m_module(NULL),
m_port(NULL)
- //m_control_panel(NULL)
{
assert(model);
assert(model->parent());
@@ -47,9 +47,6 @@ PortController::destroy()
NodeController* parent = (NodeController*)m_model->parent()->controller();
assert(parent != NULL);
- //if (m_control_panel != NULL)
- // m_control_panel->remove_port(path());
-
parent->remove_port(path(), false);
}
@@ -70,35 +67,38 @@ PortController::create_module(OmFlowCanvas* canvas)
assert(canvas);
assert(port_model());
+
+ if (m_module)
+ delete m_module;
+
m_module = new OmPortModule(canvas, this, x, y);
- // FIXME: leak
- m_patch_port = new OmPatchPort(m_module, port_model());
- m_module->add_port(m_patch_port, false);
+ if (CountedPtr<PatchModel>(port_model()->parent())) {
+ if (m_patch_port)
+ delete m_patch_port;
+
+ m_patch_port = new OmPatchPort(m_module, port_model());
+ }
+ m_module->resize();
+
m_module->move_to(x, y); // FIXME: redundant (?)
}
void
+PortController::destroy_module()
+{
+ delete m_module;
+ m_module = NULL;
+}
+
+
+void
PortController::metadata_update(const string& key, const string& value)
{
- // FIXME: double lookups
-
- //cerr << path() << ": " << key << " = " << value << endl;
-
-/* Panel now listens to model signals..
-
- if (key == "user-min") {
- port_model()->user_min(atof(value.c_str()));
- if (m_control_panel != NULL)
- m_control_panel->set_range_min(m_model->path(), atof(value.c_str()));
- } else if (key == "user-max") {
- port_model()->user_max(atof(value.c_str()));
- if (m_control_panel != NULL)
- m_control_panel->set_range_max(m_model->path(), atof(value.c_str()));
- }
-*/
+ //cerr << "Metadata " << path() << ": " << key << " = " << value << endl;
+
if (m_module != NULL) {
if (key == "module-x") {
float x = atof(value.c_str());
@@ -114,21 +114,6 @@ PortController::metadata_update(const string& key, const string& value)
GtkObjectController::metadata_update(key, value);
}
-
-/** "Register" a control panel that is monitoring this port.
- *
- * The OmPort will handle notifying the ControlPanel when state
- * changes occur, etc.
- */
-/*
-void
-PortController::set_control_panel(ControlPanel* cp)
-{
- assert(m_control_panel == NULL);
- m_control_panel = cp;
-}
-*/
-
void
PortController::set_path(const Path& new_path)
{
@@ -136,9 +121,6 @@ PortController::set_path(const Path& new_path)
if (m_port != NULL)
m_port->set_name(new_path.name());
- //if (m_control_panel != NULL)
- // m_control_panel->rename_port(m_model->path(), new_path);
-
m_model->set_path(new_path);
}
@@ -152,8 +134,7 @@ PortController::create_port(OmModule* module)
{
assert(module != NULL);
- m_port = new OmPort(module, port_model());
- module->add_port(m_port, false);
+ new OmPort(module, port_model());
}
diff --git a/src/progs/ingenuity/PortController.h b/src/progs/ingenuity/PortController.h
index 53c2cd48..1a58491b 100644
--- a/src/progs/ingenuity/PortController.h
+++ b/src/progs/ingenuity/PortController.h
@@ -35,7 +35,6 @@ namespace Ingenuity {
class Controller;
class OmPort;
class OmPatchPort;
-//class ControlPanel;
class OmModule;
class OmPortModule;
class OmFlowCanvas;
@@ -54,26 +53,22 @@ public:
virtual void destroy();
virtual void create_module(OmFlowCanvas* canvas);
+ virtual void destroy_module();
OmPortModule* module() { return m_module; }
-/*
- virtual void add_to_store();
- virtual void remove_from_store();
-*/
+
virtual void metadata_update(const string& key, const string& value);
void create_port(OmModule* module);
+ void destroy_port();
+
void set_path(const Path& new_path);
- //ControlPanel* control_panel() const { return m_control_panel; }
- //void set_control_panel(ControlPanel* cp);
-
CountedPtr<PortModel> port_model() const { return m_model; }
private:
OmPatchPort* m_patch_port; ///< Port on m_module
OmPortModule* m_module; ///< Port pseudo-module (for patch ports only)
OmPort* m_port; ///< Port on some other canvas module
- //ControlPanel* m_control_panel; ///< Control panel that contains this port
};
diff --git a/src/progs/ingenuity/SubpatchModule.cpp b/src/progs/ingenuity/SubpatchModule.cpp
index 36fecff3..d0492618 100644
--- a/src/progs/ingenuity/SubpatchModule.cpp
+++ b/src/progs/ingenuity/SubpatchModule.cpp
@@ -41,18 +41,6 @@ SubpatchModule::SubpatchModule(OmFlowCanvas* canvas, PatchController* patch)
void
-SubpatchModule::add_om_port(PortModel* pm, bool resize_to_fit)
-{
- OmPort* port = new OmPort(this, pm);
-
- port->signal_event().connect(
- sigc::bind<Port*>(sigc::mem_fun(m_canvas, &OmFlowCanvas::port_event), port));
-
- Module::add_port(port, resize_to_fit);
-}
-
-
-void
SubpatchModule::on_double_click(GdkEventButton* event)
{
assert(m_patch != NULL);
diff --git a/src/progs/ingenuity/SubpatchModule.h b/src/progs/ingenuity/SubpatchModule.h
index 13d3d2f7..c530311e 100644
--- a/src/progs/ingenuity/SubpatchModule.h
+++ b/src/progs/ingenuity/SubpatchModule.h
@@ -49,8 +49,6 @@ public:
SubpatchModule(OmFlowCanvas* canvas, PatchController* controller);
virtual ~SubpatchModule() {}
- void add_om_port(PortModel* pm, bool resize=true);
-
void on_double_click(GdkEventButton* ev);
void show_dialog();