summaryrefslogtreecommitdiffstats
path: root/src/libs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/client/ClientStore.cpp648
-rw-r--r--src/libs/client/ClientStore.hpp151
-rw-r--r--src/libs/client/ConnectionModel.hpp76
-rw-r--r--src/libs/client/DeprecatedLoader.cpp711
-rw-r--r--src/libs/client/DeprecatedLoader.hpp94
-rw-r--r--src/libs/client/HTTPClientReceiver.cpp97
-rw-r--r--src/libs/client/HTTPClientReceiver.hpp62
-rw-r--r--src/libs/client/HTTPEngineSender.cpp285
-rw-r--r--src/libs/client/HTTPEngineSender.hpp155
-rw-r--r--src/libs/client/Makefile.am69
-rw-r--r--src/libs/client/NodeModel.cpp224
-rw-r--r--src/libs/client/NodeModel.hpp101
-rw-r--r--src/libs/client/OSCClientReceiver.cpp394
-rw-r--r--src/libs/client/OSCClientReceiver.hpp107
-rw-r--r--src/libs/client/OSCEngineSender.cpp420
-rw-r--r--src/libs/client/OSCEngineSender.hpp154
-rw-r--r--src/libs/client/ObjectModel.cpp148
-rw-r--r--src/libs/client/ObjectModel.hpp115
-rw-r--r--src/libs/client/PatchModel.cpp190
-rw-r--r--src/libs/client/PatchModel.hpp105
-rw-r--r--src/libs/client/PluginModel.cpp143
-rw-r--r--src/libs/client/PluginModel.hpp142
-rw-r--r--src/libs/client/PluginUI.cpp157
-rw-r--r--src/libs/client/PluginUI.hpp65
-rw-r--r--src/libs/client/PortModel.cpp66
-rw-r--r--src/libs/client/PortModel.hpp112
-rw-r--r--src/libs/client/SigClientInterface.hpp156
-rw-r--r--src/libs/client/ThreadedSigClientInterface.cpp78
-rw-r--r--src/libs/client/ThreadedSigClientInterface.hpp184
-rw-r--r--src/libs/client/client.cpp57
-rw-r--r--src/libs/client/client.hpp43
-rw-r--r--src/libs/client/wscript35
-rw-r--r--src/libs/engine/AudioBuffer.cpp299
-rw-r--r--src/libs/engine/AudioBuffer.hpp84
-rw-r--r--src/libs/engine/AudioDriver.hpp62
-rw-r--r--src/libs/engine/Buffer.cpp38
-rw-r--r--src/libs/engine/Buffer.hpp76
-rw-r--r--src/libs/engine/ClientBroadcaster.cpp271
-rw-r--r--src/libs/engine/ClientBroadcaster.hpp97
-rw-r--r--src/libs/engine/CompiledPatch.hpp83
-rw-r--r--src/libs/engine/ConnectionImpl.cpp185
-rw-r--r--src/libs/engine/ConnectionImpl.hpp101
-rw-r--r--src/libs/engine/Context.hpp51
-rw-r--r--src/libs/engine/Driver.hpp98
-rw-r--r--src/libs/engine/DuplexPort.cpp108
-rw-r--r--src/libs/engine/DuplexPort.hpp68
-rw-r--r--src/libs/engine/Engine.cpp317
-rw-r--r--src/libs/engine/Engine.hpp130
-rw-r--r--src/libs/engine/EngineStore.cpp182
-rw-r--r--src/libs/engine/EngineStore.hpp68
-rw-r--r--src/libs/engine/Event.cpp49
-rw-r--r--src/libs/engine/Event.hpp75
-rw-r--r--src/libs/engine/EventBuffer.cpp318
-rw-r--r--src/libs/engine/EventBuffer.hpp104
-rw-r--r--src/libs/engine/EventSink.cpp74
-rw-r--r--src/libs/engine/EventSink.hpp64
-rw-r--r--src/libs/engine/EventSource.hpp60
-rw-r--r--src/libs/engine/GraphObjectImpl.cpp39
-rw-r--r--src/libs/engine/GraphObjectImpl.hpp132
-rw-r--r--src/libs/engine/HTTPEngineReceiver.cpp207
-rw-r--r--src/libs/engine/HTTPEngineReceiver.hpp59
-rw-r--r--src/libs/engine/InputPort.cpp297
-rw-r--r--src/libs/engine/InputPort.hpp88
-rw-r--r--src/libs/engine/InternalPlugin.cpp55
-rw-r--r--src/libs/engine/InternalPlugin.hpp74
-rw-r--r--src/libs/engine/JackAudioDriver.cpp384
-rw-r--r--src/libs/engine/JackAudioDriver.hpp185
-rw-r--r--src/libs/engine/JackMidiDriver.cpp267
-rw-r--r--src/libs/engine/JackMidiDriver.hpp113
-rw-r--r--src/libs/engine/LADSPANode.cpp373
-rw-r--r--src/libs/engine/LADSPANode.hpp74
-rw-r--r--src/libs/engine/LADSPAPlugin.cpp79
-rw-r--r--src/libs/engine/LADSPAPlugin.hpp78
-rw-r--r--src/libs/engine/LV2Info.cpp70
-rw-r--r--src/libs/engine/LV2Info.hpp66
-rw-r--r--src/libs/engine/LV2Node.cpp305
-rw-r--r--src/libs/engine/LV2Node.hpp75
-rw-r--r--src/libs/engine/LV2Plugin.cpp94
-rw-r--r--src/libs/engine/LV2Plugin.hpp84
-rw-r--r--src/libs/engine/Makefile.am205
-rw-r--r--src/libs/engine/MessageContext.cpp32
-rw-r--r--src/libs/engine/MessageContext.hpp51
-rw-r--r--src/libs/engine/MidiControlNode.cpp141
-rw-r--r--src/libs/engine/MidiControlNode.hpp65
-rw-r--r--src/libs/engine/MidiDriver.hpp100
-rw-r--r--src/libs/engine/MidiNoteNode.cpp390
-rw-r--r--src/libs/engine/MidiNoteNode.hpp88
-rw-r--r--src/libs/engine/MidiTriggerNode.cpp135
-rw-r--r--src/libs/engine/MidiTriggerNode.hpp61
-rw-r--r--src/libs/engine/NodeBase.cpp230
-rw-r--r--src/libs/engine/NodeBase.hpp132
-rw-r--r--src/libs/engine/NodeFactory.cpp285
-rw-r--r--src/libs/engine/NodeFactory.hpp92
-rw-r--r--src/libs/engine/NodeImpl.hpp170
-rw-r--r--src/libs/engine/OSCClientSender.cpp358
-rw-r--r--src/libs/engine/OSCClientSender.hpp136
-rw-r--r--src/libs/engine/OSCDriver.hpp82
-rw-r--r--src/libs/engine/OSCEngineReceiver.cpp884
-rw-r--r--src/libs/engine/OSCEngineReceiver.hpp129
-rw-r--r--src/libs/engine/ObjectSender.cpp150
-rw-r--r--src/libs/engine/ObjectSender.hpp57
-rw-r--r--src/libs/engine/OmInProcess.cpp66
-rw-r--r--src/libs/engine/OutputPort.cpp62
-rw-r--r--src/libs/engine/OutputPort.hpp63
-rw-r--r--src/libs/engine/PatchImpl.cpp481
-rw-r--r--src/libs/engine/PatchImpl.hpp168
-rw-r--r--src/libs/engine/PatchPlugin.hpp64
-rw-r--r--src/libs/engine/PluginImpl.cpp54
-rw-r--r--src/libs/engine/PluginImpl.hpp106
-rw-r--r--src/libs/engine/PortImpl.cpp190
-rw-r--r--src/libs/engine/PortImpl.hpp147
-rw-r--r--src/libs/engine/PostProcessor.cpp73
-rw-r--r--src/libs/engine/PostProcessor.hpp73
-rw-r--r--src/libs/engine/ProcessContext.hpp71
-rw-r--r--src/libs/engine/ProcessSlave.cpp75
-rw-r--r--src/libs/engine/ProcessSlave.hpp100
-rw-r--r--src/libs/engine/QueuedEngineInterface.cpp370
-rw-r--r--src/libs/engine/QueuedEngineInterface.hpp170
-rw-r--r--src/libs/engine/QueuedEvent.cpp50
-rw-r--r--src/libs/engine/QueuedEvent.hpp83
-rw-r--r--src/libs/engine/QueuedEventSource.cpp183
-rw-r--r--src/libs/engine/QueuedEventSource.hpp128
-rw-r--r--src/libs/engine/Responder.hpp71
-rw-r--r--src/libs/engine/ThreadManager.hpp43
-rw-r--r--src/libs/engine/TransportNode.cpp154
-rw-r--r--src/libs/engine/TransportNode.hpp45
-rw-r--r--src/libs/engine/engine.cpp56
-rw-r--r--src/libs/engine/engine.hpp42
-rw-r--r--src/libs/engine/events.hpp53
-rw-r--r--src/libs/engine/events/AllNotesOffEvent.cpp71
-rw-r--r--src/libs/engine/events/AllNotesOffEvent.hpp51
-rw-r--r--src/libs/engine/events/ClearPatchEvent.cpp133
-rw-r--r--src/libs/engine/events/ClearPatchEvent.hpp65
-rw-r--r--src/libs/engine/events/ConnectionEvent.cpp202
-rw-r--r--src/libs/engine/events/ConnectionEvent.hpp92
-rw-r--r--src/libs/engine/events/CreateNodeEvent.cpp151
-rw-r--r--src/libs/engine/events/CreateNodeEvent.hpp81
-rw-r--r--src/libs/engine/events/CreatePatchEvent.cpp157
-rw-r--r--src/libs/engine/events/CreatePatchEvent.hpp64
-rw-r--r--src/libs/engine/events/CreatePortEvent.cpp173
-rw-r--r--src/libs/engine/events/CreatePortEvent.hpp72
-rw-r--r--src/libs/engine/events/DeactivateEvent.cpp54
-rw-r--r--src/libs/engine/events/DeactivateEvent.hpp43
-rw-r--r--src/libs/engine/events/DestroyEvent.cpp201
-rw-r--r--src/libs/engine/events/DestroyEvent.hpp77
-rw-r--r--src/libs/engine/events/DisablePortMonitoringEvent.cpp87
-rw-r--r--src/libs/engine/events/DisablePortMonitoringEvent.hpp58
-rw-r--r--src/libs/engine/events/DisconnectAllEvent.cpp183
-rw-r--r--src/libs/engine/events/DisconnectAllEvent.hpp79
-rw-r--r--src/libs/engine/events/DisconnectionEvent.cpp213
-rw-r--r--src/libs/engine/events/DisconnectionEvent.hpp90
-rw-r--r--src/libs/engine/events/EnablePatchEvent.cpp86
-rw-r--r--src/libs/engine/events/EnablePatchEvent.hpp63
-rw-r--r--src/libs/engine/events/LoadPluginsEvent.cpp56
-rw-r--r--src/libs/engine/events/LoadPluginsEvent.hpp46
-rw-r--r--src/libs/engine/events/Makefile.am63
-rw-r--r--src/libs/engine/events/MidiLearnEvent.cpp89
-rw-r--r--src/libs/engine/events/MidiLearnEvent.hpp85
-rw-r--r--src/libs/engine/events/NoteEvent.cpp102
-rw-r--r--src/libs/engine/events/NoteEvent.hpp68
-rw-r--r--src/libs/engine/events/PingQueuedEvent.hpp48
-rw-r--r--src/libs/engine/events/RegisterClientEvent.cpp55
-rw-r--r--src/libs/engine/events/RegisterClientEvent.hpp55
-rw-r--r--src/libs/engine/events/RenameEvent.cpp152
-rw-r--r--src/libs/engine/events/RenameEvent.hpp64
-rw-r--r--src/libs/engine/events/RequestAllObjectsEvent.cpp59
-rw-r--r--src/libs/engine/events/RequestAllObjectsEvent.hpp48
-rw-r--r--src/libs/engine/events/RequestMetadataEvent.cpp85
-rw-r--r--src/libs/engine/events/RequestMetadataEvent.hpp62
-rw-r--r--src/libs/engine/events/RequestObjectEvent.cpp98
-rw-r--r--src/libs/engine/events/RequestObjectEvent.hpp55
-rw-r--r--src/libs/engine/events/RequestPluginEvent.cpp79
-rw-r--r--src/libs/engine/events/RequestPluginEvent.hpp53
-rw-r--r--src/libs/engine/events/RequestPluginsEvent.cpp57
-rw-r--r--src/libs/engine/events/RequestPluginsEvent.hpp47
-rw-r--r--src/libs/engine/events/RequestPortValueEvent.cpp81
-rw-r--r--src/libs/engine/events/RequestPortValueEvent.hpp56
-rw-r--r--src/libs/engine/events/SendPortActivityEvent.cpp34
-rw-r--r--src/libs/engine/events/SendPortActivityEvent.hpp67
-rw-r--r--src/libs/engine/events/SendPortValueEvent.cpp43
-rw-r--r--src/libs/engine/events/SendPortValueEvent.hpp78
-rw-r--r--src/libs/engine/events/SetMetadataEvent.cpp114
-rw-r--r--src/libs/engine/events/SetMetadataEvent.hpp65
-rw-r--r--src/libs/engine/events/SetPolyphonicEvent.cpp82
-rw-r--r--src/libs/engine/events/SetPolyphonicEvent.hpp56
-rw-r--r--src/libs/engine/events/SetPolyphonyEvent.cpp79
-rw-r--r--src/libs/engine/events/SetPolyphonyEvent.hpp56
-rw-r--r--src/libs/engine/events/SetPortValueEvent.cpp224
-rw-r--r--src/libs/engine/events/SetPortValueEvent.hpp80
-rw-r--r--src/libs/engine/events/UnregisterClientEvent.cpp45
-rw-r--r--src/libs/engine/events/UnregisterClientEvent.hpp54
-rw-r--r--src/libs/engine/jack_compat.h56
l---------src/libs/engine/lv2_contexts.h1
-rw-r--r--src/libs/engine/tuning.hpp39
-rw-r--r--src/libs/engine/types.hpp33
-rw-r--r--src/libs/engine/util.hpp78
-rw-r--r--src/libs/engine/wscript73
-rw-r--r--src/libs/gui/App.cpp440
-rw-r--r--src/libs/gui/App.hpp173
-rw-r--r--src/libs/gui/BreadCrumb.hpp81
-rw-r--r--src/libs/gui/BreadCrumbBox.cpp210
-rw-r--r--src/libs/gui/BreadCrumbBox.hpp70
-rw-r--r--src/libs/gui/Configuration.cpp109
-rw-r--r--src/libs/gui/Configuration.hpp80
-rw-r--r--src/libs/gui/ConnectWindow.cpp458
-rw-r--r--src/libs/gui/ConnectWindow.hpp105
-rw-r--r--src/libs/gui/Connection.hpp60
-rw-r--r--src/libs/gui/ControlPanel.cpp269
-rw-r--r--src/libs/gui/ControlPanel.hpp91
-rw-r--r--src/libs/gui/Controls.cpp467
-rw-r--r--src/libs/gui/Controls.hpp164
-rw-r--r--src/libs/gui/GladeFactory.cpp76
-rw-r--r--src/libs/gui/GladeFactory.hpp47
-rw-r--r--src/libs/gui/LoadPatchWindow.cpp153
-rw-r--r--src/libs/gui/LoadPatchWindow.hpp82
-rw-r--r--src/libs/gui/LoadPluginWindow.cpp464
-rw-r--r--src/libs/gui/LoadPluginWindow.hpp155
-rw-r--r--src/libs/gui/LoadRemotePatchWindow.cpp164
-rw-r--r--src/libs/gui/LoadRemotePatchWindow.hpp94
-rw-r--r--src/libs/gui/LoadSubpatchWindow.cpp187
-rw-r--r--src/libs/gui/LoadSubpatchWindow.hpp80
-rw-r--r--src/libs/gui/Makefile.am125
-rw-r--r--src/libs/gui/MessagesWindow.cpp67
-rw-r--r--src/libs/gui/MessagesWindow.hpp58
-rw-r--r--src/libs/gui/NewSubpatchWindow.cpp113
-rw-r--r--src/libs/gui/NewSubpatchWindow.hpp68
-rw-r--r--src/libs/gui/NodeControlWindow.cpp139
-rw-r--r--src/libs/gui/NodeControlWindow.hpp76
-rw-r--r--src/libs/gui/NodeMenu.cpp169
-rw-r--r--src/libs/gui/NodeMenu.hpp72
-rw-r--r--src/libs/gui/NodeModule.cpp386
-rw-r--r--src/libs/gui/NodeModule.hpp102
-rw-r--r--src/libs/gui/NodePropertiesWindow.cpp66
-rw-r--r--src/libs/gui/NodePropertiesWindow.hpp58
-rw-r--r--src/libs/gui/ObjectMenu.cpp112
-rw-r--r--src/libs/gui/ObjectMenu.hpp69
-rw-r--r--src/libs/gui/PatchCanvas.cpp773
-rw-r--r--src/libs/gui/PatchCanvas.hpp155
-rw-r--r--src/libs/gui/PatchPortModule.cpp158
-rw-r--r--src/libs/gui/PatchPortModule.hpp79
-rw-r--r--src/libs/gui/PatchPropertiesWindow.cpp92
-rw-r--r--src/libs/gui/PatchPropertiesWindow.hpp64
-rw-r--r--src/libs/gui/PatchTreeWindow.cpp243
-rw-r--r--src/libs/gui/PatchTreeWindow.hpp111
-rw-r--r--src/libs/gui/PatchView.cpp194
-rw-r--r--src/libs/gui/PatchView.hpp105
-rw-r--r--src/libs/gui/PatchWindow.cpp556
-rw-r--r--src/libs/gui/PatchWindow.hpp155
-rw-r--r--src/libs/gui/Port.cpp151
-rw-r--r--src/libs/gui/Port.hpp70
-rw-r--r--src/libs/gui/PortMenu.cpp69
-rw-r--r--src/libs/gui/PortMenu.hpp55
-rw-r--r--src/libs/gui/PortPropertiesWindow.cpp156
-rw-r--r--src/libs/gui/PortPropertiesWindow.hpp68
-rw-r--r--src/libs/gui/RenameWindow.cpp119
-rw-r--r--src/libs/gui/RenameWindow.hpp60
-rw-r--r--src/libs/gui/SubpatchModule.cpp95
-rw-r--r--src/libs/gui/SubpatchModule.hpp71
-rw-r--r--src/libs/gui/ThreadedLoader.cpp155
-rw-r--r--src/libs/gui/ThreadedLoader.hpp92
-rw-r--r--src/libs/gui/UploadPatchWindow.cpp282
-rw-r--r--src/libs/gui/UploadPatchWindow.hpp104
-rw-r--r--src/libs/gui/WindowFactory.cpp381
-rw-r--r--src/libs/gui/WindowFactory.hpp109
-rw-r--r--src/libs/gui/cmdline.h86
-rw-r--r--src/libs/gui/gui.cpp35
-rw-r--r--src/libs/gui/gui.hpp45
-rw-r--r--src/libs/gui/ingen-icon.svg54
-rw-r--r--src/libs/gui/ingen.svg54
-rw-r--r--src/libs/gui/ingen_gui.glade3337
-rw-r--r--src/libs/gui/ingen_gui.gladep9
-rw-r--r--src/libs/gui/wscript65
-rw-r--r--src/libs/module/Makefile.am22
-rw-r--r--src/libs/module/Module.cpp90
-rw-r--r--src/libs/module/Module.hpp35
-rw-r--r--src/libs/module/World.hpp78
-rw-r--r--src/libs/module/global.cpp74
-rw-r--r--src/libs/module/global.hpp33
-rw-r--r--src/libs/module/wscript17
-rw-r--r--src/libs/serialisation/Makefile.am24
-rw-r--r--src/libs/serialisation/Parser.cpp587
-rw-r--r--src/libs/serialisation/Parser.hpp126
-rw-r--r--src/libs/serialisation/Serialiser.cpp501
-rw-r--r--src/libs/serialisation/Serialiser.hpp109
-rw-r--r--src/libs/serialisation/serialisation.cpp46
-rw-r--r--src/libs/serialisation/serialisation.hpp44
-rw-r--r--src/libs/serialisation/wscript16
-rw-r--r--src/libs/shared/Builder.cpp98
-rw-r--r--src/libs/shared/Builder.hpp57
-rw-r--r--src/libs/shared/ClashAvoider.cpp214
-rw-r--r--src/libs/shared/ClashAvoider.hpp108
-rw-r--r--src/libs/shared/LV2Features.cpp66
-rw-r--r--src/libs/shared/LV2Features.hpp63
-rw-r--r--src/libs/shared/LV2URIMap.cpp75
-rw-r--r--src/libs/shared/LV2URIMap.hpp64
-rw-r--r--src/libs/shared/Makefile.am22
-rw-r--r--src/libs/shared/OSCSender.cpp125
-rw-r--r--src/libs/shared/OSCSender.hpp59
-rw-r--r--src/libs/shared/Store.cpp108
-rw-r--r--src/libs/shared/Store.hpp60
-rw-r--r--src/libs/shared/wscript19
301 files changed, 0 insertions, 41890 deletions
diff --git a/src/libs/client/ClientStore.cpp b/src/libs/client/ClientStore.cpp
deleted file mode 100644
index 18582046..00000000
--- a/src/libs/client/ClientStore.cpp
+++ /dev/null
@@ -1,648 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <raul/PathTable.hpp>
-#include "ClientStore.hpp"
-#include "ObjectModel.hpp"
-#include "PatchModel.hpp"
-#include "NodeModel.hpp"
-#include "PortModel.hpp"
-#include "PluginModel.hpp"
-#include "PatchModel.hpp"
-#include "SigClientInterface.hpp"
-
-using namespace std;
-using namespace Raul;
-
-namespace Ingen {
-namespace Client {
-
-
-ClientStore::ClientStore(SharedPtr<EngineInterface> engine, SharedPtr<SigClientInterface> emitter)
- : _engine(engine)
- , _emitter(emitter)
- , _plugins(new Plugins())
-{
- _handle_orphans = (engine && emitter);
-
- if (!emitter)
- return;
-
- emitter->signal_object_destroyed.connect(sigc::mem_fun(this, &ClientStore::destroy));
- emitter->signal_object_renamed.connect(sigc::mem_fun(this, &ClientStore::rename));
- emitter->signal_new_plugin.connect(sigc::mem_fun(this, &ClientStore::new_plugin));
- emitter->signal_new_patch.connect(sigc::mem_fun(this, &ClientStore::new_patch));
- emitter->signal_new_node.connect(sigc::mem_fun(this, &ClientStore::new_node));
- emitter->signal_new_port.connect(sigc::mem_fun(this, &ClientStore::new_port));
- emitter->signal_patch_cleared.connect(sigc::mem_fun(this, &ClientStore::patch_cleared));
- emitter->signal_connection.connect(sigc::mem_fun(this, &ClientStore::connect));
- emitter->signal_disconnection.connect(sigc::mem_fun(this, &ClientStore::disconnect));
- emitter->signal_variable_change.connect(sigc::mem_fun(this, &ClientStore::set_variable));
- emitter->signal_property_change.connect(sigc::mem_fun(this, &ClientStore::set_property));
- emitter->signal_port_value.connect(sigc::mem_fun(this, &ClientStore::set_port_value));
- emitter->signal_voice_value.connect(sigc::mem_fun(this, &ClientStore::set_voice_value));
- emitter->signal_port_activity.connect(sigc::mem_fun(this, &ClientStore::port_activity));
-}
-
-
-void
-ClientStore::clear()
-{
- Store::clear();
- _plugins->clear();
-}
-
-
-void
-ClientStore::add_plugin_orphan(SharedPtr<NodeModel> node)
-{
- if (!_handle_orphans)
- return;
-
- Raul::Table<string, list<SharedPtr<NodeModel> > >::iterator spawn
- = _plugin_orphans.find(node->plugin_uri());
-
- if (spawn != _plugin_orphans.end()) {
- spawn->second.push_back(node);
- } else {
- cerr << "WARNING: Orphans of plugin " << node->plugin_uri() << " received" << endl;
- _engine->request_plugin(node->plugin_uri());
- list<SharedPtr<NodeModel> > l;
- l.push_back(node);
- _plugin_orphans[node->plugin_uri()] = l;
- }
-}
-
-
-void
-ClientStore::resolve_plugin_orphans(SharedPtr<PluginModel> plugin)
-{
- if (!_handle_orphans)
- return;
- Raul::Table<string, list<SharedPtr<NodeModel> > >::iterator n
- = _plugin_orphans.find(plugin->uri());
-
- if (n != _plugin_orphans.end()) {
-
- list<SharedPtr<NodeModel> > spawn = n->second; // take a copy
- cerr << "Missing dependant " << plugin->uri() << " received" << endl;
-
- _plugin_orphans.erase(plugin->uri()); // prevent infinite recursion
-
- for (list<SharedPtr<NodeModel> >::iterator i = spawn.begin();
- i != spawn.end(); ++i) {
- (*i)->_plugin = plugin;
- //add_object(*i);
- }
- }
-}
-
-
-void
-ClientStore::add_connection_orphan(std::pair<Path, Path> orphan)
-{
- // Do this anyway, it's needed to get the connections for copy&paste
- //if (!_handle_orphans)
- //return;
-
- if (_handle_orphans)
- cerr << "WARNING: Orphan connection " << orphan.first
- << " -> " << orphan.second << " received." << endl;
-
- _connection_orphans.push_back(orphan);
-}
-
-
-void
-ClientStore::resolve_connection_orphans(SharedPtr<PortModel> port)
-{
- if (!_handle_orphans)
- return;
- assert(port->parent());
-
- for (list< pair<Path, Path> >::iterator c = _connection_orphans.begin();
- c != _connection_orphans.end(); ) {
-
- list< pair<Path, Path> >::iterator next = c;
- ++next;
-
- if (c->first == port->path() || c->second == port->path()) {
- cerr << "Missing dependant (" << c->first << " -> " << c->second << ") received" << endl;
- bool success = attempt_connection(c->first, c->second);
- if (success)
- _connection_orphans.erase(c);
- }
-
- c = next;
- }
-}
-
-
-void
-ClientStore::add_orphan(SharedPtr<ObjectModel> child)
-{
- if (!_handle_orphans)
- return;
- cerr << "WARNING: Orphan object " << child->path() << " received." << endl;
-
- Raul::PathTable<list<SharedPtr<ObjectModel> > >::iterator children
- = _orphans.find(child->path().parent());
-
- _engine->request_object(child->path().parent());
-
- if (children != _orphans.end()) {
- children->second.push_back(child);
- } else {
- list<SharedPtr<ObjectModel> > l;
- l.push_back(child);
- _orphans.insert(make_pair(child->path().parent(), l));
- }
-}
-
-
-void
-ClientStore::add_variable_orphan(const Path& subject_path, const string& predicate, const Atom& value)
-{
- if (!_handle_orphans)
- return;
- Raul::PathTable<list<std::pair<string, Atom> > >::iterator orphans
- = _variable_orphans.find(subject_path);
-
- _engine->request_object(subject_path);
-
- if (orphans != _variable_orphans.end()) {
- orphans->second.push_back(std::pair<string, Atom>(predicate, value));
- } else {
- list<std::pair<string, Atom> > l;
- l.push_back(std::pair<string, Atom>(predicate, value));
- _variable_orphans[subject_path] = l;
- }
-}
-
-
-void
-ClientStore::resolve_variable_orphans(SharedPtr<ObjectModel> subject)
-{
- if (!_handle_orphans)
- return;
- Raul::PathTable<list<std::pair<string, Atom> > >::iterator v
- = _variable_orphans.find(subject->path());
-
- if (v != _variable_orphans.end()) {
-
- list<std::pair<string, Atom> > values = v->second; // take a copy
-
- _variable_orphans.erase(subject->path());
- cerr << "Missing dependant " << subject->path() << " received" << endl;
-
- for (list<std::pair<string, Atom> >::iterator i = values.begin();
- i != values.end(); ++i) {
- subject->set_variable(i->first, i->second);
- }
- }
-}
-
-
-void
-ClientStore::resolve_orphans(SharedPtr<ObjectModel> parent)
-{
- if (!_handle_orphans)
- return;
- Raul::PathTable<list<SharedPtr<ObjectModel> > >::iterator c
- = _orphans.find(parent->path());
-
- if (c != _orphans.end()) {
-
- list<SharedPtr<ObjectModel> > children = c->second; // take a copy
-
- _orphans.erase(parent->path()); // prevent infinite recursion
-
- for (list<SharedPtr<ObjectModel> >::iterator i = children.begin();
- i != children.end(); ++i) {
- add_object(*i);
- }
- }
-}
-
-
-void
-ClientStore::add_object(SharedPtr<ObjectModel> object)
-{
- // If we already have "this" object, merge the existing one into the new
- // one (with precedence to the new values).
- iterator existing = find(object->path());
- if (existing != end()) {
- PtrCast<ObjectModel>(existing->second)->set(object);
- } else {
-
- if (object->path() != "/") {
- SharedPtr<ObjectModel> parent = this->object(object->path().parent());
- if (parent) {
- assert(object->path().is_child_of(parent->path()));
- object->set_parent(parent);
- parent->add_child(object);
- assert(parent && (object->parent() == parent));
-
- (*this)[object->path()] = object;
- signal_new_object.emit(object);
-
- resolve_variable_orphans(parent);
- resolve_orphans(parent);
-
- SharedPtr<PortModel> port = PtrCast<PortModel>(object);
- if (port)
- resolve_connection_orphans(port);
-
- } else {
- add_orphan(object);
- }
- } else {
- (*this)[object->path()] = object;
- signal_new_object.emit(object);
- }
-
- }
-
- /*cout << "[Store] Added " << object->path() << " {" << endl;
- for (iterator i = begin(); i != end(); ++i) {
- cout << "\t" << i->first << endl;
- }
- cout << "}" << endl;*/
-}
-
-
-SharedPtr<ObjectModel>
-ClientStore::remove_object(const Path& path)
-{
- iterator i = find(path);
-
- if (i != end()) {
- assert((*i).second->path() == path);
- SharedPtr<ObjectModel> result = PtrCast<ObjectModel>((*i).second);
- assert(result);
- //erase(i);
- iterator descendants_end = find_descendants_end(i);
- SharedPtr<Store::Objects> removed = yank(i, descendants_end);
-
- /*cout << "[Store] Removing " << i->first << " {" << endl;
- for (iterator i = removed.begin(); i != removed.end(); ++i) {
- cout << "\t" << i->first << endl;
- }
- cout << "}" << endl;*/
-
- if (result)
- result->signal_destroyed.emit();
-
- if (result->path() != "/") {
- assert(result->parent());
-
- SharedPtr<ObjectModel> parent = this->object(result->path().parent());
- if (parent) {
- parent->remove_child(result);
- }
- }
-
- assert(!object(path));
-
- return result;
-
- } else {
- return SharedPtr<ObjectModel>();
- }
-}
-
-
-SharedPtr<PluginModel>
-ClientStore::plugin(const string& uri)
-{
- assert(uri.length() > 0);
- Plugins::iterator i = _plugins->find(uri);
- if (i == _plugins->end())
- return SharedPtr<PluginModel>();
- else
- return (*i).second;
-}
-
-
-SharedPtr<ObjectModel>
-ClientStore::object(const Path& path)
-{
- assert(path.length() > 0);
- iterator i = find(path);
- if (i == end()) {
- return SharedPtr<ObjectModel>();
- } else {
- SharedPtr<ObjectModel> model = PtrCast<ObjectModel>(i->second);
- assert(model);
- assert(model->path() == "/" || model->parent());
- return model;
- }
-}
-
-void
-ClientStore::add_plugin(SharedPtr<PluginModel> pm)
-{
- // FIXME: dupes? merge, like with objects?
-
- (*_plugins)[pm->uri()] = pm;
- signal_new_plugin(pm);
- //cerr << "Plugin: " << pm->uri() << ", # plugins: " << _plugins->size() << endl;
-}
-
-
-/* ****** Signal Handlers ******** */
-
-
-void
-ClientStore::destroy(const std::string& path)
-{
- SharedPtr<ObjectModel> removed = remove_object(path);
- removed.reset();
- //cerr << "[ClientStore] removed object " << path << ", count: " << removed.use_count();
-}
-
-void
-ClientStore::rename(const Path& old_path, const Path& new_path)
-{
- iterator parent = find(old_path);
- if (parent == end()) {
- cerr << "[Store] Failed to find object " << old_path << " to rename." << endl;
- return;
- }
-
- iterator descendants_end = find_descendants_end(parent);
-
- SharedPtr< Table<Path, SharedPtr<Shared::GraphObject> > > removed
- = yank(parent, descendants_end);
-
- assert(removed->size() > 0);
-
- for (Table<Path, SharedPtr<Shared::GraphObject> >::iterator i = removed->begin(); i != removed->end(); ++i) {
- const Path& child_old_path = i->first;
- assert(Path::descendant_comparator(old_path, child_old_path));
-
- Path child_new_path;
- if (child_old_path == old_path)
- child_new_path = new_path;
- else
- child_new_path = new_path.base() + child_old_path.substr(old_path.length()+1);
-
- cerr << "[Store] Renamed " << child_old_path << " -> " << child_new_path << endl;
- PtrCast<ObjectModel>(i->second)->set_path(child_new_path);
- i->first = child_new_path;
- }
-
- cram(*removed.get());
-
- //cerr << "[Store] Table:" << endl;
- //for (size_t i=0; i < removed.size(); ++i) {
- // cerr << removed[i].first << "\t\t: " << removed[i].second << endl;
- //}
- /*for (iterator i = begin(); i != end(); ++i) {
- cerr << i->first << "\t\t: " << i->second << endl;
- }*/
-}
-
-void
-ClientStore::new_plugin(const string& uri, const string& type_uri, const string& symbol, const string& name)
-{
- SharedPtr<PluginModel> p(new PluginModel(uri, type_uri, symbol, name));
- add_plugin(p);
- resolve_plugin_orphans(p);
-}
-
-
-void
-ClientStore::new_patch(const string& path, uint32_t poly)
-{
- SharedPtr<PatchModel> p(new PatchModel(path, poly));
- add_object(p);
-}
-
-
-void
-ClientStore::new_node(const string& path, const string& plugin_uri)
-{
- SharedPtr<PluginModel> plug = plugin(plugin_uri);
- if (!plug) {
- SharedPtr<NodeModel> n(new NodeModel(plugin_uri, path));
- add_plugin_orphan(n);
- add_object(n);
- } else {
- SharedPtr<NodeModel> n(new NodeModel(plug, path));
- add_object(n);
- }
-}
-
-
-void
-ClientStore::new_port(const string& path, uint32_t index, const string& type, bool is_output)
-{
- PortModel::Direction pdir = is_output ? PortModel::OUTPUT : PortModel::INPUT;
-
- SharedPtr<PortModel> p(new PortModel(path, index, type, pdir));
- add_object(p);
- if (p->parent())
- resolve_connection_orphans(p);
-}
-
-
-void
-ClientStore::patch_cleared(const Path& path)
-{
- iterator i = find(path);
- if (i != end()) {
- assert((*i).second->path() == path);
- SharedPtr<PatchModel> patch = PtrCast<PatchModel>(i->second);
-
- iterator first_descendant = i;
- ++first_descendant;
- iterator descendants_end = find_descendants_end(i);
- SharedPtr< Table<Path, SharedPtr<Shared::GraphObject> > > removed
- = yank(first_descendant, descendants_end);
-
- for (iterator i = removed->begin(); i != removed->end(); ++i) {
- SharedPtr<ObjectModel> model = PtrCast<ObjectModel>(i->second);
- assert(model);
- model->signal_destroyed.emit();
- if (model->parent() == patch)
- patch->remove_child(model);
- }
-
- } else {
- cerr << "[Store] Unable to find patch " << path << " to clear." << endl;
- }
-}
-
-
-void
-ClientStore::set_variable(const string& subject_path, const string& predicate, const Atom& value)
-{
- SharedPtr<ObjectModel> subject = object(subject_path);
-
- if (!value.is_valid()) {
- cerr << "ERROR: variable '" << predicate << "' has no type" << endl;
- } else if (subject) {
- subject->set_variable(predicate, value);
- } else {
- add_variable_orphan(subject_path, predicate, value);
- cerr << "WARNING: variable for unknown object " << subject_path << endl;
- }
-}
-
-
-void
-ClientStore::set_property(const string& subject_path, const string& predicate, const Atom& value)
-{
- SharedPtr<ObjectModel> subject = object(subject_path);
-
- if (!value.is_valid()) {
- cerr << "ERROR: property '" << predicate << "' has no type" << endl;
- } else if (subject) {
- subject->set_property(predicate, value);
- } else {
- cerr << "WARNING: property for unknown object " << subject_path
- << " lost. Client must refresh!" << endl;
- }
-}
-
-
-void
-ClientStore::set_port_value(const string& port_path, const Raul::Atom& value)
-{
- SharedPtr<PortModel> port = PtrCast<PortModel>(object(port_path));
- if (port)
- port->value(value);
- else
- cerr << "ERROR: control change for nonexistant port " << port_path << endl;
-}
-
-
-void
-ClientStore::set_voice_value(const string& port_path, uint32_t voice, const Raul::Atom& value)
-{
- SharedPtr<PortModel> port = PtrCast<PortModel>(object(port_path));
- if (port)
- port->value(voice, value);
- else
- cerr << "ERROR: poly control change for nonexistant port " << port_path << endl;
-}
-
-
-void
-ClientStore::port_activity(const Path& port_path)
-{
- SharedPtr<PortModel> port = PtrCast<PortModel>(object(port_path));
- if (port)
- port->signal_activity.emit();
- else
- cerr << "ERROR: activity for nonexistant port " << port_path << endl;
-}
-
-
-SharedPtr<PatchModel>
-ClientStore::connection_patch(const Path& src_port_path, const Path& dst_port_path)
-{
- SharedPtr<PatchModel> patch;
-
- if (src_port_path.parent() == dst_port_path.parent())
- patch = PtrCast<PatchModel>(this->object(src_port_path.parent()));
-
- if (!patch && src_port_path.parent() == dst_port_path.parent().parent())
- patch = PtrCast<PatchModel>(this->object(src_port_path.parent()));
-
- if (!patch && src_port_path.parent().parent() == dst_port_path.parent())
- patch = PtrCast<PatchModel>(this->object(dst_port_path.parent()));
-
- if (!patch)
- patch = PtrCast<PatchModel>(this->object(src_port_path.parent().parent()));
-
- if (!patch)
- cerr << "ERROR: Unable to find connection patch " << src_port_path
- << " -> " << dst_port_path << endl;
-
- return patch;
-}
-
-
-bool
-ClientStore::attempt_connection(const Path& src_port_path, const Path& dst_port_path, bool add_orphan)
-{
- SharedPtr<PortModel> src_port = PtrCast<PortModel>(object(src_port_path));
- SharedPtr<PortModel> dst_port = PtrCast<PortModel>(object(dst_port_path));
-
- if (src_port && dst_port) {
- assert(src_port->parent());
- assert(dst_port->parent());
-
- SharedPtr<PatchModel> patch = connection_patch(src_port_path, dst_port_path);
- assert(patch);
-
- SharedPtr<ConnectionModel> cm(new ConnectionModel(src_port, dst_port));
-
- src_port->connected_to(dst_port);
- dst_port->connected_to(src_port);
-
- patch->add_connection(cm);
- return true;
- } else if (add_orphan) {
- add_connection_orphan(make_pair(src_port_path, dst_port_path));
- }
-
- return false;
-}
-
-
-void
-ClientStore::connect(const string& src_port_path, const string& dst_port_path)
-{
- attempt_connection(src_port_path, dst_port_path, true);
-}
-
-
-void
-ClientStore::disconnect(const string& src_port_path, const string& dst_port_path)
-{
- // Find the ports and create a ConnectionModel just to get at the parent path
- // finding logic in ConnectionModel. So I'm lazy.
-
- SharedPtr<PortModel> src_port = PtrCast<PortModel>(object(src_port_path));
- SharedPtr<PortModel> dst_port = PtrCast<PortModel>(object(dst_port_path));
-
- if (src_port)
- src_port->disconnected_from(dst_port);
- else
- cerr << "WARNING: Disconnection from nonexistant src port " << src_port_path << endl;
-
- if (dst_port)
- dst_port->disconnected_from(dst_port);
- else
- cerr << "WARNING: Disconnection from nonexistant dst port " << dst_port_path << endl;
-
- SharedPtr<PatchModel> patch = connection_patch(src_port_path, dst_port_path);
-
- if (patch)
- patch->remove_connection(src_port_path, dst_port_path);
- else
- cerr << "ERROR: disconnection in nonexistant patch: "
- << src_port_path << " -> " << dst_port_path << endl;
-}
-
-
-} // namespace Client
-} // namespace Ingen
-
diff --git a/src/libs/client/ClientStore.hpp b/src/libs/client/ClientStore.hpp
deleted file mode 100644
index f08fcd9b..00000000
--- a/src/libs/client/ClientStore.hpp
+++ /dev/null
@@ -1,151 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef CLIENT_STORE_HPP
-#define CLIENT_STORE_HPP
-
-#include <cassert>
-#include <string>
-#include <list>
-#include <raul/SharedPtr.hpp>
-#include <sigc++/sigc++.h>
-#include <raul/Path.hpp>
-#include <raul/Atom.hpp>
-#include <raul/PathTable.hpp>
-#include <raul/TableImpl.hpp>
-#include "interface/EngineInterface.hpp"
-#include "shared/Store.hpp"
-using std::string; using std::list;
-using Ingen::Shared::EngineInterface;
-using Raul::Path;
-using Raul::Atom;
-
-namespace Ingen {
-
-namespace Shared { class GraphObject; }
-
-namespace Client {
-
-class SigClientInterface;
-class ObjectModel;
-class PluginModel;
-class PatchModel;
-class NodeModel;
-class PortModel;
-class ConnectionModel;
-
-
-/** Automatically manages models of objects in the engine.
- *
- * \ingroup IngenClient
- */
-class ClientStore : public Shared::Store, public Shared::CommonInterface, public sigc::trackable {
-public:
- ClientStore(SharedPtr<EngineInterface> engine=SharedPtr<EngineInterface>(),
- SharedPtr<SigClientInterface> emitter=SharedPtr<SigClientInterface>());
-
- SharedPtr<PluginModel> plugin(const string& uri);
- SharedPtr<ObjectModel> object(const Path& path);
-
- void clear();
-
- typedef Raul::Table<string, SharedPtr<PluginModel> > Plugins;
- SharedPtr<const Plugins> plugins() const { return _plugins; }
- SharedPtr<Plugins> plugins() { return _plugins; }
- void set_plugins(SharedPtr<Plugins> p) { _plugins = p; }
-
- // CommonInterface
- void new_plugin(const string& uri, const string& type_uri, const string& symbol, const string& name);
- void new_patch(const string& path, uint32_t poly);
- void new_node(const string& path, const string& plugin_uri);
- void new_port(const string& path, uint32_t index, const string& data_type, bool is_output);
- void set_variable(const string& subject_path, const string& predicate, const Atom& value);
- void set_property(const string& subject_path, const string& predicate, const Atom& value);
- void set_port_value(const string& port_path, const Raul::Atom& value);
- void set_voice_value(const string& port_path, uint32_t voice, const Raul::Atom& value);
- void connect(const string& src_port_path, const string& dst_port_path);
- void disconnect(const string& src_port_path, const string& dst_port_path);
- void destroy(const string& path);
-
- typedef list< std::pair<Path, Path> > ConnectionRecords;
- const ConnectionRecords& connection_records() { return _connection_orphans; }
-
- sigc::signal<void, SharedPtr<ObjectModel> > signal_new_object;
- sigc::signal<void, SharedPtr<PluginModel> > signal_new_plugin;
-
-private:
-
- void add(Shared::GraphObject* o) { throw; }
-
- void add_object(SharedPtr<ObjectModel> object);
- SharedPtr<ObjectModel> remove_object(const Path& path);
-
- void add_plugin(SharedPtr<PluginModel> plugin);
-
- SharedPtr<PatchModel> connection_patch(const Path& src_port_path, const Path& dst_port_path);
-
- // It would be nice to integrate these somehow..
-
- void add_orphan(SharedPtr<ObjectModel> orphan);
- void resolve_orphans(SharedPtr<ObjectModel> parent);
-
- void add_connection_orphan(std::pair<Path, Path> orphan);
- void resolve_connection_orphans(SharedPtr<PortModel> port);
-
- void add_plugin_orphan(SharedPtr<NodeModel> orphan);
- void resolve_plugin_orphans(SharedPtr<PluginModel> plugin);
-
- void add_variable_orphan(const Path& subject, const string& predicate, const Atom& value);
- void resolve_variable_orphans(SharedPtr<ObjectModel> subject);
-
- void bundle_begin() {}
- void bundle_end() {}
-
- // Slots for SigClientInterface signals
- void rename(const Path& old_path, const Path& new_path);
- void patch_cleared(const Path& path);
- void port_activity(const Path& port_path);
-
- bool attempt_connection(const Path& src_port_path, const Path& dst_port_path, bool add_orphan=false);
-
- bool _handle_orphans;
-
- SharedPtr<EngineInterface> _engine;
- SharedPtr<SigClientInterface> _emitter;
-
- SharedPtr<Plugins> _plugins; ///< Map, keyed by plugin URI
-
- /** Objects we've received, but depend on the existance of another unknown object.
- * Keyed by the path of the depended-on object (for tolerance of orderless comms) */
- Raul::PathTable<list<SharedPtr<ObjectModel> > > _orphans;
-
- /** Same idea, except with plugins instead of parents.
- * It's unfortunate everything doesn't just have a URI and this was the same.. ahem.. */
- Raul::Table<string, list<SharedPtr<NodeModel> > > _plugin_orphans;
-
- /** Not orphans OF variable like the above, but orphans which are variable */
- Raul::PathTable<list<std::pair<string, Atom> > > _variable_orphans;
-
- /** Ditto */
- ConnectionRecords _connection_orphans;
-};
-
-
-} // namespace Client
-} // namespace Ingen
-
-#endif // CLIENT_STORE_HPP
diff --git a/src/libs/client/ConnectionModel.hpp b/src/libs/client/ConnectionModel.hpp
deleted file mode 100644
index 91c448df..00000000
--- a/src/libs/client/ConnectionModel.hpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef CONNECTIONMODEL_H
-#define CONNECTIONMODEL_H
-
-#include <cassert>
-#include <string>
-#include <list>
-#include <raul/Path.hpp>
-#include <raul/SharedPtr.hpp>
-#include "interface/Connection.hpp"
-#include "PortModel.hpp"
-
-namespace Ingen {
-namespace Client {
-
-class ClientStore;
-
-
-/** Class to represent a port->port connection in the engine.
- *
- * This can either have pointers to the connection ports' models, or just
- * paths as strings. The engine passes just strings (by necessity), but
- * clients can set the pointers then they don't have to worry about port
- * renaming, as the connections will always return the port's path, even
- * if it changes.
- *
- * \ingroup IngenClient
- */
-class ConnectionModel : public Shared::Connection
-{
-public:
- SharedPtr<PortModel> src_port() const { return _src_port; }
- SharedPtr<PortModel> dst_port() const { return _dst_port; }
-
- const Path src_port_path() const { return _src_port->path(); }
- const Path dst_port_path() const { return _dst_port->path(); }
-
-private:
- friend class ClientStore;
-
- ConnectionModel(SharedPtr<PortModel> src, SharedPtr<PortModel> dst)
- : _src_port(src)
- , _dst_port(dst)
- {
- assert(_src_port);
- assert(_dst_port);
- assert(_src_port->parent());
- assert(_dst_port->parent());
- assert(_src_port->path() != _dst_port->path());
- }
-
- const SharedPtr<PortModel> _src_port;
- const SharedPtr<PortModel> _dst_port;
-};
-
-
-} // namespace Client
-} // namespace Ingen
-
-#endif // CONNECTIONMODEL_H
diff --git a/src/libs/client/DeprecatedLoader.cpp b/src/libs/client/DeprecatedLoader.cpp
deleted file mode 100644
index a07893f7..00000000
--- a/src/libs/client/DeprecatedLoader.cpp
+++ /dev/null
@@ -1,711 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-#include <iostream>
-#include <fstream>
-#include <vector>
-#include <algorithm>
-#include <utility> // for pair, make_pair
-#include <cassert>
-#include <cstring>
-#include <string>
-#include <cstdlib> // for atof
-#include <cmath>
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-#include <libxml/xpath.h>
-#include <raul/Path.hpp>
-#include "interface/EngineInterface.hpp"
-#include "PatchModel.hpp"
-#include "NodeModel.hpp"
-#include "ConnectionModel.hpp"
-#include "PortModel.hpp"
-#include "PluginModel.hpp"
-#include "DeprecatedLoader.hpp"
-
-#define NS_INGEN "http://drobilla.net/ns/ingen#"
-
-using namespace std;
-
-namespace Ingen {
-namespace Client {
-
-
-/** A single port's control setting (in a preset).
- *
- * \ingroup IngenClient
- */
-class ControlModel
-{
-public:
- ControlModel(const Path& port_path, float value)
- : _port_path(port_path)
- , _value(value)
- {
- assert(_port_path.find("//") == string::npos);
- }
-
- const Path& port_path() const { return _port_path; }
- void port_path(const string& p) { _port_path = p; }
- float value() const { return _value; }
- void value(float v) { _value = v; }
-
-private:
- Path _port_path;
- float _value;
-};
-
-
-/** Model of a preset (a collection of control settings).
- *
- * \ingroup IngenClient
- */
-class PresetModel
-{
-public:
- PresetModel(const string& base_path) : _base_path(base_path) {}
-
- /** Add a control value to this preset. An empty string for a node_name
- * means the port is on the patch itself (not a node in the patch). */
- void add_control(const string& node_name, string port_name, float value) {
- if (port_name == "note_number") // FIXME: filthy kludge
- port_name = "note";
-
- if (node_name != "")
- _controls.push_back(ControlModel(_base_path + node_name +"/"+ port_name, value));
- else
- _controls.push_back(ControlModel(_base_path + port_name, value));
- }
-
- const string& name() const { return _name; }
- void name(const string& n) { _name = n; }
-
- const list<ControlModel>& controls() const { return _controls; }
-
-private:
- string _name;
- string _base_path;
- list<ControlModel> _controls;
-};
-
-
-string
-DeprecatedLoader::nameify_if_invalid(const string& name)
-{
- if (Path::is_valid_name(name)) {
- return name;
- } else {
- const string new_name = Path::nameify(name);
- assert(Path::is_valid_name(new_name));
- if (new_name != name)
- cerr << "WARNING: Illegal name '" << name << "' converted to '"
- << new_name << "'" << endl;
- return new_name;
- }
-}
-
-
-string
-DeprecatedLoader::translate_load_path(const string& path)
-{
- std::map<string,string>::iterator t = _load_path_translations.find(path);
-
- if (t != _load_path_translations.end()) {
- assert(Path::is_valid((*t).second));
- return (*t).second;
- // Filthy, filthy kludges
- // (FIXME: apply these less heavy handedly, only when it's an internal module)
- } else if (path.find("midi") != string::npos) {
- assert(Path::is_valid(path));
- if (path.substr(path.find_last_of("/")) == "/MIDI_In")
- return path.substr(0, path.find_last_of("/")) + "/input";
- else if (path.substr(path.find_last_of("/")) == "/Note_Number")
- return path.substr(0, path.find_last_of("/")) + "/note";
- else if (path.substr(path.find_last_of("/")) == "/Gate")
- return path.substr(0, path.find_last_of("/")) + "/gate";
- else if (path.substr(path.find_last_of("/")) == "/Trigger")
- return path.substr(0, path.find_last_of("/")) + "/trigger";
- else if (path.substr(path.find_last_of("/")) == "/Velocity")
- return path.substr(0, path.find_last_of("/")) + "/velocity";
- else
- return path;
- } else {
- return path;
- }
-}
-
-
-/** Add a piece of data to a Variables, translating from deprecated unqualified keys
- *
- * Adds a namespace prefix for known keys, and ignores the rest.
- */
-void
-DeprecatedLoader::add_variable(GraphObject::Variables& data, string old_key, string value)
-{
- string key = "";
- if (old_key == "module-x")
- key = "ingenuity:canvas-x";
- else if (old_key == "module-y")
- key = "ingenuity:canvas-y";
-
- if (key != "") {
- // FIXME: should this overwrite existing values?
- if (data.find(key) == data.end()) {
- // Hack to make module-x and module-y set as floats
- char* c_val = strdup(value.c_str());
- char* endptr = NULL;
-
- // FIXME: locale kludges
- char* locale = strdup(setlocale(LC_NUMERIC, NULL));
-
- float fval = strtof(c_val, &endptr);
-
- setlocale(LC_NUMERIC, locale);
- free(locale);
-
- if (endptr != c_val && *endptr == '\0')
- data[key] = Atom(fval);
- else
- data[key] = Atom(value);
-
- free(c_val);
- }
- }
-}
-
-
-/** Load a patch in to the engine (and client) from a patch file.
- *
- * The name and poly from the passed PatchModel are used. If the name is
- * the empty string, the name will be loaded from the file. If the poly
- * is 0, it will be loaded from file. Otherwise the given values will
- * be used.
- *
- * @param filename Local name of file to load patch from
- *
- * @param parent_path Patch to load this patch as a child of (empty string to load
- * to the root patch)
- *
- * @param name Name of this patch (loaded/generated if the empty string)
- * @param poly Polyphony of this patch (loaded/generated if 0)
- *
- * @param initial_data will be set last, so values passed there will override
- * any values loaded from the patch file.
- *
- * @param existing If true, the patch will be loaded into a currently
- * existing patch (ie a merging will take place). Errors will result
- * if Nodes of conflicting names exist.
- *
- * Returns the path of the newly created patch.
- */
-string
-DeprecatedLoader::load_patch(const Glib::ustring& filename,
- boost::optional<Path> parent_path,
- string name,
- GraphObject::Variables initial_data,
- bool existing)
-{
- cerr << "[DeprecatedLoader] Loading patch " << filename << " under "
- << parent_path << " / " << name << endl;
-
- Path path = parent_path ? (parent_path.get().base() + name)
- : "/" + name;
-
- const bool load_name = (name == "");
-
- size_t poly = 0;
-
- /* Use parameter overridden polyphony, if given */
- GraphObject::Variables::iterator poly_param = initial_data.find("ingen:polyphony");
- if (poly_param != initial_data.end() && poly_param->second.type() == Atom::INT)
- poly = poly_param->second.get_int32();
-
- if (initial_data.find("filename") == initial_data.end())
- initial_data["filename"] = Atom(filename.c_str()); // FIXME: URL?
-
- xmlDocPtr doc = xmlParseFile(filename.c_str());
-
- if (!doc) {
- cerr << "Unable to parse patch file." << endl;
- return "";
- }
-
- xmlNodePtr cur = xmlDocGetRootElement(doc);
-
- if (!cur) {
- cerr << "Empty document." << endl;
- xmlFreeDoc(doc);
- return "";
- }
-
- if (xmlStrcmp(cur->name, (const xmlChar*) "patch")) {
- cerr << "File is not an Ingen patch file (root node != <patch>)" << endl;
- xmlFreeDoc(doc);
- return "";
- }
-
- xmlChar* key = NULL;
- cur = cur->xmlChildrenNode;
-
- // Load Patch attributes
- while (cur != NULL) {
- key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
-
- if ((!xmlStrcmp(cur->name, (const xmlChar*)"name"))) {
- if (load_name && key) {
- if (parent_path)
- path = Path(parent_path.get()).base() + nameify_if_invalid((char*)key);
- else
- path = Path("/");
- }
- } else if ((!xmlStrcmp(cur->name, (const xmlChar*)"polyphony"))) {
- if (poly == 0) {
- poly = atoi((char*)key);
- }
- } else if (xmlStrcmp(cur->name, (const xmlChar*)"connection")
- && xmlStrcmp(cur->name, (const xmlChar*)"node")
- && xmlStrcmp(cur->name, (const xmlChar*)"subpatch")
- && xmlStrcmp(cur->name, (const xmlChar*)"filename")
- && xmlStrcmp(cur->name, (const xmlChar*)"preset")) {
- // Don't know what this tag is, add it as variable without overwriting
- // (so caller can set arbitrary parameters which will be preserved)
- if (key)
- add_variable(initial_data, (const char*)cur->name, (const char*)key);
- }
-
- xmlFree(key);
- key = NULL; // Avoid a (possible?) double free
-
- cur = cur->next;
- }
-
- if (poly == 0)
- poly = 1;
-
- cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!! LOADING " << path << endl;
-
- // Create it, if we're not merging
- if (!existing && path != "/") {
- _engine->new_patch(path, poly);
- for (GraphObject::Variables::const_iterator i = initial_data.begin(); i != initial_data.end(); ++i)
- _engine->set_variable(path, i->first, i->second);
- }
-
- // Load nodes
- cur = xmlDocGetRootElement(doc)->xmlChildrenNode;
- while (cur != NULL) {
- if ((!xmlStrcmp(cur->name, (const xmlChar*)"node")))
- load_node(path, doc, cur);
-
- cur = cur->next;
- }
-
- // Load subpatches
- cur = xmlDocGetRootElement(doc)->xmlChildrenNode;
- while (cur != NULL) {
- if ((!xmlStrcmp(cur->name, (const xmlChar*)"subpatch"))) {
- load_subpatch(filename.substr(0, filename.find_last_of("/")), path, doc, cur);
- }
- cur = cur->next;
- }
-
- // Load connections
- cur = xmlDocGetRootElement(doc)->xmlChildrenNode;
- while (cur != NULL) {
- if ((!xmlStrcmp(cur->name, (const xmlChar*)"connection"))) {
- load_connection(path, doc, cur);
- }
- cur = cur->next;
- }
-
- // Load presets (control values)
- cur = xmlDocGetRootElement(doc)->xmlChildrenNode;
- while (cur != NULL) {
- // I don't think Om ever wrote any preset other than "default"...
- if ((!xmlStrcmp(cur->name, (const xmlChar*)"preset"))) {
- SharedPtr<PresetModel> pm = load_preset(path, doc, cur);
- assert(pm != NULL);
- if (pm->name() == "default") {
- list<ControlModel>::const_iterator i = pm->controls().begin();
- for ( ; i != pm->controls().end(); ++i) {
- const float value = i->value();
- _engine->set_port_value(translate_load_path(i->port_path()), Atom(value));
- }
- } else {
- cerr << "WARNING: Unknown preset: \"" << pm->name() << endl;
- }
- }
- cur = cur->next;
- }
-
- xmlFreeDoc(doc);
- xmlCleanupParser();
-
- // Done above.. late enough?
- //for (Variables::const_iterator i = data.begin(); i != data.end(); ++i)
- // _engine->set_variable(subject, i->first, i->second);
-
- if (!existing)
- _engine->set_property(path, "ingen:enabled", (bool)true);
-
- _load_path_translations.clear();
-
- return path;
-}
-
-
-/** Build a NodeModel given a pointer to a Node in a patch file.
- */
-bool
-DeprecatedLoader::load_node(const Path& parent, xmlDocPtr doc, const xmlNodePtr node)
-{
- xmlChar* key;
- xmlNodePtr cur = node->xmlChildrenNode;
-
- string path = "";
- bool polyphonic = false;
-
- string plugin_uri;
-
- string plugin_type; // deprecated
- string library_name; // deprecated
- string plugin_label; // deprecated
-
- GraphObject::Variables initial_data;
-
- while (cur != NULL) {
- key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
-
- if ((!xmlStrcmp(cur->name, (const xmlChar*)"name"))) {
- path = parent.base() + nameify_if_invalid((char*)key);
- } else if ((!xmlStrcmp(cur->name, (const xmlChar*)"polyphonic"))) {
- polyphonic = !strcmp((char*)key, "true");
- } else if ((!xmlStrcmp(cur->name, (const xmlChar*)"type"))) {
- plugin_type = (const char*)key;
- } else if ((!xmlStrcmp(cur->name, (const xmlChar*)"library-name"))) {
- library_name = (char*)key;
- } else if ((!xmlStrcmp(cur->name, (const xmlChar*)"plugin-label"))) {
- plugin_label = (char*)key;
- } else if ((!xmlStrcmp(cur->name, (const xmlChar*)"plugin-uri"))) {
- plugin_uri = (char*)key;
- } else if ((!xmlStrcmp(cur->name, (const xmlChar*)"port"))) {
- cerr << "FIXME: load port\n";
-#if 0
- xmlNodePtr child = cur->xmlChildrenNode;
-
- string port_name;
- float user_min = 0.0;
- float user_max = 0.0;
-
- while (child != NULL) {
- key = xmlNodeListGetString(doc, child->xmlChildrenNode, 1);
-
- if ((!xmlStrcmp(child->name, (const xmlChar*)"name"))) {
- port_name = nameify_if_invalid((char*)key);
- } else if ((!xmlStrcmp(child->name, (const xmlChar*)"user-min"))) {
- user_min = atof((char*)key);
- } else if ((!xmlStrcmp(child->name, (const xmlChar*)"user-max"))) {
- user_max = atof((char*)key);
- }
-
- xmlFree(key);
- key = NULL; // Avoid a (possible?) double free
-
- child = child->next;
- }
-
- assert(path.length() > 0);
- assert(Path::is_valid(path));
-
- // FIXME: /nasty/ assumptions
- SharedPtr<PortModel> pm(new PortModel(Path(path).base() + port_name,
- PortModel::CONTROL, PortModel::INPUT, PortModel::NONE,
- 0.0, user_min, user_max));
- //pm->set_parent(nm);
- nm->add_port(pm);
-#endif
-
- } else { // Don't know what this tag is, add it as variable
- if (key)
- add_variable(initial_data, (const char*)cur->name, (const char*)key);
- }
- xmlFree(key);
- key = NULL;
-
- cur = cur->next;
- }
-
- if (path == "") {
- cerr << "[DeprecatedLoader] Malformed patch file (node tag has empty children)" << endl;
- cerr << "[DeprecatedLoader] Node ignored." << endl;
- return false;
- }
-
- // Compatibility hacks for old patches that represent patch ports as nodes
- if (plugin_uri == "") {
- bool is_port = false;
-
- if (plugin_type == "Internal") {
- // FIXME: indices
- if (plugin_label == "audio_input") {
- _engine->new_port(path, 0, "ingen:AudioPort", false);
- is_port = true;
- } else if (plugin_label == "audio_output") {
- _engine->new_port(path, 0, "ingen:AudioPort", true);
- is_port = true;
- } else if (plugin_label == "control_input") {
- _engine->new_port(path, 0, "ingen:ControlPort", false);
- is_port = true;
- } else if (plugin_label == "control_output" ) {
- _engine->new_port(path, 0, "ingen:ControlPort", true);
- is_port = true;
- } else if (plugin_label == "midi_input") {
- _engine->new_port(path, 0, "ingen:MIDIPort", false);
- is_port = true;
- } else if (plugin_label == "midi_output" ) {
- _engine->new_port(path, 0, "ingen:MIDIPort", true);
- is_port = true;
- } else {
- cerr << "WARNING: Unknown internal plugin label \"" << plugin_label << "\"" << endl;
- }
- }
-
- if (is_port) {
- const string old_path = path;
- const string new_path = (Path::is_valid(old_path) ? old_path : Path::pathify(old_path));
-
- if (!Path::is_valid(old_path))
- cerr << "WARNING: Translating invalid port path \"" << old_path << "\" => \""
- << new_path << "\"" << endl;
-
- // Set up translations (for connections etc) to alias both the old
- // module path and the old module/port path to the new port path
- _load_path_translations[old_path] = new_path;
- _load_path_translations[old_path + "/in"] = new_path;
- _load_path_translations[old_path + "/out"] = new_path;
-
- path = new_path;
-
- for (GraphObject::Variables::const_iterator i = initial_data.begin(); i != initial_data.end(); ++i)
- _engine->set_variable(path, i->first, i->second);
-
- return SharedPtr<NodeModel>();
-
- } else {
- if (plugin_label == "note_in") {
- plugin_uri = NS_INGEN "note_node";
- } else if (plugin_label == "control_input") {
- plugin_uri = NS_INGEN "control_node";
- } else if (plugin_label == "transport") {
- plugin_uri = NS_INGEN "transport_node";
- } else if (plugin_label == "trigger_in") {
- plugin_uri = NS_INGEN "trigger_node";
- } else {
- cerr << "WARNING: Unknown deprecated node (label " << plugin_label
- << ")." << endl;
- }
-
- if (plugin_uri != "")
- _engine->new_node(path, plugin_uri);
- else
- _engine->new_node_deprecated(path, plugin_type, library_name, plugin_label);
-
- _engine->set_property(path, "ingen:polyphonic", polyphonic);
-
- for (GraphObject::Variables::const_iterator i = initial_data.begin(); i != initial_data.end(); ++i)
- _engine->set_variable(path, i->first, i->second);
-
- return true;
- }
-
- // Not deprecated
- } else {
- _engine->new_node(path, plugin_uri);
- _engine->set_property(path, "ingen:polyphonic", polyphonic);
- for (GraphObject::Variables::const_iterator i = initial_data.begin(); i != initial_data.end(); ++i)
- _engine->set_variable(path, i->first, i->second);
- return true;
- }
-
- // (shouldn't get here)
-}
-
-
-bool
-DeprecatedLoader::load_subpatch(const string& base_filename, const Path& parent, xmlDocPtr doc, const xmlNodePtr subpatch)
-{
- xmlChar *key;
- xmlNodePtr cur = subpatch->xmlChildrenNode;
-
- string name = "";
- string filename = "";
- size_t poly = 0;
-
- GraphObject::Variables initial_data;
-
- while (cur != NULL) {
- key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
-
- if ((!xmlStrcmp(cur->name, (const xmlChar*)"name"))) {
- name = (const char*)key;
- } else if ((!xmlStrcmp(cur->name, (const xmlChar*)"polyphony"))) {
- initial_data.insert(make_pair("ingen::polyphony", (int)poly));
- } else if ((!xmlStrcmp(cur->name, (const xmlChar*)"filename"))) {
- filename = base_filename + "/" + (const char*)key;
- } else { // Don't know what this tag is, add it as variable
- if (key != NULL && strlen((const char*)key) > 0)
- add_variable(initial_data, (const char*)cur->name, (const char*)key);
- }
- xmlFree(key);
- key = NULL;
-
- cur = cur->next;
- }
-
- cout << "Loading subpatch " << filename << " under " << parent << endl;
- // load_patch sets the passed variable last, so values stored in the parent
- // will override values stored in the child patch file
- /*string path = */load_patch(filename, parent, name, initial_data, false);
-
- return false;
-}
-
-
-/** Build a ConnectionModel given a pointer to a connection in a patch file.
- */
-bool
-DeprecatedLoader::load_connection(const Path& parent, xmlDocPtr doc, const xmlNodePtr node)
-{
- xmlChar *key;
- xmlNodePtr cur = node->xmlChildrenNode;
-
- string source_node, source_port, dest_node, dest_port;
-
- while (cur != NULL) {
- key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
-
- if ((!xmlStrcmp(cur->name, (const xmlChar*)"source-node"))) {
- source_node = (char*)key;
- } else if ((!xmlStrcmp(cur->name, (const xmlChar*)"source-port"))) {
- source_port = (char*)key;
- } else if ((!xmlStrcmp(cur->name, (const xmlChar*)"destination-node"))) {
- dest_node = (char*)key;
- } else if ((!xmlStrcmp(cur->name, (const xmlChar*)"destination-port"))) {
- dest_port = (char*)key;
- }
-
- xmlFree(key);
- key = NULL; // Avoid a (possible?) double free
-
- cur = cur->next;
- }
-
- if (source_node == "" || source_port == "" || dest_node == "" || dest_port == "") {
- cerr << "ERROR: Malformed patch file (connection tag has empty children)" << endl;
- cerr << "ERROR: Connection ignored." << endl;
- return false;
- }
-
- // Compatibility fixes for old (fundamentally broken) patches
- source_node = nameify_if_invalid(source_node);
- source_port = nameify_if_invalid(source_port);
- dest_node = nameify_if_invalid(dest_node);
- dest_port = nameify_if_invalid(dest_port);
-
- _engine->connect(
- translate_load_path(parent.base() + source_node +"/"+ source_port),
- translate_load_path(parent.base() + dest_node +"/"+ dest_port));
-
- return true;
-}
-
-
-/** Build a PresetModel given a pointer to a preset in a patch file.
- */
-SharedPtr<PresetModel>
-DeprecatedLoader::load_preset(const Path& parent, xmlDocPtr doc, const xmlNodePtr node)
-{
- xmlNodePtr cur = node->xmlChildrenNode;
- xmlChar* key;
-
- SharedPtr<PresetModel> pm(new PresetModel(parent.base()));
-
- while (cur != NULL) {
- key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
-
- if ((!xmlStrcmp(cur->name, (const xmlChar*)"name"))) {
- assert(key != NULL);
- pm->name((char*)key);
- } else if ((!xmlStrcmp(cur->name, (const xmlChar*)"control"))) {
- xmlNodePtr child = cur->xmlChildrenNode;
-
- string node_name = "", port_name = "";
- float val = 0.0;
-
- while (child != NULL) {
- key = xmlNodeListGetString(doc, child->xmlChildrenNode, 1);
-
- if ((!xmlStrcmp(child->name, (const xmlChar*)"node-name"))) {
- node_name = (char*)key;
- } else if ((!xmlStrcmp(child->name, (const xmlChar*)"port-name"))) {
- port_name = (char*)key;
- } else if ((!xmlStrcmp(child->name, (const xmlChar*)"value"))) {
- val = atof((char*)key);
- }
-
- xmlFree(key);
- key = NULL; // Avoid a (possible?) double free
-
- child = child->next;
- }
-
- // Compatibility fixes for old patch files
- if (node_name != "")
- node_name = nameify_if_invalid(node_name);
- port_name = nameify_if_invalid(port_name);
-
- if (port_name == "") {
- string msg = "Unable to parse control in patch file ( node = ";
- msg.append(node_name).append(", port = ").append(port_name).append(")");
- cerr << "ERROR: " << msg << endl;
- //m_client_hooks->error(msg);
- } else {
- // FIXME: temporary compatibility, remove any slashes from port name
- // remove this soon once patches have migrated
- string::size_type slash_index;
- while ((slash_index = port_name.find("/")) != string::npos)
- port_name[slash_index] = '-';
-
- pm->add_control(node_name, port_name, val);
- }
- }
- xmlFree(key);
- key = NULL;
- cur = cur->next;
- }
- if (pm->name() == "") {
- cerr << "Preset in patch file has no name." << endl;
- //m_client_hooks->error("Preset in patch file has no name.");
- pm->name("Unnamed");
- }
-
- return pm;
-}
-
-} // namespace Client
-} // namespace Ingen
diff --git a/src/libs/client/DeprecatedLoader.hpp b/src/libs/client/DeprecatedLoader.hpp
deleted file mode 100644
index c1af52c2..00000000
--- a/src/libs/client/DeprecatedLoader.hpp
+++ /dev/null
@@ -1,94 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef PATCHLIBRARIAN_H
-#define PATCHLIBRARIAN_H
-
-#include <map>
-#include <utility>
-#include <string>
-#include <cassert>
-#include <boost/optional.hpp>
-#include <glibmm/ustring.h>
-#include <libxml/tree.h>
-#include <raul/SharedPtr.hpp>
-#include <raul/Path.hpp>
-#include "interface/EngineInterface.hpp"
-#include "interface/GraphObject.hpp"
-#include "ObjectModel.hpp"
-
-using std::string;
-using Ingen::Shared::EngineInterface;
-using Ingen::Shared::GraphObject;
-
-namespace Ingen {
-namespace Client {
-
-class PatchModel;
-class NodeModel;
-class ConnectionModel;
-class PresetModel; // defined in DeprecatedLoader.cpp
-
-
-/** Loads deprecated (XML) patch files (from the Om days).
- *
- * \ingroup IngenClient
- */
-class DeprecatedLoader
-{
-public:
- DeprecatedLoader(SharedPtr<EngineInterface> engine)
- : /*_patch_search_path(".")*/ _engine(engine)
- {
- assert(_engine);
- }
-
- /*void path(const string& path) { _patch_search_path = path; }
- const string& path() { return _patch_search_path; }*/
-
- string find_file(const string& filename, const string& additional_path = "");
-
- string load_patch(const Glib::ustring& filename,
- boost::optional<Path> parent_path,
- string name,
- GraphObject::Variables initial_data,
- bool existing = false);
-
-private:
- void add_variable(GraphObject::Variables& data, string key, string value);
-
- string nameify_if_invalid(const string& name);
- string translate_load_path(const string& path);
-
- //string _patch_search_path;
- SharedPtr<EngineInterface> _engine;
-
- /// Translations of paths from the loading file to actual paths (for deprecated patches)
- std::map<string, string> _load_path_translations;
-
- bool load_node(const Path& parent, xmlDocPtr doc, const xmlNodePtr cur);
- bool load_connection(const Path& parent, xmlDocPtr doc, const xmlNodePtr cur);
- bool load_subpatch(const string& base_filename, const Path& parent, xmlDocPtr doc, const xmlNodePtr cur);
-
- SharedPtr<PresetModel> load_preset(const Path& parent, xmlDocPtr doc, const xmlNodePtr cur);
-};
-
-
-} // namespace Client
-} // namespace Ingen
-
-#endif // PATCHLIBRARIAN_H
diff --git a/src/libs/client/HTTPClientReceiver.cpp b/src/libs/client/HTTPClientReceiver.cpp
deleted file mode 100644
index ece55ab2..00000000
--- a/src/libs/client/HTTPClientReceiver.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2008 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <list>
-#include <cassert>
-#include <cstring>
-#include <iostream>
-#include <sstream>
-#include <raul/AtomLiblo.hpp>
-#include "module/Module.hpp"
-#include "HTTPClientReceiver.hpp"
-
-using namespace std;
-using namespace Raul;
-
-namespace Ingen {
-namespace Client {
-
-
-HTTPClientReceiver::HTTPClientReceiver(
- Shared::World* world,
- const std::string& url,
- SharedPtr<Shared::ClientInterface> target)
- : _target(target)
- , _world(world)
- , _url(url)
- , _session(NULL)
-{
- start(false);
-}
-
-
-HTTPClientReceiver::~HTTPClientReceiver()
-{
- stop();
-}
-
-
-void
-HTTPClientReceiver::message_callback(SoupSession* session, SoupMessage* msg, void* ptr)
-{
- HTTPClientReceiver* me = (HTTPClientReceiver*)ptr;
- cout << "RECEIVED ASYNC MESSAGE: " << msg->response_body->data << endl;
- me->_target->response_ok(0);
- me->_target->enable();
- me->_parser->parse_string(me->_world, me->_target.get(), Glib::ustring(msg->response_body->data),
- Glib::ustring("/"), Glib::ustring(""));
-}
-
-
-void
-HTTPClientReceiver::start(bool dump)
-{
- Glib::Mutex::Lock lock(_world->rdf_world->mutex());
- if (!_parser) {
- if (!_world->serialisation_module)
- _world->serialisation_module = Ingen::Shared::load_module("ingen_serialisation");
-
- if (_world->serialisation_module) {
- Parser* (*new_parser)() = NULL;
- if (_world->serialisation_module->get_symbol("new_parser", (void*&)new_parser))
- _parser = SharedPtr<Parser>(new_parser());
- }
- }
- _session = soup_session_async_new();
- SoupMessage* msg = soup_message_new("GET", _url.c_str());
- soup_session_queue_message (_session, msg, message_callback, this);
-}
-
-
-void
-HTTPClientReceiver::stop()
-{
- if (_session != NULL) {
- //unregister_client();
- soup_session_abort(_session);
- _session = NULL;
- }
-}
-
-
-} // namespace Client
-} // namespace Ingen
diff --git a/src/libs/client/HTTPClientReceiver.hpp b/src/libs/client/HTTPClientReceiver.hpp
deleted file mode 100644
index bab55578..00000000
--- a/src/libs/client/HTTPClientReceiver.hpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2008 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef HTTPCLIENTRECEIVER_H
-#define HTTPCLIENTRECEIVER_H
-
-#include <cstdlib>
-#include <boost/utility.hpp>
-#include <libsoup/soup.h>
-#include "interface/ClientInterface.hpp"
-#include "serialisation/Parser.hpp"
-#include "redlandmm/World.hpp"
-#include "raul/Deletable.hpp"
-
-namespace Ingen {
-namespace Client {
-
-
-class HTTPClientReceiver : public boost::noncopyable, public Raul::Deletable
-{
-public:
- HTTPClientReceiver(Shared::World* world,
- const std::string& url,
- SharedPtr<Shared::ClientInterface> target);
-
- ~HTTPClientReceiver();
-
- std::string uri() const { return _url; }
-
- void start(bool dump);
- void stop();
-
-private:
- static void message_callback(SoupSession* session, SoupMessage* msg, void* ptr);
-
- SharedPtr<Shared::ClientInterface> _target;
-
- Shared::World* _world;
- const std::string _url;
- SoupSession* _session;
- SharedPtr<Parser> _parser;
-};
-
-
-} // namespace Client
-} // namespace Ingen
-
-#endif // HTTPCLIENTRECEIVER_H
diff --git a/src/libs/client/HTTPEngineSender.cpp b/src/libs/client/HTTPEngineSender.cpp
deleted file mode 100644
index 733e0ac7..00000000
--- a/src/libs/client/HTTPEngineSender.cpp
+++ /dev/null
@@ -1,285 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2008 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <iostream>
-#include <libsoup/soup.h>
-#include "HTTPEngineSender.hpp"
-
-using namespace std;
-
-namespace Ingen {
-namespace Client {
-
-
-HTTPEngineSender::HTTPEngineSender(const string& engine_url)
- : _engine_url(engine_url)
- , _id(0)
- , _enabled(true)
-{
- _session = soup_session_sync_new();
-}
-
-
-HTTPEngineSender::~HTTPEngineSender()
-{
- soup_session_abort(_session);
-}
-
-
-void
-HTTPEngineSender::attach(int32_t ping_id, bool block)
-{
- /*SoupMessage *msg;
- msg = soup_message_new ("GET", _engine_url.c_str());
- int status = soup_session_send_message (_session, msg);
- cout << "STATUS: " << status << endl;
- cout << "RESPONSE: " << msg->response_body->data << endl;*/
-}
-
-
-/* *** EngineInterface implementation below here *** */
-
-
-/** Register with the engine via HTTP.
- *
- * Note that this does not actually use 'key', since the engine creates
- * it's own key for HTTP clients (namely the incoming URL), for NAT
- * traversal. It is a parameter to remain compatible with EngineInterface.
- */
-void
-HTTPEngineSender::register_client(ClientInterface* client)
-{
-
-}
-
-
-void
-HTTPEngineSender::unregister_client(const string& uri)
-{
-
-}
-
-
-// Engine commands
-void
-HTTPEngineSender::load_plugins()
-{
-
-}
-
-
-void
-HTTPEngineSender::activate()
-{
-
-}
-
-
-void
-HTTPEngineSender::deactivate()
-{
-
-}
-
-
-void
-HTTPEngineSender::quit()
-{
-
-}
-
-
-
-// Object commands
-
-void
-HTTPEngineSender::new_patch(const string& path,
- uint32_t poly)
-{
-}
-
-
-void
-HTTPEngineSender::new_port(const string& path,
- uint32_t index,
- const string& data_type,
- bool is_output)
-{
-}
-
-
-void
-HTTPEngineSender::new_node(const string& path,
- const string& plugin_uri)
-{
-}
-
-
-/** Create a node using library name and plugin label (DEPRECATED).
- *
- * DO NOT USE THIS.
- */
-void
-HTTPEngineSender::new_node_deprecated(const string& path,
- const string& plugin_type,
- const string& library_name,
- const string& plugin_label)
-{
-}
-
-
-void
-HTTPEngineSender::rename(const string& old_path,
- const string& new_name)
-{
-}
-
-
-void
-HTTPEngineSender::destroy(const string& path)
-{
-}
-
-
-void
-HTTPEngineSender::clear_patch(const string& patch_path)
-{
-}
-
-
-void
-HTTPEngineSender::connect(const string& src_port_path,
- const string& dst_port_path)
-{
-}
-
-
-void
-HTTPEngineSender::disconnect(const string& src_port_path,
- const string& dst_port_path)
-{
-}
-
-
-void
-HTTPEngineSender::disconnect_all(const string& parent_patch_path,
- const string& node_path)
-{
-}
-
-
-void
-HTTPEngineSender::set_port_value(const string& port_path,
- const Raul::Atom& value)
-{
-}
-
-
-void
-HTTPEngineSender::set_voice_value(const string& port_path,
- uint32_t voice,
- const Raul::Atom& value)
-{
-}
-
-
-void
-HTTPEngineSender::set_program(const string& node_path,
- uint32_t bank,
- uint32_t program)
-{
-}
-
-
-void
-HTTPEngineSender::midi_learn(const string& node_path)
-{
-}
-
-
-void
-HTTPEngineSender::set_variable(const string& obj_path,
- const string& predicate,
- const Raul::Atom& value)
-{
-}
-
-
-void
-HTTPEngineSender::set_property(const string& obj_path,
- const string& predicate,
- const Raul::Atom& value)
-{
-}
-
-
-
-// Requests //
-
-void
-HTTPEngineSender::ping()
-{
-}
-
-
-void
-HTTPEngineSender::request_plugin(const string& uri)
-{
-}
-
-
-void
-HTTPEngineSender::request_object(const string& path)
-{
-}
-
-
-void
-HTTPEngineSender::request_port_value(const string& port_path)
-{
-}
-
-
-void
-HTTPEngineSender::request_variable(const string& object_path, const string& key)
-{
-}
-
-
-void
-HTTPEngineSender::request_property(const string& object_path, const string& key)
-{
-}
-
-
-void
-HTTPEngineSender::request_plugins()
-{
-}
-
-
-void
-HTTPEngineSender::request_all_objects()
-{
-}
-
-
-
-} // namespace Client
-} // namespace Ingen
-
-
diff --git a/src/libs/client/HTTPEngineSender.hpp b/src/libs/client/HTTPEngineSender.hpp
deleted file mode 100644
index 411ddfd5..00000000
--- a/src/libs/client/HTTPEngineSender.hpp
+++ /dev/null
@@ -1,155 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2008 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef HTTPENGINESENDER_H
-#define HTTPENGINESENDER_H
-
-#include <inttypes.h>
-#include <string>
-#include <libsoup/soup.h>
-#include "interface/EngineInterface.hpp"
-using std::string;
-using Ingen::Shared::EngineInterface;
-using Ingen::Shared::ClientInterface;
-
-namespace Ingen {
-namespace Client {
-
-
-/* HTTP (via libsoup) interface to the engine.
- *
- * Clients can use this opaquely as an EngineInterface to control the engine
- * over HTTP (whether over a network or not).
- *
- * \ingroup IngenClient
- */
-class HTTPEngineSender : public EngineInterface {
-public:
- HTTPEngineSender(const string& engine_url);
- ~HTTPEngineSender();
-
- string uri() const { return _engine_url; }
-
- inline int32_t next_id()
- { int32_t ret = (_id == -1) ? -1 : _id++; return ret; }
-
- void set_next_response_id(int32_t id) { _id = id; }
- void disable_responses() { _id = -1; }
-
- void attach(int32_t ping_id, bool block);
-
-
- /* *** EngineInterface implementation below here *** */
-
- void enable() { _enabled = true; }
- void disable() { _enabled = false; }
-
- void bundle_begin() { transfer_begin(); }
- void bundle_end() { transfer_end(); }
-
- void transfer_begin();
- void transfer_end();
-
- // Client registration
- void register_client(ClientInterface* client);
- void unregister_client(const string& uri);
-
- // Engine commands
- void load_plugins();
- void activate();
- void deactivate();
- void quit();
-
- // Object commands
-
- void new_patch(const string& path,
- uint32_t poly);
-
- void new_port(const string& path,
- uint32_t index,
- const string& data_type,
- bool is_output);
-
- void new_node(const string& path,
- const string& plugin_uri);
-
- void new_node_deprecated(const string& path,
- const string& plugin_type,
- const string& library_name,
- const string& plugin_label);
-
- void rename(const string& old_path,
- const string& new_name);
-
- void destroy(const string& path);
-
- void clear_patch(const string& patch_path);
-
- void connect(const string& src_port_path,
- const string& dst_port_path);
-
- void disconnect(const string& src_port_path,
- const string& dst_port_path);
-
- void disconnect_all(const string& parent_patch_path,
- const string& node_path);
-
- void set_port_value(const string& port_path,
- const Raul::Atom& value);
-
- void set_voice_value(const string& port_path,
- uint32_t voice,
- const Raul::Atom& value);
-
- void set_program(const string& node_path,
- uint32_t bank,
- uint32_t program);
-
- void midi_learn(const string& node_path);
-
- void set_variable(const string& obj_path,
- const string& predicate,
- const Raul::Atom& value);
-
- void set_property(const string& obj_path,
- const string& predicate,
- const Raul::Atom& value);
-
- // Requests //
- void ping();
- void request_plugin(const string& uri);
- void request_object(const string& path);
- void request_port_value(const string& port_path);
- void request_variable(const string& path, const string& key);
- void request_property(const string& path, const string& key);
- void request_plugins();
- void request_all_objects();
-
-protected:
- SoupSession* _session;
- const string _engine_url;
- int _client_port;
- int32_t _id;
- bool _enabled;
-};
-
-
-} // namespace Client
-} // namespace Ingen
-
-#endif // HTTPENGINESENDER_H
-
diff --git a/src/libs/client/Makefile.am b/src/libs/client/Makefile.am
deleted file mode 100644
index 4af7c243..00000000
--- a/src/libs/client/Makefile.am
+++ /dev/null
@@ -1,69 +0,0 @@
-if BUILD_CLIENT_LIB
-
-
-moduledir = $(libdir)/ingen
-
-module_LTLIBRARIES = libingen_client.la
-
-libingen_client_la_CXXFLAGS = \
- -DPKGDATADIR=\"$(pkgdatadir)\" \
- @INGEN_CFLAGS@ \
- @GLIBMM_CFLAGS@ \
- @LIBLO_CFLAGS@ \
- @LSIGCPP_CFLAGS@ \
- @GLIBMM_CFLAGS@ \
- @LXML2_CFLAGS@ \
- @RAUL_CFLAGS@ \
- @REDLANDMM_CFLAGS@ \
- @SLV2_CFLAGS@ \
- @SOUP_CFLAGS@
-
-libingen_client_la_LIBADD = \
- ../shared/libingen_shared.la \
- @GLIBMM_LIBS@ \
- @LIBLO_LIBS@ \
- @LSIGCPP_LIBS@ \
- @LXML2_LIBS@ \
- @RAUL_LIBS@ \
- @REDLANDMM_LIBS@ \
- @SLV2_LIBS@ \
- @SOUP_LIBS@
-
-libingen_client_la_SOURCES = \
- ClientStore.cpp \
- ClientStore.hpp \
- ConnectionModel.hpp \
- DeprecatedLoader.cpp \
- DeprecatedLoader.hpp \
- NodeModel.cpp \
- NodeModel.hpp \
- OSCClientReceiver.cpp \
- OSCClientReceiver.hpp \
- OSCEngineSender.cpp \
- OSCEngineSender.hpp \
- ObjectModel.cpp \
- ObjectModel.hpp \
- PatchModel.cpp \
- PatchModel.hpp \
- PluginModel.cpp \
- PluginModel.hpp \
- PluginUI.cpp \
- PluginUI.hpp \
- PortModel.cpp \
- PortModel.hpp \
- SigClientInterface.hpp \
- ThreadedSigClientInterface.cpp \
- ThreadedSigClientInterface.hpp \
- client.cpp \
- client.hpp
-
-if WITH_SOUP
-libingen_client_la_SOURCES += \
- HTTPClientReceiver.cpp \
- HTTPClientReceiver.hpp \
- HTTPEngineSender.cpp \
- HTTPEngineSender.hpp
-endif
-
-endif # BUILD_CLIENT_LIB
-
diff --git a/src/libs/client/NodeModel.cpp b/src/libs/client/NodeModel.cpp
deleted file mode 100644
index ac0c8e68..00000000
--- a/src/libs/client/NodeModel.cpp
+++ /dev/null
@@ -1,224 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include CONFIG_H_PATH
-
-#include <cassert>
-#include <cmath>
-#include "interface/Port.hpp"
-#include "NodeModel.hpp"
-#include "PatchModel.hpp"
-
-namespace Ingen {
-namespace Client {
-
-
-NodeModel::NodeModel(SharedPtr<PluginModel> plugin, const Path& path)
- : ObjectModel(path)
- , _plugin_uri(plugin->uri())
- , _plugin(plugin)
- , _num_values(0)
- , _min_values(0)
- , _max_values(0)
-{
-}
-
-NodeModel::NodeModel(const string& plugin_uri, const Path& path)
- : ObjectModel(path)
- , _plugin_uri(plugin_uri)
- , _num_values(0)
- , _min_values(0)
- , _max_values(0)
-{
-}
-
-
-NodeModel::NodeModel(const NodeModel& copy)
- : ObjectModel(copy)
- , _plugin_uri(copy._plugin_uri)
- , _num_values(copy._num_values)
- , _min_values((float*)malloc(sizeof(float) * _num_values))
- , _max_values((float*)malloc(sizeof(float) * _num_values))
-{
- memcpy(_min_values, copy._min_values, sizeof(float) * _num_values);
- memcpy(_max_values, copy._max_values, sizeof(float) * _num_values);
-}
-
-
-NodeModel::~NodeModel()
-{
- clear();
-}
-
-
-void
-NodeModel::remove_port(SharedPtr<PortModel> port)
-{
- // FIXME: slow
- for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) {
- if ((*i) == port) {
- _ports.erase(i);
- break;
- }
- }
- signal_removed_port.emit(port);
-}
-
-
-void
-NodeModel::remove_port(const Path& port_path)
-{
- // FIXME: slow
- for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) {
- if ((*i)->path() == port_path) {
- _ports.erase(i);
- break;
- }
- }
-}
-
-
-void
-NodeModel::clear()
-{
- _ports.clear();
- assert(_ports.empty());
- delete[] _min_values;
- delete[] _max_values;
- _min_values = 0;
- _max_values = 0;
-}
-
-
-void
-NodeModel::add_child(SharedPtr<ObjectModel> c)
-{
- assert(c->parent().get() == this);
-
- //ObjectModel::add_child(c);
-
- SharedPtr<PortModel> pm = PtrCast<PortModel>(c);
- assert(pm);
- add_port(pm);
-}
-
-
-bool
-NodeModel::remove_child(SharedPtr<ObjectModel> c)
-{
- assert(c->path().is_child_of(_path));
- assert(c->parent().get() == this);
-
- //bool ret = ObjectModel::remove_child(c);
-
- SharedPtr<PortModel> pm = PtrCast<PortModel>(c);
- assert(pm);
- remove_port(pm);
-
- //return ret;
- return true;
-}
-
-
-void
-NodeModel::add_port(SharedPtr<PortModel> pm)
-{
- assert(pm);
- assert(pm->path().is_child_of(_path));
- assert(pm->parent().get() == this);
-
- Ports::iterator existing = find(_ports.begin(), _ports.end(), pm);
-
- // Store should have handled this by merging the two
- assert(existing == _ports.end());
-
- _ports.push_back(pm);
- signal_new_port.emit(pm);
-}
-
-
-SharedPtr<PortModel>
-NodeModel::get_port(const string& port_name) const
-{
- assert(port_name.find("/") == string::npos);
- for (Ports::const_iterator i = _ports.begin(); i != _ports.end(); ++i)
- if ((*i)->path().name() == port_name)
- return (*i);
- return SharedPtr<PortModel>();
-}
-
-
-Shared::Port*
-NodeModel::port(uint32_t index) const
-{
- assert(index < num_ports());
- return dynamic_cast<Shared::Port*>(_ports[index].get());
-}
-
-
-void
-NodeModel::port_value_range(SharedPtr<PortModel> port, float& min, float& max)
-{
- assert(port->parent().get() == this);
-
-#ifdef HAVE_SLV2
- // Plugin value first
- if (_plugin && _plugin->type() == PluginModel::LV2) {
-
- if (!_min_values) {
-
- Glib::Mutex::Lock lock(PluginModel::rdf_world()->mutex());
-
- _num_values = slv2_plugin_get_num_ports(_plugin->slv2_plugin());
- _min_values = new float[_num_values];
- _max_values = new float[_num_values];
- slv2_plugin_get_port_ranges_float(_plugin->slv2_plugin(),
- _min_values, _max_values, 0);
- }
-
- if (!std::isnan(_min_values[port->index()]))
- min = _min_values[port->index()];
- if (!std::isnan(_max_values[port->index()]))
- max = _max_values[port->index()];
- }
-#endif
-
- // Possibly overriden
- const Atom& min_atom = port->get_variable("ingen:minimum");
- const Atom& max_atom = port->get_variable("ingen:maximum");
- if (min_atom.type() == Atom::FLOAT)
- min = min_atom.get_float();
- if (max_atom.type() == Atom::FLOAT)
- max = max_atom.get_float();
-}
-
-
-void
-NodeModel::set(SharedPtr<ObjectModel> model)
-{
- SharedPtr<NodeModel> node = PtrCast<NodeModel>(model);
- if (node) {
- _plugin_uri = node->_plugin_uri;
- _plugin = node->_plugin;
- }
-
- ObjectModel::set(model);
-}
-
-
-} // namespace Client
-} // namespace Ingen
diff --git a/src/libs/client/NodeModel.hpp b/src/libs/client/NodeModel.hpp
deleted file mode 100644
index 03afc17c..00000000
--- a/src/libs/client/NodeModel.hpp
+++ /dev/null
@@ -1,101 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef NODEMODEL_H
-#define NODEMODEL_H
-
-#include <cstdlib>
-#include <iostream>
-#include <string>
-#include <sigc++/sigc++.h>
-#include <raul/Table.hpp>
-#include <raul/Path.hpp>
-#include <raul/SharedPtr.hpp>
-#include "interface/Node.hpp"
-#include "interface/Port.hpp"
-#include "ObjectModel.hpp"
-#include "PortModel.hpp"
-#include "PluginModel.hpp"
-
-using std::string;
-using Raul::Table;
-
-namespace Ingen {
-namespace Client {
-
-class PluginModel;
-class ClientStore;
-
-
-/** Node model class, used by the client to store engine's state.
- *
- * \ingroup IngenClient
- */
-class NodeModel : public ObjectModel, virtual public Ingen::Shared::Node
-{
-public:
- NodeModel(const NodeModel& copy);
- virtual ~NodeModel();
-
- typedef vector<SharedPtr<PortModel> > Ports;
-
- SharedPtr<PortModel> get_port(const string& port_name) const;
-
- Shared::Port* port(uint32_t index) const;
-
- const string& plugin_uri() const { return _plugin_uri; }
- const Shared::Plugin* plugin() const { return _plugin.get(); }
- uint32_t num_ports() const { return _ports.size(); }
- const Ports& ports() const { return _ports; }
-
- void port_value_range(SharedPtr<PortModel> port, float& min, float& max);
-
- // Signals
- sigc::signal<void, SharedPtr<PortModel> > signal_new_port;
- sigc::signal<void, SharedPtr<PortModel> > signal_removed_port;
-
-protected:
- friend class ClientStore;
-
- NodeModel(const string& plugin_uri, const Path& path);
- NodeModel(SharedPtr<PluginModel> plugin, const Path& path);
-
- NodeModel(const Path& path);
- void add_child(SharedPtr<ObjectModel> c);
- bool remove_child(SharedPtr<ObjectModel> c);
- void add_port(SharedPtr<PortModel> pm);
- void remove_port(SharedPtr<PortModel> pm);
- void remove_port(const Path& port_path);
- void add_program(int bank, int program, const string& name);
- void remove_program(int bank, int program);
- void set(SharedPtr<ObjectModel> model);
-
- virtual void clear();
-
- Ports _ports; ///< Vector of ports (not a Table to preserve order)
- string _plugin_uri; ///< Plugin URI (if PluginModel is unknown)
- SharedPtr<PluginModel> _plugin; ///< The plugin this node is an instance of
- uint32_t _num_values; ///< Size of _min_values and _max_values
- float* _min_values; ///< Port min values (cached for LV2)
- float* _max_values; ///< Port max values (cached for LV2)
-};
-
-
-} // namespace Client
-} // namespace Ingen
-
-#endif // NODEMODEL_H
diff --git a/src/libs/client/OSCClientReceiver.cpp b/src/libs/client/OSCClientReceiver.cpp
deleted file mode 100644
index 8ebd9d8e..00000000
--- a/src/libs/client/OSCClientReceiver.cpp
+++ /dev/null
@@ -1,394 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "OSCClientReceiver.hpp"
-#include <raul/AtomLiblo.hpp>
-#include <list>
-#include <cassert>
-#include <cstring>
-#include <iostream>
-#include <sstream>
-
-using namespace std;
-using namespace Raul;
-
-namespace Ingen {
-namespace Client {
-
-
-OSCClientReceiver::OSCClientReceiver(int listen_port, SharedPtr<Shared::ClientInterface> target)
- : _target(target)
- , _listen_port(listen_port)
- , _st(NULL)
-{
- start(false); // true = dump, false = shutup
-}
-
-
-OSCClientReceiver::~OSCClientReceiver()
-{
- stop();
-}
-
-
-void
-OSCClientReceiver::start(bool dump_osc)
-{
- if (_st != NULL)
- return;
-
- // Attempt preferred port
- if (_listen_port != 0) {
- char port_str[8];
- snprintf(port_str, 8, "%d", _listen_port);
- _st = lo_server_thread_new(port_str, lo_error_cb);
- }
-
- // Find a free port
- if (!_st) {
- _st = lo_server_thread_new(NULL, lo_error_cb);
- _listen_port = lo_server_thread_get_port(_st);
- }
-
- if (_st == NULL) {
- cerr << "[OSCClientReceiver] Could not start OSC listener. Aborting." << endl;
- exit(EXIT_FAILURE);
- } else {
- cout << "[OSCClientReceiver] Started OSC listener on port " << lo_server_thread_get_port(_st) << endl;
- }
-
- // Print all incoming messages
- if (dump_osc)
- lo_server_thread_add_method(_st, NULL, NULL, generic_cb, NULL);
-
- setup_callbacks();
-
- // Display any uncaught messages to the console
- //lo_server_thread_add_method(_st, NULL, NULL, unknown_cb, NULL);
-
- lo_server_thread_start(_st);
-}
-
-
-void
-OSCClientReceiver::stop()
-{
- if (_st != NULL) {
- //unregister_client();
- lo_server_thread_free(_st);
- _st = NULL;
- }
-}
-
-
-int
-OSCClientReceiver::generic_cb(const char* path, const char* types, lo_arg** argv, int argc, void* data, void* user_data)
-{
- printf("[OSCMsg] %s (%s)\t", path, types);
-
- for (int i=0; i < argc; ++i) {
- lo_arg_pp(lo_type(types[i]), argv[i]);
- printf("\t");
- }
- printf("\n");
-
- /*for (int i=0; i < argc; ++i) {
- printf(" '%c' ", types[i]);
- lo_arg_pp(lo_type(types[i]), argv[i]);
- printf("\n");
- }
- printf("\n");*/
-
- return 1; // not handled
-}
-
-
-void
-OSCClientReceiver::lo_error_cb(int num, const char* msg, const char* path)
-{
- cerr << "Got error from server: " << msg << endl;
-}
-
-
-
-int
-OSCClientReceiver::unknown_cb(const char* path, const char* types, lo_arg** argv, int argc, void* data, void* user_data)
-{
- std::string msg = "Received unknown OSC message: ";
- msg += path;
-
- cerr << msg << endl;
-
- return 0;
-}
-
-
-void
-OSCClientReceiver::setup_callbacks()
-{
- lo_server_thread_add_method(_st, "/ingen/ok", "i", response_ok_cb, this);
- lo_server_thread_add_method(_st, "/ingen/error", "is", response_error_cb, this);
- lo_server_thread_add_method(_st, "/ingen/plugin", "ssss", plugin_cb, this);
- lo_server_thread_add_method(_st, "/ingen/new_patch", "si", new_patch_cb, this);
- lo_server_thread_add_method(_st, "/ingen/destroyed", "s", destroyed_cb, this);
- lo_server_thread_add_method(_st, "/ingen/patch_cleared", "s", patch_cleared_cb, this);
- lo_server_thread_add_method(_st, "/ingen/object_renamed", "ss", object_renamed_cb, this);
- lo_server_thread_add_method(_st, "/ingen/new_connection", "ss", connection_cb, this);
- lo_server_thread_add_method(_st, "/ingen/disconnection", "ss", disconnection_cb, this);
- lo_server_thread_add_method(_st, "/ingen/new_node", "ss", new_node_cb, this);
- lo_server_thread_add_method(_st, "/ingen/new_port", "sisi", new_port_cb, this);
- lo_server_thread_add_method(_st, "/ingen/set_variable", NULL, set_variable_cb, this);
- lo_server_thread_add_method(_st, "/ingen/set_property", NULL, set_property_cb, this);
- lo_server_thread_add_method(_st, "/ingen/set_port_value", "sf", set_port_value_cb, this);
- lo_server_thread_add_method(_st, "/ingen/set_voice_value", "sif", set_voice_value_cb, this);
- lo_server_thread_add_method(_st, "/ingen/port_activity", "s", port_activity_cb, this);
- lo_server_thread_add_method(_st, "/ingen/program_add", "siis", program_add_cb, this);
- lo_server_thread_add_method(_st, "/ingen/program_remove", "sii", program_remove_cb, this);
-}
-
-
-/** Catches errors that aren't a direct result of a client request.
- */
-int
-OSCClientReceiver::_error_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- _target->error((char*)argv[0]);
- return 0;
-}
-
-
-int
-OSCClientReceiver::_new_patch_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- _target->new_patch(&argv[0]->s, argv[1]->i); // path, poly
- return 0;
-}
-
-
-int
-OSCClientReceiver::_destroyed_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- _target->destroy((const char*)&argv[0]->s);
- return 0;
-}
-
-
-int
-OSCClientReceiver::_patch_cleared_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- _target->patch_cleared((const char*)&argv[0]->s);
- return 0;
-}
-
-
-int
-OSCClientReceiver::_object_renamed_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- _target->object_renamed((const char*)&argv[0]->s, (const char*)&argv[1]->s);
- return 0;
-}
-
-
-int
-OSCClientReceiver::_connection_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- const char* const src_port_path = &argv[0]->s;
- const char* const dst_port_path = &argv[1]->s;
-
- _target->connect(src_port_path, dst_port_path);
-
- return 0;
-}
-
-
-int
-OSCClientReceiver::_disconnection_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- const char* src_port_path = &argv[0]->s;
- const char* dst_port_path = &argv[1]->s;
-
- _target->disconnect(src_port_path, dst_port_path);
-
- return 0;
-}
-
-
-/** Notification of a new node creation.
- */
-int
-OSCClientReceiver::_new_node_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- const char* uri = &argv[0]->s;
- const char* node_path = &argv[1]->s;
-
- _target->new_node(uri, node_path);
-
- return 0;
-}
-
-
-/** Notification of a new port creation.
- */
-int
-OSCClientReceiver::_new_port_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- const char* port_path = &argv[0]->s;
- const uint32_t index = argv[1]->i;
- const char* type = &argv[2]->s;
- const bool is_output = (argv[3]->i == 1);
-
- _target->new_port(port_path, index, type, is_output);
-
- return 0;
-}
-
-
-/** Notification of a new or updated variable.
- */
-int
-OSCClientReceiver::_set_variable_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- if (argc != 3 || types[0] != 's' || types[1] != 's')
- return 1;
-
- const char* obj_path = &argv[0]->s;
- const char* key = &argv[1]->s;
-
- Atom value = AtomLiblo::lo_arg_to_atom(types[2], argv[2]);
-
- _target->set_variable(obj_path, key, value);
-
- return 0;
-}
-
-
-/** Notification of a new or updated property.
- */
-int
-OSCClientReceiver::_set_property_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- if (argc != 3 || types[0] != 's' || types[1] != 's')
- return 1;
-
- const char* obj_path = &argv[0]->s;
- const char* key = &argv[1]->s;
-
- Atom value = AtomLiblo::lo_arg_to_atom(types[2], argv[2]);
-
- _target->set_property(obj_path, key, value);
-
- return 0;
-}
-
-
-int
-OSCClientReceiver::_set_port_value_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- const char* const port_path = &argv[0]->s;
- const float value = argv[1]->f;
-
- _target->set_port_value(port_path, value);
-
- return 0;
-}
-
-
-int
-OSCClientReceiver::_set_voice_value_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- const char* const port_path = &argv[0]->s;
- const int voice = argv[1]->i;
- const float value = argv[2]->f;
-
- _target->set_voice_value(port_path, voice, value);
-
- return 0;
-}
-
-
-int
-OSCClientReceiver::_port_activity_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- const char* const port_path = &argv[0]->s;
-
- _target->port_activity(port_path);
-
- return 0;
-}
-
-
-int
-OSCClientReceiver::_response_ok_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- assert(!strcmp(types, "i"));
- _target->response_ok(argv[0]->i);
-
- return 0;
-}
-
-
-int
-OSCClientReceiver::_response_error_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- assert(!strcmp(types, "is"));
- _target->response_error(argv[0]->i, &argv[1]->s);
-
- return 0;
-}
-
-
-/** A plugin info response from the server, in response to an /ingen/send_plugins
- */
-int
-OSCClientReceiver::_plugin_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- assert(argc == 4 && !strcmp(types, "ssss"));
- _target->new_plugin(&argv[0]->s, &argv[1]->s, &argv[2]->s, &argv[3]->s); // uri, type, symbol, name
-
- return 0;
-}
-
-
-int
-OSCClientReceiver::_program_add_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- const char* node_path = &argv[0]->s;
- int32_t bank = argv[1]->i;
- int32_t program = argv[2]->i;
- const char* name = &argv[3]->s;
-
- _target->program_add(node_path, bank, program, name);
-
- return 0;
-}
-
-
-int
-OSCClientReceiver::_program_remove_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- const char* node_path = &argv[0]->s;
- int32_t bank = argv[1]->i;
- int32_t program = argv[2]->i;
-
- _target->program_remove(node_path, bank, program);
-
- return 0;
-}
-
-
-} // namespace Client
-} // namespace Ingen
diff --git a/src/libs/client/OSCClientReceiver.hpp b/src/libs/client/OSCClientReceiver.hpp
deleted file mode 100644
index ea5871b3..00000000
--- a/src/libs/client/OSCClientReceiver.hpp
+++ /dev/null
@@ -1,107 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef OSCCLIENTRECEIVER_H
-#define OSCCLIENTRECEIVER_H
-
-#include <cstdlib>
-#include <boost/utility.hpp>
-#include <lo/lo.h>
-#include "interface/ClientInterface.hpp"
-#include "raul/Deletable.hpp"
-
-namespace Ingen {
-namespace Client {
-
-/** Arguments to a liblo handler */
-#define LO_HANDLER_ARGS const char* path, const char* types, lo_arg** argv, int argc, lo_message msg
-
-/** Define a static handler to be passed to lo_add_method, which is a trivial
- * wrapper around a non-static method that does the real work. */
-#define LO_HANDLER(name) \
-int _##name##_cb (LO_HANDLER_ARGS);\
-inline static int name##_cb(LO_HANDLER_ARGS, void* osc_listener)\
-{ return ((OSCClientReceiver*)osc_listener)->_##name##_cb(path, types, argv, argc, msg); }
-
-
-/** Callbacks for "notification band" OSC messages.
- *
- * Receives all notification of engine state, but not replies on the "control
- * band". See OSC namespace documentation for details.
- *
- * Right now this class and Comm share the same lo_server_thread and the barrier
- * between them is a bit odd, but eventually this class will be able to listen
- * on a completely different port (ie have it's own lo_server_thread) to allow
- * things like listening to the notification band over TCP while sending commands
- * on the control band over UDP.
- *
- * \ingroup IngenClient
- */
-class OSCClientReceiver : public boost::noncopyable, public Raul::Deletable
-{
-public:
- OSCClientReceiver(int listen_port, SharedPtr<Shared::ClientInterface> target);
- ~OSCClientReceiver();
-
- std::string uri() const { return lo_server_thread_get_url(_st); }
-
- void start(bool dump_osc);
- void stop();
-
- int listen_port() { return _listen_port; }
- std::string listen_url() { return lo_server_thread_get_url(_st); }
-
-private:
- void setup_callbacks();
-
- static void lo_error_cb(int num, const char* msg, const char* path);
-
- static int generic_cb(const char* path, const char* types, lo_arg** argv, int argc, void* data, void* user_data);
- static int unknown_cb(const char* path, const char* types, lo_arg** argv, int argc, void* data, void* osc_receiver);
-
- SharedPtr<Shared::ClientInterface> _target;
-
- int _listen_port;
- lo_server_thread _st;
-
- LO_HANDLER(error);
- LO_HANDLER(response_ok);
- LO_HANDLER(response_error);
- LO_HANDLER(plugin);
- LO_HANDLER(plugin_list_end);
- LO_HANDLER(new_patch);
- LO_HANDLER(destroyed);
- LO_HANDLER(patch_cleared);
- LO_HANDLER(object_renamed);
- LO_HANDLER(connection);
- LO_HANDLER(disconnection);
- LO_HANDLER(new_node);
- LO_HANDLER(new_port);
- LO_HANDLER(set_variable);
- LO_HANDLER(set_property);
- LO_HANDLER(set_port_value);
- LO_HANDLER(set_voice_value);
- LO_HANDLER(port_activity);
- LO_HANDLER(program_add);
- LO_HANDLER(program_remove);
-};
-
-
-} // namespace Client
-} // namespace Ingen
-
-#endif // OSCCLIENTRECEIVER_H
diff --git a/src/libs/client/OSCEngineSender.cpp b/src/libs/client/OSCEngineSender.cpp
deleted file mode 100644
index c21d16ce..00000000
--- a/src/libs/client/OSCEngineSender.cpp
+++ /dev/null
@@ -1,420 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <iostream>
-#include <raul/AtomLiblo.hpp>
-#include "OSCEngineSender.hpp"
-
-using namespace std;
-using Raul::Atom;
-
-namespace Ingen {
-namespace Client {
-
-
-/** Note the sending port is implicitly set by liblo, lo_send by default sends
- * from the most recently created server, so create the OSC listener before
- * this to have it all happen on the same port. Yeah, this is a big magic :/
- */
-OSCEngineSender::OSCEngineSender(const string& engine_url)
- : _engine_url(engine_url)
- , _id(0)
-{
- _address = lo_address_new_from_url(engine_url.c_str());
-}
-
-
-OSCEngineSender::~OSCEngineSender()
-{
- lo_address_free(_address);
-}
-
-
-/** Attempt to connect to the engine (by pinging it).
- *
- * This doesn't register a client (or otherwise affect the client/engine state).
- * To check for success wait for the ping response with id @a ping_id (using the
- * relevant OSCClientReceiver).
- *
- * Passing a client_port of 0 will automatically choose a free port. If the
- * @a block parameter is true, this function will not return until a connection
- * has successfully been made.
- */
-void
-OSCEngineSender::attach(int32_t ping_id, bool block)
-{
- if (!_address)
- _address = lo_address_new_from_url(_engine_url.c_str());
-
- if (_address == NULL) {
- cerr << "Aborting: Unable to connect to " << _engine_url << endl;
- exit(EXIT_FAILURE);
- }
-
- cout << "[OSCEngineSender] Attempting to contact engine at " << _engine_url << " ..." << endl;
-
- _id = ping_id;
- this->ping();
-}
-
-/* *** EngineInterface implementation below here *** */
-
-
-/** Register with the engine via OSC.
- *
- * Note that this does not actually use 'key', since the engine creates
- * it's own key for OSC clients (namely the incoming URL), for NAT
- * traversal. It is a parameter to remain compatible with EngineInterface.
- */
-void
-OSCEngineSender::register_client(ClientInterface* client)
-{
- // FIXME: use parameters.. er, somehow.
- send("/ingen/register_client", "i", next_id(), LO_ARGS_END, LO_ARGS_END);
-}
-
-
-void
-OSCEngineSender::unregister_client(const string& uri)
-{
- send("/ingen/unregister_client", "i", next_id(), LO_ARGS_END);
-}
-
-
-// Engine commands
-void
-OSCEngineSender::load_plugins()
-{
- send("/ingen/load_plugins", "i", next_id(), LO_ARGS_END);
-}
-
-
-void
-OSCEngineSender::activate()
-{
- send("/ingen/activate", "i", next_id(), LO_ARGS_END);
-}
-
-
-void
-OSCEngineSender::deactivate()
-{
- send("/ingen/deactivate", "i", next_id(), LO_ARGS_END);
-}
-
-
-void
-OSCEngineSender::quit()
-{
- send("/ingen/quit", "i", next_id(), LO_ARGS_END);
-}
-
-
-
-// Object commands
-
-void
-OSCEngineSender::new_patch(const string& path,
- uint32_t poly)
-{
- send("/ingen/new_patch", "isi",
- next_id(),
- path.c_str(),
- poly,
- LO_ARGS_END);
-}
-
-
-void
-OSCEngineSender::new_port(const string& path,
- uint32_t index,
- const string& data_type,
- bool is_output)
-{
- // FIXME: use index
- send("/ingen/new_port", "issi",
- next_id(),
- path.c_str(),
- data_type.c_str(),
- (is_output ? 1 : 0),
- LO_ARGS_END);
-}
-
-
-void
-OSCEngineSender::new_node(const string& path,
- const string& plugin_uri)
-{
-
- send("/ingen/new_node", "iss",
- next_id(),
- path.c_str(),
- plugin_uri.c_str(),
- LO_ARGS_END);
-}
-
-
-/** Create a node using library name and plugin label (DEPRECATED).
- *
- * DO NOT USE THIS.
- */
-void
-OSCEngineSender::new_node_deprecated(const string& path,
- const string& plugin_type,
- const string& library_name,
- const string& plugin_label)
-{
- send("/ingen/new_node", "issss",
- next_id(),
- path.c_str(),
- plugin_type.c_str(),
- library_name.c_str(),
- plugin_label.c_str(),
- LO_ARGS_END);
-}
-
-
-void
-OSCEngineSender::rename(const string& old_path,
- const string& new_name)
-{
- send("/ingen/rename", "iss",
- next_id(),
- old_path.c_str(),
- new_name.c_str(),
- LO_ARGS_END);
-}
-
-
-void
-OSCEngineSender::destroy(const string& path)
-{
- send("/ingen/destroy", "is",
- next_id(),
- path.c_str(),
- LO_ARGS_END);
-}
-
-
-void
-OSCEngineSender::clear_patch(const string& patch_path)
-{
- send("/ingen/clear_patch", "is",
- next_id(),
- patch_path.c_str(),
- LO_ARGS_END);
-}
-
-
-void
-OSCEngineSender::connect(const string& src_port_path,
- const string& dst_port_path)
-{
- send("/ingen/connect", "iss",
- next_id(),
- src_port_path.c_str(),
- dst_port_path.c_str(),
- LO_ARGS_END);
-}
-
-
-void
-OSCEngineSender::disconnect(const string& src_port_path,
- const string& dst_port_path)
-{
- send("/ingen/disconnect", "iss",
- next_id(),
- src_port_path.c_str(),
- dst_port_path.c_str(),
- LO_ARGS_END);
-}
-
-
-void
-OSCEngineSender::disconnect_all(const string& parent_patch_path,
- const string& node_path)
-{
- send("/ingen/disconnect_all", "iss",
- next_id(),
- parent_patch_path.c_str(),
- node_path.c_str(),
- LO_ARGS_END);
-}
-
-
-void
-OSCEngineSender::set_port_value(const string& port_path,
- const Raul::Atom& value)
-{
- lo_message m = lo_message_new();
- lo_message_add_int32(m, next_id());
- lo_message_add_string(m, port_path.c_str());
- if (value.type() == Atom::BLOB)
- lo_message_add_string(m, value.get_blob_type());
- Raul::AtomLiblo::lo_message_add_atom(m, value);
- send_message("/ingen/set_port_value", m);
-}
-
-
-void
-OSCEngineSender::set_voice_value(const string& port_path,
- uint32_t voice,
- const Raul::Atom& value)
-{
- lo_message m = lo_message_new();
- lo_message_add_int32(m, next_id());
- lo_message_add_string(m, port_path.c_str());
- lo_message_add_int32(m, voice);
- if (value.type() == Atom::BLOB)
- lo_message_add_string(m, value.get_blob_type());
- Raul::AtomLiblo::lo_message_add_atom(m, value);
- send_message("/ingen/set_port_value", m);
-}
-
-
-void
-OSCEngineSender::set_program(const string& node_path,
- uint32_t bank,
- uint32_t program)
-{
- send((string("/dssi") + node_path + "/program").c_str(),
- "ii",
- bank,
- program,
- LO_ARGS_END);
-}
-
-
-void
-OSCEngineSender::midi_learn(const string& node_path)
-{
- send("/ingen/midi_learn", "is",
- next_id(),
- node_path.c_str(),
- LO_ARGS_END);
-}
-
-
-void
-OSCEngineSender::set_variable(const string& obj_path,
- const string& predicate,
- const Raul::Atom& value)
-{
- lo_message m = lo_message_new();
- lo_message_add_int32(m, next_id());
- lo_message_add_string(m, obj_path.c_str());
- lo_message_add_string(m, predicate.c_str());
- Raul::AtomLiblo::lo_message_add_atom(m, value);
- send_message("/ingen/set_variable", m);
-}
-
-
-void
-OSCEngineSender::set_property(const string& obj_path,
- const string& predicate,
- const Raul::Atom& value)
-{
- lo_message m = lo_message_new();
- lo_message_add_int32(m, next_id());
- lo_message_add_string(m, obj_path.c_str());
- lo_message_add_string(m, predicate.c_str());
- Raul::AtomLiblo::lo_message_add_atom(m, value);
- send_message("/ingen/set_property", m);
-}
-
-
-
-// Requests //
-
-void
-OSCEngineSender::ping()
-{
- send("/ingen/ping", "i", next_id(), LO_ARGS_END);
-}
-
-
-void
-OSCEngineSender::request_plugin(const string& uri)
-{
- send("/ingen/request_plugin", "is",
- next_id(),
- uri.c_str(),
- LO_ARGS_END);
-}
-
-
-void
-OSCEngineSender::request_object(const string& path)
-{
- send("/ingen/request_object", "is",
- next_id(),
- path.c_str(),
- LO_ARGS_END);
-}
-
-
-void
-OSCEngineSender::request_port_value(const string& port_path)
-{
- send("/ingen/request_port_value", "is",
- next_id(),
- port_path.c_str(),
- LO_ARGS_END);
-}
-
-
-void
-OSCEngineSender::request_variable(const string& object_path, const string& key)
-{
- send("/ingen/request_variable", "iss",
- next_id(),
- object_path.c_str(),
- key.c_str(),
- LO_ARGS_END);
-}
-
-
-void
-OSCEngineSender::request_property(const string& object_path, const string& key)
-{
- send("/ingen/request_property", "iss",
- next_id(),
- object_path.c_str(),
- key.c_str(),
- LO_ARGS_END);
-}
-
-
-void
-OSCEngineSender::request_plugins()
-{
- send("/ingen/request_plugins", "i", next_id(), LO_ARGS_END);
-}
-
-
-void
-OSCEngineSender::request_all_objects()
-{
- send("/ingen/request_all_objects", "i", next_id(), LO_ARGS_END);
-}
-
-
-
-} // namespace Client
-} // namespace Ingen
-
-
diff --git a/src/libs/client/OSCEngineSender.hpp b/src/libs/client/OSCEngineSender.hpp
deleted file mode 100644
index ef4a2fa3..00000000
--- a/src/libs/client/OSCEngineSender.hpp
+++ /dev/null
@@ -1,154 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef OSCENGINESENDER_H
-#define OSCENGINESENDER_H
-
-#include <inttypes.h>
-#include <string>
-#include <lo/lo.h>
-#include "interface/EngineInterface.hpp"
-#include "shared/OSCSender.hpp"
-using std::string;
-using Ingen::Shared::EngineInterface;
-using Ingen::Shared::ClientInterface;
-
-namespace Ingen {
-namespace Client {
-
-
-/* OSC (via liblo) interface to the engine.
- *
- * Clients can use this opaquely as an EngineInterface* to control the engine
- * over OSC (whether over a network or not, etc).
- *
- * \ingroup IngenClient
- */
-class OSCEngineSender : public EngineInterface, public Shared::OSCSender {
-public:
- OSCEngineSender(const string& engine_url);
-
- ~OSCEngineSender();
-
- std::string uri() const { return _engine_url; }
-
- inline int32_t next_id()
- { int32_t ret = (_id == -1) ? -1 : _id++; return ret; }
-
- void set_next_response_id(int32_t id) { _id = id; }
- void disable_responses() { _id = -1; }
-
- void attach(int32_t ping_id, bool block);
-
-
- /* *** EngineInterface implementation below here *** */
-
- void enable() { _enabled = true; }
- void disable() { _enabled = false; }
-
- void bundle_begin() { OSCSender::bundle_begin(); }
- void bundle_end() { OSCSender::bundle_end(); }
- void transfer_begin() { OSCSender::transfer_begin(); }
- void transfer_end() { OSCSender::transfer_end(); }
-
- // Client registration
- void register_client(ClientInterface* client);
- void unregister_client(const string& uri);
-
- // Engine commands
- void load_plugins();
- void activate();
- void deactivate();
- void quit();
-
- // Object commands
-
- void new_patch(const string& path,
- uint32_t poly);
-
- void new_port(const string& path,
- uint32_t index,
- const string& data_type,
- bool is_output);
-
- void new_node(const string& path,
- const string& plugin_uri);
-
- void new_node_deprecated(const string& path,
- const string& plugin_type,
- const string& library_name,
- const string& plugin_label);
-
- void rename(const string& old_path,
- const string& new_name);
-
- void destroy(const string& path);
-
- void clear_patch(const string& patch_path);
-
- void connect(const string& src_port_path,
- const string& dst_port_path);
-
- void disconnect(const string& src_port_path,
- const string& dst_port_path);
-
- void disconnect_all(const string& parent_patch_path,
- const string& node_path);
-
- void set_port_value(const string& port_path,
- const Raul::Atom& value);
-
- void set_voice_value(const string& port_path,
- uint32_t voice,
- const Raul::Atom& value);
-
- void set_program(const string& node_path,
- uint32_t bank,
- uint32_t program);
-
- void midi_learn(const string& node_path);
-
- void set_variable(const string& obj_path,
- const string& predicate,
- const Raul::Atom& value);
-
- void set_property(const string& obj_path,
- const string& predicate,
- const Raul::Atom& value);
-
- // Requests //
- void ping();
- void request_plugin(const string& uri);
- void request_object(const string& path);
- void request_port_value(const string& port_path);
- void request_variable(const string& path, const string& key);
- void request_property(const string& path, const string& key);
- void request_plugins();
- void request_all_objects();
-
-protected:
- const string _engine_url;
- int _client_port;
- int32_t _id;
-};
-
-
-} // namespace Client
-} // namespace Ingen
-
-#endif // OSCENGINESENDER_H
-
diff --git a/src/libs/client/ObjectModel.cpp b/src/libs/client/ObjectModel.cpp
deleted file mode 100644
index ede5f822..00000000
--- a/src/libs/client/ObjectModel.cpp
+++ /dev/null
@@ -1,148 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <iostream>
-#include <raul/TableImpl.hpp>
-#include "interface/GraphObject.hpp"
-#include "ObjectModel.hpp"
-
-using namespace std;
-
-namespace Ingen {
-namespace Client {
-
-
-ObjectModel::ObjectModel(const Path& path)
- : _path(path)
-{
-}
-
-
-ObjectModel::~ObjectModel()
-{
-}
-
-
-/** Get a variable for this object.
- *
- * @return Metadata value with key @a key, empty string otherwise.
- */
-const Atom&
-ObjectModel::get_variable(const string& key) const
-{
- static const Atom null_atom;
-
- Variables::const_iterator i = _variables.find(key);
- if (i != _variables.end())
- return i->second;
- else
- return null_atom;
-}
-
-
-/** Get a variable for this object.
- *
- * @return Metadata value with key @a key, empty string otherwise.
- */
-Atom&
-ObjectModel::get_variable( string& key)
-{
- static Atom null_atom;
-
- Variables::iterator i = _variables.find(key);
- if (i != _variables.end())
- return i->second;
- else
- return null_atom;
-}
-
-
-/** Get a property of this object.
- *
- * @return Metadata value with key @a key, empty string otherwise.
- */
-const Atom&
-ObjectModel::get_property(const string& key) const
-{
- static const Atom null_atom;
-
- Properties::const_iterator i = _properties.find(key);
- if (i != _properties.end())
- return i->second;
- else
- return null_atom;
-}
-
-
-/** Get a property of this object.
- *
- * @return Metadata value with key @a key, empty string otherwise.
- */
-Atom&
-ObjectModel::get_property(const string& key)
-{
- static Atom null_atom;
-
- Properties::iterator i = _properties.find(key);
- if (i != _properties.end())
- return i->second;
- else
- return null_atom;
-}
-
-
-bool
-ObjectModel::polyphonic() const
-{
- Properties::const_iterator i = _properties.find("ingen:polyphonic");
- return (i != _properties.end() && i->second.type() == Atom::BOOL && i->second.get_bool());
-}
-
-
-/** Merge the data of @a model with self, as much as possible.
- *
- * This will merge the two models, but with any conflict take the value in
- * @a model as correct. The paths of the two models MUST be equal.
- */
-void
-ObjectModel::set(SharedPtr<ObjectModel> o)
-{
- assert(_path == o->path());
- if (o->_parent)
- _parent = o->_parent;
-
- for (Variables::const_iterator v = o->variables().begin(); v != o->variables().end(); ++v) {
- Variables::const_iterator mine = _variables.find(v->first);
- if (mine != _variables.end())
- cerr << "WARNING: " << _path << "Client/Server variable mismatch: " << v->first << endl;
- _variables[v->first] = v->second;
- signal_variable.emit(v->first, v->second);
- }
-
- for (Properties::const_iterator v = o->properties().begin(); v != o->properties().end(); ++v) {
- Properties::const_iterator mine = _properties.find(v->first);
- if (mine != _properties.end())
- cerr << "WARNING: " << _path << "Client/Server property mismatch: " << v->first << endl;
- _properties[v->first] = v->second;
- signal_variable.emit(v->first, v->second);
- }
-}
-
-
-} // namespace Client
-} // namespace Ingen
-
diff --git a/src/libs/client/ObjectModel.hpp b/src/libs/client/ObjectModel.hpp
deleted file mode 100644
index 11cc87a4..00000000
--- a/src/libs/client/ObjectModel.hpp
+++ /dev/null
@@ -1,115 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef OBJECTMODEL_H
-#define OBJECTMODEL_H
-
-#include <cstdlib>
-#include <iostream>
-#include <string>
-#include <algorithm>
-#include <cassert>
-#include <boost/utility.hpp>
-#include <sigc++/sigc++.h>
-#include <raul/Atom.hpp>
-#include <raul/Path.hpp>
-#include <raul/SharedPtr.hpp>
-#include <raul/PathTable.hpp>
-#include "interface/GraphObject.hpp"
-
-using Raul::PathTable;
-using std::string;
-using Raul::Atom;
-using Raul::Path;
-using Raul::Symbol;
-
-namespace Ingen {
-namespace Client {
-
-class ClientStore;
-
-
-/** Base class for all GraphObject models (NodeModel, PatchModel, PortModel).
- *
- * There are no non-const public methods intentionally, models are not allowed
- * to be manipulated directly by anything (but the Store) because of the
- * asynchronous nature of engine control. To change something, use the
- * controller (which the model probably shouldn't have a reference to but oh
- * well, it reduces Collection Hell) and wait for the result (as a signal
- * from this Model).
- *
- * \ingroup IngenClient
- */
-class ObjectModel : virtual public Ingen::Shared::GraphObject
-{
-public:
- virtual ~ObjectModel();
-
- const Atom& get_variable(const string& key) const;
- Atom& get_variable( string& key);
- const Atom& get_property(const string& key) const;
- Atom& get_property(const string& key);
-
- virtual void set_variable(const string& key, const Atom& value)
- { _variables[key] = value; signal_variable.emit(key, value); }
-
- virtual void set_property(const string& key, const Atom& value)
- { _properties[key] = value; signal_property.emit(key, value); }
-
- const Variables& variables() const { return _variables; }
- const Properties& properties() const { return _properties; }
- Variables& variables() { return _variables; }
- Properties& properties() { return _properties; }
- const Path path() const { return _path; }
- const Symbol symbol() const { return _path.name(); }
- SharedPtr<ObjectModel> parent() const { return _parent; }
- bool polyphonic() const;
-
- GraphObject* graph_parent() const { return _parent.get(); }
-
- // Signals
- sigc::signal<void, SharedPtr<ObjectModel> > signal_new_child;
- sigc::signal<void, SharedPtr<ObjectModel> > signal_removed_child;
- sigc::signal<void, const string&, const Atom&> signal_variable;
- sigc::signal<void, const string&, const Atom&> signal_property;
- sigc::signal<void> signal_destroyed;
- sigc::signal<void> signal_renamed;
-
-protected:
- friend class ClientStore;
-
- ObjectModel(const Path& path);
-
- virtual void set_path(const Path& p) { _path = p; signal_renamed.emit(); }
- virtual void set_parent(SharedPtr<ObjectModel> p) { assert(p); _parent = p; }
- virtual void add_child(SharedPtr<ObjectModel> c) {}
- virtual bool remove_child(SharedPtr<ObjectModel> c) { return true; }
-
- virtual void set(SharedPtr<ObjectModel> model);
-
- Path _path;
- SharedPtr<ObjectModel> _parent;
-
- Variables _variables;
- Properties _properties;
-};
-
-
-} // namespace Client
-} // namespace Ingen
-
-#endif // OBJECTMODEL_H
diff --git a/src/libs/client/PatchModel.cpp b/src/libs/client/PatchModel.cpp
deleted file mode 100644
index af20c9f8..00000000
--- a/src/libs/client/PatchModel.cpp
+++ /dev/null
@@ -1,190 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "PatchModel.hpp"
-#include "NodeModel.hpp"
-#include "ConnectionModel.hpp"
-#include "ClientStore.hpp"
-#include <cassert>
-#include <iostream>
-
-using std::cerr; using std::cout; using std::endl;
-
-namespace Ingen {
-namespace Client {
-
-
-void
-PatchModel::add_child(SharedPtr<ObjectModel> c)
-{
- assert(c->parent().get() == this);
-
- SharedPtr<PortModel> pm = PtrCast<PortModel>(c);
- if (pm) {
- add_port(pm);
- return;
- }
-
- SharedPtr<NodeModel> nm = PtrCast<NodeModel>(c);
- if (nm)
- signal_new_node.emit(nm);
-}
-
-
-bool
-PatchModel::remove_child(SharedPtr<ObjectModel> o)
-{
- assert(o->path().is_child_of(_path));
- assert(o->parent().get() == this);
-
- SharedPtr<PortModel> pm = PtrCast<PortModel>(o);
- if (pm)
- remove_port(pm);
-
- // Remove any connections which referred to this object,
- // since they can't possibly exist anymore
- for (Connections::iterator j = _connections->begin(); j != _connections->end() ; ) {
-
- Connections::iterator next = j;
- ++next;
-
- SharedPtr<ConnectionModel> cm = PtrCast<ConnectionModel>(*j);
- assert(cm);
-
- if (cm->src_port_path().parent() == o->path()
- || cm->src_port_path() == o->path()
- || cm->dst_port_path().parent() == o->path()
- || cm->dst_port_path() == o->path()) {
- signal_removed_connection.emit(cm);
- _connections->erase(j); // cuts our reference
- assert(!get_connection(cm->src_port_path(), cm->dst_port_path())); // no duplicates
- }
- j = next;
- }
-
- SharedPtr<NodeModel> nm = PtrCast<NodeModel>(o);
- if (nm)
- signal_removed_node.emit(nm);
-
- return true;
-}
-
-
-void
-PatchModel::clear()
-{
- _connections->clear();
-
- NodeModel::clear();
-
- assert(_connections->empty());
- assert(_ports.empty());
-}
-
-
-SharedPtr<ConnectionModel>
-PatchModel::get_connection(const string& src_port_path, const string& dst_port_path) const
-{
- for (Connections::const_iterator i = _connections->begin(); i != _connections->end(); ++i)
- if ((*i)->src_port_path() == src_port_path && (*i)->dst_port_path() == dst_port_path)
- return PtrCast<ConnectionModel>(*i);
-
- return SharedPtr<ConnectionModel>();
-}
-
-
-/** Add a connection to this patch.
- *
- * A reference to @a cm is taken, released on deletion or removal.
- * If @a cm only contains paths (not pointers to the actual ports), the ports
- * will be found and set. The ports referred to not existing as children of
- * this patch is a fatal error.
- */
-void
-PatchModel::add_connection(SharedPtr<ConnectionModel> cm)
-{
- // Store should have 'resolved' the connection already
- assert(cm);
- assert(cm->src_port());
- assert(cm->dst_port());
- assert(cm->src_port()->parent());
- assert(cm->dst_port()->parent());
- assert(cm->src_port_path() != cm->dst_port_path());
- assert(cm->src_port()->parent().get() == this
- || cm->src_port()->parent()->parent().get() == this);
- assert(cm->dst_port()->parent().get() == this
- || cm->dst_port()->parent()->parent().get() == this);
-
- SharedPtr<ConnectionModel> existing = get_connection(cm->src_port_path(), cm->dst_port_path());
-
- if (existing) {
- assert(cm->src_port() == existing->src_port());
- assert(cm->dst_port() == existing->dst_port());
- } else {
- _connections->push_back(new Connections::Node(cm));
- signal_new_connection.emit(cm);
- }
-}
-
-
-void
-PatchModel::remove_connection(const string& src_port_path, const string& dst_port_path)
-{
- for (Connections::iterator i = _connections->begin(); i != _connections->end(); ++i) {
- SharedPtr<ConnectionModel> cm = PtrCast<ConnectionModel>(*i);
- assert(cm);
- if (cm->src_port_path() == src_port_path && cm->dst_port_path() == dst_port_path) {
- signal_removed_connection.emit(cm);
- delete _connections->erase(i); // cuts our reference
- assert(!get_connection(src_port_path, dst_port_path)); // no duplicates
- return;
- }
- }
-
- cerr << "[PatchModel::remove_connection] WARNING: Failed to find connection " <<
- src_port_path << " -> " << dst_port_path << endl;
-}
-
-
-bool
-PatchModel::enabled() const
-{
- Properties::const_iterator i = _properties.find("ingen:enabled");
- return (i != _properties.end() && i->second.type() == Atom::BOOL && i->second.get_bool());
-}
-
-
-void
-PatchModel::set_property(const string& key, const Atom& value)
-{
- ObjectModel::set_property(key, value);
- if (key == "ingen:polyphony")
- _poly = value.get_int32();
-}
-
-
-bool
-PatchModel::polyphonic() const
-{
- return (_parent)
- ? (_poly > 1) && _poly == PtrCast<PatchModel>(_parent)->poly() && _poly > 1
- : (_poly > 1);
-}
-
-
-} // namespace Client
-} // namespace Ingen
diff --git a/src/libs/client/PatchModel.hpp b/src/libs/client/PatchModel.hpp
deleted file mode 100644
index 70c8df0e..00000000
--- a/src/libs/client/PatchModel.hpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef PATCHMODEL_H
-#define PATCHMODEL_H
-
-#include <cassert>
-#include <list>
-#include <string>
-#include <sigc++/sigc++.h>
-#include <raul/SharedPtr.hpp>
-#include "interface/Patch.hpp"
-#include "NodeModel.hpp"
-
-#include "ConnectionModel.hpp"
-
-using std::list; using std::string;
-
-namespace Ingen {
-namespace Client {
-
-class ClientStore;
-
-
-/** Client's model of a patch.
- *
- * \ingroup IngenClient
- */
-class PatchModel : public NodeModel, public Ingen::Shared::Patch
-{
-public:
- /* WARNING: Copy constructor creates a shallow copy WRT connections */
-
- const Connections& connections() const { return *_connections.get(); }
-
- SharedPtr<ConnectionModel> get_connection(const string& src_port_path,
- const string& dst_port_path) const;
-
- uint32_t poly() const { return _poly; }
- uint32_t internal_polyphony() const { return _poly; }
- bool enabled() const;
- bool polyphonic() const;
-
- /** "editable" = arranging,connecting,adding,deleting,etc
- * not editable (control mode) you can just change controllers (performing)
- */
- bool get_editable() const { return _editable; }
- void set_editable(bool e) { if (_editable != e) {
- _editable = e;
- signal_editable.emit(e);
- } }
-
- virtual void set_property(const string& key, const Atom& value);
-
- // Signals
- sigc::signal<void, SharedPtr<NodeModel> > signal_new_node;
- sigc::signal<void, SharedPtr<NodeModel> > signal_removed_node;
- sigc::signal<void, SharedPtr<ConnectionModel> > signal_new_connection;
- sigc::signal<void, SharedPtr<ConnectionModel> > signal_removed_connection;
- sigc::signal<void, bool> signal_editable;
-
-private:
- friend class ClientStore;
-
- PatchModel(const Path& patch_path, size_t internal_poly)
- : NodeModel("ingen:Patch", patch_path)
- , _connections(new Connections())
- , _poly(internal_poly)
- , _editable(true)
- {
- }
-
- void clear();
- void add_child(SharedPtr<ObjectModel> c);
- bool remove_child(SharedPtr<ObjectModel> c);
-
- void add_connection(SharedPtr<ConnectionModel> cm);
- void remove_connection(const string& src_port_path, const string& dst_port_path);
-
- SharedPtr<Connections> _connections;
- uint32_t _poly;
- bool _editable;
-};
-
-typedef Table<string, SharedPtr<PatchModel> > PatchModelMap;
-
-
-} // namespace Client
-} // namespace Ingen
-
-#endif // PATCHMODEL_H
diff --git a/src/libs/client/PluginModel.cpp b/src/libs/client/PluginModel.cpp
deleted file mode 100644
index ff7e5b5c..00000000
--- a/src/libs/client/PluginModel.cpp
+++ /dev/null
@@ -1,143 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <sstream>
-#include <raul/Path.hpp>
-#include "PluginModel.hpp"
-#include "PatchModel.hpp"
-#include "PluginUI.hpp"
-
-using namespace std;
-using Ingen::Shared::EngineInterface;
-
-namespace Ingen {
-namespace Client {
-
-#ifdef HAVE_SLV2
-SLV2World PluginModel::_slv2_world = NULL;
-SLV2Plugins PluginModel::_slv2_plugins = NULL;
-#endif
-
-Redland::World* PluginModel::_rdf_world = NULL;
-
-
-string
-PluginModel::default_node_symbol()
-{
- return Raul::Path::nameify(_symbol);
-}
-
-
-string
-PluginModel::human_name()
-{
-#ifdef HAVE_SLV2
- if (_slv2_plugin) {
- SLV2Value name = slv2_plugin_get_name(_slv2_plugin);
- string ret = slv2_value_as_string(name);
- slv2_value_free(name);
- return ret;
- }
-#endif
- return default_node_symbol();
-}
-
-
-string
-PluginModel::port_human_name(uint32_t index)
-{
-#ifdef HAVE_SLV2
- if (_slv2_plugin) {
- Glib::Mutex::Lock lock(_rdf_world->mutex());
- SLV2Port port = slv2_plugin_get_port_by_index(_slv2_plugin, index);
- SLV2Value name = slv2_port_get_name(_slv2_plugin, port);
- string ret = slv2_value_as_string(name);
- slv2_value_free(name);
- return ret;
- }
-#endif
- return "";
-}
-
-
-#ifdef HAVE_SLV2
-bool
-PluginModel::has_ui() const
-{
- Glib::Mutex::Lock lock(_rdf_world->mutex());
-
- SLV2Value gtk_gui_uri = slv2_value_new_uri(_slv2_world,
- "http://lv2plug.in/ns/extensions/ui#GtkUI");
-
- SLV2UIs uis = slv2_plugin_get_uis(_slv2_plugin);
-
- if (slv2_values_size(uis) > 0)
- for (unsigned i=0; i < slv2_uis_size(uis); ++i)
- if (slv2_ui_is_a(slv2_uis_get_at(uis, i), gtk_gui_uri))
- return true;
-
- return false;
-}
-
-
-SharedPtr<PluginUI>
-PluginModel::ui(Ingen::Shared::World* world, SharedPtr<NodeModel> node) const
-{
- if (_type != LV2)
- return SharedPtr<PluginUI>();
-
- SharedPtr<PluginUI> ret = PluginUI::create(world, node, _slv2_plugin);
- return ret;
-}
-
-
-const string&
-PluginModel::icon_path() const
-{
- if (_icon_path == "" && _type == LV2) {
- Glib::Mutex::Lock lock(_rdf_world->mutex());
- _icon_path = get_lv2_icon_path(_slv2_plugin);
- }
-
- return _icon_path;
-}
-
-
-/** RDF world mutex must be held by the caller */
-string
-PluginModel::get_lv2_icon_path(SLV2Plugin plugin)
-{
- string result;
- SLV2Value svg_icon_pred = slv2_value_new_uri(_slv2_world,
- "http://ll-plugins.nongnu.org/lv2/namespace#svgIcon");
-
- SLV2Values paths = slv2_plugin_get_value(plugin, svg_icon_pred);
-
- if (slv2_values_size(paths) > 0) {
- SLV2Value value = slv2_values_get_at(paths, 0);
- if (slv2_value_is_uri(value))
- result = slv2_uri_to_path(slv2_value_as_string(value));
- slv2_values_free(paths);
- }
-
- slv2_value_free(svg_icon_pred);
- return result;
-}
-#endif
-
-} // namespace Client
-} // namespace Ingen
diff --git a/src/libs/client/PluginModel.hpp b/src/libs/client/PluginModel.hpp
deleted file mode 100644
index e2137e19..00000000
--- a/src/libs/client/PluginModel.hpp
+++ /dev/null
@@ -1,142 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef PLUGINMODEL_H
-#define PLUGINMODEL_H
-
-#include CONFIG_H_PATH
-#include <string>
-#include <iostream>
-#include <raul/Path.hpp>
-#include <raul/SharedPtr.hpp>
-#include <redlandmm/World.hpp>
-#ifdef HAVE_SLV2
-#include <slv2/slv2.h>
-#endif
-#include "interface/EngineInterface.hpp"
-#include "interface/Plugin.hpp"
-#include "module/World.hpp"
-
-using std::string;
-
-namespace Ingen {
-namespace Client {
-
-class PatchModel;
-class NodeModel;
-class PluginUI;
-
-
-/** Model for a plugin available for loading.
- *
- * \ingroup IngenClient
- */
-class PluginModel : public Ingen::Shared::Plugin
-{
-public:
- PluginModel(const string& uri, const string& type_uri, const string& symbol, const string& name)
- : _type(type_from_uri(type_uri))
- , _uri(uri)
- , _symbol(symbol)
- , _name(name)
- {
-#ifdef HAVE_SLV2
- Glib::Mutex::Lock lock(_rdf_world->mutex());
- SLV2Value plugin_uri = slv2_value_new_uri(_slv2_world, uri.c_str());
- _slv2_plugin = slv2_plugins_get_by_uri(_slv2_plugins, plugin_uri);
- slv2_value_free(plugin_uri);
-#endif
- }
-
- Type type() const { return _type; }
- const string& uri() const { return _uri; }
- const string& name() const { return _name; }
-
- /** DEPRECATED */
- Type type_from_string(const string& type_string) {
- if (type_string == "LV2") return LV2;
- else if (type_string == "LADSPA") return LADSPA;
- else if (type_string == "Internal") return Internal;
- else if (type_string == "Patch") return Patch;
- else return Internal; // ?
- }
-
- Type type_from_uri(const string& type_uri) {
- if (type_uri.substr(0, 6) != "ingen:") {
- return Plugin::Internal; // ?
- } else {
- return type_from_string(type_uri.substr(6));
- }
- }
-
- string default_node_symbol();
- string human_name();
- string port_human_name(uint32_t index);
-
-#ifdef HAVE_SLV2
- static SLV2World slv2_world() { return _slv2_world; }
- SLV2Plugin slv2_plugin() { return _slv2_plugin; }
-
- SLV2Port slv2_port(uint32_t index) {
- Glib::Mutex::Lock lock(_rdf_world->mutex());
- return slv2_plugin_get_port_by_index(_slv2_plugin, index);
- }
-
- static void set_slv2_world(SLV2World world) {
- Glib::Mutex::Lock lock(_rdf_world->mutex());
- _slv2_world = world;
- _slv2_plugins = slv2_world_get_all_plugins(_slv2_world);
- }
-
- bool has_ui() const;
-
- SharedPtr<PluginUI> ui(Ingen::Shared::World* world,
- SharedPtr<NodeModel> node) const;
-
- const string& icon_path() const;
- static string get_lv2_icon_path(SLV2Plugin plugin);
-#endif
-
- static void set_rdf_world(Redland::World& world) {
- _rdf_world = &world;
- }
-
- static Redland::World* rdf_world() { return _rdf_world; }
-
-private:
- const Type _type;
- const string _uri;
- const string _symbol;
- const string _name;
-
-#ifdef HAVE_SLV2
- static SLV2World _slv2_world;
- static SLV2Plugins _slv2_plugins;
-
- SLV2Plugin _slv2_plugin;
- mutable string _icon_path;
-#endif
-
- static Redland::World* _rdf_world;
-};
-
-
-} // namespace Client
-} // namespace Ingen
-
-#endif // PLUGINMODEL_H
-
diff --git a/src/libs/client/PluginUI.cpp b/src/libs/client/PluginUI.cpp
deleted file mode 100644
index 9c562135..00000000
--- a/src/libs/client/PluginUI.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <iostream>
-#include "lv2ext/lv2_event_helpers.h"
-#include "shared/LV2URIMap.hpp"
-#include "PluginUI.hpp"
-#include "NodeModel.hpp"
-#include "PortModel.hpp"
-
-using namespace std;
-using Ingen::Shared::EngineInterface;
-using Ingen::Shared::LV2URIMap;
-using Ingen::Shared::LV2Features;
-
-namespace Ingen {
-namespace Client {
-
-static void
-lv2_ui_write(LV2UI_Controller controller,
- uint32_t port_index,
- uint32_t buffer_size,
- uint32_t format,
- const void* buffer)
-{
- /*
- cerr << "lv2_ui_write (format " << format << "):" << endl;
- fprintf(stderr, "RAW:\n");
- for (uint32_t i=0; i < buffer_size; ++i) {
- unsigned char byte = ((unsigned char*)buffer)[i];
- if (byte >= 32 && byte <= 126)
- fprintf(stderr, "%c ", ((unsigned char*)buffer)[i]);
- else
- fprintf(stderr, "%2X ", ((unsigned char*)buffer)[i]);
- }
- fprintf(stderr, "\n");
- */
-
- PluginUI* ui = (PluginUI*)controller;
-
- SharedPtr<PortModel> port = ui->node()->ports()[port_index];
-
- const LV2Features::Feature* f = ui->world()->lv2_features->feature(LV2_URI_MAP_URI);
- LV2URIMap* map = (LV2URIMap*)f->controller;
- assert(map);
-
- // float (special case, always 0)
- if (format == 0) {
- assert(buffer_size == 4);
- if (*(float*)buffer == port->value().get_float())
- return; // do nothing (handle stupid plugin UIs that feed back)
-
- ui->world()->engine->set_port_value(port->path(), Atom(*(float*)buffer));
-
- // FIXME: slow, need to cache ID
- } else if (format == map->uri_to_id(NULL, "http://lv2plug.in/ns/extensions/ui#Events")) {
- uint32_t midi_event_type = map->uri_to_id(NULL, "http://lv2plug.in/ns/ext/midi#MidiEvent");
- LV2_Event_Buffer* buf = (LV2_Event_Buffer*)buffer;
- LV2_Event_Iterator iter;
- uint8_t* data;
- lv2_event_begin(&iter, buf);
- while (lv2_event_is_valid(&iter)) {
- LV2_Event* const ev = lv2_event_get(&iter, &data);
- if (ev->type == midi_event_type) {
- // FIXME: bundle multiple events by writing an entire buffer here
- ui->world()->engine->set_port_value(port->path(),
- Atom("lv2_midi:MidiEvent", ev->size, data));
- } else {
- cerr << "WARNING: Unable to send event type " << ev->type <<
- " over OSC, ignoring event" << endl;
- }
-
- lv2_event_increment(&iter);
- }
- } else {
- cerr << "WARNING: Unknown value format " << format
- << ", either plugin " << ui->node()->plugin()->uri() << " is broken"
- << " or this is an Ingen bug" << endl;
- }
-}
-
-
-PluginUI::PluginUI(Ingen::Shared::World* world,
- SharedPtr<NodeModel> node)
- : _world(world)
- , _node(node)
- , _instance(NULL)
-{
-}
-
-
-PluginUI::~PluginUI()
-{
- Glib::Mutex::Lock lock(PluginModel::rdf_world()->mutex());
- slv2_ui_instance_free(_instance);
-}
-
-
-SharedPtr<PluginUI>
-PluginUI::create(Ingen::Shared::World* world,
- SharedPtr<NodeModel> node,
- SLV2Plugin plugin)
-{
- Glib::Mutex::Lock lock(PluginModel::rdf_world()->mutex());
- SharedPtr<PluginUI> ret;
-
- SLV2Value gtk_gui_uri = slv2_value_new_uri(world->slv2_world,
- "http://lv2plug.in/ns/extensions/ui#GtkUI");
-
- SLV2UIs uis = slv2_plugin_get_uis(plugin);
- SLV2UI ui = NULL;
-
- if (slv2_values_size(uis) > 0) {
- for (unsigned i=0; i < slv2_uis_size(uis); ++i) {
- SLV2UI this_ui = slv2_uis_get_at(uis, i);
- if (slv2_ui_is_a(this_ui, gtk_gui_uri)) {
- ui = this_ui;
- break;
- }
- }
- }
-
- if (ui) {
- cout << "Found GTK Plugin UI: " << slv2_ui_get_uri(ui) << endl;
- ret = SharedPtr<PluginUI>(new PluginUI(world, node));
- SLV2UIInstance inst = slv2_ui_instantiate(
- plugin, ui, lv2_ui_write, ret.get(), world->lv2_features->lv2_features());
-
- if (inst) {
- ret->set_instance(inst);
- } else {
- cerr << "ERROR: Failed to instantiate Plugin UI" << endl;
- ret = SharedPtr<PluginUI>();
- }
- }
-
- slv2_value_free(gtk_gui_uri);
- return ret;
-}
-
-
-} // namespace Client
-} // namespace Ingen
diff --git a/src/libs/client/PluginUI.hpp b/src/libs/client/PluginUI.hpp
deleted file mode 100644
index d20dd16a..00000000
--- a/src/libs/client/PluginUI.hpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef PLUGINUI_H
-#define PLUGINUI_H
-
-#include <slv2/slv2.h>
-#include <raul/SharedPtr.hpp>
-#include "module/World.hpp"
-
-namespace Ingen {
-namespace Shared { class EngineInterface; }
-namespace Client {
-
-class NodeModel;
-
-
-/** Model for a plugin available for loading.
- *
- * \ingroup IngenClient
- */
-class PluginUI {
-public:
- ~PluginUI();
-
- static SharedPtr<PluginUI> create(Ingen::Shared::World* world,
- SharedPtr<NodeModel> node,
- SLV2Plugin plugin);
-
- Ingen::Shared::World* world() const { return _world; }
- SharedPtr<NodeModel> node() const { return _node; }
- SLV2UIInstance instance() const { return _instance; }
-
-private:
- PluginUI(Ingen::Shared::World* world,
- SharedPtr<NodeModel> node);
-
- void set_instance(SLV2UIInstance instance) { _instance = instance; }
-
- Ingen::Shared::World* _world;
- SharedPtr<NodeModel> _node;
- SLV2UIInstance _instance;
-};
-
-
-} // namespace Client
-} // namespace Ingen
-
-#endif // PLUGINUI_H
-
-
diff --git a/src/libs/client/PortModel.cpp b/src/libs/client/PortModel.cpp
deleted file mode 100644
index c18378db..00000000
--- a/src/libs/client/PortModel.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "PortModel.hpp"
-#include "NodeModel.hpp"
-
-namespace Ingen {
-namespace Client {
-
-
-bool
-PortModel::is_logarithmic() const
-{
- const Atom& hint = get_variable("ingen:logarithmic");
- return (hint.is_valid() && hint.get_bool() > 0);
-}
-
-
-bool
-PortModel::is_integer() const
-{
- const Atom& hint = get_variable("ingen:integer");
- return (hint.is_valid() && hint.get_bool() > 0);
-}
-
-
-bool
-PortModel::is_toggle() const
-{
- const Atom& hint = get_variable("ingen:toggled");
- return (hint.is_valid() && hint.get_bool() > 0);
-}
-
-
-void
-PortModel::set(SharedPtr<ObjectModel> model)
-{
- SharedPtr<PortModel> port = PtrCast<PortModel>(model);
- if (port) {
- _index = port->_index;
- _type = port->_type;
- _direction = port->_direction;
- _current_val = port->_current_val;
- _connections = port->_connections;
- signal_value_changed.emit(_current_val);
- }
-
- ObjectModel::set(model);
-}
-
-} // namespace Client
-} // namespace Ingen
diff --git a/src/libs/client/PortModel.hpp b/src/libs/client/PortModel.hpp
deleted file mode 100644
index a7f52679..00000000
--- a/src/libs/client/PortModel.hpp
+++ /dev/null
@@ -1,112 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef PORTMODEL_H
-#define PORTMODEL_H
-
-#include <cstdlib>
-#include <iostream>
-#include <string>
-#include <vector>
-#include <sigc++/sigc++.h>
-#include <raul/SharedPtr.hpp>
-#include <raul/Path.hpp>
-#include "interface/Port.hpp"
-#include "ObjectModel.hpp"
-
-using std::string; using std::vector;
-
-namespace Ingen {
-namespace Client {
-
-
-/** Model of a port.
- *
- * \ingroup IngenClient
- */
-class PortModel : public ObjectModel, public Ingen::Shared::Port
-{
-public:
- enum Direction { INPUT, OUTPUT };
-
- inline uint32_t index() const { return _index; }
- inline DataType type() const { return _type; }
- inline const Atom& value() const { return _current_val; }
- inline bool connected() const { return (_connections > 0); }
- inline bool is_input() const { return (_direction == INPUT); }
- inline bool is_output() const { return (_direction == OUTPUT); }
-
- bool is_logarithmic() const;
- bool is_integer() const;
- bool is_toggle() const;
-
- inline bool operator==(const PortModel& pm) const { return (_path == pm._path); }
-
- inline void value(const Atom& val) {
- if (val != _current_val) {
- _current_val = val;
- signal_value_changed.emit(val);
- }
- }
-
- inline void value(uint32_t voice, const Atom& val) {
- // FIXME: implement properly
- signal_voice_changed.emit(voice, val);
- }
-
- // Signals
- sigc::signal<void, const Atom&> signal_value_changed; ///< Value ports
- sigc::signal<void, uint32_t, const Atom&> signal_voice_changed; ///< Polyphonic value ports
- sigc::signal<void> signal_activity; ///< Message ports
- sigc::signal<void, SharedPtr<PortModel> > signal_connection;
- sigc::signal<void, SharedPtr<PortModel> > signal_disconnection;
-
-private:
- friend class ClientStore;
-
- PortModel(const Path& path, uint32_t index, DataType type, Direction dir)
- : ObjectModel(path)
- , _index(index)
- , _type(type)
- , _direction(dir)
- , _current_val(0.0f)
- , _connections(0)
- {
- if (_type == DataType::UNKNOWN)
- std::cerr << "[PortModel] Warning: Unknown port type" << std::endl;
- }
-
- void add_child(SharedPtr<ObjectModel> c) { throw; }
- bool remove_child(SharedPtr<ObjectModel> c) { throw; }
-
- void connected_to(SharedPtr<PortModel> p) { ++_connections; signal_connection.emit(p); }
- void disconnected_from(SharedPtr<PortModel> p) { --_connections; signal_disconnection.emit(p); }
-
- void set(SharedPtr<ObjectModel> model);
-
- uint32_t _index;
- DataType _type;
- Direction _direction;
- Atom _current_val;
- size_t _connections;
-};
-
-
-} // namespace Client
-} // namespace Ingen
-
-#endif // PORTMODEL_H
diff --git a/src/libs/client/SigClientInterface.hpp b/src/libs/client/SigClientInterface.hpp
deleted file mode 100644
index 7ab32c12..00000000
--- a/src/libs/client/SigClientInterface.hpp
+++ /dev/null
@@ -1,156 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef SIGCLIENTINTERFACE_H
-#define SIGCLIENTINTERFACE_H
-
-#include <inttypes.h>
-#include <string>
-#include <sigc++/sigc++.h>
-#include "interface/ClientInterface.hpp"
-using std::string;
-
-namespace Ingen {
-namespace Client {
-
-
-/** A LibSigC++ signal emitting interface for clients to use.
- *
- * This simply emits an sigc signal for every event (eg OSC message) coming from
- * the engine. Use Store (which extends this) if you want a nice client-side
- * model of the engine.
- *
- * The signals here match the calls to ClientInterface exactly. See the
- * documentation for ClientInterface for meanings of signal parameters.
- */
-class SigClientInterface : public Ingen::Shared::ClientInterface, public sigc::trackable
-{
-public:
- SigClientInterface() : _enabled(true) {}
-
- bool enabled() const { return _enabled; }
-
- std::string uri() const { return "(internal)"; }
-
- // Signal parameters match up directly with ClientInterface calls
-
- sigc::signal<void, int32_t> signal_response_ok;
- sigc::signal<void, int32_t, string> signal_response_error;
- sigc::signal<void> signal_bundle_begin;
- sigc::signal<void> signal_bundle_end;
- sigc::signal<void, string> signal_error;
- sigc::signal<void, string, string, string, string> signal_new_plugin;
- sigc::signal<void, string, uint32_t> signal_new_patch;
- sigc::signal<void, string, string> signal_new_node;
- sigc::signal<void, string, uint32_t, string, bool> signal_new_port;
- sigc::signal<void, string> signal_patch_cleared;
- sigc::signal<void, string, string> signal_object_renamed;
- sigc::signal<void, string> signal_object_destroyed;
- sigc::signal<void, string, string> signal_connection;
- sigc::signal<void, string, string> signal_disconnection;
- sigc::signal<void, string, string, Raul::Atom> signal_variable_change;
- sigc::signal<void, string, string, Raul::Atom> signal_property_change;
- sigc::signal<void, string, Raul::Atom> signal_port_value;
- sigc::signal<void, string, uint32_t, Raul::Atom> signal_voice_value;
- sigc::signal<void, string> signal_port_activity;
- sigc::signal<void, string, uint32_t, uint32_t, string> signal_program_add;
- sigc::signal<void, string, uint32_t, uint32_t> signal_program_remove;
-
- /** Fire pending signals. Only does anything on derived classes (that may queue) */
- virtual bool emit_signals() { return false; }
-
-protected:
-
- bool _enabled;
-
- // ClientInterface hooks that fire the above signals
-
- void enable() { _enabled = true; }
- void disable() { _enabled = false ; }
-
- void bundle_begin()
- { if (_enabled) signal_bundle_begin.emit(); }
-
- void bundle_end()
- { if (_enabled) signal_bundle_end.emit(); }
-
- void transfer_begin() {}
- void transfer_end() {}
-
- void response_ok(int32_t id)
- { if (_enabled) signal_response_ok.emit(id); }
-
- void response_error(int32_t id, const string& msg)
- { if (_enabled) signal_response_error.emit(id, msg); }
-
- void error(const string& msg)
- { if (_enabled) signal_error.emit(msg); }
-
- void new_plugin(const string& uri, const string& type_uri, const string& symbol, const string& name)
- { if (_enabled) signal_new_plugin.emit(uri, type_uri, symbol, name); }
-
- void new_patch(const string& path, uint32_t poly)
- { if (_enabled) signal_new_patch.emit(path, poly); }
-
- void new_node(const string& path, const string& plugin_uri)
- { if (_enabled) signal_new_node.emit(path, plugin_uri); }
-
- void new_port(const string& path, uint32_t index, const string& data_type, bool is_output)
- { if (_enabled) signal_new_port.emit(path, index, data_type, is_output); }
-
- void connect(const string& src_port_path, const string& dst_port_path)
- { if (_enabled) signal_connection.emit(src_port_path, dst_port_path); }
-
- void destroy(const string& path)
- { if (_enabled) signal_object_destroyed.emit(path); }
-
- void patch_cleared(const string& path)
- { if (_enabled) signal_patch_cleared.emit(path); }
-
- void object_renamed(const string& old_path, const string& new_path)
- { if (_enabled) signal_object_renamed.emit(old_path, new_path); }
-
- void disconnect(const string& src_port_path, const string& dst_port_path)
- { if (_enabled) signal_disconnection.emit(src_port_path, dst_port_path); }
-
- void set_variable(const string& path, const string& key, const Raul::Atom& value)
- { if (_enabled) signal_variable_change.emit(path, key, value); }
-
- void set_property(const string& path, const string& key, const Raul::Atom& value)
- { if (_enabled) signal_property_change.emit(path, key, value); }
-
- void set_port_value(const string& port_path, const Raul::Atom& value)
- { if (_enabled) signal_port_value.emit(port_path, value); }
-
- void set_voice_value(const string& port_path, uint32_t voice, const Raul::Atom& value)
- { if (_enabled) signal_voice_value.emit(port_path, voice, value); }
-
- void port_activity(const string& port_path)
- { if (_enabled) signal_port_activity.emit(port_path); }
-
- void program_add(const string& path, uint32_t bank, uint32_t program, const string& name)
- { if (_enabled) signal_program_add.emit(path, bank, program, name); }
-
- void program_remove(const string& path, uint32_t bank, uint32_t program)
- { if (_enabled) signal_program_remove.emit(path, bank, program); }
-};
-
-
-} // namespace Client
-} // namespace Ingen
-
-#endif
diff --git a/src/libs/client/ThreadedSigClientInterface.cpp b/src/libs/client/ThreadedSigClientInterface.cpp
deleted file mode 100644
index ef95133b..00000000
--- a/src/libs/client/ThreadedSigClientInterface.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "ThreadedSigClientInterface.hpp"
-#include <iostream>
-
-using namespace std;
-
-namespace Ingen {
-namespace Client {
-
-
-/** Push an event (from the engine, ie 'new patch') on to the queue.
- */
-void
-ThreadedSigClientInterface::push_sig(Closure ev)
-{
- _attached = true;
- if (!_enabled)
- return;
-
- bool success = false;
- while (!success) {
- success = _sigs.push(ev);
- if (!success) {
- cerr << "WARNING: Client event queue full. Waiting..." << endl;
- _mutex.lock();
- _cond.wait(_mutex);
- _mutex.unlock();
- cerr << "Queue drained, continuing" << endl;
- }
- }
-}
-
-
-/** Process all queued events that came from the OSC thread.
- *
- * This function should be called from the Gtk thread to emit signals and cause
- * the connected methods to execute.
- */
-bool
-ThreadedSigClientInterface::emit_signals()
-{
- // Process a limited number of events, to prevent locking the GTK
- // thread indefinitely while processing continually arriving events
-
- size_t num_processed = 0;
- while (!_sigs.empty() && num_processed++ < (_sigs.capacity() * 3 / 4)) {
- Closure& ev = _sigs.front();
- ev();
- ev.disconnect();
- _sigs.pop();
- }
-
- _mutex.lock();
- _cond.broadcast();
- _mutex.unlock();
-
- return true;
-}
-
-
-} // namespace Client
-} // namespace Ingen
diff --git a/src/libs/client/ThreadedSigClientInterface.hpp b/src/libs/client/ThreadedSigClientInterface.hpp
deleted file mode 100644
index 3014c139..00000000
--- a/src/libs/client/ThreadedSigClientInterface.hpp
+++ /dev/null
@@ -1,184 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef THREADEDSIGCLIENTINTERFACE_H
-#define THREADEDSIGCLIENTINTERFACE_H
-
-#include <inttypes.h>
-#include <string>
-#include <sigc++/sigc++.h>
-#include <glibmm/thread.h>
-#include "interface/ClientInterface.hpp"
-#include "SigClientInterface.hpp"
-#include <raul/Atom.hpp>
-#include <raul/SRSWQueue.hpp>
-
-using std::string;
-
-/** Returns nothing and takes no parameters (because they have all been bound) */
-typedef sigc::slot<void> Closure;
-
-namespace Ingen {
-namespace Shared { class EngineInterface; }
-namespace Client {
-
-
-/** A LibSigC++ signal emitting interface for clients to use.
- *
- * This emits signals (possibly) in a different thread than the ClientInterface
- * functions are called. It must be explicitly driven with the emit_signals()
- * function, which fires all enqueued signals up until the present. You can
- * use this in a GTK idle callback for receiving thread safe engine signals.
- */
-class ThreadedSigClientInterface : public SigClientInterface
-{
-public:
- ThreadedSigClientInterface(uint32_t queue_size)
- : _sigs(queue_size)
- , response_ok_slot(signal_response_ok.make_slot())
- , response_error_slot(signal_response_error.make_slot())
- , error_slot(signal_error.make_slot())
- , new_plugin_slot(signal_new_plugin.make_slot())
- , new_patch_slot(signal_new_patch.make_slot())
- , new_node_slot(signal_new_node.make_slot())
- , new_port_slot(signal_new_port.make_slot())
- , connection_slot(signal_connection.make_slot())
- , patch_cleared_slot(signal_patch_cleared.make_slot())
- , object_destroyed_slot(signal_object_destroyed.make_slot())
- , object_renamed_slot(signal_object_renamed.make_slot())
- , disconnection_slot(signal_disconnection.make_slot())
- , variable_change_slot(signal_variable_change.make_slot())
- , property_change_slot(signal_property_change.make_slot())
- , port_value_slot(signal_port_value.make_slot())
- , port_activity_slot(signal_port_activity.make_slot())
- , program_add_slot(signal_program_add.make_slot())
- , program_remove_slot(signal_program_remove.make_slot())
- {
- }
-
- virtual std::string uri() const { return "(internal)"; }
-
- virtual void subscribe(Shared::EngineInterface* engine) { throw; }
-
- bool enabled() const { return _attached; }
-
- void bundle_begin()
- { push_sig(bundle_begin_slot); }
-
- void bundle_end()
- { push_sig(bundle_end_slot); }
-
- void transfer_begin() {}
- void transfer_end() {}
-
- void response_ok(int32_t id)
- { push_sig(sigc::bind(response_ok_slot, id)); }
-
- void response_error(int32_t id, const string& msg)
- { push_sig(sigc::bind(response_error_slot, id, msg)); }
-
- void error(const string& msg)
- { push_sig(sigc::bind(error_slot, msg)); }
-
- void new_plugin(const string& uri, const string& type_uri, const string& symbol, const string& name)
- { push_sig(sigc::bind(new_plugin_slot, uri, type_uri, symbol, name)); }
-
- void new_patch(const string& path, uint32_t poly)
- { push_sig(sigc::bind(new_patch_slot, path, poly)); }
-
- void new_node(const string& path, const string& plugin_uri)
- { push_sig(sigc::bind(new_node_slot, path, plugin_uri)); }
-
- void new_port(const string& path, uint32_t index, const string& data_type, bool is_output)
- { push_sig(sigc::bind(new_port_slot, path, index, data_type, is_output)); }
-
- void connect(const string& src_port_path, const string& dst_port_path)
- { push_sig(sigc::bind(connection_slot, src_port_path, dst_port_path)); }
-
- void destroy(const string& path)
- { push_sig(sigc::bind(object_destroyed_slot, path)); }
-
- void patch_cleared(const string& path)
- { push_sig(sigc::bind(patch_cleared_slot, path)); }
-
- void object_renamed(const string& old_path, const string& new_path)
- { push_sig(sigc::bind(object_renamed_slot, old_path, new_path)); }
-
- void disconnect(const string& src_port_path, const string& dst_port_path)
- { push_sig(sigc::bind(disconnection_slot, src_port_path, dst_port_path)); }
-
- void set_variable(const string& path, const string& key, const Raul::Atom& value)
- { push_sig(sigc::bind(variable_change_slot, path, key, value)); }
-
- void set_property(const string& path, const string& key, const Raul::Atom& value)
- { push_sig(sigc::bind(property_change_slot, path, key, value)); }
-
- void set_port_value(const string& port_path, const Raul::Atom& value)
- { push_sig(sigc::bind(port_value_slot, port_path, value)); }
-
- void set_voice_value(const string& port_path, uint32_t voice, const Raul::Atom& value)
- { push_sig(sigc::bind(voice_value_slot, port_path, voice, value)); }
-
- void port_activity(const string& port_path)
- { push_sig(sigc::bind(port_activity_slot, port_path)); }
-
- void program_add(const string& path, uint32_t bank, uint32_t program, const string& name)
- { push_sig(sigc::bind(program_add_slot, path, bank, program, name)); }
-
- void program_remove(const string& path, uint32_t bank, uint32_t program)
- { push_sig(sigc::bind(program_remove_slot, path, bank, program)); }
-
- /** Process all queued events - Called from GTK thread to emit signals. */
- bool emit_signals();
-
-private:
- void push_sig(Closure ev);
-
- Glib::Mutex _mutex;
- Glib::Cond _cond;
-
- Raul::SRSWQueue<Closure> _sigs;
- bool _attached;
-
- sigc::slot<void> bundle_begin_slot;
- sigc::slot<void> bundle_end_slot;
- sigc::slot<void, int32_t> response_ok_slot;
- sigc::slot<void, int32_t, string> response_error_slot;
- sigc::slot<void, string> error_slot;
- sigc::slot<void, string, string, string, string> new_plugin_slot;
- sigc::slot<void, string, uint32_t> new_patch_slot;
- sigc::slot<void, string, string> new_node_slot;
- sigc::slot<void, string, uint32_t, string, bool> new_port_slot;
- sigc::slot<void, string, string> connection_slot;
- sigc::slot<void, string> patch_cleared_slot;
- sigc::slot<void, string> object_destroyed_slot;
- sigc::slot<void, string, string> object_renamed_slot;
- sigc::slot<void, string, string> disconnection_slot;
- sigc::slot<void, string, string, Raul::Atom> variable_change_slot;
- sigc::slot<void, string, string, Raul::Atom> property_change_slot;
- sigc::slot<void, string, Raul::Atom> port_value_slot;
- sigc::slot<void, string, uint32_t, Raul::Atom> voice_value_slot;
- sigc::slot<void, string> port_activity_slot;
- sigc::slot<void, string, uint32_t, uint32_t, string> program_add_slot;
- sigc::slot<void, string, uint32_t, uint32_t> program_remove_slot;
-};
-
-
-} // namespace Client
-} // namespace Ingen
-
-#endif
diff --git a/src/libs/client/client.cpp b/src/libs/client/client.cpp
deleted file mode 100644
index f3d62471..00000000
--- a/src/libs/client/client.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include CONFIG_H_PATH
-
-#include <iostream>
-#include "client.hpp"
-#include "OSCEngineSender.hpp"
-#ifdef WITH_SOUP
-#include "HTTPEngineSender.hpp"
-#endif
-
-using namespace std;
-
-namespace Ingen {
-namespace Client {
-
-
-SharedPtr<Ingen::Shared::EngineInterface>
-new_remote_interface(const std::string& url)
-{
- const string scheme = url.substr(0, url.find(":"));
- cout << "SCHEME: " << scheme << endl;
- if (scheme == "osc.udp" || scheme == "osc.tcp") {
- OSCEngineSender* oes = new OSCEngineSender(url);
- oes->attach(rand(), true);
- return SharedPtr<Shared::EngineInterface>(oes);
-#ifdef WITH_SOUP
- } else if (scheme == "http") {
- HTTPEngineSender* hes = new HTTPEngineSender(url);
- hes->attach(rand(), true);
- return SharedPtr<Shared::EngineInterface>(hes);
-#endif
- } else {
- cerr << "WARNING: Unknown URI scheme '" << scheme << "'" << endl;
- return SharedPtr<Shared::EngineInterface>();
- }
-}
-
-
-} // namespace Client
-} // namespace Ingen
-
diff --git a/src/libs/client/client.hpp b/src/libs/client/client.hpp
deleted file mode 100644
index 82166da5..00000000
--- a/src/libs/client/client.hpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef INGEN_CLIENT_H
-#define INGEN_CLIENT_H
-
-#include <raul/SharedPtr.hpp>
-
-namespace Ingen {
-
-class Engine;
-
-namespace Shared { class EngineInterface; }
-
-namespace Client {
-
-extern "C" {
-
- SharedPtr<Shared::EngineInterface> new_remote_interface(const std::string& url);
- SharedPtr<Shared::EngineInterface> new_queued_interface(SharedPtr<Ingen::Engine> engine);
-
-}
-
-
-} // namespace Client
-} // namespace Ingen
-
-#endif // INGEN_CLIENT_H
-
diff --git a/src/libs/client/wscript b/src/libs/client/wscript
deleted file mode 100644
index 6b4408a7..00000000
--- a/src/libs/client/wscript
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/usr/bin/env python
-import Params
-
-def build(bld):
- obj = bld.create_obj('cpp', 'shlib')
- obj.source = '''
- ClientStore.cpp
- NodeModel.cpp
- ObjectModel.cpp
- PatchModel.cpp
- PluginModel.cpp
- PluginUI.cpp
- PortModel.cpp
- ThreadedSigClientInterface.cpp
- client.cpp
- '''
-
- if bld.env()['HAVE_SOUP']:
- obj.source += '''
- HTTPClientReceiver.cpp
- HTTPEngineSender.cpp
- '''
-
- if bld.env()['HAVE_XML2']:
- obj.source += ' DeprecatedLoader.cpp '
-
- if bld.env()['HAVE_LIBLO']:
- obj.source += ' OSCClientReceiver.cpp OSCEngineSender.cpp '
-
- obj.includes = ['..', '../../common', '../..']
- obj.name = 'libingen_client'
- obj.target = 'ingen_client'
- obj.uselib = 'GLIBMM SLV2 RAUL REDLANDMM SOUP XML2 SIGCPP'
- obj.vnum = '0.0.0'
-
diff --git a/src/libs/engine/AudioBuffer.cpp b/src/libs/engine/AudioBuffer.cpp
deleted file mode 100644
index 098103c0..00000000
--- a/src/libs/engine/AudioBuffer.cpp
+++ /dev/null
@@ -1,299 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <iostream>
-#include <cassert>
-#include <stdlib.h>
-#include "AudioBuffer.hpp"
-
-using namespace std;
-
-/* TODO: Be sure these functions are vectorized by GCC when it's vectorizer
- * stops sucking. Probably a good idea to inline them as well */
-
-namespace Ingen {
-
-
-AudioBuffer::AudioBuffer(size_t size)
- : Buffer((size == 1) ? DataType::CONTROL : DataType::AUDIO, size)
- , _data(NULL)
- , _local_data(NULL)
- , _size(size)
- , _filled_size(0)
- , _state(OK)
- , _set_value(0)
- , _set_time(0)
-{
- assert(_size > 0);
- allocate();
- assert(data());
-}
-
-
-void
-AudioBuffer::resize(size_t size)
-{
- _size = size;
-
- Sample* const old_data = _data;
-
- const bool using_local_data = (_data == _local_data);
-
- deallocate();
-
- const int ret = posix_memalign((void**)&_local_data, 16, _size * sizeof(Sample));
- if (ret != 0) {
- cerr << "[Buffer] Failed to allocate buffer. Aborting." << endl;
- exit(EXIT_FAILURE);
- }
-
- assert(ret == 0);
- assert(_local_data);
-
- if (using_local_data)
- _data = _local_data;
- else
- _data = old_data;
-
- set_block(0, 0, _size-1);
-}
-
-
-/** Allocate and use a locally managed buffer (data).
- */
-void
-AudioBuffer::allocate()
-{
- assert(!_joined_buf);
- assert(_local_data == NULL);
- assert(_size > 0);
-
- const int ret = posix_memalign((void**)&_local_data, 16, _size * sizeof(Sample));
- if (ret != 0) {
- cerr << "[Buffer] Failed to allocate buffer. Aborting." << endl;
- exit(EXIT_FAILURE);
- }
-
- assert(ret == 0);
- assert(_local_data);
-
- _data = _local_data;
-
- set_block(0, 0, _size-1);
-}
-
-
-/** Free locally allocated buffer.
- */
-void
-AudioBuffer::deallocate()
-{
- assert(!_joined_buf);
- free(_local_data);
- _local_data = NULL;
- _data = NULL;
-}
-
-
-/** Empty (ie zero) the buffer.
- */
-void
-AudioBuffer::clear()
-{
- set_block(0, 0, _size-1);
- _state = OK;
- _filled_size = 0;
-}
-
-
-/** Set value of buffer to @a val after @a start_sample.
- *
- * The Buffer will handle setting the intial portion of the buffer to the
- * value on the next cycle automatically (if @a start_sample is > 0), as
- * long as pre_process() is called every cycle.
- */
-void
-AudioBuffer::set_value(Sample val, FrameTime cycle_start, FrameTime time)
-{
- if (_size == 1)
- time = cycle_start;
-
- FrameTime offset = time - cycle_start;
- assert(offset <= _size);
-
- if (offset < _size) {
- set_block(val, offset, _size - 1);
-
- if (offset > 0)
- _state = HALF_SET_CYCLE_1;
- } // else trigger at very end of block
-
- _set_time = time;
- _set_value = val;
-}
-
-
-/** Set a block of buffer to @a val.
- *
- * @a start_sample and @a end_sample define the inclusive range to be set.
- */
-void
-AudioBuffer::set_block(Sample val, size_t start_offset, size_t end_offset)
-{
- assert(end_offset >= start_offset);
- assert(end_offset < _size);
-
- Sample* const buf = data();
- assert(buf);
-
- for (size_t i = start_offset; i <= end_offset; ++i)
- buf[i] = val;
-}
-
-
-/** Scale a block of buffer by @a val.
- *
- * @a start_sample and @a end_sample define the inclusive range to be set.
- */
-void
-AudioBuffer::scale(Sample val, size_t start_sample, size_t end_sample)
-{
- assert(end_sample >= start_sample);
- assert(end_sample < _size);
-
- Sample* const buf = data();
- assert(buf);
-
- for (size_t i=start_sample; i <= end_sample; ++i)
- buf[i] *= val;
-}
-
-
-/** Copy a block of @a src into buffer.
- *
- * @a start_sample and @a end_sample define the inclusive range to be set.
- * This function only copies the same range in one buffer to another.
- */
-void
-AudioBuffer::copy(const Buffer* src, size_t start_sample, size_t end_sample)
-{
- assert(end_sample >= start_sample);
- assert(end_sample < _size);
- assert(src);
- assert(src->type() == DataType::CONTROL || DataType::AUDIO);
-
- Sample* const buf = data();
- assert(buf);
-
- const Sample* const src_buf = ((AudioBuffer*)src)->data();
- assert(src_buf);
-
- for (size_t i=start_sample; i <= end_sample; ++i)
- buf[i] = src_buf[i];
-}
-
-
-/** Accumulate a block of @a src into @a dst.
- *
- * @a start_sample and @a end_sample define the inclusive range to be accumulated.
- * This function only adds the same range in one buffer to another.
- */
-void
-AudioBuffer::accumulate(const AudioBuffer* const src, size_t start_sample, size_t end_sample)
-{
- assert(end_sample >= start_sample);
- assert(end_sample < _size);
- assert(src);
-
- Sample* const buf = data();
- assert(buf);
-
- const Sample* const src_buf = src->data();
- assert(src_buf);
-
- for (size_t i=start_sample; i <= end_sample; ++i)
- buf[i] += src_buf[i];
-
-}
-
-
-/** Use another buffer's data instead of the local one.
- *
- * This buffer will essentially be identical to @a buf after this call.
- */
-bool
-AudioBuffer::join(Buffer* buf)
-{
- AudioBuffer* abuf = dynamic_cast<AudioBuffer*>(buf);
- if (!abuf)
- return false;
-
- assert(abuf->size() >= _size);
-
- _joined_buf = abuf;
- _filled_size = abuf->filled_size();
-
- assert(_filled_size <= _size);
-
- return true;
-}
-
-
-void
-AudioBuffer::unjoin()
-{
- _joined_buf = NULL;
- _data = _local_data;
-}
-
-
-void
-AudioBuffer::prepare_read(FrameTime start, SampleCount nframes)
-{
- // FIXME: nframes parameter doesn't actually work,
- // writing starts from 0 every time
- assert(_size == 1 || nframes == _size);
-
- switch (_state) {
- case HALF_SET_CYCLE_1:
- if (start > _set_time)
- _state = HALF_SET_CYCLE_2;
- break;
- case HALF_SET_CYCLE_2:
- set_block(_set_value, 0, _size-1);
- _state = OK;
- break;
- default:
- break;
- }
-}
-
-
-/** Set the buffer (data) used.
- *
- * This is only to be used by Drivers (to provide zero-copy processing).
- */
-void
-AudioBuffer::set_data(Sample* buf)
-{
- assert(buf);
- assert(!_joined_buf);
- _data = buf;
-}
-
-
-} // namespace Ingen
diff --git a/src/libs/engine/AudioBuffer.hpp b/src/libs/engine/AudioBuffer.hpp
deleted file mode 100644
index 513c188f..00000000
--- a/src/libs/engine/AudioBuffer.hpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AUDIOBUFFER_H
-#define AUDIOBUFFER_H
-
-#include <cstddef>
-#include <cassert>
-#include <boost/utility.hpp>
-#include "types.hpp"
-#include "Buffer.hpp"
-
-namespace Ingen {
-
-
-class AudioBuffer : public Buffer
-{
-public:
- AudioBuffer(size_t capacity);
-
- void clear();
- void set_value(Sample val, FrameTime cycle_start, FrameTime time);
- void set_block(Sample val, size_t start_offset, size_t end_offset);
- void scale(Sample val, size_t start_sample, size_t end_sample);
- void copy(const Buffer* src, size_t start_sample, size_t end_sample);
- void accumulate(const AudioBuffer* src, size_t start_sample, size_t end_sample);
-
- bool join(Buffer* buf);
- void unjoin();
-
- /** For driver use only!! */
- void set_data(Sample* data);
-
- inline const void* raw_data() const { return _data; }
- inline void* raw_data() { return _data; }
-
- inline Sample* data() const { return _data; }
-
- inline Sample& value_at(size_t offset) const
- { assert(offset < _size); return data()[offset]; }
-
- void prepare_read(FrameTime start, SampleCount nframes);
- void prepare_write(FrameTime start, SampleCount nframes) {}
-
- void rewind() const {}
- void resize(size_t size);
-
- void filled_size(size_t size) { _filled_size = size; }
- size_t filled_size() const { return _filled_size; }
- size_t size() const { return _size; }
-
-private:
- enum State { OK, HALF_SET_CYCLE_1, HALF_SET_CYCLE_2 };
-
- void allocate();
- void deallocate();
-
- Sample* _data; ///< Used data pointer (probably same as _local_data)
- Sample* _local_data; ///< Locally allocated buffer (possibly unused if joined or set_data used)
- size_t _size; ///< Allocated buffer size
- size_t _filled_size; ///< Usable buffer size (for MIDI ports etc)
- State _state; ///< State of buffer for setting values next cycle
- Sample _set_value; ///< Value set by @ref set (may need to be set next cycle)
- FrameTime _set_time; ///< Time _set_value was set (to reset next cycle)
-};
-
-
-} // namespace Ingen
-
-#endif // AUDIOBUFFER_H
diff --git a/src/libs/engine/AudioDriver.hpp b/src/libs/engine/AudioDriver.hpp
deleted file mode 100644
index 6b5ea8dc..00000000
--- a/src/libs/engine/AudioDriver.hpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AUDIODRIVER_H
-#define AUDIODRIVER_H
-
-#include <raul/List.hpp>
-#include <raul/Path.hpp>
-#include "Driver.hpp"
-#include "types.hpp"
-#include "interface/DataType.hpp"
-
-namespace Ingen {
-
-class PatchImpl;
-class AudioDriver;
-class PortImpl;
-class ProcessContext;
-
-
-/** Audio driver abstract base class.
- *
- * \ingroup engine
- */
-class AudioDriver : public Driver
-{
-public:
- AudioDriver() : Driver(DataType::AUDIO) {}
-
- virtual void set_root_patch(PatchImpl* patch) = 0;
- virtual PatchImpl* root_patch() = 0;
-
- virtual void add_port(DriverPort* port) = 0;
- virtual DriverPort* remove_port(const Raul::Path& path) = 0;
-
- virtual SampleCount buffer_size() const = 0;
- virtual SampleCount sample_rate() const = 0;
- virtual SampleCount frame_time() const = 0;
-
- virtual bool is_realtime() const = 0;
-
- virtual ProcessContext& context() = 0;
-};
-
-
-} // namespace Ingen
-
-#endif // AUDIODRIVER_H
diff --git a/src/libs/engine/Buffer.cpp b/src/libs/engine/Buffer.cpp
deleted file mode 100644
index d019146c..00000000
--- a/src/libs/engine/Buffer.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "AudioBuffer.hpp"
-#include "EventBuffer.hpp"
-
-namespace Ingen {
-
-
-Buffer*
-Buffer::create(DataType type, size_t size)
-{
- if (type.is_control())
- return new AudioBuffer(1);
- else if (type.is_audio())
- return new AudioBuffer(size);
- else if (type.is_event())
- return new EventBuffer(size);
- else
- throw;
-}
-
-
-} // namespace Ingen
diff --git a/src/libs/engine/Buffer.hpp b/src/libs/engine/Buffer.hpp
deleted file mode 100644
index e388e2e8..00000000
--- a/src/libs/engine/Buffer.hpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef BUFFER_H
-#define BUFFER_H
-
-#include <cstddef>
-#include <cassert>
-#include <boost/utility.hpp>
-#include <raul/Deletable.hpp>
-#include "types.hpp"
-#include "interface/DataType.hpp"
-
-namespace Ingen {
-
-
-class Buffer : public boost::noncopyable, public Raul::Deletable
-{
-public:
- Buffer(Shared::DataType type, size_t size)
- : _type(type)
- , _size(size)
- , _joined_buf(NULL)
- {}
-
- static Buffer* create(Shared::DataType type, size_t size);
-
- /** Clear contents and reset state */
- virtual void clear() = 0;
-
- virtual void* raw_data() = 0;
- virtual const void* raw_data() const = 0;
-
- /** Rewind (ie reset read pointer), but leave contents unchanged */
- virtual void rewind() const = 0;
-
- virtual void prepare_read(FrameTime start, SampleCount nframes) = 0;
- virtual void prepare_write(FrameTime start, SampleCount nframes) = 0;
-
- bool is_joined() const { return (_joined_buf != NULL); }
- Buffer* joined_buffer() const { return _joined_buf; }
-
- virtual bool join(Buffer* buf) = 0;
- virtual void unjoin() = 0;
-
- virtual void copy(const Buffer* src, size_t start_sample, size_t end_sample) = 0;
-
- virtual void resize(size_t size) { _size = size; }
-
- Shared::DataType type() const { return _type; }
- size_t size() const { return _size; }
-
-protected:
- Shared::DataType _type;
- size_t _size;
- Buffer* _joined_buf;
-};
-
-
-} // namespace Ingen
-
-#endif // BUFFER_H
diff --git a/src/libs/engine/ClientBroadcaster.cpp b/src/libs/engine/ClientBroadcaster.cpp
deleted file mode 100644
index d754f072..00000000
--- a/src/libs/engine/ClientBroadcaster.cpp
+++ /dev/null
@@ -1,271 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <cassert>
-#include <iostream>
-#include <unistd.h>
-#include "interface/ClientInterface.hpp"
-#include "ClientBroadcaster.hpp"
-#include "EngineStore.hpp"
-#include "NodeFactory.hpp"
-#include "util.hpp"
-#include "PatchImpl.hpp"
-#include "NodeImpl.hpp"
-#include "PluginImpl.hpp"
-#include "PortImpl.hpp"
-#include "ConnectionImpl.hpp"
-#include "AudioDriver.hpp"
-#include "ObjectSender.hpp"
-#include "OSCClientSender.hpp"
-
-using namespace std;
-using Ingen::Shared::ClientInterface;
-
-namespace Ingen {
-
-
-/** Register a client to receive messages over the notification band.
- */
-void
-ClientBroadcaster::register_client(const string& uri, ClientInterface* client)
-{
- Clients::iterator i = _clients.find(uri);
-
- if (i == _clients.end()) {
- _clients[uri] = client;
- cout << "[ClientBroadcaster] Registered client: " << uri << endl;
- } else {
- cout << "[ClientBroadcaster] Client already registered: " << uri << endl;
- }
-}
-
-
-/** Remove a client from the list of registered clients.
- *
- * @return true if client was found and removed.
- */
-bool
-ClientBroadcaster::unregister_client(const string& uri)
-{
- size_t erased = _clients.erase(uri);
-
- if (erased > 0)
- cout << "Unregistered client: " << uri << endl;
- else
- cout << "Failed to find client to unregister: " << uri << endl;
-
- return (erased > 0);
-}
-
-
-
-/** Looks up the client with the given @a source address (which is used as the
- * unique identifier for registered clients).
- *
- * (A responder is passed to remove the dependency on liblo addresses in request
- * events, in anticipation of libom and multiple ways of responding to clients).
- */
-ClientInterface*
-ClientBroadcaster::client(const string& uri)
-{
- Clients::iterator i = _clients.find(uri);
- if (i != _clients.end()) {
- return (*i).second;
- } else {
- return NULL;
- }
-}
-
-
-void
-ClientBroadcaster::bundle_begin()
-{
- for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i)
- (*i).second->bundle_begin();
-}
-
-
-void
-ClientBroadcaster::bundle_end()
-{
- for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i)
- (*i).second->bundle_end();
-}
-
-
-void
-ClientBroadcaster::send_error(const string& msg)
-{
- for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i)
- (*i).second->error(msg);
-}
-
-void
-ClientBroadcaster::send_plugins_to(ClientInterface* client, const NodeFactory::Plugins& plugins)
-{
- client->transfer_begin();
-
- for (NodeFactory::Plugins::const_iterator i = plugins.begin(); i != plugins.end(); ++i) {
- const PluginImpl* const plugin = i->second;
- client->new_plugin(plugin->uri(), plugin->type_uri(), plugin->symbol(), plugin->name());
- }
-
- client->transfer_end();
-}
-
-
-void
-ClientBroadcaster::send_plugins(const NodeFactory::Plugins& plugins)
-{
- for (Clients::const_iterator c = _clients.begin(); c != _clients.end(); ++c)
- send_plugins_to((*c).second, plugins);
-}
-
-
-void
-ClientBroadcaster::send_node(const NodeImpl* node, bool recursive)
-{
- for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i)
- ObjectSender::send_node((*i).second, node, recursive);
-}
-
-
-void
-ClientBroadcaster::send_port(const PortImpl* port)
-{
- for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i)
- ObjectSender::send_port((*i).second, port);
-}
-
-
-void
-ClientBroadcaster::send_destroyed(const string& path)
-{
- assert(path != "/");
- for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i)
- (*i).second->destroy(path);
-}
-
-
-void
-ClientBroadcaster::send_patch_cleared(const string& patch_path)
-{
- for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i)
- (*i).second->patch_cleared(patch_path);
-}
-
-void
-ClientBroadcaster::send_connection(const SharedPtr<const ConnectionImpl> c)
-{
- for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i)
- (*i).second->connect(c->src_port()->path(), c->dst_port()->path());
-}
-
-
-void
-ClientBroadcaster::send_disconnection(const string& src_port_path, const string& dst_port_path)
-{
- for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i)
- (*i).second->disconnect(src_port_path, dst_port_path);
-}
-
-
-/** Send notification of a variable update.
- *
- * Like control changes, does not send update to client that set the variable, if applicable.
- */
-void
-ClientBroadcaster::send_variable_change(const string& node_path, const string& key, const Atom& value)
-{
- for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i)
- (*i).second->set_variable(node_path, key, value);
-}
-
-
-/** Send notification of a property update.
- *
- * Like control changes, does not send update to client that set the property, if applicable.
- */
-void
-ClientBroadcaster::send_property_change(const string& node_path, const string& key, const Atom& value)
-{
- for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i)
- (*i).second->set_property(node_path, key, value);
-}
-
-
-/** Send notification of a control change.
- *
- * If responder is specified, the notification will not be send to the address of
- * that responder (to avoid sending redundant information back to clients and
- * forcing clients to ignore things to avoid feedback loops etc).
- */
-void
-ClientBroadcaster::send_port_value(const string& port_path, const Raul::Atom& value)
-{
- for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i)
- (*i).second->set_port_value(port_path, value);
-}
-
-
-void
-ClientBroadcaster::send_port_activity(const string& port_path)
-{
- for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i)
- (*i).second->port_activity(port_path);
-}
-
-
-void
-ClientBroadcaster::send_program_add(const string& node_path, int bank, int program, const string& name)
-{
- for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i)
- (*i).second->program_add(node_path, bank, program, name);
-}
-
-
-void
-ClientBroadcaster::send_program_remove(const string& node_path, int bank, int program)
-{
- for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i)
- (*i).second->program_remove(node_path, bank, program);
-}
-
-
-/** Send a patch.
- *
- * Sends all objects underneath Patch - contained Nodes, etc.
- */
-void
-ClientBroadcaster::send_patch(const PatchImpl* p, bool recursive)
-{
- for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i)
- ObjectSender::send_patch((*i).second, p, recursive);
-}
-
-
-/** Sends notification of an GraphObject's renaming
- */
-void
-ClientBroadcaster::send_rename(const string& old_path, const string& new_path)
-{
- for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i)
- (*i).second->object_renamed(old_path, new_path);
-}
-
-
-} // namespace Ingen
diff --git a/src/libs/engine/ClientBroadcaster.hpp b/src/libs/engine/ClientBroadcaster.hpp
deleted file mode 100644
index b0963610..00000000
--- a/src/libs/engine/ClientBroadcaster.hpp
+++ /dev/null
@@ -1,97 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef CLIENTBROADCASTER_H
-#define CLIENTBROADCASTER_H
-
-#include <string>
-#include <list>
-#include <map>
-#include <lo/lo.h>
-#include <pthread.h>
-#include <raul/SharedPtr.hpp>
-#include "interface/ClientInterface.hpp"
-#include "types.hpp"
-#include "NodeFactory.hpp"
-
-using std::string;
-
-namespace Ingen {
-
-class NodeImpl;
-class PortImpl;
-class PluginImpl;
-class PatchImpl;
-class ConnectionImpl;
-using Shared::ClientInterface;
-
-
-/** Broadcaster for all clients.
- *
- * This sends messages to all client simultaneously through the opaque
- * ClientInterface. The clients may be OSC driver, in process, theoretically
- * anything that implements ClientInterface.
- *
- * This also serves as the database of all registered clients.
- *
- * \ingroup engine
- */
-class ClientBroadcaster
-{
-public:
- void register_client(const string& uri, ClientInterface* client);
- bool unregister_client(const string& uri);
-
- ClientInterface* client(const string& uri);
-
- //void send_client_registration(const string& url, int client_id);
-
- void bundle_begin();
- void bundle_end();
-
- // Error that isn't the direct result of a request
- void send_error(const string& msg);
-
- void send_plugins(const NodeFactory::Plugins& plugin_list);
- void send_patch(const PatchImpl* p, bool recursive);
- void send_node(const NodeImpl* node, bool recursive);
- void send_port(const PortImpl* port);
- void send_destroyed(const string& path);
- void send_patch_cleared(const string& patch_path);
- void send_connection(const SharedPtr<const ConnectionImpl> connection);
- void send_disconnection(const string& src_port_path, const string& dst_port_path);
- void send_rename(const string& old_path, const string& new_path);
- void send_variable_change(const string& node_path, const string& key, const Raul::Atom& value);
- void send_property_change(const string& node_path, const string& key, const Raul::Atom& value);
- void send_port_value(const string& port_path, const Raul::Atom& value);
- void send_port_activity(const string& port_path);
- void send_program_add(const string& node_path, int bank, int program, const string& name);
- void send_program_remove(const string& node_path, int bank, int program);
-
- void send_plugins_to(ClientInterface*, const NodeFactory::Plugins& plugin_list);
-
-private:
- typedef std::map<string, ClientInterface*> Clients;
- Clients _clients;
-};
-
-
-
-} // namespace Ingen
-
-#endif // CLIENTBROADCASTER_H
-
diff --git a/src/libs/engine/CompiledPatch.hpp b/src/libs/engine/CompiledPatch.hpp
deleted file mode 100644
index 9ca1d6e9..00000000
--- a/src/libs/engine/CompiledPatch.hpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef COMPILED_PATCH_HPP
-#define COMPILED_PATCH_HPP
-
-#include <iostream>
-#include <vector>
-#include <raul/List.hpp>
-#include <raul/Deletable.hpp>
-#include <boost/utility.hpp>
-
-using Raul::List;
-
-using namespace std;
-
-namespace Ingen {
-
-
-/** All information required about a node to execute it in an audio thread.
- */
-struct CompiledNode {
- CompiledNode(NodeImpl* n, size_t np, List<NodeImpl*>* d)
- : _node(n), _n_providers(np)
- {
- // Copy to a vector for maximum iteration speed and cache optimization
- // (Need to take a copy anyway)
-
- _dependants.reserve(d->size());
- for (List<NodeImpl*>::iterator i = d->begin(); i != d->end(); ++i)
- _dependants.push_back(*i);
- }
-
- NodeImpl* node() const { return _node; }
- size_t n_providers() const { return _n_providers; }
- const vector<NodeImpl*>& dependants() const { return _dependants; }
-
-private:
- NodeImpl* _node;
- size_t _n_providers; ///< Number of input ready signals to trigger run
- vector<NodeImpl*> _dependants; ///< Nodes this one's output ports are connected to
-};
-
-
-/** A patch and a set of connections, "compiled" into a flat structure with
- * the correct order so the audio thread(s) can execute it without
- * threading problems (since the preprocessor thread fiddles with other
- * things).
- *
- * Currently objects still have some 'heavyweight' connection state, but
- * eventually this should be the only place a particular set of connections
- * in a patch is stored, so various "connection presets" can be switched
- * in a realtime safe way.
- *
- * The nodes contained here are sorted in the order they must be executed.
- * The parallel processing algorithm guarantees no node will be executed
- * before it's providers, using this order as well as semaphores.
- */
-struct CompiledPatch : public std::vector<CompiledNode>
- , public Raul::Deletable
- , public boost::noncopyable {
- /*CompiledPatch() : std::vector<CompiledNode>() {}
- CompiledPatch(size_t reserve) : std::vector<CompiledNode>(reserve) {}*/
-};
-
-
-} // namespace Ingen
-
-#endif // COMPILED_PATCH_HPP
diff --git a/src/libs/engine/ConnectionImpl.cpp b/src/libs/engine/ConnectionImpl.cpp
deleted file mode 100644
index d226b4dd..00000000
--- a/src/libs/engine/ConnectionImpl.cpp
+++ /dev/null
@@ -1,185 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <algorithm>
-#include <raul/Maid.hpp>
-#include "util.hpp"
-#include "ConnectionImpl.hpp"
-#include "NodeImpl.hpp"
-#include "PortImpl.hpp"
-#include "AudioBuffer.hpp"
-#include "ProcessContext.hpp"
-
-#include <iostream>
-using namespace std;
-
-namespace Ingen {
-
-
-/** Constructor for a connection from a node's output port.
- *
- * This handles both polyphonic and monophonic nodes, transparently to the
- * user (InputPort).
- */
-ConnectionImpl::ConnectionImpl(PortImpl* src_port, PortImpl* dst_port)
- : _src_port(src_port)
- , _dst_port(dst_port)
- , _local_buffer(NULL)
- , _buffer_size(dst_port->buffer_size())
- /*, _must_mix( (src_port->poly() != dst_port->poly())
- || (src_port->buffer(0)->size() < dst_port->buffer(0)->size()) )*/
- , _must_mix( (src_port->polyphonic() && (! dst_port->polyphonic()))
- || (src_port->poly() != dst_port->poly() )
- || (src_port->buffer(0)->size() < dst_port->buffer(0)->size()) )
- , _pending_disconnection(false)
-{
- assert(src_port);
- assert(dst_port);
- assert(src_port != dst_port);
- assert(src_port->path() != dst_port->path());
- assert(src_port->type() == dst_port->type()
- || ( (src_port->type() == DataType::CONTROL || src_port->type() == DataType::AUDIO)
- && (dst_port->type() == DataType::CONTROL || dst_port->type() == DataType::AUDIO) ));
-
- /*assert((src_port->parent_node()->poly() == dst_port->parent_node()->poly())
- || (src_port->parent_node()->poly() == 1 || dst_port->parent_node()->poly() == 1));*/
-
- if (type() == DataType::EVENT)
- _must_mix = false; // FIXME: kludge
-
- if (_must_mix)
- _local_buffer = Buffer::create(dst_port->type(), dst_port->buffer(0)->size());
-
- /* FIXME: 1->1 connections with a destination with fixed buffers copies unecessarily */
- //cerr << src_port->path() << " -> " << dst_port->path() << " must mix: " << _must_mix << endl;
-}
-
-
-ConnectionImpl::~ConnectionImpl()
-{
- delete _local_buffer;
-}
-
-
-void
-ConnectionImpl::set_buffer_size(size_t size)
-{
- if (_must_mix) {
- assert(_local_buffer);
- delete _local_buffer;
-
- _local_buffer = Buffer::create(_dst_port->type(), _dst_port->buffer(0)->size());
- }
-
- _buffer_size = size;
-}
-
-
-void
-ConnectionImpl::prepare_poly(uint32_t poly)
-{
- _src_port->prepare_poly(poly);
-
- if (type() == DataType::CONTROL || type() == DataType::AUDIO)
- _must_mix = (poly > 1) && (
- (_src_port->poly() != _dst_port->poly())
- || (_src_port->polyphonic() && !_dst_port->polyphonic())
- || (_src_port->parent()->polyphonic() && !_dst_port->parent()->polyphonic()) );
-
- /*cerr << src_port()->path() << " * " << src_port()->poly()
- << " -> " << dst_port()->path() << " * " << dst_port()->poly()
- << "\t\tmust mix: " << _must_mix << " at poly " << poly << endl;*/
-
- if (_must_mix && ! _local_buffer)
- _local_buffer = Buffer::create(_dst_port->type(), _dst_port->buffer(0)->size());
-}
-
-
-void
-ConnectionImpl::apply_poly(Raul::Maid& maid, uint32_t poly)
-{
- _src_port->apply_poly(maid, poly);
- if (poly == 1 && _local_buffer && !_must_mix) {
- maid.push(_local_buffer);
- _local_buffer = NULL;
- }
-}
-
-
-void
-ConnectionImpl::process(ProcessContext& context)
-{
- // FIXME: nframes parameter not used
- assert(_buffer_size == 1 || _buffer_size == context.nframes());
-
- /* Thought: A poly output port can be connected to multiple mono input
- * ports, which means this mix down would have to happen many times.
- * Adding a method to OutputPort that mixes down all it's outputs into
- * a buffer (if it hasn't been done already this cycle) and returns that
- * would avoid having to mix multiple times. Probably not a very common
- * case, but it would be faster anyway. */
-
- /*cerr << src_port()->path() << " * " << src_port()->poly()
- << " -> " << dst_port()->path() << " * " << dst_port()->poly()
- << "\t\tmust mix: " << _must_mix << endl;*/
-
- if (_must_mix && (type() == DataType::CONTROL || type() == DataType::AUDIO)) {
-
- const AudioBuffer* const src_buffer = (AudioBuffer*)src_port()->buffer(0);
- AudioBuffer* mix_buf = (AudioBuffer*)_local_buffer;
-
- assert(mix_buf);
-
- const size_t copy_size = std::min(src_buffer->size(), mix_buf->size());
-
- // Copy src buffer to start of mix buffer
- mix_buf->copy((AudioBuffer*)src_port()->buffer(0), 0, copy_size-1);
-
- // Write last value of src buffer to remainder of dst buffer, if necessary
- if (copy_size < mix_buf->size())
- mix_buf->set_block(src_buffer->value_at(copy_size-1), copy_size, mix_buf->size()-1);
-
- // Accumulate the source's voices into local buffer starting at the second
- // voice (buffer is already set to first voice above)
- for (uint32_t j=1; j < src_port()->poly(); ++j) {
- mix_buf->accumulate((AudioBuffer*)src_port()->buffer(j), 0, copy_size-1);
- }
-
- // Find the summed value and write it to the remainder of dst buffer
- if (copy_size < mix_buf->size()) {
- float src_value = src_buffer->value_at(copy_size-1);
- for (uint32_t j=1; j < src_port()->poly(); ++j)
- src_value += ((AudioBuffer*)src_port()->buffer(j))->value_at(copy_size-1);
-
- mix_buf->set_block(src_value, copy_size, mix_buf->size()-1);
- }
-
- // Scale the buffer down.
- if (src_port()->poly() > 1)
- mix_buf->scale(1.0f/(float)src_port()->poly(), 0, _buffer_size-1);
-
- } else if (_must_mix && type() == DataType::EVENT) {
-
- std::cerr << "WARNING: No event mixing." << std::endl;
-
- }
-
-}
-
-
-} // namespace Ingen
-
diff --git a/src/libs/engine/ConnectionImpl.hpp b/src/libs/engine/ConnectionImpl.hpp
deleted file mode 100644
index b3da1b54..00000000
--- a/src/libs/engine/ConnectionImpl.hpp
+++ /dev/null
@@ -1,101 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef CONNECTIONIMPL_H
-#define CONNECTIONIMPL_H
-
-#include <cstdlib>
-#include <boost/utility.hpp>
-#include <raul/Deletable.hpp>
-#include "interface/DataType.hpp"
-#include "interface/Connection.hpp"
-#include "PortImpl.hpp"
-#include "types.hpp"
-
-namespace Ingen {
-
-class PortImpl;
-class Buffer;
-
-
-/** Represents a single inbound connection for an InputPort.
- *
- * This can be a group of ports (ie coming from a polyphonic Node) or
- * a single Port. This class exists basically as an abstraction of mixing
- * down polyphonic inputs, so InputPort can just deal with mixing down
- * multiple connections (oblivious to the polyphonic situation of the
- * connection itself).
- *
- * \ingroup engine
- */
-class ConnectionImpl : public Raul::Deletable, public Shared::Connection
-{
-public:
- ConnectionImpl(PortImpl* src_port, PortImpl* dst_port);
- virtual ~ConnectionImpl();
-
- PortImpl* src_port() const { return _src_port; }
- PortImpl* dst_port() const { return _dst_port; }
-
- const Raul::Path src_port_path() const { return _src_port->path(); }
- const Raul::Path dst_port_path() const { return _dst_port->path(); }
-
- /** Used by some (recursive) events to prevent double disconnections */
- bool pending_disconnection() { return _pending_disconnection; }
- void pending_disconnection(bool b) { _pending_disconnection = b; }
-
- void process(ProcessContext& context);
-
- /** Get the buffer for a particular voice.
- * A Connection is smart - it knows the destination port requesting the
- * buffer, and will return accordingly (ie the same buffer for every voice
- * in a mono->poly connection).
- */
- inline Buffer* buffer(size_t voice) const;
-
- void set_buffer_size(size_t size);
- void prepare_poly(uint32_t poly);
- void apply_poly(Raul::Maid& maid, uint32_t poly);
-
- DataType type() const { return _src_port->type(); }
-
-protected:
- PortImpl* const _src_port;
- PortImpl* const _dst_port;
- Buffer* _local_buffer;
- size_t _buffer_size;
- bool _must_mix;
- bool _pending_disconnection;
-};
-
-
-inline Buffer*
-ConnectionImpl::buffer(size_t voice) const
-{
- if (_must_mix) {
- return _local_buffer;
- } else if ( ! _src_port->polyphonic()) {
- return _src_port->buffer(0);
- } else {
- return _src_port->buffer(voice);
- }
-}
-
-
-} // namespace Ingen
-
-#endif // CONNECTIONIMPL_H
diff --git a/src/libs/engine/Context.hpp b/src/libs/engine/Context.hpp
deleted file mode 100644
index 2e000fb1..00000000
--- a/src/libs/engine/Context.hpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef CONTEXT_H
-#define CONTEXT_H
-
-namespace Ingen {
-
-class Engine;
-
-class Context
-{
-public:
- enum ID {
- AUDIO,
- MESSAGE
- };
-
- Context(Engine& engine, ID id)
- : _id(id)
- , _engine(engine)
- {}
-
- virtual ~Context() {}
-
- inline Engine& engine() const { return _engine; }
-
-protected:
- ID _id; ///< Fast ID for this context
- Engine& _engine; ///< Engine we're running in
-};
-
-
-} // namespace Ingen
-
-#endif // CONTEXT_H
-
diff --git a/src/libs/engine/Driver.hpp b/src/libs/engine/Driver.hpp
deleted file mode 100644
index 590b66b5..00000000
--- a/src/libs/engine/Driver.hpp
+++ /dev/null
@@ -1,98 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef DRIVER_H
-#define DRIVER_H
-
-#include <string>
-#include <boost/utility.hpp>
-#include <raul/Path.hpp>
-#include "interface/DataType.hpp"
-#include "DuplexPort.hpp"
-
-namespace Ingen {
-
-class DuplexPort;
-
-
-/** Representation of a "system" (eg outside Ingen) port.
- *
- * This is the class through which the rest of the engine manages everything
- * related to driver ports. Derived classes are expected to have a pointer to
- * their driver (to be able to perform the operation necessary).
- *
- * \ingroup engine
- */
-class DriverPort : boost::noncopyable {
-public:
- virtual ~DriverPort() {}
-
- /** Set the name of the system port */
- virtual void set_name(const std::string& name) = 0;
-
- bool is_input() const { return _patch_port->is_input(); }
- DuplexPort* patch_port() const { return _patch_port; }
-
-protected:
- /** is_input from the perspective outside of ingen */
- DriverPort(DuplexPort* port) : _patch_port(port) {}
-
- DuplexPort* _patch_port;
-};
-
-
-/** Driver abstract base class.
- *
- * A Driver is, from the perspective of GraphObjects (nodes, patches, ports) an
- * interface for managing system ports. An implementation of Driver basically
- * needs to manage DriverPorts, and handle writing/reading data to/from them.
- *
- * \ingroup engine
- */
-class Driver : boost::noncopyable
-{
-public:
- Driver(DataType type)
- : _type(type)
- {}
-
- virtual ~Driver() {}
-
- virtual void activate() = 0;
- virtual void deactivate() = 0;
-
- virtual bool is_activated() const = 0;
-
- /** Create a port ready to be inserted with add_input (non realtime).
- *
- * May return NULL if the Driver can not drive the port for some reason.
- */
- virtual DriverPort* create_port(DuplexPort* patch_port) = 0;
-
- virtual DriverPort* driver_port(const Raul::Path& path) = 0;
-
- virtual void add_port(DriverPort* port) = 0;
- virtual DriverPort* remove_port(const Raul::Path& path) = 0;
-
-protected:
- DataType _type;
-};
-
-
-} // namespace Ingen
-
-#endif // DRIVER_H
diff --git a/src/libs/engine/DuplexPort.cpp b/src/libs/engine/DuplexPort.cpp
deleted file mode 100644
index 31bfbe09..00000000
--- a/src/libs/engine/DuplexPort.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <iostream>
-#include <cstdlib>
-#include <cassert>
-#include "util.hpp"
-#include "DuplexPort.hpp"
-#include "ConnectionImpl.hpp"
-#include "OutputPort.hpp"
-#include "NodeImpl.hpp"
-#include "ProcessContext.hpp"
-#include "EventBuffer.hpp"
-
-using namespace std;
-
-namespace Ingen {
-
-
-DuplexPort::DuplexPort(NodeImpl* parent, const string& name, uint32_t index, uint32_t poly, DataType type, const Atom& value, size_t buffer_size, bool is_output)
- : PortImpl(parent, name, index, poly, type, value, buffer_size)
- , InputPort(parent, name, index, poly, type, value, buffer_size)
- , OutputPort(parent, name, index, poly, type, value, buffer_size)
- , _is_output(is_output)
-{
- assert(PortImpl::_parent == parent);
-}
-
-
-void
-DuplexPort::pre_process(ProcessContext& context)
-{
- // <BrainHurt>
-
- /*cerr << endl << "{ duplex pre" << endl;
- cerr << path() << " duplex pre: fixed buffers: " << fixed_buffers() << endl;
- cerr << path() << " duplex pre: buffer: " << buffer(0) << endl;
- cerr << path() << " duplex pre: is_output: " << _is_output << " { " << endl;*/
-
- /*if (type() == DataType::EVENT)
- for (uint32_t i=0; i < _poly; ++i)
- cerr << path() << " (" << buffer(i) << ") # events: "
- << ((EventBuffer*)buffer(i))->event_count()
- << ", joined: " << _buffers->at(i)->is_joined() << endl;*/
-
- if (_is_output) {
-
- for (uint32_t i=0; i < _poly; ++i)
- if (!_buffers->at(i)->is_joined())
- _buffers->at(i)->prepare_write(context.start(), context.nframes());
-
- } else {
-
- for (uint32_t i=0; i < _poly; ++i)
- _buffers->at(i)->prepare_read(context.start(), context.nframes());
-
- broadcast(context);
- }
-
- //cerr << "} duplex pre " << path() << endl;
-
- // </BrainHurt>
-}
-
-
-void
-DuplexPort::post_process(ProcessContext& context)
-{
- // <BrainHurt>
-
- /*cerr << endl << "{ duplex post" << endl;
- cerr << path() << " duplex post: fixed buffers: " << fixed_buffers() << endl;
- cerr << path() << " duplex post: buffer: " << buffer(0) << endl;
- cerr << path() << " duplex post: is_output: " << _is_output << " { " << endl;
-
- if (type() == DataType::EVENT)
- for (uint32_t i=0; i < _poly; ++i)
- cerr << path() << " (" << buffer(i) << ") # events: "
- << ((EventBuffer*)buffer(i))->event_count()
- << ", joined: " << _buffers->at(i)->is_joined() << endl;*/
-
- if (_is_output) {
- InputPort::pre_process(context); // Mix down inputs
- broadcast(context);
- }
-
- //cerr << "} duplex post " << path() << endl;
-
- // </BrainHurt>
-}
-
-
-} // namespace Ingen
-
diff --git a/src/libs/engine/DuplexPort.hpp b/src/libs/engine/DuplexPort.hpp
deleted file mode 100644
index 43d202a9..00000000
--- a/src/libs/engine/DuplexPort.hpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef DUPLEXPORT_H
-#define DUPLEXPORT_H
-
-#include <string>
-#include <raul/Array.hpp>
-#include "types.hpp"
-#include "Buffer.hpp"
-#include "InputPort.hpp"
-#include "OutputPort.hpp"
-
-namespace Ingen {
-
-class NodeImpl;
-
-
-/** A duplex port (which is both an InputPort and an OutputPort)
- *
- * This is used for Patch ports, since they need to appear as both an input
- * and an output port based on context. Eg. a patch output appears as an
- * input inside the patch, so nodes inside the patch can feed it data.
- *
- * \ingroup engine
- */
-class DuplexPort : public InputPort, public OutputPort
-{
-public:
- DuplexPort(NodeImpl* parent,
- const std::string& name,
- uint32_t index,
- uint32_t poly,
- DataType type,
- const Atom& value,
- size_t buffer_size,
- bool is_output);
-
- virtual ~DuplexPort() {}
-
- void pre_process(ProcessContext& context);
- void post_process(ProcessContext& context);
-
- bool is_input() const { return !_is_output; }
- bool is_output() const { return _is_output; }
-
-protected:
- bool _is_output;
-};
-
-
-} // namespace Ingen
-
-#endif // DUPLEXPORT_H
diff --git a/src/libs/engine/Engine.cpp b/src/libs/engine/Engine.cpp
deleted file mode 100644
index a08a37ca..00000000
--- a/src/libs/engine/Engine.cpp
+++ /dev/null
@@ -1,317 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <cassert>
-#include <sys/mman.h>
-#include <iostream>
-#include <unistd.h>
-#include <raul/Deletable.hpp>
-#include <raul/Maid.hpp>
-#include <raul/SharedPtr.hpp>
-#include "Engine.hpp"
-#include CONFIG_H_PATH
-#include "tuning.hpp"
-#include "Event.hpp"
-#include "common/interface/EventType.hpp"
-#include "shared/Store.hpp"
-#include "JackAudioDriver.hpp"
-#include "NodeFactory.hpp"
-#include "ClientBroadcaster.hpp"
-#include "PatchImpl.hpp"
-#include "EngineStore.hpp"
-#include "MidiDriver.hpp"
-#include "OSCDriver.hpp"
-#include "QueuedEventSource.hpp"
-#include "PostProcessor.hpp"
-#include "CreatePatchEvent.hpp"
-#include "EnablePatchEvent.hpp"
-#include "OSCEngineReceiver.hpp"
-#ifdef HAVE_SOUP
-#include "HTTPEngineReceiver.hpp"
-#endif
-#include "PostProcessor.hpp"
-#include "ProcessSlave.hpp"
-#include "ProcessContext.hpp"
-#include "MessageContext.hpp"
-#include "ThreadManager.hpp"
-#ifdef HAVE_JACK_MIDI
-#include "JackMidiDriver.hpp"
-#endif
-using namespace std;
-
-namespace Ingen {
-
-
-Engine::Engine(Ingen::Shared::World* world)
- : _world(world)
- , _midi_driver(NULL)
- , _osc_driver(NULL)
- , _maid(new Raul::Maid(maid_queue_size))
- , _post_processor(new PostProcessor(*this, /**_maid, */post_processor_queue_size))
- , _broadcaster(new ClientBroadcaster())
- , _node_factory(new NodeFactory(world))
- , _message_context(new MessageContext(*this))
- , _quit_flag(false)
- , _activated(false)
-{
- if (world->store) {
- assert(PtrCast<EngineStore>(world->store));
- } else {
- world->store = SharedPtr<Store>(new EngineStore());
- }
-}
-
-
-Engine::~Engine()
-{
- deactivate();
-
- for (EngineStore::iterator i = engine_store()->begin();
- i != engine_store()->end(); ++i) {
- if ( ! PtrCast<GraphObjectImpl>(i->second)->parent() )
- i->second.reset();
- }
-
- delete _broadcaster;
- delete _node_factory;
- delete _osc_driver;
- delete _post_processor;
- //delete _lash_driver;
-
- delete _maid;
-
- munlockall();
-}
-
-
-SharedPtr<EngineStore>
-Engine::engine_store() const
-{
- return PtrCast<EngineStore>(_world->store);
-}
-
-
-Driver*
-Engine::driver(DataType type, EventType event_type)
-{
- if (type == DataType::AUDIO) {
- return _audio_driver.get();
- } else if (type == DataType::EVENT) {
- if (event_type == EventType::MIDI) {
- return _midi_driver;
- } else if (event_type == EventType::OSC) {
- return _osc_driver;
- }
- }
-
- return NULL;
-}
-
-
-int
-Engine::main()
-{
- Thread::get().set_context(THREAD_POST_PROCESS);
-
- // Loop until quit flag is set (by OSCReceiver)
- while ( ! _quit_flag) {
- nanosleep(&main_rate, NULL);
- main_iteration();
- }
- cout << "[Main] Done main loop." << endl;
-
- deactivate();
-
- return 0;
-}
-
-
-/** Run one iteration of the main loop.
- *
- * NOT realtime safe (this is where deletion actually occurs)
- */
-bool
-Engine::main_iteration()
-{
-/*#ifdef HAVE_LASH
- // Process any pending LASH events
- if (lash_driver->enabled())
- lash_driver->process_events();
-#endif*/
- // Run the maid (garbage collector)
- _post_processor->process();
- _maid->cleanup();
-
- return !_quit_flag;
-}
-
-
-void
-Engine::start_jack_driver()
-{
- if ( ! _audio_driver)
- _audio_driver = SharedPtr<AudioDriver>(new JackAudioDriver(*this));
- else
- cerr << "[Engine::start_jack_driver] Audio driver already running" << endl;
-}
-
-
-void
-Engine::start_osc_driver(int port)
-{
- if (_event_source) {
- cerr << "WARNING: Replacing event source" << endl;
- _event_source.reset();
- }
-
- _event_source = SharedPtr<EventSource>(new OSCEngineReceiver(
- *this, pre_processor_queue_size, port));
-}
-
-
-void
-Engine::start_http_driver(int port)
-{
-#ifdef HAVE_SOUP
- // FIXE: leak
- HTTPEngineReceiver* server = new HTTPEngineReceiver(*this, port);
- server->activate();
-#endif
-}
-
-
-SharedPtr<QueuedEngineInterface>
-Engine::new_queued_interface()
-{
- if (_event_source) {
- cerr << "WARNING: Replacing event source" << endl;
- _event_source.reset();
- }
-
- SharedPtr<QueuedEngineInterface> result(new QueuedEngineInterface(
- *this, Ingen::event_queue_size, Ingen::event_queue_size));
-
- _event_source = result;
-
- return result;
-}
-
-/*
-void
-Engine::set_event_source(SharedPtr<EventSource> source)
-{
- if (_event_source)
- cerr << "Warning: Dropped event source (engine interface)" << endl;
-
- _event_source = source;
-}
-*/
-
-
-bool
-Engine::activate(size_t parallelism)
-{
- if (_activated)
- return false;
-
- assert(_audio_driver);
- assert(_event_source);
-
-#ifdef HAVE_JACK_MIDI
- _midi_driver = new JackMidiDriver(((JackAudioDriver*)_audio_driver.get())->jack_client());
-#else
- _midi_driver = new DummyMidiDriver();
-#endif
-
- _event_source->activate();
-
- // Create root patch
-
- PatchImpl* root_patch = new PatchImpl(*this, "", 1, NULL,
- _audio_driver->sample_rate(), _audio_driver->buffer_size(), 1);
- root_patch->activate();
- _world->store->add(root_patch);
- root_patch->compiled_patch(root_patch->compile());
-
- assert(_audio_driver->root_patch() == NULL);
- _audio_driver->set_root_patch(root_patch);
-
- _audio_driver->activate();
-
- _process_slaves.clear();
- _process_slaves.reserve(parallelism);
- for (size_t i=0; i < parallelism - 1; ++i)
- _process_slaves.push_back(new ProcessSlave(*this, _audio_driver->is_realtime()));
-
- root_patch->enable();
-
- //_post_processor->start();
-
- _activated = true;
-
- return true;
-}
-
-
-void
-Engine::deactivate()
-{
- if (!_activated)
- return;
-
- _event_source->deactivate();
-
- /*for (Tree<GraphObject*>::iterator i = _engine_store->objects().begin();
- i != _engine_store->objects().end(); ++i)
- if ((*i)->as_node() != NULL && (*i)->as_node()->parent() == NULL)
- (*i)->as_node()->deactivate();*/
-
- if (_midi_driver != NULL) {
- _midi_driver->deactivate();
- delete _midi_driver;
- _midi_driver = NULL;
- }
-
- _audio_driver->deactivate();
-
- _audio_driver->root_patch()->deactivate();
-
- for (size_t i=0; i < _process_slaves.size(); ++i) {
- delete _process_slaves[i];
- }
-
- _process_slaves.clear();
-
- // Finalize any lingering events (unlikely)
- _post_processor->process();
-
- _audio_driver.reset();
- _event_source.reset();
-
- _activated = false;
-}
-
-
-void
-Engine::process_events(ProcessContext& context)
-{
- if (_event_source)
- _event_source->process(*_post_processor, context);
-}
-
-
-} // namespace Ingen
diff --git a/src/libs/engine/Engine.hpp b/src/libs/engine/Engine.hpp
deleted file mode 100644
index fce826db..00000000
--- a/src/libs/engine/Engine.hpp
+++ /dev/null
@@ -1,130 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef ENGINE_H
-#define ENGINE_H
-
-#include CONFIG_H_PATH
-#include <cassert>
-#include <vector>
-#include <boost/utility.hpp>
-#include <raul/SharedPtr.hpp>
-#include "module/global.hpp"
-#include "interface/DataType.hpp"
-#include "interface/EventType.hpp"
-
-template<typename T> class Queue;
-
-namespace Raul { class Maid; }
-
-namespace Ingen {
-
-class AudioDriver;
-class MidiDriver;
-class OSCDriver;
-class NodeFactory;
-class ClientBroadcaster;
-class EngineStore;
-class EventSource;
-class PostProcessor;
-class Event;
-class QueuedEvent;
-class QueuedEngineInterface;
-class Driver;
-class ProcessSlave;
-class ProcessContext;
-class MessageContext;
-
-
-/** The main class for the Engine.
- *
- * This is a (GoF) facade for the engine. Pointers to all components are
- * available for more advanced control than this facade allows.
- *
- * \ingroup engine
- */
-class Engine : boost::noncopyable
-{
-public:
- Engine(Ingen::Shared::World* world);
-
- virtual ~Engine();
-
- virtual int main();
- virtual bool main_iteration();
-
- /** Set the quit flag that should kill all threads and exit cleanly.
- * Note that it will take some time. */
- virtual void quit() { _quit_flag = true; }
-
- virtual void start_jack_driver();
- virtual void start_osc_driver(int port);
- virtual void start_http_driver(int port);
-
- virtual SharedPtr<QueuedEngineInterface> new_queued_interface();
-
- virtual bool activate(size_t parallelism);
- virtual void deactivate();
-
- void process_events(ProcessContext& context);
-
- virtual bool activated() { return _activated; }
-
- Raul::Maid* maid() const { return _maid; }
- EventSource* event_source() const { return _event_source.get(); }
- AudioDriver* audio_driver() const { return _audio_driver.get(); }
- MidiDriver* midi_driver() const { return _midi_driver; }
- OSCDriver* osc_driver() const { return _osc_driver; }
- PostProcessor* post_processor() const { return _post_processor; }
- ClientBroadcaster* broadcaster() const { return _broadcaster; }
- NodeFactory* node_factory() const { return _node_factory; }
- MessageContext* message_context() const { return _message_context; }
-
- SharedPtr<EngineStore> engine_store() const;
-
- /** Return the active driver for the given type */
- Driver* driver(DataType type, EventType event_type);
-
- Ingen::Shared::World* world() { return _world; }
-
- typedef std::vector<ProcessSlave*> ProcessSlaves;
- inline const ProcessSlaves& process_slaves() const { return _process_slaves; }
- inline ProcessSlaves& process_slaves() { return _process_slaves; }
-
-private:
- ProcessSlaves _process_slaves;
-
- Ingen::Shared::World* _world;
-
- SharedPtr<EventSource> _event_source;
- SharedPtr<AudioDriver> _audio_driver;
- MidiDriver* _midi_driver;
- OSCDriver* _osc_driver;
- Raul::Maid* _maid;
- PostProcessor* _post_processor;
- ClientBroadcaster* _broadcaster;
- NodeFactory* _node_factory;
- MessageContext* _message_context;
-
- bool _quit_flag;
- bool _activated;
-};
-
-
-} // namespace Ingen
-
-#endif // ENGINE_H
diff --git a/src/libs/engine/EngineStore.cpp b/src/libs/engine/EngineStore.cpp
deleted file mode 100644
index 9fcd3806..00000000
--- a/src/libs/engine/EngineStore.cpp
+++ /dev/null
@@ -1,182 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <utility>
-#include <vector>
-#include <raul/List.hpp>
-#include <raul/PathTable.hpp>
-#include <raul/TableImpl.hpp>
-#include "EngineStore.hpp"
-#include "PatchImpl.hpp"
-#include "NodeImpl.hpp"
-#include "PortImpl.hpp"
-#include "ThreadManager.hpp"
-
-using namespace std;
-using namespace Raul;
-
-namespace Ingen {
-
-
-/** Find the Patch at the given path.
- */
-PatchImpl*
-EngineStore::find_patch(const Path& path)
-{
- GraphObjectImpl* const object = find_object(path);
- return dynamic_cast<PatchImpl*>(object);
-}
-
-
-/** Find the Node at the given path.
- */
-NodeImpl*
-EngineStore::find_node(const Path& path)
-{
- GraphObjectImpl* const object = find_object(path);
- return dynamic_cast<NodeImpl*>(object);
-}
-
-
-/** Find the Port at the given path.
- */
-PortImpl*
-EngineStore::find_port(const Path& path)
-{
- GraphObjectImpl* const object = find_object(path);
- return dynamic_cast<PortImpl*>(object);
-}
-
-
-/** Find the Object at the given path.
- */
-GraphObjectImpl*
-EngineStore::find_object(const Path& path)
-{
- iterator i = find(path);
- return ((i == end()) ? NULL : dynamic_cast<GraphObjectImpl*>(i->second.get()));
-}
-
-
-/** Add an object to the store. Not realtime safe.
- */
-void
-EngineStore::add(GraphObject* obj)
-{
- GraphObjectImpl* o = dynamic_cast<GraphObjectImpl*>(obj);
- assert(o);
-
- assert(ThreadManager::current_thread_id() == THREAD_PRE_PROCESS);
-
- Store::add(obj);
-}
-
-
-/** Add a family of objects to the store. Not realtime safe.
- */
-void
-EngineStore::add(const Objects& table)
-{
- assert(ThreadManager::current_thread_id() == THREAD_PRE_PROCESS);
-
- //cerr << "[EngineStore] Adding " << o[0].second->path() << endl;
- cram(table);
-
- /*cerr << "[EngineStore] Adding Table:" << endl;
- for (const_iterator i = table.begin(); i != table.end(); ++i) {
- cerr << i->first << " = " << i->second->path() << endl;
- }*/
-}
-
-
-/** Remove an object from the store.
- *
- * Returned is a vector containing all descendants of the object removed
- * including the object itself, in lexicographically sorted order by Path.
- */
-SharedPtr<EngineStore::Objects>
-EngineStore::remove(const Path& path)
-{
- return remove(find(path));
-}
-
-
-/** Remove an object from the store.
- *
- * Returned is a vector containing all descendants of the object removed
- * including the object itself, in lexicographically sorted order by Path.
- */
-SharedPtr<EngineStore::Objects>
-EngineStore::remove(iterator object)
-{
- assert(ThreadManager::current_thread_id() == THREAD_PRE_PROCESS);
-
- if (object != end()) {
- iterator descendants_end = find_descendants_end(object);
- //cout << "[EngineStore] Removing " << object->first << " {" << endl;
- SharedPtr<Objects> removed = yank(object, descendants_end);
- /*for (iterator i = removed->begin(); i != removed->end(); ++i) {
- cout << "\t" << i->first << endl;
- }
- cout << "}" << endl;*/
-
- return removed;
-
- } else {
- cerr << "[EngineStore] WARNING: Removing " << object->first << " failed." << endl;
- return SharedPtr<EngineStore>();
- }
-}
-
-
-/** Remove all children of an object from the store.
- *
- * Returned is a vector containing all descendants of the object removed
- * in lexicographically sorted order by Path.
- */
-SharedPtr<EngineStore::Objects>
-EngineStore::remove_children(const Path& path)
-{
- return remove_children(find(path));
-}
-
-
-/** Remove all children of an object from the store.
- *
- * Returned is a vector containing all descendants of the object removed
- * in lexicographically sorted order by Path.
- */
-SharedPtr<EngineStore::Objects>
-EngineStore::remove_children(iterator object)
-{
- if (object != end()) {
- iterator descendants_end = find_descendants_end(object);
- if (descendants_end != object) {
- iterator first_child = object;
- ++first_child;
- return yank(first_child, descendants_end);
- }
- } else {
- cerr << "[EngineStore] WARNING: Removing children of " << object->first << " failed." << endl;
- return SharedPtr<EngineStore::Objects>();
- }
-
- return SharedPtr<EngineStore::Objects>();
-}
-
-
-} // namespace Ingen
diff --git a/src/libs/engine/EngineStore.hpp b/src/libs/engine/EngineStore.hpp
deleted file mode 100644
index ad656aeb..00000000
--- a/src/libs/engine/EngineStore.hpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef OBJECTSTORE_H
-#define OBJECTSTORE_H
-
-#include <string>
-#include <raul/PathTable.hpp>
-#include <raul/SharedPtr.hpp>
-#include "shared/Store.hpp"
-
-using std::string;
-using namespace Raul;
-
-namespace Ingen {
-
-namespace Shared { class GraphObject; }
-
-class PatchImpl;
-class NodeImpl;
-class PortImpl;
-class GraphObjectImpl;
-
-
-/** Storage for all GraphObjects (tree of GraphObject's sorted by path).
- *
- * All looking up in pre_process() methods (and anything else that isn't in-band
- * with the audio thread) should use this (to read and modify the GraphObject
- * tree).
- *
- * Searching with find*() is fast (O(log(n)) binary search on contiguous
- * memory) and realtime safe, but modification (add or remove) are neither.
- */
-class EngineStore : public Shared::Store
-{
-public:
- PatchImpl* find_patch(const Path& path);
- NodeImpl* find_node(const Path& path);
- PortImpl* find_port(const Path& path);
- GraphObjectImpl* find_object(const Path& path);
-
- void add(Shared::GraphObject* o);
- void add(const Objects& family);
-
- SharedPtr<Objects> remove(const Path& path);
- SharedPtr<Objects> remove(Objects::iterator i);
- SharedPtr<Objects> remove_children(const Path& path);
- SharedPtr<Objects> remove_children(Objects::iterator i);
-};
-
-
-} // namespace Ingen
-
-#endif // OBJECTSTORE
diff --git a/src/libs/engine/Event.cpp b/src/libs/engine/Event.cpp
deleted file mode 100644
index 8e5c33da..00000000
--- a/src/libs/engine/Event.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "Event.hpp"
-#include "ThreadManager.hpp"
-#include "ProcessContext.hpp"
-
-namespace Ingen {
-
-
-void
-Event::execute(ProcessContext& context)
-{
- assert(ThreadManager::current_thread_id() == THREAD_PROCESS);
- assert(!_executed);
- assert(_time <= context.end());
-
- // Missed the event, jitter, damnit.
- if (_time < context.start())
- _time = context.start();
-
- _executed = true;
-}
-
-
-void
-Event::post_process()
-{
- // FIXME: Not true witn monolithic GUI/engine
- //assert(ThreadManager::current_thread_id() == THREAD_POST_PROCESS);
-}
-
-
-} // namespace Ingen
-
diff --git a/src/libs/engine/Event.hpp b/src/libs/engine/Event.hpp
deleted file mode 100644
index 5860da2a..00000000
--- a/src/libs/engine/Event.hpp
+++ /dev/null
@@ -1,75 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef EVENT_H
-#define EVENT_H
-
-#include <cassert>
-#include <raul/SharedPtr.hpp>
-#include <raul/Deletable.hpp>
-#include "types.hpp"
-
-namespace Ingen {
-
-class Engine;
-class Responder;
-class ProcessContext;
-
-
-/** Base class for all events (both realtime and QueuedEvent).
- *
- * This is for time-critical events like note ons. There is no non-realtime
- * pre-execute method as in QueuedEvent's, any lookups etc need to be done in the
- * realtime execute() method.
- *
- * QueuedEvent extends this class with a pre_process() method for any work that needs
- * to be done before processing in the realtime audio thread.
- *
- * \ingroup engine
- */
-class Event : public Raul::Deletable
-{
-public:
- virtual ~Event() {}
-
- /** Execute this event in the audio thread (MUST be realtime safe). */
- virtual void execute(ProcessContext& context);
-
- /** Perform any actions after execution (ie send replies to commands)
- * (no realtime requirements). */
- virtual void post_process();
-
- inline SampleCount time() const { return _time; }
-
-protected:
- Event(Engine& engine, SharedPtr<Responder> responder, FrameTime time)
- : _engine(engine)
- , _responder(responder)
- , _time(time)
- , _executed(false)
- {}
-
- Engine& _engine;
- SharedPtr<Responder> _responder;
- FrameTime _time;
- bool _executed;
-};
-
-
-} // namespace Ingen
-
-#endif // EVENT_H
diff --git a/src/libs/engine/EventBuffer.cpp b/src/libs/engine/EventBuffer.cpp
deleted file mode 100644
index e8584597..00000000
--- a/src/libs/engine/EventBuffer.cpp
+++ /dev/null
@@ -1,318 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#define __STDC_LIMIT_MACROS 1
-#include <stdint.h>
-#include <iostream>
-#include "EventBuffer.hpp"
-#include "lv2ext/lv2_event.h"
-#include "lv2ext/lv2_event_helpers.h"
-
-using namespace std;
-
-namespace Ingen {
-
-
-/** Allocate a new event buffer.
- * \a capacity is in bytes (not number of events).
- */
-EventBuffer::EventBuffer(size_t capacity)
- : Buffer(DataType(DataType::EVENT), capacity)
- , _latest_frames(0)
- , _latest_subframes(0)
-{
- if (capacity > UINT32_MAX) {
- cerr << "Event buffer size " << capacity << " too large, aborting." << endl;
- throw std::bad_alloc();
- }
-
- int ret = posix_memalign((void**)&_local_buf, 16, sizeof(LV2_Event_Buffer) + capacity);
- if (ret) {
- cerr << "Failed to allocate event buffer. Aborting." << endl;
- exit(EXIT_FAILURE);
- }
-
- _local_buf->event_count = 0;
- _local_buf->capacity = (uint32_t)capacity;
- _local_buf->size = 0;
- _local_buf->data = reinterpret_cast<uint8_t*>(_local_buf + 1);
- _buf = _local_buf;
-
- reset(0);
-
- //cerr << "Creating MIDI Buffer " << _buf << ", capacity = " << _buf->capacity << endl;
-}
-
-
-EventBuffer::~EventBuffer()
-{
- free(_local_buf);
-}
-
-
-/** Use another buffer's data instead of the local one.
- *
- * This buffer will essentially be identical to @a buf after this call.
- */
-bool
-EventBuffer::join(Buffer* buf)
-{
- EventBuffer* mbuf = dynamic_cast<EventBuffer*>(buf);
- if (mbuf) {
- _buf = mbuf->local_data();
- _joined_buf = mbuf;
- _iter = mbuf->_iter;
- _iter.buf = _buf;
- return false;
- } else {
- return false;
- }
-
- //assert(mbuf->size() == _size);
-
- _joined_buf = mbuf;
-
- return true;
-}
-
-
-void
-EventBuffer::unjoin()
-{
- _joined_buf = NULL;
- _buf = _local_buf;
- reset(_this_nframes);
-}
-
-
-void
-EventBuffer::prepare_read(FrameTime start, SampleCount nframes)
-{
- //cerr << "\t" << this << " prepare_read: " << event_count() << endl;
- rewind();
- _this_nframes = nframes;
-}
-
-
-void
-EventBuffer::prepare_write(FrameTime start, SampleCount nframes)
-{
- //cerr << "\t" << this << " prepare_write: " << event_count() << endl;
- reset(nframes);
-}
-
-/** FIXME: parameters ignored */
-void
-EventBuffer::copy(const Buffer* src_buf, size_t start_sample, size_t end_sample)
-{
- const EventBuffer* src = dynamic_cast<const EventBuffer*>(src_buf);
- assert(src);
- assert(_buf->capacity >= src->_buf->capacity);
-
- clear();
- src->rewind();
-
- memcpy(_buf, src->_buf, src->_buf->size);
-}
-
-
-/** Increment the read position by one event.
- *
- * \return true if increment was successful, or false if end of buffer reached.
- */
-bool
-EventBuffer::increment() const
-{
- if (lv2_event_is_valid(&_iter)) {
- lv2_event_increment(&_iter);
- return true;
- } else {
- return false;
- }
-}
-
-
-/**
- * \return true iff the cursor is valid (ie get_event is safe)
- */
-bool
-EventBuffer::is_valid() const
-{
- return lv2_event_is_valid(&_iter);
-}
-
-
-/** Append an event to the buffer.
- *
- * \a timestamp must be >= the latest event in the buffer,
- * and < this_nframes()
- *
- * \return true on success
- */
-bool
-EventBuffer::append(uint32_t frames,
- uint32_t subframes,
- uint16_t type,
- uint16_t size,
- const uint8_t* data)
-{
-#ifndef NDEBUG
- if (lv2_event_is_valid(&_iter)) {
- LV2_Event* last_event = lv2_event_get(&_iter, NULL);
- assert(last_event->frames < frames
- || (last_event->frames == frames && last_event->subframes <= subframes));
- }
-#endif
-
- /*cout << "Appending event type " << type << ", size " << size
- << " @ " << frames << "." << subframes << endl;*/
-
- const bool ret = lv2_event_write(&_iter, frames, subframes, type, size, data);
-
- if (!ret)
- cerr << "ERROR: Failed to write event." << endl;
-
- _latest_frames = frames;
- _latest_subframes = subframes;
-
- return ret;
-}
-
-
-/** Append a buffer of events to the buffer.
- *
- * \a timestamp must be >= the latest event in the buffer,
- * and < this_nframes()
- *
- * \return true on success
- */
-bool
-EventBuffer::append(const LV2_Event_Buffer* buf)
-{
- uint8_t** data;
- bool ret = true;
-
- LV2_Event_Iterator iter;
- for (lv2_event_begin(&iter, _buf); lv2_event_is_valid(&iter); lv2_event_increment(&iter)) {
- LV2_Event* ev = lv2_event_get(&iter, data);
-
-#ifndef NDEBUG
- assert((ev->frames > _latest_frames)
- || (ev->frames == _latest_frames
- && ev->subframes >= _latest_subframes));
-#endif
-
- if (!(ret = append(ev->frames, ev->subframes, ev->type, ev->size, *data))) {
- cerr << "ERROR: Failed to write event." << endl;
- break;
- }
-
- _latest_frames = ev->frames;
- _latest_subframes = ev->subframes;
- }
-
- return ret;
-}
-
-
-/** Read an event from the current position in the buffer
- *
- * \return true if read was successful, or false if end of buffer reached
- */
-bool
-EventBuffer::get_event(uint32_t* frames,
- uint32_t* subframes,
- uint16_t* type,
- uint16_t* size,
- uint8_t** data) const
-{
- if (lv2_event_is_valid(&_iter)) {
- LV2_Event* ev = lv2_event_get(&_iter, data);
- *frames = ev->frames;
- *subframes = ev->subframes;
- *type = ev->type;
- *size = ev->size;
- return true;
- } else {
- return false;
- }
-}
-
-
-/** Clear, and merge \a a and \a b into this buffer.
- *
- * FIXME: This is slow.
- *
- * \return true if complete merge was successful
- */
-bool
-EventBuffer::merge(const EventBuffer& a, const EventBuffer& b)
-{
- // Die if a merge isn't necessary as it's expensive
- assert(a.size() > 0 && b.size() > 0);
-
- reset(_this_nframes);
-
- a.rewind();
- b.rewind();
-
-#if 0
- uint32_t a_frames;
- uint32_t a_subframes;
- uint16_t a_type;
- uint16_t a_size;
- uint8_t* a_data;
-
- uint32_t b_frames;
- uint32_t b_subframes;
- uint16_t b_type;
- uint16_t b_size;
- uint8_t* b_data;
-#endif
-
- cout << "FIXME: merge" << endl;
-#if 0
- a.get_event(&a_frames, &a_subframes, &a_type, &a_size, &a_data);
- b.get_event(&b_frames, &b_subframes, &b_type, &b_size, &b_data);
-
- while (true) {
- if (a_data && (!b_data || (a_time < b_time))) {
- append(a_time, a_size, a_data);
- if (a.increment())
- a.get_event(&a_time, &a_size, &a_data);
- else
- a_data = NULL;
- } else if (b_data) {
- append(b_time, b_size, b_data);
- if (b.increment())
- b.get_event(&b_time, &b_size, &b_data);
- else
- b_data = NULL;
- } else {
- break;
- }
- }
-
- _latest_stamp = max(a_time, b_time);
-#endif
-
- return true;
-}
-
-
-} // namespace Ingen
-
diff --git a/src/libs/engine/EventBuffer.hpp b/src/libs/engine/EventBuffer.hpp
deleted file mode 100644
index 0c80d452..00000000
--- a/src/libs/engine/EventBuffer.hpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef EVENTBUFFER_H
-#define EVENTBUFFER_H
-
-#include <iostream>
-#include <lv2ext/lv2_event.h>
-#include <lv2ext/lv2_event_helpers.h>
-#include "Buffer.hpp"
-#include "interface/DataType.hpp"
-
-namespace Ingen {
-
-
-class EventBuffer : public Buffer {
-public:
- EventBuffer(size_t capacity);
-
- ~EventBuffer();
-
- void prepare_read(FrameTime start, SampleCount nframes);
- void prepare_write(FrameTime start, SampleCount nframes);
-
- bool join(Buffer* buf);
- void unjoin();
-
- inline uint32_t this_nframes() const { return _this_nframes; }
- inline uint32_t event_count() const { return _buf->event_count; }
-
- inline void* raw_data() { return _buf; }
- inline const void* raw_data() const { return _buf; }
-
- inline LV2_Event_Buffer* local_data() { return _local_buf; }
- inline const LV2_Event_Buffer* local_data() const { return _local_buf; }
-
- inline LV2_Event_Buffer* data() { return _buf; }
- inline const LV2_Event_Buffer* data() const { return _buf; }
-
- void copy(const Buffer* src, size_t start_sample, size_t end_sample);
-
- inline void rewind() const { lv2_event_begin(&_iter, _buf); }
- inline void clear() { reset(_this_nframes); }
- inline void reset(SampleCount nframes) {
- //std::cerr << this << " reset" << std::endl;
- _this_nframes = nframes;
- _latest_frames = 0;
- _latest_subframes = 0;
- _buf->event_count = 0;
- _buf->size = 0;
- rewind();
- }
-
- bool increment() const;
- bool is_valid() const;
-
- uint32_t latest_frames() const { return _latest_frames; }
- uint32_t latest_subframes() const { return _latest_subframes; }
-
- bool get_event(uint32_t* frames,
- uint32_t* subframes,
- uint16_t* type,
- uint16_t* size,
- uint8_t** data) const;
-
- bool append(uint32_t frames,
- uint32_t subframes,
- uint16_t type,
- uint16_t size,
- const uint8_t* data);
-
- bool append(const LV2_Event_Buffer* buf);
-
- bool merge(const EventBuffer& a, const EventBuffer& b);
-
-private:
- LV2_Event_Buffer* _buf; ///< Contents (maybe belong to _joined_buf)
- LV2_Event_Buffer* _local_buf; ///< Local contents
-
- mutable LV2_Event_Iterator _iter; ///< Iterator into _buf
-
- uint32_t _latest_frames; ///< Latest time of all events (frames)
- uint32_t _latest_subframes; ///< Latest time of all events (subframes)
- uint32_t _this_nframes; ///< Current cycle nframes
-};
-
-
-} // namespace Ingen
-
-#endif // EVENTBUFFER_H
diff --git a/src/libs/engine/EventSink.cpp b/src/libs/engine/EventSink.cpp
deleted file mode 100644
index 6c775d4c..00000000
--- a/src/libs/engine/EventSink.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <iostream>
-#include "events/SendPortValueEvent.hpp"
-#include "EventSink.hpp"
-#include "PortImpl.hpp"
-
-using namespace std;
-
-namespace Ingen {
-
-#if 0
-void
-EventSink::control_change(Port* port, FrameTime time, float val)
-{
- //cerr << "CONTROL CHANGE: " << port->path() << " == " << val << endl;
- SendPortValueEvent ev(_engine, time, port, false, 0, val);
- _events.write(sizeof(ev), (uchar*)&ev);
-}
-#endif
-
-/** \a size is not size_t because an event will never be even remotely close
- * to UINT32_MAX in size, so uint32_t saves wasted space on 64-bit.
- */
-bool
-EventSink::write(uint32_t size, const Event* ev)
-{
- if (size > _events.write_space())
- return false;
-
- _events.write(sizeof(uint32_t), (uint8_t*)&size);
- _events.write(size, (uint8_t*)ev);
-
- return true;
-}
-
-
-/** Read the next event into event_buffer.
- *
- * \a event_buffer can be casted to Event* and virtual methods called.
- */
-bool
-EventSink::read(uint32_t event_buffer_size, uint8_t* event_buffer)
-{
- uint32_t read_size;
- bool success = _events.full_read(sizeof(uint32_t), (uint8_t*)&read_size);
- if (!success)
- return false;
-
- assert(read_size <= event_buffer_size);
-
- if (read_size > 0)
- return _events.full_read(read_size, event_buffer);
- else
- return false;
-}
-
-
-} // namespace Ingen
diff --git a/src/libs/engine/EventSink.hpp b/src/libs/engine/EventSink.hpp
deleted file mode 100644
index 9e937d1a..00000000
--- a/src/libs/engine/EventSink.hpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef EVENTSINK_H
-#define EVENTSINK_H
-
-#include <list>
-#include <utility>
-#include <raul/RingBuffer.hpp>
-#include "events/SendPortValueEvent.hpp"
-#include "types.hpp"
-
-namespace Ingen {
-
-class PortImpl;
-class Engine;
-class SendPortValueEvent;
-
-
-/** Sink for events generated in the audio thread.
- *
- * Implemented as a flat ringbuffer of events, which are constructed directly
- * in the ringbuffer rather than allocated on the heap (in order to make
- * writing realtime safe).
- *
- * \ingroup engine
- */
-class EventSink
-{
-public:
- EventSink(Engine& engine, size_t capacity) : _engine(engine), _events(capacity) {}
-
- /* FIXME: Figure out variable sized event queues and make this a generic
- * interface (ie don't add a method for every event type, crap..) */
-
- bool write(uint32_t size, const Event* ev);
-
- bool read(uint32_t event_buffer_size, uint8_t* event_buffer);
-
-private:
- Engine& _engine;
- Raul::RingBuffer<uchar> _events;
-};
-
-
-
-} // namespace Ingen
-
-#endif // EVENTSINK_H
-
diff --git a/src/libs/engine/EventSource.hpp b/src/libs/engine/EventSource.hpp
deleted file mode 100644
index 68532d16..00000000
--- a/src/libs/engine/EventSource.hpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef EVENTSOURCE_H
-#define EVENTSOURCE_H
-
-#include "types.hpp"
-
-namespace Ingen {
-
-class Event;
-class QueuedEvent;
-class PostProcessor;
-
-
-/** Source for events to run in the audio thread.
- *
- * The AudioDriver gets events from an EventSource in the process callback
- * (realtime audio thread) and executes them, then they are sent to the
- * PostProcessor and finalised (post-processing thread).
- *
- * There are two distinct classes of events - "queued" and "stamped". Queued
- * events are events that require non-realtime pre-processing before being
- * executed in the process thread. Stamped events are timestamped realtime
- * events that require no pre-processing and can be executed immediately
- * (with sample accuracy).
- */
-class EventSource
-{
-public:
- virtual ~EventSource() {}
-
- virtual void activate() = 0;
- virtual void deactivate() = 0;
-
- virtual void process(PostProcessor& dest, ProcessContext& context) = 0;
-
-protected:
- size_t _capacity;
-};
-
-
-} // namespace Ingen
-
-#endif // EVENTSOURCE_H
-
diff --git a/src/libs/engine/GraphObjectImpl.cpp b/src/libs/engine/GraphObjectImpl.cpp
deleted file mode 100644
index 0e1abc57..00000000
--- a/src/libs/engine/GraphObjectImpl.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "GraphObjectImpl.hpp"
-#include "PatchImpl.hpp"
-#include "EngineStore.hpp"
-
-namespace Ingen {
-
-
-PatchImpl*
-GraphObjectImpl::parent_patch() const
-{
- return dynamic_cast<PatchImpl*>((NodeImpl*)_parent);
-}
-
-
-SharedPtr<GraphObject>
-GraphObjectImpl::find_child(const string& name) const
-{
- throw;
-}
-
-
-} // namespace Ingen
diff --git a/src/libs/engine/GraphObjectImpl.hpp b/src/libs/engine/GraphObjectImpl.hpp
deleted file mode 100644
index 9b1f675d..00000000
--- a/src/libs/engine/GraphObjectImpl.hpp
+++ /dev/null
@@ -1,132 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef GRAPHOBJECTIMPL_H
-#define GRAPHOBJECTIMPL_H
-
-#include <string>
-#include <map>
-#include <cstddef>
-#include <cassert>
-#include <raul/Deletable.hpp>
-#include <raul/Path.hpp>
-#include <raul/Atom.hpp>
-#include "interface/GraphObject.hpp"
-#include "types.hpp"
-
-using Raul::Atom;
-using Raul::Path;
-using Raul::Symbol;
-
-namespace Raul { class Maid; }
-
-namespace Ingen {
-
-class PatchImpl;
-class ProcessContext;
-
-
-/** An object on the audio graph - Patch, Node, Port, etc.
- *
- * Each of these is a Raul::Deletable and so can be deleted in a realtime safe
- * way from anywhere, and they all have a map of variable for clients to store
- * arbitrary values in (which the engine puts no significance to whatsoever).
- *
- * \ingroup engine
- */
-class GraphObjectImpl : virtual public Ingen::Shared::GraphObject
-{
-public:
- virtual ~GraphObjectImpl() {}
-
- bool polyphonic() const { return _polyphonic; }
- virtual bool set_polyphonic(Raul::Maid& maid, bool p) { _polyphonic = p; return true; }
-
- GraphObject* graph_parent() const { return _parent; }
-
- inline GraphObjectImpl* parent() const { return _parent; }
- const Symbol symbol() const { return _name; }
-
- virtual void process(ProcessContext& context) = 0;
-
- /** Rename */
- virtual void set_path(const Path& new_path) {
- assert(new_path.parent() == path().parent());
- _name = new_path.name();
- assert(_name.find("/") == std::string::npos);
- }
-
- void set_variable(const std::string& key, const Atom& value)
- { _variables[key] = value; }
-
- void set_property(const std::string& key, const Atom& value)
- { _properties[key] = value; }
-
- const Atom& get_variable(const std::string& key) {
- static Atom null_atom;
- Variables::iterator i = _variables.find(key);
- return (i != _variables.end()) ? (*i).second : null_atom;
- }
-
- const Atom& get_property(const std::string& key) {
- static Atom null_atom;
- Properties::iterator i = _properties.find(key);
- return (i != _properties.end()) ? (*i).second : null_atom;
- }
-
- const Variables& variables() const { return _variables; }
- const Properties& properties() const { return _properties; }
- Variables& variables() { return _variables; }
- Properties& properties() { return _properties; }
-
- /** The Patch this object is a child of. */
- virtual PatchImpl* parent_patch() const;
-
- /** Path is dynamically generated from parent to ease renaming */
- const Path path() const {
- if (_parent == NULL)
- return Path(std::string("/").append(_name));
- else if (_parent->path() == "/")
- return Path(std::string("/").append(_name));
- else
- return Path(_parent->path() +"/"+ _name);
- }
-
- SharedPtr<GraphObject> find_child(const std::string& name) const;
-
-protected:
- GraphObjectImpl(GraphObjectImpl* parent, const std::string& name, bool polyphonic=false)
- : _parent(parent), _name(name), _polyphonic(polyphonic)
- {
- assert(parent == NULL || _name.length() > 0);
- assert(_name.find("/") == std::string::npos);
- assert(path().find("//") == std::string::npos);
- }
-
- GraphObjectImpl* _parent;
- std::string _name;
- bool _polyphonic;
-
-private:
- Variables _variables;
- Properties _properties;
-};
-
-
-} // namespace Ingen
-
-#endif // GRAPHOBJECTIMPL_H
diff --git a/src/libs/engine/HTTPEngineReceiver.cpp b/src/libs/engine/HTTPEngineReceiver.cpp
deleted file mode 100644
index 1b21e184..00000000
--- a/src/libs/engine/HTTPEngineReceiver.cpp
+++ /dev/null
@@ -1,207 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <iostream>
-#include <cstdlib>
-#include <cstdio>
-#include <string>
-#include <boost/format.hpp>
-#include "types.hpp"
-#include <raul/SharedPtr.hpp>
-#include <raul/AtomLiblo.hpp>
-#include "interface/ClientInterface.hpp"
-#include "module/Module.hpp"
-#include "serialisation/serialisation.hpp"
-#include "serialisation/Serialiser.hpp"
-#include "serialisation/Parser.hpp"
-#include "engine/ThreadManager.hpp"
-#include "HTTPEngineReceiver.hpp"
-#include "QueuedEventSource.hpp"
-#include "ClientBroadcaster.hpp"
-#include "EngineStore.hpp"
-
-using namespace std;
-using namespace Ingen::Shared;
-
-namespace Ingen {
-
-
-HTTPEngineReceiver::HTTPEngineReceiver(Engine& engine, uint16_t port)
- : QueuedEngineInterface(engine, 2, 2)
- , _server(soup_server_new(SOUP_SERVER_PORT, port, NULL))
-{
- _receive_thread = new ReceiveThread(*this);
-
- soup_server_add_handler(_server, NULL, message_callback, this, NULL);
-
- cout << "Started HTTP server on port " << soup_server_get_port(_server) << endl;
- Thread::set_name("HTTP receiver");
-
- if (!engine.world()->serialisation_module)
- engine.world()->serialisation_module = Ingen::Shared::load_module("ingen_serialisation");
-
- if (engine.world()->serialisation_module) {
- if (!engine.world()->serialiser)
- engine.world()->serialiser = SharedPtr<Serialiser>(
- Ingen::Serialisation::new_serialiser(engine.world(), engine.engine_store()));
-
- if (!engine.world()->parser)
- engine.world()->parser = SharedPtr<Parser>(
- Ingen::Serialisation::new_parser());
- } else {
- cerr << "WARNING: Failed to load ingen_serialisation module, HTTP disabled." << endl;
- }
-}
-
-
-HTTPEngineReceiver::~HTTPEngineReceiver()
-{
- deactivate();
-
- if (_server != NULL) {
- soup_server_quit(_server);
- _server = NULL;
- }
-}
-
-
-void
-HTTPEngineReceiver::activate()
-{
- QueuedEventSource::activate();
- _receive_thread->set_name("HTTP Receiver");
- _receive_thread->start();
-}
-
-
-void
-HTTPEngineReceiver::deactivate()
-{
- cout << "[HTTPEngineReceiver] Stopped HTTP listening thread" << endl;
- _receive_thread->stop();
- QueuedEventSource::deactivate();
-}
-
-
-void
-HTTPEngineReceiver::message_callback(SoupServer* server, SoupMessage* msg, const char* path,
- GHashTable *query, SoupClientContext* client, void* data)
-{
- HTTPEngineReceiver* me = (HTTPEngineReceiver*)data;
-
- SharedPtr<Store> store = me->_engine.world()->store;
- if (!store) {
- soup_message_set_status (msg, SOUP_STATUS_INTERNAL_SERVER_ERROR);
- return;
- }
-
- if (!Path::is_valid(path)) {
- soup_message_set_status (msg, SOUP_STATUS_BAD_REQUEST);
- const string& err = (boost::format("Bad path: %1%") % path).str();
- soup_message_set_response (msg, "text/plain", SOUP_MEMORY_COPY,
- err.c_str(), err.length());
- return;
- }
-
- if (msg->method == SOUP_METHOD_GET) {
- Glib::RWLock::ReaderLock lock(store->lock());
-
- // Find object
- Store::const_iterator start = store->find(path);
- if (start == store->end()) {
- soup_message_set_status (msg, SOUP_STATUS_NOT_FOUND);
- const string& err = (boost::format("No such object: %1%") % path).str();
- soup_message_set_response (msg, "text/plain", SOUP_MEMORY_COPY,
- err.c_str(), err.length());
- return;
- }
-
- // Get serialiser
- SharedPtr<Serialiser> serialiser = me->_engine.world()->serialiser;
- if (!serialiser) {
- soup_message_set_status (msg, SOUP_STATUS_INTERNAL_SERVER_ERROR);
- soup_message_set_response (msg, "text/plain", SOUP_MEMORY_STATIC,
- "No serialiser available\n", 24);
- return;
- }
-
-#if 0
- SoupMessageHeaders* in_head = msg->request_headers;
- const char* str = soup_message_headers_get(in_head, "Accept");
- cout << "Accept: " << str << endl;
-#endif
-
- // Serialise object
- const string response = serialiser->to_string(start->second,
- "http://example.org", GraphObject::Variables());
-
-#if 0
- FILE* xhtml_file = fopen("/home/dave/ingen_ui.xhtml", "r");
- string response;
- while (!feof(xhtml_file)) {
- int c = fgetc(xhtml_file);
- if (c != EOF)
- response += (char)c;
- }
- fclose(xhtml_file);
-#endif
-
- soup_message_set_status (msg, SOUP_STATUS_OK);
- soup_message_set_response (msg, "text/plain", SOUP_MEMORY_COPY,
- response.c_str(), response.length());
-
- } else if (msg->method == SOUP_METHOD_PUT) {
- Glib::RWLock::WriterLock lock(store->lock());
-
- // Be sure object doesn't exist
- Store::const_iterator start = store->find(path);
- if (start != store->end()) {
- soup_message_set_status (msg, SOUP_STATUS_CONFLICT);
- return;
- }
-
- // Get parser
- SharedPtr<Parser> parser = me->_engine.world()->parser;
- if (!parser) {
- soup_message_set_status (msg, SOUP_STATUS_INTERNAL_SERVER_ERROR);
- return;
- }
-
- //cout << "POST: " << msg->request_body->data << endl;
-
- // Load object
- soup_message_set_status (msg, SOUP_STATUS_NOT_IMPLEMENTED);
- } else if (msg->method == SOUP_METHOD_POST) {
- //cout << "PUT: " << msg->request_body->data << endl;
- soup_message_set_status (msg, SOUP_STATUS_NOT_IMPLEMENTED);
- } else {
- soup_message_set_status (msg, SOUP_STATUS_NOT_IMPLEMENTED);
- }
-}
-
-
-/** Override the semaphore driven _run method of QueuedEngineInterface
- * to wait on HTTP requests and process them immediately in this thread.
- */
-void
-HTTPEngineReceiver::ReceiveThread::_run()
-{
- soup_server_run(_receiver._server);
-}
-
-
-} // namespace Ingen
diff --git a/src/libs/engine/HTTPEngineReceiver.hpp b/src/libs/engine/HTTPEngineReceiver.hpp
deleted file mode 100644
index 34c425b2..00000000
--- a/src/libs/engine/HTTPEngineReceiver.hpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2008 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef HTTPENGINERECEIVER_H
-#define HTTPENGINERECEIVER_H
-
-#include CONFIG_H_PATH
-#include <string>
-#include <stdint.h>
-#include <libsoup/soup.h>
-#include <raul/SharedPtr.hpp>
-#include "QueuedEngineInterface.hpp"
-
-namespace Ingen {
-
-class HTTPEngineReceiver : public QueuedEngineInterface
-{
-public:
- HTTPEngineReceiver(Engine& engine, uint16_t port);
- ~HTTPEngineReceiver();
-
- void activate();
- void deactivate();
-
-private:
- struct ReceiveThread : public Raul::Thread {
- ReceiveThread(HTTPEngineReceiver& receiver) : _receiver(receiver) {}
- virtual void _run();
- private:
- HTTPEngineReceiver& _receiver;
- };
-
- friend class ReceiveThread;
-
- static void message_callback(SoupServer* server, SoupMessage* msg, const char* path,
- GHashTable *query, SoupClientContext* client, void* data);
-
- ReceiveThread* _receive_thread;
- SoupServer* _server;
-};
-
-
-} // namespace Ingen
-
-#endif // HTTPENGINERECEIVER_H
diff --git a/src/libs/engine/InputPort.cpp b/src/libs/engine/InputPort.cpp
deleted file mode 100644
index cf5501ca..00000000
--- a/src/libs/engine/InputPort.cpp
+++ /dev/null
@@ -1,297 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "InputPort.hpp"
-#include <iostream>
-#include <cstdlib>
-#include <cassert>
-#include "AudioBuffer.hpp"
-#include "EventBuffer.hpp"
-#include "ConnectionImpl.hpp"
-#include "OutputPort.hpp"
-#include "NodeImpl.hpp"
-#include "ProcessContext.hpp"
-#include "util.hpp"
-
-using namespace std;
-
-namespace Ingen {
-
-
-InputPort::InputPort(NodeImpl* parent,
- const string& name,
- uint32_t index,
- uint32_t poly,
- DataType type,
- const Atom& value,
- size_t buffer_size)
- : PortImpl(parent, name, index, poly, type, value, buffer_size)
-{
-}
-
-
-void
-InputPort::set_buffer_size(size_t size)
-{
- PortImpl::set_buffer_size(size);
- assert(_buffer_size = size);
-
- for (Connections::iterator c = _connections.begin(); c != _connections.end(); ++c)
- ((ConnectionImpl*)c->get())->set_buffer_size(size);
-
-}
-
-
-bool
-InputPort::prepare_poly(uint32_t poly)
-{
- PortImpl::prepare_poly(poly);
-
- for (Connections::iterator c = _connections.begin(); c != _connections.end(); ++c)
- ((ConnectionImpl*)c->get())->prepare_poly(poly);
-
- connect_buffers();
- return true;
-}
-
-
-bool
-InputPort::apply_poly(Raul::Maid& maid, uint32_t poly)
-{
- if (!_polyphonic || !_parent->polyphonic())
- return true;
-
- for (Connections::iterator c = _connections.begin(); c != _connections.end(); ++c)
- ((ConnectionImpl*)c->get())->apply_poly(maid, poly);
-
- PortImpl::apply_poly(maid, poly);
- assert(this->poly() == poly);
-
- if (_connections.size() == 1) {
- ConnectionImpl* c = _connections.begin()->get();
- for (uint32_t i=0; i < _poly; ++i)
- _buffers->at(i)->join(c->buffer(i));
- }
-
- connect_buffers();
-
- return true;
-}
-
-
-/** Add a connection. Realtime safe.
- *
- * The buffer of this port will be set directly to the connection's buffer
- * if there is only one connection, since no mixing needs to take place.
- */
-void
-InputPort::add_connection(Connections::Node* const c)
-{
- _connections.push_back(c);
-
- bool modify_buffers = !_fixed_buffers;
-
- if (modify_buffers) {
- if (_connections.size() == 1) {
- // Use buffer directly to avoid copying
- for (uint32_t i=0; i < _poly; ++i) {
- _buffers->at(i)->join(c->elem()->buffer(i));
- }
- } else if (_connections.size() == 2) {
- // Used to directly use single connection buffer, now there's two
- // so have to use local ones again and mix down
- for (uint32_t i=0; i < _poly; ++i) {
- _buffers->at(i)->unjoin();
- }
- }
- PortImpl::connect_buffers();
- }
-
- // Automatically broadcast connected control inputs
- if (_type == DataType::CONTROL)
- _broadcast = true;
-}
-
-
-/** Remove a connection. Realtime safe.
- */
-InputPort::Connections::Node*
-InputPort::remove_connection(const OutputPort* src_port)
-{
- bool modify_buffers = !_fixed_buffers;
-
- bool found = false;
- Connections::Node* connection = NULL;
- for (Connections::iterator i = _connections.begin(); i != _connections.end(); ++i) {
- if ((*i)->src_port()->path() == src_port->path()) {
- connection = _connections.erase(i);
- found = true;
- }
- }
-
- if ( ! found) {
- cerr << "WARNING: [InputPort::remove_connection] Connection not found !" << endl;
- exit(EXIT_FAILURE);
- } else {
- if (_connections.size() == 0) {
- for (uint32_t i=0; i < _poly; ++i) {
- // Use a local buffer
- if (modify_buffers)
- _buffers->at(i)->unjoin();
- _buffers->at(i)->clear(); // Write silence
- }
- } else if (modify_buffers && _connections.size() == 1) {
- // Share a buffer
- for (uint32_t i=0; i < _poly; ++i) {
- _buffers->at(i)->join((*_connections.begin())->buffer(i));
- }
- }
- }
-
- if (modify_buffers)
- PortImpl::connect_buffers();
-
- // Turn off broadcasting if we're not connected any more (FIXME: not quite right..)
- if (_type == DataType::CONTROL && _connections.size() == 0)
- _broadcast = false;
-
- return connection;
-}
-
-
-/** Returns whether this port is connected to the passed port.
- */
-/*bool
-InputPort::is_connected_to(const OutputPort* port) const
-{
- for (Connections::const_iterator i = _connections.begin(); i != _connections.end(); ++i)
- if ((*i)->src_port() == port)
- return true;
-
- return false;
-}*/
-
-
-/** Prepare buffer for access, mixing if necessary. Realtime safe.
- * FIXME: nframes parameter not used,
- */
-void
-InputPort::pre_process(ProcessContext& context)
-{
- // If value has been set (e.g. events pushed) by the user,
- // don't do anything this cycle to avoid smashing the value
- if (_set_by_user)
- return;
-
- bool do_mixdown = true;
-
- if (_connections.size() == 0) {
- for (uint32_t i=0; i < _poly; ++i)
- buffer(i)->prepare_read(context.start(), context.nframes());
- return;
- }
-
- for (Connections::iterator c = _connections.begin(); c != _connections.end(); ++c)
- (*c)->process(context);
-
- if ( ! _fixed_buffers) {
- // If only one connection, try to use buffer directly (zero copy)
- if (_connections.size() == 1) {
- for (uint32_t i=0; i < _poly; ++i) {
- //cerr << path() << " joining to " << (*_connections.begin())->buffer(i) << endl;
- _buffers->at(i)->join((*_connections.begin())->buffer(i));
- }
- do_mixdown = false;
- }
- connect_buffers();
- } else {
- do_mixdown = true;
- }
-
- for (uint32_t i=0; i < _poly; ++i)
- buffer(i)->prepare_read(context.start(), context.nframes());
-
- /*cerr << path() << " poly = " << _poly << ", mixdown: " << do_mixdown
- << ", fixed buffers: " << _fixed_buffers << ", joined: " << _buffers->at(0)->is_joined()
- << " to " << _buffers->at(0)->joined_buffer() << endl;*/
-
- /*if (type() == DataType::EVENT)
- for (uint32_t i=0; i < _poly; ++i)
- cerr << path() << " (" << buffer(i) << ") # events: "
- << ((EventBuffer*)buffer(i))->event_count()
- << ", joined: " << _buffers->at(i)->is_joined() << endl;*/
-
- if (!do_mixdown) {
- /*#ifndef NDEBUG
- for (uint32_t i=0; i < _poly; ++i)
- assert(buffer(i) == (*_connections.begin())->buffer(i));
- #endif*/
- return;
- }
-
- if (_type == DataType::CONTROL || _type == DataType::AUDIO) {
- for (uint32_t voice=0; voice < _poly; ++voice) {
- // Copy first connection
- buffer(voice)->copy(
- (*_connections.begin())->buffer(voice), 0, _buffer_size-1);
-
- // Accumulate the rest
- if (_connections.size() > 1) {
-
- Connections::iterator c = _connections.begin();
-
- for (++c; c != _connections.end(); ++c)
- ((AudioBuffer*)buffer(voice))->accumulate(
- ((AudioBuffer*)(*c)->buffer(voice)), 0, _buffer_size-1);
- }
- }
- } else {
- assert(_poly == 1);
-
- // FIXME
- if (_connections.size() > 1)
- cerr << "WARNING: MIDI mixing not implemented, only first connection used." << endl;
-
- // Copy first connection
- _buffers->at(0)->copy(
- (*_connections.begin())->buffer(0), 0, _buffer_size-1);
- }
-}
-
-
-void
-InputPort::post_process(ProcessContext& context)
-{
- broadcast(context);
-
- // Prepare for next cycle
- for (uint32_t i=0; i < _poly; ++i)
- buffer(i)->prepare_write(context.start(), context.nframes());
-
- _set_by_user = false;
-
- /*if (_broadcast && (_type == DataType::CONTROL)) {
- const Sample value = ((AudioBuffer*)(*_buffers)[0])->value_at(0);
-
- cerr << path() << " input post: buffer: " << buffer(0) << " value = "
- << value << " (last " << _last_broadcasted_value << ")" <<endl;
- }*/
-}
-
-
-} // namespace Ingen
-
diff --git a/src/libs/engine/InputPort.hpp b/src/libs/engine/InputPort.hpp
deleted file mode 100644
index 2617882f..00000000
--- a/src/libs/engine/InputPort.hpp
+++ /dev/null
@@ -1,88 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef INPUTPORT_H
-#define INPUTPORT_H
-
-#include <string>
-#include <cstdlib>
-#include <cassert>
-#include <raul/List.hpp>
-#include <raul/SharedPtr.hpp>
-#include "PortImpl.hpp"
-using std::string;
-
-namespace Ingen {
-
-class ConnectionImpl;
-class OutputPort;
-class NodeImpl;
-
-
-/** An input port on a Node or Patch.
- *
- * All ports have a Buffer, but the actual contents (data) of that buffer may be
- * set directly to the incoming connection's buffer if there's only one inbound
- * connection, to eliminate the need to copy/mix.
- *
- * If a port has multiple connections, they will be mixed down into the local
- * buffer and it will be used.
- *
- * \ingroup engine
- */
-class InputPort : virtual public PortImpl
-{
-public:
- InputPort(NodeImpl* parent,
- const string& name,
- uint32_t index,
- uint32_t poly,
- DataType type,
- const Atom& value,
- size_t buffer_size);
-
- virtual ~InputPort() {}
-
- typedef Raul::List< SharedPtr<ConnectionImpl> > Connections;
-
- void add_connection(Connections::Node* c);
- Connections::Node* remove_connection(const OutputPort* src_port);
-
- const Connections& connections() { return _connections; }
-
- bool prepare_poly(uint32_t poly);
- bool apply_poly(Raul::Maid& maid, uint32_t poly);
-
- void pre_process(ProcessContext& context);
- void post_process(ProcessContext& context);
-
- bool is_connected() const { return (_connections.size() > 0); }
- //bool is_connected_to(const OutputPort* port) const;
-
- bool is_input() const { return true; }
- bool is_output() const { return false; }
-
- virtual void set_buffer_size(size_t size);
-
-private:
- Connections _connections;
-};
-
-
-} // namespace Ingen
-
-#endif // INPUTPORT_H
diff --git a/src/libs/engine/InternalPlugin.cpp b/src/libs/engine/InternalPlugin.cpp
deleted file mode 100644
index 1c6a92a5..00000000
--- a/src/libs/engine/InternalPlugin.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <cassert>
-#include "InternalPlugin.hpp"
-#include "MidiNoteNode.hpp"
-#include "MidiTriggerNode.hpp"
-#include "MidiControlNode.hpp"
-#include "TransportNode.hpp"
-#include "Engine.hpp"
-#include "AudioDriver.hpp"
-
-namespace Ingen {
-
-
-NodeImpl*
-InternalPlugin::instantiate(const string& name,
- bool polyphonic,
- Ingen::PatchImpl* parent,
- Engine& engine)
-{
- assert(_type == Internal);
-
- SampleCount srate = engine.audio_driver()->sample_rate();
- SampleCount buffer_size = engine.audio_driver()->buffer_size();
-
- if (_uri == NS_INGEN "note_node") {
- return new MidiNoteNode(name, polyphonic, parent, srate, buffer_size);
- } else if (_uri == NS_INGEN "trigger_node") {
- return new MidiTriggerNode(name, polyphonic, parent, srate, buffer_size);
- } else if (_uri == NS_INGEN "control_node") {
- return new MidiControlNode(name, polyphonic, parent, srate, buffer_size);
- } else if (_uri == NS_INGEN "transport_node") {
- return new TransportNode(name, polyphonic, parent, srate, buffer_size);
- } else {
- return NULL;
- }
-}
-
-
-} // namespace Ingen
diff --git a/src/libs/engine/InternalPlugin.hpp b/src/libs/engine/InternalPlugin.hpp
deleted file mode 100644
index c04c9015..00000000
--- a/src/libs/engine/InternalPlugin.hpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef INTERNALPLUGIN_H
-#define INTERNALPLUGIN_H
-
-#include CONFIG_H_PATH
-
-#ifndef HAVE_SLV2
-#error "This file requires SLV2, but HAVE_SLV2 is not defined. Please report."
-#endif
-
-#include <cstdlib>
-#include <glibmm/module.h>
-#include <boost/utility.hpp>
-#include <dlfcn.h>
-#include <string>
-#include <iostream>
-#include <slv2/slv2.h>
-#include "types.hpp"
-#include "PluginImpl.hpp"
-
-#define NS_INGEN "http://drobilla.net/ns/ingen#"
-
-namespace Ingen {
-
-class NodeImpl;
-
-
-/** Implementation of an Internal plugin.
- */
-class InternalPlugin : public PluginImpl
-{
-public:
- InternalPlugin(const std::string& uri,
- const std::string& symbol,
- const std::string& name)
- : PluginImpl(Plugin::Internal, uri)
- , _symbol(symbol)
- , _name(name)
- {}
-
- NodeImpl* instantiate(const std::string& name,
- bool polyphonic,
- Ingen::PatchImpl* parent,
- Engine& engine);
-
- const string symbol() const { return _symbol; }
- const string name() const { return _name; }
-
-private:
- const string _symbol;
- const string _name;
-};
-
-
-} // namespace Ingen
-
-#endif // INTERNALPLUGIN_H
-
diff --git a/src/libs/engine/JackAudioDriver.cpp b/src/libs/engine/JackAudioDriver.cpp
deleted file mode 100644
index eff04653..00000000
--- a/src/libs/engine/JackAudioDriver.cpp
+++ /dev/null
@@ -1,384 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "JackAudioDriver.hpp"
-#include CONFIG_H_PATH
-#include "tuning.hpp"
-#include <iostream>
-#include <cstdlib>
-#include <raul/List.hpp>
-#include "Engine.hpp"
-#include "util.hpp"
-#include "Event.hpp"
-#include "ThreadManager.hpp"
-#include "QueuedEvent.hpp"
-#include "EventSource.hpp"
-#include "PostProcessor.hpp"
-#include "NodeImpl.hpp"
-#include "PatchImpl.hpp"
-#include "PortImpl.hpp"
-#include "MidiDriver.hpp"
-#include "DuplexPort.hpp"
-#include "EventSource.hpp"
-#include "AudioBuffer.hpp"
-#include "ProcessSlave.hpp"
-
-using namespace std;
-
-namespace Ingen {
-
-
-//// JackAudioPort ////
-
-JackAudioPort::JackAudioPort(JackAudioDriver* driver, DuplexPort* patch_port)
- : DriverPort(patch_port)
- , Raul::List<JackAudioPort*>::Node(this)
- , _driver(driver)
- , _jack_port(NULL)
- , _jack_buffer(NULL)
-{
- assert(patch_port->poly() == 1);
-
- _jack_port = jack_port_register(_driver->jack_client(),
- patch_port->path().c_str(), JACK_DEFAULT_AUDIO_TYPE,
- (patch_port->is_input()) ? JackPortIsInput : JackPortIsOutput,
- 0);
-
- if (_jack_port == NULL) {
- cerr << "[JackAudioPort] ERROR: Failed to register port " << patch_port->path() << endl;
- throw JackAudioDriver::PortRegistrationFailedException();
- }
-
- patch_port->buffer(0)->clear();
- patch_port->fixed_buffers(true);
-}
-
-
-JackAudioPort::~JackAudioPort()
-{
- jack_port_unregister(_driver->jack_client(), _jack_port);
-}
-
-
-void
-JackAudioPort::prepare_buffer(jack_nframes_t nframes)
-{
- jack_sample_t* jack_buf = (jack_sample_t*)jack_port_get_buffer(_jack_port, nframes);
-
- AudioBuffer* patch_buf = (AudioBuffer*)_patch_port->buffer(0);
-
- //cerr << "[JACK] " << _patch_port->path() << " buffer: " << patch_buf << endl;
-
- if (jack_buf != _jack_buffer) {
- patch_buf->set_data(jack_buf);
- _jack_buffer = jack_buf;
- }
-
- assert(patch_buf->data() == jack_buf);
-}
-
-
-//// JackAudioDriver ////
-
-JackAudioDriver::JackAudioDriver(Engine& engine,
- std::string server_name,
- jack_client_t* jack_client)
- : _engine(engine)
- , _jack_thread(NULL)
- , _client(jack_client)
- , _buffer_size(jack_client ? jack_get_buffer_size(jack_client) : 0)
- , _sample_rate(jack_client ? jack_get_sample_rate(jack_client) : 0)
- , _is_activated(false)
- , _local_client(true) // FIXME
- , _process_context(engine)
- , _root_patch(NULL)
-{
- if (!_client) {
- // Try supplied server name
- if (server_name != "") {
- _client = jack_client_open("Ingen", JackServerName, NULL, server_name.c_str());
- if (_client)
- cerr << "[JackAudioDriver] Connected to JACK server '" <<
- server_name << "'" << endl;
- }
-
- // Either server name not specified, or supplied server name does not exist
- // Connect to default server
- if (!_client) {
- _client = jack_client_open("Ingen", JackNullOption, NULL);
-
- if (_client)
- cerr << "[JackAudioDriver] Connected to default JACK server." << endl;
- }
-
- // Still failed
- if (!_client) {
- cerr << "[JackAudioDriver] Unable to connect to Jack. Exiting." << endl;
- exit(EXIT_FAILURE);
- }
-
- _buffer_size = jack_get_buffer_size(_client);
- _sample_rate = jack_get_sample_rate(_client);
- }
-
- jack_on_shutdown(_client, shutdown_cb, this);
-
- jack_set_thread_init_callback(_client, thread_init_cb, this);
- jack_set_sample_rate_callback(_client, sample_rate_cb, this);
- jack_set_buffer_size_callback(_client, buffer_size_cb, this);
-}
-
-
-JackAudioDriver::~JackAudioDriver()
-{
- deactivate();
-
- if (_local_client)
- jack_client_close(_client);
-}
-
-
-void
-JackAudioDriver::activate()
-{
- if (_is_activated) {
- cerr << "[JackAudioDriver] Jack driver already activated." << endl;
- return;
- }
-
- jack_set_process_callback(_client, process_cb, this);
-
- _is_activated = true;
-
- if (jack_activate(_client)) {
- cerr << "[JackAudioDriver] Could not activate Jack client, aborting." << endl;
- exit(EXIT_FAILURE);
- } else {
- cout << "[JackAudioDriver] Activated Jack client." << endl;
-/*#ifdef HAVE_LASH
- _engine.lash_driver()->set_jack_client_name(jack_client_get_name(_client));
-#endif*/
- }
-}
-
-
-void
-JackAudioDriver::deactivate()
-{
- if (_is_activated) {
-
- //for (Raul::List<JackAudioPort*>::iterator i = _ports.begin(); i != _ports.end(); ++i)
- // jack_port_unregister(_client, (*i)->jack_port());
-
- jack_deactivate(_client);
- _is_activated = false;
-
- _ports.clear();
-
- cout << "[JackAudioDriver] Deactivated Jack client." << endl;
-
- //_engine.post_processor()->stop();
- }
-}
-
-
-/** Add a Jack port.
- *
- * Realtime safe, this is to be called at the beginning of a process cycle to
- * insert (and actually begin using) a new port.
- *
- * See create_port() and remove_port().
- */
-void
-JackAudioDriver::add_port(DriverPort* port)
-{
- assert(ThreadManager::current_thread_id() == THREAD_PROCESS);
-
- assert(dynamic_cast<JackAudioPort*>(port));
- _ports.push_back((JackAudioPort*)port);
-}
-
-
-/** Remove a Jack port.
- *
- * Realtime safe. This is to be called at the beginning of a process cycle to
- * remove the port from the lists read by the audio thread, so the port
- * will no longer be used and can be removed afterwards.
- *
- * It is the callers responsibility to delete the returned port.
- */
-DriverPort*
-JackAudioDriver::remove_port(const Path& path)
-{
- assert(ThreadManager::current_thread_id() == THREAD_PROCESS);
-
- for (Raul::List<JackAudioPort*>::iterator i = _ports.begin(); i != _ports.end(); ++i)
- if ((*i)->patch_port()->path() == path)
- return _ports.erase(i)->elem(); // FIXME: LEAK
-
- cerr << "[JackAudioDriver::remove_port] WARNING: Unable to find Jack port " << path << endl;
- return NULL;
-}
-
-
-DriverPort*
-JackAudioDriver::port(const Path& path)
-{
- for (Raul::List<JackAudioPort*>::iterator i = _ports.begin(); i != _ports.end(); ++i)
- if ((*i)->patch_port()->path() == path)
- return (*i);
-
- return NULL;
-}
-
-
-DriverPort*
-JackAudioDriver::create_port(DuplexPort* patch_port)
-{
- try {
- if (patch_port->buffer_size() == _buffer_size)
- return new JackAudioPort(this, patch_port);
- else
- return NULL;
- } catch (...) {
- return NULL;
- }
-}
-
-
-DriverPort*
-JackAudioDriver::driver_port(const Path& path)
-{
- assert(ThreadManager::current_thread_id() == THREAD_PROCESS);
-
- for (Raul::List<JackAudioPort*>::iterator i = _ports.begin(); i != _ports.end(); ++i)
- if ((*i)->patch_port()->path() == path)
- return (*i);
-
- return NULL;
-}
-
-
-/**** Jack Callbacks ****/
-
-
-
-/** Jack process callback, drives entire audio thread.
- *
- * \callgraph
- */
-int
-JackAudioDriver::_process_cb(jack_nframes_t nframes)
-{
- if (nframes == 0 || ! _is_activated)
- return 0;
-
- // FIXME: all of this time stuff is screwy
-
- // FIXME: support nframes != buffer_size, even though that never damn well happens
- assert(nframes == _buffer_size);
-
- // Jack can elect to not call this function for a cycle, if overloaded
- // FIXME: this doesn't make sense, and the start time isn't used anyway
- const jack_nframes_t start_of_current_cycle = jack_last_frame_time(_client);
-
- const jack_nframes_t end_of_current_cycle = start_of_current_cycle + nframes;
-#ifndef NDEBUG
- // FIXME: support changing cycle length
- const jack_nframes_t start_of_last_cycle = start_of_current_cycle - nframes;
- assert(start_of_current_cycle - start_of_last_cycle == nframes);
-#endif
-
- _transport_state = jack_transport_query(_client, &_position);
-
- _process_context.set_time_slice(nframes, start_of_current_cycle, end_of_current_cycle);
-
- for (Engine::ProcessSlaves::iterator i = _engine.process_slaves().begin();
- i != _engine.process_slaves().end(); ++i) {
- (*i)->context().set_time_slice(nframes, start_of_current_cycle, end_of_current_cycle);
- }
-
- // Process events that came in during the last cycle
- // (Aiming for jitter-free 1 block event latency, ideally)
- _engine.process_events(_process_context);
-
- // Set buffers of patch ports to Jack port buffers (zero-copy processing)
- for (Raul::List<JackAudioPort*>::iterator i = _ports.begin(); i != _ports.end(); ++i) {
- assert(*i);
- (*i)->prepare_buffer(nframes);
- }
-
- assert(_engine.midi_driver());
- _engine.midi_driver()->pre_process(_process_context);
-
- // Run root patch
- if (_root_patch)
- _root_patch->process(_process_context);
-
- _engine.midi_driver()->post_process(_process_context);
-
- _engine.post_processor()->set_end_time(_process_context.end());
-
- return 0;
-}
-
-
-void
-JackAudioDriver::_thread_init_cb()
-{
- // Initialize thread specific data
- _jack_thread = Thread::create_for_this_thread("Jack");
- assert(&Thread::get() == _jack_thread);
- _jack_thread->set_context(THREAD_PROCESS);
- assert(ThreadManager::current_thread_id() == THREAD_PROCESS);
-}
-
-void
-JackAudioDriver::_shutdown_cb()
-{
- cout << "[JackAudioDriver] Jack shutdown. Exiting." << endl;
- _engine.quit();
- _jack_thread = NULL;
-}
-
-
-int
-JackAudioDriver::_sample_rate_cb(jack_nframes_t nframes)
-{
- if (_is_activated) {
- cerr << "[JackAudioDriver] On-the-fly sample rate changing not supported (yet). Aborting." << endl;
- exit(EXIT_FAILURE);
- } else {
- _sample_rate = nframes;
- }
- return 0;
-}
-
-
-int
-JackAudioDriver::_buffer_size_cb(jack_nframes_t nframes)
-{
- if (_root_patch) {
- _root_patch->set_buffer_size(nframes);
- _buffer_size = nframes;
- }
- return 0;
-}
-
-
-} // namespace Ingen
-
diff --git a/src/libs/engine/JackAudioDriver.hpp b/src/libs/engine/JackAudioDriver.hpp
deleted file mode 100644
index 3beb775a..00000000
--- a/src/libs/engine/JackAudioDriver.hpp
+++ /dev/null
@@ -1,185 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef JACKAUDIODRIVER_H
-#define JACKAUDIODRIVER_H
-
-#include <jack/jack.h>
-#include <jack/transport.h>
-#include <raul/Thread.hpp>
-#include <raul/Path.hpp>
-#include <raul/List.hpp>
-#include "AudioDriver.hpp"
-#include "Buffer.hpp"
-#include "ProcessContext.hpp"
-
-namespace Ingen {
-
-class Engine;
-class PatchImpl;
-class PortImpl;
-class DuplexPort;
-class JackAudioDriver;
-typedef jack_default_audio_sample_t jack_sample_t;
-
-
-/** Used internally by JackAudioDriver to represent a Jack port.
- *
- * A Jack port always has a one-to-one association with a Patch port.
- */
-class JackAudioPort : public DriverPort, public Raul::List<JackAudioPort*>::Node
-{
-public:
- JackAudioPort(JackAudioDriver* driver, DuplexPort* patch_port);
- ~JackAudioPort();
-
- void set_name(const std::string& name) { jack_port_set_name(_jack_port, name.c_str()); };
-
- void prepare_buffer(jack_nframes_t nframes);
-
- jack_port_t* jack_port() const { return _jack_port; }
-
-private:
- JackAudioDriver* _driver;
- jack_port_t* _jack_port;
- jack_sample_t* _jack_buffer; ///< Cached for output ports
-};
-
-
-
-/** The Jack AudioDriver.
- *
- * The process callback here drives the entire audio thread by "pulling"
- * events from queues, processing them, running the patches, and passing
- * events along to the PostProcessor.
- *
- * \ingroup engine
- */
-class JackAudioDriver : public AudioDriver
-{
-public:
- JackAudioDriver(Engine& engine,
- std::string server_name = "",
- jack_client_t* jack_client = 0);
-
- ~JackAudioDriver();
-
- void activate();
- void deactivate();
- void enable();
- void disable();
-
- DriverPort* port(const Raul::Path& path);
- DriverPort* create_port(DuplexPort* patch_port);
-
- void add_port(DriverPort* port);
- DriverPort* remove_port(const Raul::Path& path);
-
- DriverPort* driver_port(const Raul::Path& path);
-
- PatchImpl* root_patch() { return _root_patch; }
- void set_root_patch(PatchImpl* patch) { _root_patch = patch; }
-
- ProcessContext& context() { return _process_context; }
-
- /** Transport state for this frame.
- * Intended to only be called from the audio thread. */
- inline const jack_position_t* position() { return &_position; }
- inline jack_transport_state_t transport_state() { return _transport_state; }
-
- bool is_realtime() const { return jack_is_realtime(_client); }
-
- jack_client_t* jack_client() const { return _client; }
- SampleCount buffer_size() const { return _buffer_size; }
- SampleCount sample_rate() const { return _sample_rate; }
- bool is_activated() const { return _is_activated; }
-
- inline SampleCount frame_time() const { return jack_frame_time(_client); }
-
- class PortRegistrationFailedException : public std::exception {};
-
-private:
- friend class JackAudioPort;
-
- // These are the static versions of the callbacks, they call
- // the non-static ones below
- inline static void thread_init_cb(void* const jack_driver);
- inline static void shutdown_cb(void* const jack_driver);
- inline static int process_cb(jack_nframes_t nframes, void* const jack_driver);
- inline static int buffer_size_cb(jack_nframes_t nframes, void* const jack_driver);
- inline static int sample_rate_cb(jack_nframes_t nframes, void* const jack_driver);
-
- // Non static callbacks
- void _thread_init_cb();
- void _shutdown_cb();
- int _process_cb(jack_nframes_t nframes);
- int _buffer_size_cb(jack_nframes_t nframes);
- int _sample_rate_cb(jack_nframes_t nframes);
-
- Engine& _engine;
- Raul::Thread* _jack_thread;
- jack_client_t* _client;
- jack_nframes_t _buffer_size;
- jack_nframes_t _sample_rate;
- bool _is_activated;
- bool _local_client; ///< Whether _client should be closed on destruction
- jack_position_t _position;
- jack_transport_state_t _transport_state;
-
- Raul::List<JackAudioPort*> _ports;
- ProcessContext _process_context;
-
- PatchImpl* _root_patch;
-};
-
-
-inline int JackAudioDriver::process_cb(jack_nframes_t nframes, void* jack_driver)
-{
- assert(jack_driver);
- return ((JackAudioDriver*)jack_driver)->_process_cb(nframes);
-}
-
-inline void JackAudioDriver::thread_init_cb(void* jack_driver)
-{
- assert(jack_driver);
- return ((JackAudioDriver*)jack_driver)->_thread_init_cb();
-}
-
-inline void JackAudioDriver::shutdown_cb(void* jack_driver)
-{
- assert(jack_driver);
- return ((JackAudioDriver*)jack_driver)->_shutdown_cb();
-}
-
-
-inline int JackAudioDriver::buffer_size_cb(jack_nframes_t nframes, void* jack_driver)
-{
- assert(jack_driver);
- return ((JackAudioDriver*)jack_driver)->_buffer_size_cb(nframes);
-}
-
-
-inline int JackAudioDriver::sample_rate_cb(jack_nframes_t nframes, void* jack_driver)
-{
- assert(jack_driver);
- return ((JackAudioDriver*)jack_driver)->_sample_rate_cb(nframes);
-}
-
-
-} // namespace Ingen
-
-#endif // JACKAUDIODRIVER_H
diff --git a/src/libs/engine/JackMidiDriver.cpp b/src/libs/engine/JackMidiDriver.cpp
deleted file mode 100644
index 9e236541..00000000
--- a/src/libs/engine/JackMidiDriver.cpp
+++ /dev/null
@@ -1,267 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-() */
-
-#include <iostream>
-#include <cstdlib>
-#include <pthread.h>
-#include <raul/Maid.hpp>
-#include <raul/midi_events.h>
-#include "types.hpp"
-#include "JackMidiDriver.hpp"
-#include "JackAudioDriver.hpp"
-#include "ThreadManager.hpp"
-#include "AudioDriver.hpp"
-#include "EventBuffer.hpp"
-#include "DuplexPort.hpp"
-#include "ProcessContext.hpp"
-#include "jack_compat.h"
-using namespace std;
-
-namespace Ingen {
-
-
-//// JackMidiPort ////
-
-JackMidiPort::JackMidiPort(JackMidiDriver* driver, DuplexPort* patch_port)
- : DriverPort(patch_port)
- , Raul::List<JackMidiPort*>::Node(this)
- , _driver(driver)
- , _jack_port(NULL)
-{
- assert(patch_port->poly() == 1);
-
- _jack_port = jack_port_register(_driver->jack_client(),
- patch_port->path().c_str(), JACK_DEFAULT_MIDI_TYPE,
- (patch_port->is_input()) ? JackPortIsInput : JackPortIsOutput,
- 0);
-
- if (_jack_port == NULL) {
- cerr << "[JackMidiPort] ERROR: Failed to register port " << patch_port->path() << endl;
- throw JackAudioDriver::PortRegistrationFailedException();
- }
-
- patch_port->buffer(0)->clear();
-}
-
-
-JackMidiPort::~JackMidiPort()
-{
- jack_port_unregister(_driver->jack_client(), _jack_port);
-}
-
-
-/** Prepare input for a block before a cycle is run, in the audio thread.
- *
- * This is simple since Jack MIDI is in-band with audio.
- */
-void
-JackMidiPort::pre_process(ProcessContext& context)
-{
- if ( ! is_input() )
- return;
-
- assert(_patch_port->poly() == 1);
-
- EventBuffer* patch_buf = dynamic_cast<EventBuffer*>(_patch_port->buffer(0));
- assert(patch_buf);
-
- void* jack_buffer = jack_port_get_buffer(_jack_port, context.nframes());
- const jack_nframes_t event_count = jack_midi_get_event_count(jack_buffer);
-
- patch_buf->prepare_write(context.start(), context.nframes());
-
- // Copy events from Jack port buffer into patch port buffer
- for (jack_nframes_t i=0; i < event_count; ++i) {
- jack_midi_event_t ev;
- jack_midi_event_get(&ev, jack_buffer, i);
-
- // FIXME: type is hardcoded for now, we should get it from
- // the type map instead
- const bool success = patch_buf->append(ev.time, 0, 1, ev.size, ev.buffer);
- if (!success)
- cerr << "WARNING: Failed to write MIDI to port buffer, event(s) lost!" << endl;
- }
-
- //if (event_count)
- // cerr << "Jack MIDI got " << event_count << " events." << endl;
-}
-
-
-/** Prepare output for a block after a cycle is run, in the audio thread.
- *
- * This is simple since Jack MIDI is in-band with audio.
- */
-void
-JackMidiPort::post_process(ProcessContext& context)
-{
- if (is_input())
- return;
-
- EventBuffer* patch_buf = dynamic_cast<EventBuffer*>(_patch_port->buffer(0));
- void* jack_buf = jack_port_get_buffer(_jack_port, context.nframes());
-
- assert(_patch_port->poly() == 1);
- assert(patch_buf);
-
- patch_buf->prepare_read(context.start(), context.nframes());
- jack_midi_clear_buffer(jack_buf);
-
- uint32_t frames = 0;
- uint32_t subframes = 0;
- uint16_t type = 0;
- uint16_t size = 0;
- uint8_t* data = NULL;
-
- // Copy events from Jack port buffer into patch port buffer
- for (patch_buf->rewind(); patch_buf->is_valid(); patch_buf->increment()) {
- patch_buf->get_event(&frames, &subframes, &type, &size, &data);
- jack_midi_event_write(jack_buf, frames, data, size);
- }
-
- //if (event_count)
- // cerr << "Jack MIDI wrote " << event_count << " events." << endl;
-}
-
-
-
-//// JackMidiDriver ////
-
-
-bool JackMidiDriver::_midi_thread_exit_flag = true;
-
-
-JackMidiDriver::JackMidiDriver(jack_client_t* client)
- : _client(client)
- , _is_activated(false)
- , _is_enabled(false)
-{
-}
-
-
-JackMidiDriver::~JackMidiDriver()
-{
- deactivate();
-}
-
-
-/** Launch and start the MIDI thread.
- */
-void
-JackMidiDriver::activate()
-{
- _is_activated = true;
-}
-
-
-/** Terminate the MIDI thread.
- */
-void
-JackMidiDriver::deactivate()
-{
- _is_activated = false;
-}
-
-
-/** Build flat arrays of events to be used as input for the given cycle.
- */
-void
-JackMidiDriver::pre_process(ProcessContext& context)
-{
- for (Raul::List<JackMidiPort*>::iterator i = _in_ports.begin(); i != _in_ports.end(); ++i)
- (*i)->pre_process(context);
-}
-
-
-/** Write the output from any (top-level, exported) MIDI output ports to Jack ports.
- */
-void
-JackMidiDriver::post_process(ProcessContext& context)
-{
- for (Raul::List<JackMidiPort*>::iterator i = _out_ports.begin(); i != _out_ports.end(); ++i)
- (*i)->post_process(context);
-}
-
-
-/** Add an Jack MIDI port.
- *
- * Realtime safe, this is to be called at the beginning of a process cycle to
- * insert (and actually begin using) a new port.
- *
- * See new_port() and remove_port().
- */
-void
-JackMidiDriver::add_port(DriverPort* port)
-{
- assert(ThreadManager::current_thread_id() == THREAD_PROCESS);
- assert(dynamic_cast<JackMidiPort*>(port));
-
- if (port->is_input())
- _in_ports.push_back((JackMidiPort*)port);
- else
- _out_ports.push_back((JackMidiPort*)port);
-}
-
-
-/** Remove an Jack MIDI port.
- *
- * Realtime safe. This is to be called at the beginning of a process cycle to
- * remove the port from the lists read by the audio thread, so the port
- * will no longer be used and can be removed afterwards.
- *
- * It is the callers responsibility to delete the returned port.
- */
-DriverPort*
-JackMidiDriver::remove_port(const Path& path)
-{
- assert(ThreadManager::current_thread_id() == THREAD_PROCESS);
-
- // FIXME: duplex?
-
- for (Raul::List<JackMidiPort*>::iterator i = _in_ports.begin(); i != _in_ports.end(); ++i)
- if ((*i)->patch_port()->path() == path)
- return _in_ports.erase(i)->elem(); // FIXME: LEAK
-
- for (Raul::List<JackMidiPort*>::iterator i = _out_ports.begin(); i != _out_ports.end(); ++i)
- if ((*i)->patch_port()->path() == path)
- return _out_ports.erase(i)->elem(); // FIXME: LEAK
-
- cerr << "[JackMidiDriver::remove_input] WARNING: Unable to find Jack port " << path << endl;
- return NULL;
-}
-
-
-DriverPort*
-JackMidiDriver::driver_port(const Path& path)
-{
- assert(ThreadManager::current_thread_id() == THREAD_PROCESS);
-
- // FIXME: duplex?
-
- for (Raul::List<JackMidiPort*>::iterator i = _in_ports.begin(); i != _in_ports.end(); ++i)
- if ((*i)->patch_port()->path() == path)
- return (*i);
-
- for (Raul::List<JackMidiPort*>::iterator i = _out_ports.begin(); i != _out_ports.end(); ++i)
- if ((*i)->patch_port()->path() == path)
- return (*i);
-
- return NULL;
-}
-
-
-} // namespace Ingen
-
diff --git a/src/libs/engine/JackMidiDriver.hpp b/src/libs/engine/JackMidiDriver.hpp
deleted file mode 100644
index 7889c4fa..00000000
--- a/src/libs/engine/JackMidiDriver.hpp
+++ /dev/null
@@ -1,113 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef JACKMIDIDRIVER_H
-#define JACKMIDIDRIVER_H
-
-#include <jack/jack.h>
-#include <jack/midiport.h>
-#include <raul/List.hpp>
-#include CONFIG_H_PATH
-#include "MidiDriver.hpp"
-
-namespace Ingen {
-
-class NodeImpl;
-class SetPortValueEvent;
-class JackMidiDriver;
-class DuplexPort;
-
-
-/** Representation of an JACK MIDI port.
- *
- * \ingroup engine
- */
-class JackMidiPort : public DriverPort, public Raul::List<JackMidiPort*>::Node
-{
-public:
- JackMidiPort(JackMidiDriver* driver, DuplexPort* port);
- virtual ~JackMidiPort();
-
- void pre_process(ProcessContext& context);
- void post_process(ProcessContext& context);
-
- void set_name(const std::string& name) { jack_port_set_name(_jack_port, name.c_str()); };
-
-private:
- JackMidiDriver* _driver;
- jack_port_t* _jack_port;
-};
-
-
-/** Jack MIDI driver.
- *
- * This driver reads Jack MIDI events and dispatches them to the appropriate
- * JackMidiPort for processing.
- *
- * \ingroup engine
- */
-class JackMidiDriver : public MidiDriver
-{
-public:
- JackMidiDriver(jack_client_t* client);
- ~JackMidiDriver();
-
- void activate();
- void deactivate();
- void enable() { _is_enabled = true; }
- void disable() { _is_enabled = false; }
-
- bool is_activated() const { return _is_activated; }
- bool is_enabled() const { return _is_enabled; }
-
- void pre_process(ProcessContext& context);
- void post_process(ProcessContext& context);
-
- JackMidiPort* create_port(DuplexPort* patch_port)
- { return new JackMidiPort(this, patch_port); }
-
- void add_port(DriverPort* port);
- DriverPort* remove_port(const Raul::Path& path);
-
- DriverPort* driver_port(const Raul::Path& path);
-
- jack_client_t* jack_client() { return _client; }
-
-private:
- Raul::List<JackMidiPort*> _in_ports;
- Raul::List<JackMidiPort*> _out_ports;
-
- friend class JackMidiPort;
-
- void add_output(Raul::List<JackMidiPort*>::Node* port);
- Raul::List<JackMidiPort*>::Node* remove_output(JackMidiPort* port);
-
- // MIDI thread
- static void* process_midi_in(void* me);
-
- jack_client_t* _client;
- pthread_t _process_thread;
- bool _is_activated;
- bool _is_enabled;
- static bool _midi_thread_exit_flag;
-};
-
-
-} // namespace Ingen
-
-
-#endif // JACKMIDIDRIVER_H
diff --git a/src/libs/engine/LADSPANode.cpp b/src/libs/engine/LADSPANode.cpp
deleted file mode 100644
index 22f5bbf3..00000000
--- a/src/libs/engine/LADSPANode.cpp
+++ /dev/null
@@ -1,373 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <iostream>
-#include <cassert>
-#include <cmath>
-#include <stdint.h>
-#include <raul/Maid.hpp>
-#include <boost/optional.hpp>
-#include "LADSPANode.hpp"
-#include "AudioBuffer.hpp"
-#include "InputPort.hpp"
-#include "OutputPort.hpp"
-#include "PluginImpl.hpp"
-#include "ProcessContext.hpp"
-
-using namespace std;
-
-namespace Ingen {
-
-
-/** Partially construct a LADSPANode.
- *
- * Object is not usable until instantiate() is called with success.
- * (It _will_ crash!)
- */
-LADSPANode::LADSPANode(PluginImpl* plugin, const string& path, bool polyphonic, PatchImpl* parent, const LADSPA_Descriptor* descriptor, SampleRate srate, size_t buffer_size)
- : NodeBase(plugin, path, polyphonic, parent, srate, buffer_size)
- , _descriptor(descriptor)
- , _instances(NULL)
- , _prepared_instances(NULL)
-{
- assert(_descriptor != NULL);
-}
-
-
-LADSPANode::~LADSPANode()
-{
- for (uint32_t i=0; i < _polyphony; ++i)
- _descriptor->cleanup((*_instances)[i]);
-
- delete _instances;
-}
-
-
-bool
-LADSPANode::prepare_poly(uint32_t poly)
-{
- NodeBase::prepare_poly(poly);
-
- if ( (!_polyphonic)
- || (_prepared_instances && poly <= _prepared_instances->size()) ) {
- return true;
- }
-
- _prepared_instances = new Raul::Array<LADSPA_Handle>(poly, *_instances);
- for (uint32_t i = _polyphony; i < _prepared_instances->size(); ++i) {
- _prepared_instances->at(i) = _descriptor->instantiate(_descriptor, _srate);
- if (_prepared_instances->at(i) == NULL) {
- cerr << "Failed to instantiate plugin!" << endl;
- return false;
- }
-
- if (_activated && _descriptor->activate)
- _descriptor->activate(_prepared_instances->at(i));
- }
-
- return true;
-}
-
-
-bool
-LADSPANode::apply_poly(Raul::Maid& maid, uint32_t poly)
-{
- if (!_polyphonic)
- return true;
-
- if (_prepared_instances) {
- assert(poly <= _prepared_instances->size());
- maid.push(_instances);
- _instances = _prepared_instances;
- _prepared_instances = NULL;
- }
-
- assert(poly <= _instances->size());
- _polyphony = poly;
-
- return NodeBase::apply_poly(maid, poly);
-}
-
-
-static string
-nameify_if_invalid(const string& name)
-{
- if (Path::is_valid_name(name)) {
- return name;
- } else {
- const string new_name = Path::nameify(name);
- assert(Path::is_valid_name(new_name));
- if (new_name != name)
- cerr << "Symbol '" << new_name << "' generated from LADSPA name '" << name << endl;
- return new_name;
- }
-}
-
-
-/** Instantiate self from LADSPA plugin descriptor.
- *
- * Implemented as a seperate function (rather than in the constructor) to
- * allow graceful error-catching of broken plugins.
- *
- * Returns whether or not plugin was successfully instantiated. If return
- * value is false, this object may not be used.
- */
-bool
-LADSPANode::instantiate()
-{
- if (!_ports)
- _ports = new Raul::Array<PortImpl*>(_descriptor->PortCount);
-
- _instances = new Raul::Array<LADSPA_Handle>(_polyphony, NULL);
-
- size_t port_buffer_size = 0;
-
- for (uint32_t i=0; i < _polyphony; ++i) {
- (*_instances)[i] = _descriptor->instantiate(_descriptor, _srate);
- if ((*_instances)[i] == NULL) {
- cerr << "Failed to instantiate plugin!" << endl;
- return false;
- }
- }
-
- string port_name;
- string port_path;
-
- PortImpl* port = NULL;
-
- for (size_t j=0; j < _descriptor->PortCount; ++j) {
- port_name = nameify_if_invalid(_descriptor->PortNames[j]);
-
- string::size_type slash_index;
-
- // Name mangling, to guarantee port names are unique
- for (size_t k=0; k < _descriptor->PortCount; ++k) {
- assert(_descriptor->PortNames[k] != NULL);
- if (k != j && port_name == _descriptor->PortNames[k]) { // clash
- if (LADSPA_IS_PORT_CONTROL(_descriptor->PortDescriptors[j]))
- port_name += "(CR)";
- else
- port_name += "(AR)";
- }
- // Replace all slashes with "-" (so they don't screw up paths)
- while ((slash_index = port_name.find("/")) != string::npos)
- port_name[slash_index] = '-';
- }
-
- /*if (_descriptor->PortNames[j] != port_name)
- cerr << "NOTICE: Translated LADSPA port name: " <<
- _descriptor->PortNames[j] << " -> " << port_name << endl;*/
-
- port_path = path() + "/" + port_name;
-
- DataType type = DataType::AUDIO;
- port_buffer_size = _buffer_size;
-
- if (LADSPA_IS_PORT_CONTROL(_descriptor->PortDescriptors[j])) {
- type = DataType::CONTROL;
- port_buffer_size = 1;
- } else {
- assert(LADSPA_IS_PORT_AUDIO(_descriptor->PortDescriptors[j]));
- }
- assert (LADSPA_IS_PORT_INPUT(_descriptor->PortDescriptors[j])
- || LADSPA_IS_PORT_OUTPUT(_descriptor->PortDescriptors[j]));
-
- boost::optional<Sample> default_val, min, max;
- get_port_limits(j, default_val, min, max);
-
- const float value = default_val ? default_val.get() : 0.0f;
-
- if (LADSPA_IS_PORT_INPUT(_descriptor->PortDescriptors[j])) {
- port = new InputPort(this, port_name, j, _polyphony, type, value, port_buffer_size);
- _ports->at(j) = port;
- } else if (LADSPA_IS_PORT_OUTPUT(_descriptor->PortDescriptors[j])) {
- port = new OutputPort(this, port_name, j, _polyphony, type, value, port_buffer_size);
- _ports->at(j) = port;
- }
-
- assert(port);
- assert(_ports->at(j) == port);
-
- // Work around broke-ass crackhead plugins
- if (default_val && default_val.get() < min.get()) {
- cerr << "WARNING: Broken LADSPA " << _descriptor->UniqueID
- << ": Port default < minimum. Minimum adjusted." << endl;
- min = default_val;
- }
-
- if (default_val && default_val.get() > max.get()) {
- cerr << "WARNING: Broken LADSPA " << _descriptor->UniqueID
- << ": Maximum adjusted." << endl;
- max = default_val;
- }
-
- // Set initial/default value
- if (port->buffer_size() == 1) {
- for (uint32_t i=0; i < _polyphony; ++i)
- ((AudioBuffer*)port->buffer(i))->set_value(value, 0, 0);
- }
-
- if (port->is_input() && port->buffer_size() == 1) {
- if (min)
- port->set_variable("ingen:minimum", min.get());
- if (max)
- port->set_variable("ingen:maximum", max.get());
- if (default_val)
- port->set_variable("ingen:default", default_val.get());
- }
- }
-
- return true;
-}
-
-
-void
-LADSPANode::activate()
-{
- NodeBase::activate();
-
- for (uint32_t i=0; i < _polyphony; ++i) {
- for (unsigned long j=0; j < _descriptor->PortCount; ++j) {
- set_port_buffer(i, j, _ports->at(j)->buffer(i));
- /* if (port->type() == DataType::FLOAT && port->buffer_size() == 1)
- port->set_value(0.0f, 0); // FIXME
- else if (port->type() == DataType::FLOAT && port->buffer_size() > 1)
- port->set_value(0.0f, 0);*/
- }
- if (_descriptor->activate != NULL)
- _descriptor->activate((*_instances)[i]);
- }
-}
-
-
-void
-LADSPANode::deactivate()
-{
- NodeBase::deactivate();
-
- for (uint32_t i=0; i < _polyphony; ++i)
- if (_descriptor->deactivate != NULL)
- _descriptor->deactivate((*_instances)[i]);
-}
-
-
-void
-LADSPANode::process(ProcessContext& context)
-{
- NodeBase::pre_process(context);
-
- for (uint32_t i=0; i < _polyphony; ++i)
- _descriptor->run((*_instances)[i], context.nframes());
-
- NodeBase::post_process(context);
-}
-
-
-void
-LADSPANode::set_port_buffer(uint32_t voice, uint32_t port_num, Buffer* buf)
-{
- assert(voice < _polyphony);
-
- AudioBuffer* audio_buffer = dynamic_cast<AudioBuffer*>(buf);
- assert(audio_buffer);
-
- if (port_num < _descriptor->PortCount)
- _descriptor->connect_port((*_instances)[voice], port_num,
- audio_buffer->data());
-}
-
-
-void
-LADSPANode::get_port_limits(unsigned long port_index,
- boost::optional<Sample>& normal,
- boost::optional<Sample>& lower,
- boost::optional<Sample>& upper)
-{
- LADSPA_PortRangeHintDescriptor hint_descriptor = _descriptor->PortRangeHints[port_index].HintDescriptor;
-
- /* set upper and lower, possibly adjusted to the sample rate */
- if (LADSPA_IS_HINT_SAMPLE_RATE(hint_descriptor)) {
- upper = _descriptor->PortRangeHints[port_index].UpperBound * _srate;
- lower = _descriptor->PortRangeHints[port_index].LowerBound * _srate;
- } else {
- upper = _descriptor->PortRangeHints[port_index].UpperBound;
- lower = _descriptor->PortRangeHints[port_index].LowerBound;
- }
-
- if (LADSPA_IS_HINT_LOGARITHMIC(hint_descriptor)) {
- /* FLT_EPSILON is defined as the different between 1.0 and the minimum
- * float greater than 1.0. So, if lower is < FLT_EPSILON, it will be 1.0
- * and the logarithmic control will have a base of 1 and thus not change
- */
- if (lower.get() < FLT_EPSILON) lower = FLT_EPSILON;
- }
-
-
- if (LADSPA_IS_HINT_HAS_DEFAULT(hint_descriptor)) {
-
- if (LADSPA_IS_HINT_DEFAULT_MINIMUM(hint_descriptor)) {
- normal = lower;
- } else if (LADSPA_IS_HINT_DEFAULT_LOW(hint_descriptor)) {
- assert(lower);
- assert(upper);
- if (LADSPA_IS_HINT_LOGARITHMIC(hint_descriptor)) {
- normal = exp(log(lower.get()) * 0.75 + log(upper.get()) * 0.25);
- } else {
- normal = lower.get() * 0.75 + upper.get() * 0.25;
- }
- } else if (LADSPA_IS_HINT_DEFAULT_MIDDLE(hint_descriptor)) {
- assert(lower);
- assert(upper);
- if (LADSPA_IS_HINT_LOGARITHMIC(hint_descriptor)) {
- normal = exp(log(lower.get()) * 0.5 + log(upper.get()) * 0.5);
- } else {
- normal = lower.get() * 0.5 + upper.get() * 0.5;
- }
- } else if (LADSPA_IS_HINT_DEFAULT_HIGH(hint_descriptor)) {
- assert(lower);
- assert(upper);
- if (LADSPA_IS_HINT_LOGARITHMIC(hint_descriptor)) {
- normal = exp(log(lower.get()) * 0.25 + log(upper.get()) * 0.75);
- } else {
- normal = lower.get() * 0.25 + upper.get() * 0.75;
- }
- } else if (LADSPA_IS_HINT_DEFAULT_MAXIMUM(hint_descriptor)) {
- assert(upper);
- normal = upper.get();
- } else if (LADSPA_IS_HINT_DEFAULT_0(hint_descriptor)) {
- normal = 0.0;
- } else if (LADSPA_IS_HINT_DEFAULT_1(hint_descriptor)) {
- normal = 1.0;
- } else if (LADSPA_IS_HINT_DEFAULT_100(hint_descriptor)) {
- normal = 100.0;
- } else if (LADSPA_IS_HINT_DEFAULT_440(hint_descriptor)) {
- normal = 440.0;
- }
- } else { // No default hint
- if (LADSPA_IS_HINT_BOUNDED_BELOW(hint_descriptor)) {
- assert(lower);
- normal = lower.get();
- } else if (LADSPA_IS_HINT_BOUNDED_ABOVE(hint_descriptor)) {
- assert(upper);
- normal = upper.get();
- }
- }
-}
-
-
-} // namespace Ingen
-
diff --git a/src/libs/engine/LADSPANode.hpp b/src/libs/engine/LADSPANode.hpp
deleted file mode 100644
index 53d7ad9e..00000000
--- a/src/libs/engine/LADSPANode.hpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef LADSPANODE_H
-#define LADSPANODE_H
-
-#include <string>
-#include <ladspa.h>
-#include <boost/optional.hpp>
-#include "types.hpp"
-#include "NodeBase.hpp"
-#include "PluginImpl.hpp"
-
-namespace Ingen {
-
-
-/** An instance of a LADSPA plugin.
- *
- * \ingroup engine
- */
-class LADSPANode : public NodeBase
-{
-public:
- LADSPANode(PluginImpl* plugin,
- const string& name,
- bool polyphonic,
- PatchImpl* parent,
- const LADSPA_Descriptor* descriptor,
- SampleRate srate,
- size_t buffer_size);
-
- ~LADSPANode();
-
- bool instantiate();
-
- bool prepare_poly(uint32_t poly);
- bool apply_poly(Raul::Maid& maid, uint32_t poly);
-
- void activate();
- void deactivate();
-
- void process(ProcessContext& context);
-
- void set_port_buffer(uint32_t voice, uint32_t port_num, Buffer* buf);
-
-protected:
- void get_port_limits(unsigned long port_index,
- boost::optional<Sample>& default_value,
- boost::optional<Sample>& lower_bound,
- boost::optional<Sample>& upper_bound);
-
- const LADSPA_Descriptor* _descriptor;
- Raul::Array<LADSPA_Handle>* _instances;
- Raul::Array<LADSPA_Handle>* _prepared_instances;
-};
-
-
-} // namespace Ingen
-
-#endif // LADSPANODE_H
diff --git a/src/libs/engine/LADSPAPlugin.cpp b/src/libs/engine/LADSPAPlugin.cpp
deleted file mode 100644
index 4a0b5c14..00000000
--- a/src/libs/engine/LADSPAPlugin.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <cassert>
-#include <ladspa.h>
-#include <iostream>
-#include "LADSPAPlugin.hpp"
-#include "LADSPANode.hpp"
-#include "NodeImpl.hpp"
-#include "Engine.hpp"
-#include "AudioDriver.hpp"
-
-using namespace std;
-
-namespace Ingen {
-
-
-NodeImpl*
-LADSPAPlugin::instantiate(const string& name,
- bool polyphonic,
- Ingen::PatchImpl* parent,
- Engine& engine)
-{
- assert(_id != 0);
-
- SampleCount srate = engine.audio_driver()->sample_rate();
- SampleCount buffer_size = engine.audio_driver()->buffer_size();
-
- LADSPA_Descriptor_Function df = NULL;
- LADSPANode* n = NULL;
-
- load(); // FIXME: unload at some point
- assert(_module);
- assert(*_module);
-
- if (!_module->get_symbol("ladspa_descriptor", (void*&)df)) {
- cerr << "Looks like this isn't a LADSPA plugin." << endl;
- return NULL;
- }
-
- // Attempt to find the plugin in library
- LADSPA_Descriptor* descriptor = NULL;
- for (unsigned long i=0; (descriptor = (LADSPA_Descriptor*)df(i)) != NULL; ++i) {
- if (descriptor->UniqueID == _id) {
- break;
- }
- }
-
- if (descriptor != NULL) {
- n = new LADSPANode(this, name, polyphonic, parent, descriptor, srate, buffer_size);
-
- if ( ! n->instantiate() ) {
- delete n;
- n = NULL;
- }
-
- } else {
- cerr << "Could not find plugin \"" << _id << "\" in " << _library_path << endl;
- }
-
- return n;
-}
-
-
-} // namespace Ingen
diff --git a/src/libs/engine/LADSPAPlugin.hpp b/src/libs/engine/LADSPAPlugin.hpp
deleted file mode 100644
index 2414be7c..00000000
--- a/src/libs/engine/LADSPAPlugin.hpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef LADSPAPLUGIN_H
-#define LADSPAPLUGIN_H
-
-#include CONFIG_H_PATH
-
-#include <cstdlib>
-#include <glibmm/module.h>
-#include <boost/utility.hpp>
-#include <dlfcn.h>
-#include <string>
-#include <iostream>
-#include <raul/Path.hpp>
-#include "types.hpp"
-#include "PluginImpl.hpp"
-
-namespace Ingen {
-
-class NodeImpl;
-
-
-/** Implementation of a LADSPA plugin (loaded shared library).
- */
-class LADSPAPlugin : public PluginImpl
-{
-public:
- LADSPAPlugin(const std::string& library_path,
- const std::string& uri,
- unsigned long id,
- const string& label,
- const string& name)
- : PluginImpl(Plugin::LADSPA, uri, library_path)
- , _id(id)
- , _label(label)
- , _name(name)
- {}
-
- NodeImpl* instantiate(const std::string& name,
- bool polyphonic,
- Ingen::PatchImpl* parent,
- Engine& engine);
-
- const std::string& label() const { return _label; }
- unsigned long id() const { return _id; }
- const string symbol() const { return Raul::Path::nameify(_label); }
- const string name() const { return _name; }
-
- const string library_name() const {
- return _library_path.substr(_library_path.find_last_of("/")+1);
- }
-
-private:
- const unsigned long _id;
- const std::string _label;
- const std::string _name;
-};
-
-
-} // namespace Ingen
-
-#endif // LADSPAPLUGIN_H
-
diff --git a/src/libs/engine/LV2Info.cpp b/src/libs/engine/LV2Info.cpp
deleted file mode 100644
index 43dd014b..00000000
--- a/src/libs/engine/LV2Info.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2008 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#define __STDC_LIMIT_MACROS 1
-#include <cassert>
-#include <iostream>
-#include <stdint.h>
-#include "LV2Info.hpp"
-#include <module/World.hpp>
-
-using namespace std;
-
-namespace Ingen {
-
-LV2Info::LV2Info(Ingen::Shared::World* world)
- : input_class(slv2_value_new_uri(world->slv2_world, SLV2_PORT_CLASS_INPUT))
- , output_class(slv2_value_new_uri(world->slv2_world, SLV2_PORT_CLASS_OUTPUT))
- , control_class(slv2_value_new_uri(world->slv2_world, SLV2_PORT_CLASS_CONTROL))
- , audio_class(slv2_value_new_uri(world->slv2_world, SLV2_PORT_CLASS_AUDIO))
- , event_class(slv2_value_new_uri(world->slv2_world, SLV2_PORT_CLASS_EVENT))
- , _world(world)
-{
- assert(world);
-
- LV2_Event_Feature* ev_data = (LV2_Event_Feature*)malloc(sizeof(LV2_Event_Feature));
- ev_data->lv2_event_ref = &LV2Info::event_ref;
- ev_data->lv2_event_unref = &LV2Info::event_ref;
- ev_data->callback_data = this;
- LV2_Feature* ev_feature = (LV2_Feature*)malloc(sizeof(LV2_Event_Feature));
- ev_feature->URI = LV2_EVENT_URI;
- ev_feature->data = ev_data;
-
- world->lv2_features->add_feature(LV2_EVENT_URI, ev_feature, ev_data);
-}
-
-
-LV2Info::~LV2Info()
-{
- slv2_value_free(input_class);
- slv2_value_free(output_class);
- slv2_value_free(control_class);
- slv2_value_free(audio_class);
- slv2_value_free(event_class);
-}
-
-
-uint32_t
-LV2Info::event_ref(LV2_Event_Callback_Data callback_data,
- LV2_Event* event)
-{
- return 0;
-}
-
-
-
-} // namespace Ingen
diff --git a/src/libs/engine/LV2Info.hpp b/src/libs/engine/LV2Info.hpp
deleted file mode 100644
index f4859ac7..00000000
--- a/src/libs/engine/LV2Info.hpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2008 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef LV2INFO_H
-#define LV2INFO_H
-
-#include CONFIG_H_PATH
-#ifndef HAVE_SLV2
-#error "This file requires SLV2, but HAVE_SLV2 is not defined. Please report."
-#endif
-
-#include <map>
-#include <string>
-#include <slv2/slv2.h>
-#include "module/global.hpp"
-#include "module/World.hpp"
-#include "shared/LV2URIMap.hpp"
-#include "lv2ext/lv2_uri_map.h"
-#include "lv2ext/lv2_event.h"
-
-namespace Ingen {
-
-
-/** Stuff that may need to be passed to an LV2 plugin (i.e. LV2 features).
- */
-class LV2Info : public Shared::LV2URIMap {
-public:
- LV2Info(Ingen::Shared::World* world);
- ~LV2Info();
-
- SLV2Value input_class;
- SLV2Value output_class;
- SLV2Value control_class;
- SLV2Value audio_class;
- SLV2Value event_class;
-
- Ingen::Shared::World& world() { return *_world; }
- SLV2World lv2_world() { return _world->slv2_world; }
-
- static uint32_t event_ref(LV2_Event_Callback_Data callback_data,
- LV2_Event* event);
-
- LV2_Feature** lv2_features() const { return _world->lv2_features->lv2_features(); }
-
-private:
- Ingen::Shared::World* _world;
-};
-
-
-} // namespace Ingen
-
-#endif // LV2INFO_H
diff --git a/src/libs/engine/LV2Node.cpp b/src/libs/engine/LV2Node.cpp
deleted file mode 100644
index a06cc55a..00000000
--- a/src/libs/engine/LV2Node.cpp
+++ /dev/null
@@ -1,305 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <iostream>
-#include <cassert>
-#include <float.h>
-#include <stdint.h>
-#include <cmath>
-#include <raul/Maid.hpp>
-#include "AudioBuffer.hpp"
-#include "InputPort.hpp"
-#include "LV2Node.hpp"
-#include "LV2Plugin.hpp"
-#include "EventBuffer.hpp"
-#include "OutputPort.hpp"
-#include "ProcessContext.hpp"
-#include "lv2_contexts.h"
-
-using namespace std;
-
-namespace Ingen {
-
-
-/** Partially construct a LV2Node.
- *
- * Object is not usable until instantiate() is called with success.
- * (It _will_ crash!)
- */
-LV2Node::LV2Node(LV2Plugin* plugin,
- const string& name,
- bool polyphonic,
- PatchImpl* parent,
- SampleRate srate,
- size_t buffer_size)
- : NodeBase(plugin, name, polyphonic, parent, srate, buffer_size)
- , _lv2_plugin(plugin)
- , _instances(NULL)
- , _prepared_instances(NULL)
- , _message_run(NULL)
-{
- assert(_lv2_plugin);
-}
-
-
-LV2Node::~LV2Node()
-{
- for (uint32_t i=0; i < _polyphony; ++i)
- slv2_instance_free((*_instances)[i]);
-
- delete _instances;
-}
-
-
-bool
-LV2Node::prepare_poly(uint32_t poly)
-{
- NodeBase::prepare_poly(poly);
-
- if ( (!_polyphonic)
- || (_prepared_instances && poly <= _prepared_instances->size()) ) {
- return true;
- }
-
- _prepared_instances = new Raul::Array<SLV2Instance>(poly, *_instances);
- for (uint32_t i = _polyphony; i < _prepared_instances->size(); ++i) {
- // FIXME: features array (in NodeFactory) must be passed!
- _prepared_instances->at(i) = slv2_plugin_instantiate(
- _lv2_plugin->slv2_plugin(), _srate, NULL);
-
- if (_prepared_instances->at(i) == NULL) {
- cerr << "Failed to instantiate plugin!" << endl;
- return false;
- }
-
- if (_activated)
- slv2_instance_activate(_prepared_instances->at(i));
- }
-
- return true;
-}
-
-
-bool
-LV2Node::apply_poly(Raul::Maid& maid, uint32_t poly)
-{
- if (!_polyphonic)
- return true;
-
- if (_prepared_instances) {
- assert(poly <= _prepared_instances->size());
- maid.push(_instances);
- _instances = _prepared_instances;
- _prepared_instances = NULL;
- }
-
- assert(poly <= _instances->size());
- _polyphony = poly;
-
- return NodeBase::apply_poly(maid, poly);
-}
-
-
-/** Instantiate self from LV2 plugin descriptor.
- *
- * Implemented as a seperate function (rather than in the constructor) to
- * allow graceful error-catching of broken plugins.
- *
- * Returns whether or not plugin was successfully instantiated. If return
- * value is false, this object may not be used.
- */
-bool
-LV2Node::instantiate()
-{
- SharedPtr<LV2Info> info = _lv2_plugin->lv2_info();
- SLV2Plugin plug = _lv2_plugin->slv2_plugin();
-
- uint32_t num_ports = slv2_plugin_get_num_ports(plug);
- assert(num_ports > 0);
-
- _ports = new Raul::Array<PortImpl*>(num_ports, NULL);
- _instances = new Raul::Array<SLV2Instance>(_polyphony, NULL);
-
- uint32_t port_buffer_size = 0;
-
- for (uint32_t i=0; i < _polyphony; ++i) {
- (*_instances)[i] = slv2_plugin_instantiate(plug, _srate, info->lv2_features());
- if ((*_instances)[i] == NULL) {
- cerr << "Failed to instantiate plugin!" << endl;
- return false;
- }
-
- const void* ctx_ext = slv2_instance_get_extension_data(
- (*_instances)[i], LV2_CONTEXT_MESSAGE);
-
- if (ctx_ext) {
- cerr << "HAS CONTEXT EXTENSION" << endl;
- if (_message_run == NULL)
- _message_run = new MessageRunFuncs(_polyphony, NULL);
- LV2MessageContext* mc = (LV2MessageContext*)ctx_ext;
- (*_message_run)[i] = mc->message_run;
- }
- }
-
- string port_name;
- string port_path;
-
- PortImpl* port = NULL;
-
- float* def_values = new float[num_ports];
- slv2_plugin_get_port_ranges_float(plug, 0, 0, def_values);
-
- for (uint32_t j=0; j < num_ports; ++j) {
- SLV2Port id = slv2_plugin_get_port_by_index(plug, j);
-
- // LV2 shortnames are guaranteed to be unique, valid C identifiers
- port_name = slv2_value_as_string(slv2_port_get_symbol(plug, id));
-
- assert(port_name.find("/") == string::npos);
-
- port_path = path() + "/" + port_name;
-
- DataType data_type = DataType::UNKNOWN;
- if (slv2_port_is_a(plug, id, info->control_class)) {
- data_type = DataType::CONTROL;
- port_buffer_size = 1;
- } else if (slv2_port_is_a(plug, id, info->audio_class)) {
- data_type = DataType::AUDIO;
- port_buffer_size = _buffer_size;
- } else if (slv2_port_is_a(plug, id, info->event_class)) {
- data_type = DataType::EVENT;
- port_buffer_size = _buffer_size;
- }
-
- enum { UNKNOWN, INPUT, OUTPUT } direction = UNKNOWN;
- if (slv2_port_is_a(plug, id, info->input_class)) {
- direction = INPUT;
- } else if (slv2_port_is_a(plug, id, info->output_class)) {
- direction = OUTPUT;
- }
-
- if (data_type == DataType::UNKNOWN || direction == UNKNOWN) {
- delete _ports;
- _ports = NULL;
- delete _instances;
- _instances = NULL;
- return false;
- }
-
- // FIXME: need nice type preserving SLV2Value -> Raul::Atom conversion
- float def = isnan(def_values[j]) ? 0.0f : def_values[j];
- Atom defatm = def;
-
- if (direction == INPUT)
- port = new InputPort(this, port_name, j, _polyphony, data_type, defatm, port_buffer_size);
- else
- port = new OutputPort(this, port_name, j, _polyphony, data_type, defatm, port_buffer_size);
-
- if (direction == INPUT && data_type == DataType::CONTROL)
- ((AudioBuffer*)port->buffer(0))->set_value(def, 0, 0);
-
- SLV2Value pred = slv2_value_new_uri(info->lv2_world(),
- "http://lv2plug.in/ns/dev/contexts#context");
- SLV2Values contexts = slv2_port_get_value(plug, id, pred);
- for (uint32_t i = 0; i < slv2_values_size(contexts); ++i) {
- SLV2Value c = slv2_values_get_at(contexts, i);
- const char* context = slv2_value_as_string(c);
- if (!strcmp("http://lv2plug.in/ns/dev/contexts#MessageContext", context)) {
- cout << "MESSAGE CONTEXT!" << endl;
- port->set_context(Context::MESSAGE);
- } else {
- cout << "UNKNOWN CONTEXT: "
- << slv2_value_as_string(slv2_values_get_at(contexts, i))
- << endl;
- }
- }
-
- _ports->at(j) = port;
- }
-
- delete [] def_values;
-
- return true;
-}
-
-
-void
-LV2Node::activate()
-{
- NodeBase::activate();
-
- for (uint32_t i=0; i < _polyphony; ++i) {
- for (unsigned long j=0; j < num_ports(); ++j) {
- PortImpl* const port = _ports->at(j);
-
- set_port_buffer(i, j, port->buffer(i));
-
- if (port->type() == DataType::CONTROL) {
- ((AudioBuffer*)port->buffer(i))->set_value(port->value().get_float(), 0, 0);
- } else if (port->type() == DataType::AUDIO) {
- ((AudioBuffer*)port->buffer(i))->set_value(0.0f, 0, 0);
- }
- }
- slv2_instance_activate((*_instances)[i]);
- }
-}
-
-
-void
-LV2Node::deactivate()
-{
- NodeBase::deactivate();
-
- for (uint32_t i=0; i < _polyphony; ++i)
- slv2_instance_deactivate((*_instances)[i]);
-}
-
-
-void
-LV2Node::message_process(MessageContext& context, uint32_t* output)
-{
- // FIXME: voice
- if (_message_run)
- (*_message_run)[0]((*_instances)[0], output);
-
- /* MESSAGE PROCESS */
-}
-
-
-void
-LV2Node::process(ProcessContext& context)
-{
- NodeBase::pre_process(context);
-
- for (uint32_t i=0; i < _polyphony; ++i)
- slv2_instance_run((*_instances)[i], context.nframes());
-
- NodeBase::post_process(context);
-}
-
-
-void
-LV2Node::set_port_buffer(uint32_t voice, uint32_t port_num, Buffer* buf)
-{
- assert(voice < _polyphony);
-
- slv2_instance_connect_port((*_instances)[voice], port_num, buf->raw_data());
-}
-
-
-} // namespace Ingen
-
diff --git a/src/libs/engine/LV2Node.hpp b/src/libs/engine/LV2Node.hpp
deleted file mode 100644
index 3187005c..00000000
--- a/src/libs/engine/LV2Node.hpp
+++ /dev/null
@@ -1,75 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef LV2NODE_H
-#define LV2NODE_H
-
-#include <string>
-#include <slv2/slv2.h>
-#include "types.hpp"
-#include "NodeBase.hpp"
-
-namespace Ingen {
-
-class LV2Plugin;
-
-
-/** An instance of a LV2 plugin.
- *
- * \ingroup engine
- */
-class LV2Node : public NodeBase
-{
-public:
- LV2Node(LV2Plugin* plugin,
- const string& name,
- bool polyphonic,
- PatchImpl* parent,
- SampleRate srate,
- size_t buffer_size);
-
- ~LV2Node();
-
- bool instantiate();
-
- bool prepare_poly(uint32_t poly);
- bool apply_poly(Raul::Maid& maid, uint32_t poly);
-
- void activate();
- void deactivate();
-
- void message_process(MessageContext& context, uint32_t* output);
-
- void process(ProcessContext& context);
-
- void set_port_buffer(uint32_t voice, uint32_t port_num, Buffer* buf);
-
-protected:
- LV2Plugin* _lv2_plugin;
- Raul::Array<SLV2Instance>* _instances;
- Raul::Array<SLV2Instance>* _prepared_instances;
-
- typedef bool (*MessageRunFunc)(LV2_Handle, uint32_t*);
- typedef Raul::Array<MessageRunFunc> MessageRunFuncs;
- MessageRunFuncs* _message_run;
-};
-
-
-} // namespace Ingen
-
-#endif // LV2NODE_H
-
diff --git a/src/libs/engine/LV2Plugin.cpp b/src/libs/engine/LV2Plugin.cpp
deleted file mode 100644
index 90a3a6b8..00000000
--- a/src/libs/engine/LV2Plugin.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <cassert>
-#include <glibmm.h>
-#include <redlandmm/World.hpp>
-#include "LV2Plugin.hpp"
-#include "LV2Node.hpp"
-#include "NodeImpl.hpp"
-#include "Engine.hpp"
-#include "AudioDriver.hpp"
-
-namespace Ingen {
-
-
-const string
-LV2Plugin::symbol() const
-{
- string working = _uri;
- if (working[working.length()-1] == '/')
- working = working.substr(0, working.length()-1);
-
- while (working.length() > 0) {
- size_t last_slash = working.find_last_of("/");
- const string symbol = working.substr(last_slash+1);
- if ( (symbol[0] >= 'a' && symbol[0] <= 'z')
- || (symbol[0] >= 'A' && symbol[0] <= 'Z') )
- return Path::nameify(symbol);
- else
- working = working.substr(0, last_slash);
- }
-
- return "lv2_symbol";
-}
-
-
-const string
-LV2Plugin::name() const
-{
- if (_name)
- return slv2_value_as_string(_name);
- else
- return "(no name)";
-}
-
-
-NodeImpl*
-LV2Plugin::instantiate(const string& name,
- bool polyphonic,
- Ingen::PatchImpl* parent,
- Engine& engine)
-{
- SampleCount srate = engine.audio_driver()->sample_rate();
- SampleCount buffer_size = engine.audio_driver()->buffer_size();
-
- load(); // FIXME: unload at some point
-
- Glib::Mutex::Lock lock(engine.world()->rdf_world->mutex());
- LV2Node* n = new LV2Node(this, name, polyphonic, parent, srate, buffer_size);
-
- if ( ! n->instantiate() ) {
- delete n;
- n = NULL;
- }
-
- return n;
-}
-
-
-void
-LV2Plugin::slv2_plugin(SLV2Plugin p)
-{
- _slv2_plugin = p;
- if (_name)
- slv2_value_free(_name);
- _name = slv2_plugin_get_name(_slv2_plugin);
-}
-
-
-} // namespace Ingen
diff --git a/src/libs/engine/LV2Plugin.hpp b/src/libs/engine/LV2Plugin.hpp
deleted file mode 100644
index c9bc4ff9..00000000
--- a/src/libs/engine/LV2Plugin.hpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef LV2PLUGIN_H
-#define LV2PLUGIN_H
-
-#include CONFIG_H_PATH
-
-#ifndef HAVE_SLV2
-#error "This file requires SLV2, but HAVE_SLV2 is not defined. Please report."
-#endif
-
-#include <cstdlib>
-#include <glibmm/module.h>
-#include <boost/utility.hpp>
-#include <dlfcn.h>
-#include <string>
-#include <iostream>
-#include <slv2/slv2.h>
-#include <raul/SharedPtr.hpp>
-#include "types.hpp"
-#include "PluginImpl.hpp"
-#include "LV2Info.hpp"
-
-using std::string;
-using Ingen::Shared::Plugin;
-
-
-namespace Ingen {
-
-class PatchImpl;
-class NodeImpl;
-
-
-/** Implementation of an LV2 plugin (loaded shared library).
- */
-class LV2Plugin : public PluginImpl
-{
-public:
- LV2Plugin(SharedPtr<LV2Info> lv2_info, const string& uri)
- : PluginImpl(Plugin::LV2, uri)
- , _name(NULL)
- , _slv2_plugin(NULL)
- , _lv2_info(lv2_info)
- {}
-
- NodeImpl* instantiate(const string& name,
- bool polyphonic,
- Ingen::PatchImpl* parent,
- Engine& engine);
-
- const string symbol() const;
- const string name() const;
-
- SharedPtr<LV2Info> lv2_info() const { return _lv2_info; }
-
- SLV2Plugin slv2_plugin() const { return _slv2_plugin; }
- void slv2_plugin(SLV2Plugin p);
-
-private:
- SLV2Value _name;
- SLV2Plugin _slv2_plugin;
- SharedPtr<LV2Info> _lv2_info;
-};
-
-
-} // namespace Ingen
-
-#endif // LV2PLUGIN_H
-
diff --git a/src/libs/engine/Makefile.am b/src/libs/engine/Makefile.am
deleted file mode 100644
index 3c464de3..00000000
--- a/src/libs/engine/Makefile.am
+++ /dev/null
@@ -1,205 +0,0 @@
-SUBDIRS = events
-
-MAINTAINERCLEANFILES = Makefile.in
-
-moduledir = $(libdir)/ingen
-
-module_LTLIBRARIES = libingen_engine.la
-libingen_engine_la_CXXFLAGS = \
- @GLIBMM_CFLAGS@ \
- @INGEN_CFLAGS@ \
- @JACK_CFLAGS@ \
- @LIBLO_CFLAGS@ \
- @RAUL_CFLAGS@ \
- @REDLANDMM_CFLAGS@ \
- @SLV2_CFLAGS@ \
- @SOUP_CFLAGS@
-
-libingen_engine_la_LDFLAGS = -no-undefined -module -avoid-version
-libingen_engine_la_LIBADD = \
- ../shared/libingen_shared.la \
- ../module/libingen_module.la \
- @GLIBMM_LIBS@ \
- @JACK_LIBS@ \
- @LIBLO_LIBS@ \
- @RAUL_LIBS@ \
- @REDLANDMM_LIBS@ \
- @SLV2_LIBS@ \
- @SOUP_LIBS@
-
-AM_CFLAGS=-std=c99
-
-libingen_engine_la_SOURCES = \
- AudioBuffer.cpp \
- AudioBuffer.hpp \
- AudioDriver.hpp \
- Buffer.cpp \
- Buffer.hpp \
- ClientBroadcaster.cpp \
- ClientBroadcaster.hpp \
- CompiledPatch.hpp \
- ConnectionImpl.cpp \
- ConnectionImpl.hpp \
- Driver.hpp \
- DuplexPort.cpp \
- DuplexPort.hpp \
- Engine.cpp \
- Engine.hpp \
- EngineStore.cpp \
- EngineStore.hpp \
- Event.cpp \
- Event.hpp \
- EventBuffer.cpp \
- EventBuffer.hpp \
- EventSink.cpp \
- EventSink.hpp \
- EventSource.hpp \
- GraphObjectImpl.cpp \
- GraphObjectImpl.hpp \
- InputPort.cpp \
- InputPort.hpp \
- InternalPlugin.cpp \
- InternalPlugin.hpp \
- JackAudioDriver.cpp \
- JackAudioDriver.hpp \
- JackMidiDriver.cpp \
- JackMidiDriver.hpp \
- LADSPAPlugin.cpp \
- LADSPAPlugin.hpp \
- LV2Info.cpp \
- LV2Info.hpp \
- LV2Plugin.cpp \
- LV2Plugin.hpp \
- MessageContext.cpp \
- MessageContext.hpp \
- MidiControlNode.cpp \
- MidiControlNode.hpp \
- MidiDriver.hpp \
- MidiNoteNode.cpp \
- MidiNoteNode.hpp \
- MidiTriggerNode.cpp \
- MidiTriggerNode.hpp \
- NodeBase.cpp \
- NodeBase.hpp \
- NodeFactory.cpp \
- NodeFactory.hpp \
- NodeImpl.hpp \
- OSCClientSender.cpp \
- OSCClientSender.hpp \
- OSCDriver.hpp \
- OSCEngineReceiver.cpp \
- OSCEngineReceiver.hpp \
- ObjectSender.cpp \
- ObjectSender.hpp \
- OutputPort.cpp \
- OutputPort.hpp \
- PatchImpl.cpp \
- PatchImpl.hpp \
- PatchPlugin.hpp \
- PluginImpl.cpp \
- PluginImpl.hpp \
- PortImpl.cpp \
- PortImpl.hpp \
- PostProcessor.cpp \
- PostProcessor.hpp \
- ProcessContext.hpp \
- ProcessSlave.cpp \
- ProcessSlave.hpp \
- QueuedEngineInterface.cpp \
- QueuedEngineInterface.hpp \
- QueuedEvent.cpp \
- QueuedEvent.hpp \
- QueuedEventSource.cpp \
- QueuedEventSource.hpp \
- Responder.hpp \
- ThreadManager.hpp \
- TransportNode.cpp \
- TransportNode.hpp \
- engine.cpp \
- engine.hpp \
- events.hpp \
- events/AllNotesOffEvent.cpp \
- events/AllNotesOffEvent.hpp \
- events/ClearPatchEvent.cpp \
- events/ClearPatchEvent.hpp \
- events/ConnectionEvent.cpp \
- events/ConnectionEvent.hpp \
- events/CreateNodeEvent.cpp \
- events/CreateNodeEvent.hpp \
- events/CreatePatchEvent.cpp \
- events/CreatePatchEvent.hpp \
- events/CreatePortEvent.cpp \
- events/CreatePortEvent.hpp \
- events/DeactivateEvent.cpp \
- events/DeactivateEvent.hpp \
- events/DestroyEvent.cpp \
- events/DestroyEvent.hpp \
- events/DisconnectAllEvent.cpp \
- events/DisconnectAllEvent.hpp \
- events/DisconnectionEvent.cpp \
- events/DisconnectionEvent.hpp \
- events/EnablePatchEvent.cpp \
- events/EnablePatchEvent.hpp \
- events/LoadPluginsEvent.cpp \
- events/LoadPluginsEvent.hpp \
- events/MidiLearnEvent.cpp \
- events/MidiLearnEvent.hpp \
- events/NoteEvent.cpp \
- events/NoteEvent.hpp \
- events/PingQueuedEvent.hpp \
- events/RegisterClientEvent.cpp \
- events/RegisterClientEvent.hpp \
- events/RenameEvent.cpp \
- events/RenameEvent.hpp \
- events/RequestAllObjectsEvent.cpp \
- events/RequestAllObjectsEvent.hpp \
- events/RequestMetadataEvent.cpp \
- events/RequestMetadataEvent.hpp \
- events/RequestObjectEvent.cpp \
- events/RequestObjectEvent.hpp \
- events/RequestPluginEvent.cpp \
- events/RequestPluginEvent.hpp \
- events/RequestPluginsEvent.cpp \
- events/RequestPluginsEvent.hpp \
- events/RequestPortValueEvent.cpp \
- events/RequestPortValueEvent.hpp \
- events/SendPortActivityEvent.cpp \
- events/SendPortActivityEvent.hpp \
- events/SendPortValueEvent.cpp \
- events/SendPortValueEvent.hpp \
- events/SetMetadataEvent.cpp \
- events/SetMetadataEvent.hpp \
- events/SetPolyphonicEvent.cpp \
- events/SetPolyphonicEvent.hpp \
- events/SetPolyphonyEvent.cpp \
- events/SetPolyphonyEvent.hpp \
- events/SetPortValueEvent.cpp \
- events/SetPortValueEvent.hpp \
- events/UnregisterClientEvent.cpp \
- events/UnregisterClientEvent.hpp \
- jack_compat.h \
- lv2_contexts.h \
- tuning.hpp \
- types.hpp \
- util.hpp
-
-if WITH_LADSPA
-libingen_engine_la_SOURCES += \
- LADSPANode.hpp \
- LADSPANode.cpp
-endif
-
-if WITH_LV2
-libingen_engine_la_SOURCES += \
- LV2Node.hpp \
- LV2Node.cpp
-endif
-
-if WITH_SOUP
-libingen_engine_la_SOURCES += \
- HTTPEngineReceiver.cpp \
- HTTPEngineReceiver.hpp
-endif
-
-
-
diff --git a/src/libs/engine/MessageContext.cpp b/src/libs/engine/MessageContext.cpp
deleted file mode 100644
index 30f04b05..00000000
--- a/src/libs/engine/MessageContext.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2008 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "MessageContext.hpp"
-#include "NodeImpl.hpp"
-
-namespace Ingen {
-
-void
-MessageContext::run(NodeImpl* node)
-{
- uint32_t outputs;
- node->message_process(*this, &outputs);
-
- // Don't care what the plugin output, yet...
-}
-
-} // namespace Ingen
diff --git a/src/libs/engine/MessageContext.hpp b/src/libs/engine/MessageContext.hpp
deleted file mode 100644
index 31531521..00000000
--- a/src/libs/engine/MessageContext.hpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007-2008 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef MESSAGECONTEXT_H
-#define MESSAGECONTEXT_H
-
-#include "EventSink.hpp"
-#include "Context.hpp"
-
-namespace Ingen {
-
-class NodeImpl;
-
-/** Context of a message_process() call.
- *
- * The message context is a non-hard-realtime thread used to execute things
- * that can take too long to execute in an audio thread, and do sloppy timed
- * event propagation and scheduling. Interface to plugins via the
- * LV2 contexts extension.
- *
- * \ingroup engine
- */
-class MessageContext : public Context
-{
-public:
- MessageContext(Engine& engine)
- : Context(engine, MESSAGE)
- {}
-
- void run(NodeImpl* node);
-};
-
-
-} // namespace Ingen
-
-#endif // MESSAGECONTEXT_H
-
diff --git a/src/libs/engine/MidiControlNode.cpp b/src/libs/engine/MidiControlNode.cpp
deleted file mode 100644
index bfe0e57e..00000000
--- a/src/libs/engine/MidiControlNode.cpp
+++ /dev/null
@@ -1,141 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <math.h>
-#include <raul/midi_events.h>
-#include "MidiControlNode.hpp"
-#include "PostProcessor.hpp"
-#include "MidiLearnEvent.hpp"
-#include "InputPort.hpp"
-#include "OutputPort.hpp"
-#include "InternalPlugin.hpp"
-#include "AudioBuffer.hpp"
-#include "ProcessContext.hpp"
-#include "EventBuffer.hpp"
-#include "util.hpp"
-
-namespace Ingen {
-
-
-MidiControlNode::MidiControlNode(const string& path,
- bool polyphonic,
- PatchImpl* parent,
- SampleRate srate,
- size_t buffer_size)
- : NodeBase(new InternalPlugin(NS_INGEN "control_node", "controller", "MIDI Controller")
- , path, false, parent, srate, buffer_size)
- , _learning(false)
-{
- _ports = new Raul::Array<PortImpl*>(6);
-
- _midi_in_port = new InputPort(this, "input", 0, 1, DataType::EVENT, Atom(), _buffer_size);
- _ports->at(0) = _midi_in_port;
-
- _param_port = new InputPort(this, "controller", 1, 1, DataType::CONTROL, 0.0f, 1);
- _param_port->set_variable("ingen:minimum", 0.0f);
- _param_port->set_variable("ingen:maximum", 127.0f);
- _param_port->set_variable("ingen:integer", true);
- _ports->at(1) = _param_port;
-
- _log_port = new InputPort(this, "logarithmic", 2, 1, DataType::CONTROL, 0.0f, 1);
- _log_port->set_variable("ingen:toggled", true);
- _ports->at(2) = _log_port;
-
- _min_port = new InputPort(this, "minimum", 3, 1, DataType::CONTROL, 0.0f, 1);
- _ports->at(3) = _min_port;
-
- _max_port = new InputPort(this, "maximum", 4, 1, DataType::CONTROL, 1.0f, 1);
- _ports->at(4) = _max_port;
-
- _audio_port = new OutputPort(this, "ar_output", 5, 1, DataType::AUDIO, 0.0f, _buffer_size);
- _ports->at(5) = _audio_port;
-}
-
-
-void
-MidiControlNode::process(ProcessContext& context)
-{
- NodeBase::pre_process(context);
-
- uint32_t frames = 0;
- uint32_t subframes = 0;
- uint16_t type = 0;
- uint16_t size = 0;
- uint8_t* buf = NULL;
-
- EventBuffer* const midi_in = (EventBuffer*)_midi_in_port->buffer(0);
- assert(midi_in->this_nframes() == context.nframes());
-
- while (midi_in->get_event(&frames, &subframes, &type, &size, &buf)) {
- // FIXME: type
- if (size >= 3 && (buf[0] & 0xF0) == MIDI_CMD_CONTROL)
- control(context, buf[1], buf[2], frames + context.start());
-
- midi_in->increment();
- }
-
- NodeBase::post_process(context);
-}
-
-
-void
-MidiControlNode::control(ProcessContext& context, uchar control_num, uchar val, FrameTime time)
-{
- assert(time - context.start() < _buffer_size);
-
- Sample scaled_value;
-
- const Sample nval = (val / 127.0f); // normalized [0, 1]
-
- if (_learning) {
- assert(false); // FIXME FIXME FIXME
-#if 0
- assert(_learn_event != NULL);
- _param_port->set_value(control_num, offset);
- assert(_param_port->buffer(0)->value_at(0) == control_num);
- _learn_event->set_value(control_num);
- _learn_event->execute(offset);
- //Engine::instance().post_processor()->push(_learn_event);
- //Engine::instance().post_processor()->whip();
- _learning = false;
- _learn_event = NULL;
-#endif
- }
-
- const Sample min_port_val = ((AudioBuffer*)_min_port->buffer(0))->value_at(0);
- const Sample max_port_val = ((AudioBuffer*)_max_port->buffer(0))->value_at(0);
- const Sample log_port_val = ((AudioBuffer*)_log_port->buffer(0))->value_at(0);
-
- if (log_port_val > 0.0f) {
- // haaaaack, stupid negatives and logarithms
- Sample log_offset = 0;
- if (min_port_val < 0)
- log_offset = fabs(min_port_val);
- const Sample min = log(min_port_val + 1 + log_offset);
- const Sample max = log(max_port_val + 1 + log_offset);
- scaled_value = expf(nval * (max - min) + min) - 1 - log_offset;
- } else {
- scaled_value = ((nval) * (max_port_val - min_port_val)) + min_port_val;
- }
-
- if (control_num == ((AudioBuffer*)_param_port->buffer(0))->value_at(0))
- ((AudioBuffer*)_audio_port->buffer(0))->set_value(scaled_value, context.start(), time);
-}
-
-
-} // namespace Ingen
-
diff --git a/src/libs/engine/MidiControlNode.hpp b/src/libs/engine/MidiControlNode.hpp
deleted file mode 100644
index 2f0496a3..00000000
--- a/src/libs/engine/MidiControlNode.hpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef MIDICONTROLNODE_H
-#define MIDICONTROLNODE_H
-
-#include <string>
-#include "NodeBase.hpp"
-
-namespace Ingen {
-
-class MidiLearnResponseEvent;
-class InputPort;
-class OutputPort;
-
-
-/** MIDI control input node.
- *
- * Creating one of these nodes is how a user makes "MIDI Bindings". Note that
- * this node will always be monophonic, the poly parameter is ignored.
- *
- * \ingroup engine
- */
-class MidiControlNode : public NodeBase
-{
-public:
- MidiControlNode(const std::string& path, bool polyphonic, PatchImpl* parent, SampleRate srate, size_t buffer_size);
-
- void process(ProcessContext& context);
-
- void control(ProcessContext& context, uchar control_num, uchar val, FrameTime time);
-
- void learn(MidiLearnResponseEvent* ev) { _learning = true; _learn_event = ev; }
-
-private:
- bool _learning;
-
- InputPort* _midi_in_port;
- InputPort* _param_port;
- InputPort* _log_port;
- InputPort* _min_port;
- InputPort* _max_port;
- OutputPort* _audio_port;
-
- MidiLearnResponseEvent* _learn_event;
-};
-
-
-} // namespace Ingen
-
-#endif // MIDICONTROLNODE_H
diff --git a/src/libs/engine/MidiDriver.hpp b/src/libs/engine/MidiDriver.hpp
deleted file mode 100644
index e268124b..00000000
--- a/src/libs/engine/MidiDriver.hpp
+++ /dev/null
@@ -1,100 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef MIDIDRIVER_H
-#define MIDIDRIVER_H
-
-#include <iostream>
-#include "types.hpp"
-#include "Driver.hpp"
-#include "EventBuffer.hpp"
-#include "ProcessContext.hpp"
-
-namespace Ingen {
-
-class ProcessContext;
-
-
-/** Midi driver abstract base class.
- *
- * \ingroup engine
- */
-class MidiDriver : public Driver
-{
-public:
- MidiDriver() : Driver(DataType::EVENT) {}
-
- /** Prepare input for the specified (upcoming) cycle.
- *
- * Realtime safe, run in audio thread before executing the graph for a cycle.
- */
- virtual void pre_process(ProcessContext& context) = 0;
-
- /** Prepare output for the specified (just completed) cycle.
- *
- * Realtime safe, run in audio thread after executing the graph for a cycle.
- */
- virtual void post_process(ProcessContext& context) = 0;
-};
-
-
-
-/** Dummy MIDIDriver.
- *
- * Not abstract, all functions are dummies. One of these will be allocated and
- * "used" if no working MIDI driver is loaded. (Doing it this way as opposed to
- * just making MidiDriver have dummy functions makes sure any existing MidiDriver
- * derived class actually implements the required functions).
- *
- * \ingroup engine
- */
-class DummyMidiDriver : public MidiDriver
-{
-public:
- DummyMidiDriver() {
- std::cout << "[DummyMidiDriver] Started Dummy MIDI driver." << std::endl;
- }
-
- ~DummyMidiDriver() {}
-
- void activate() {}
- void deactivate() {}
-
- bool is_activated() const { return false; }
- bool is_enabled() const { return false; }
-
- void enable() {}
- void disable() {}
-
- DriverPort* create_port(DuplexPort* patch_port) { return NULL; }
-
- DriverPort* driver_port(const Raul::Path& path) { return NULL; }
-
- DriverPort* new_port(DuplexPort* patch_port) { return NULL; }
-
- void add_port(DriverPort* port) {}
- DriverPort* remove_port(const Raul::Path& path) { return NULL; }
-
- void pre_process(ProcessContext& context) {}
- void post_process(ProcessContext& context) {}
-};
-
-
-
-} // namespace Ingen
-
-#endif // MIDIDRIVER_H
diff --git a/src/libs/engine/MidiNoteNode.cpp b/src/libs/engine/MidiNoteNode.cpp
deleted file mode 100644
index ae7a7f0e..00000000
--- a/src/libs/engine/MidiNoteNode.cpp
+++ /dev/null
@@ -1,390 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <raul/Array.hpp>
-#include <raul/Maid.hpp>
-#include <raul/midi_events.h>
-#include <cmath>
-#include <iostream>
-#include "AudioBuffer.hpp"
-#include "AudioDriver.hpp"
-#include "InputPort.hpp"
-#include "InternalPlugin.hpp"
-#include "EventBuffer.hpp"
-#include "MidiNoteNode.hpp"
-#include "OutputPort.hpp"
-#include "PatchImpl.hpp"
-#include "ProcessContext.hpp"
-#include "util.hpp"
-
-using namespace std;
-
-namespace Ingen {
-
-
-MidiNoteNode::MidiNoteNode(const string& path, bool polyphonic, PatchImpl* parent, SampleRate srate, size_t buffer_size)
- : NodeBase(new InternalPlugin(NS_INGEN "note_node", "note", "MIDI Note"),
- path, polyphonic, parent, srate, buffer_size)
- , _voices(new Raul::Array<Voice>(_polyphony))
- , _prepared_voices(NULL)
- , _sustain(false)
-{
- _ports = new Raul::Array<PortImpl*>(5);
-
- _midi_in_port = new InputPort(this, "input", 0, 1, DataType::EVENT, Atom(), _buffer_size);
- _ports->at(0) = _midi_in_port;
-
- _freq_port = new OutputPort(this, "frequency", 1, _polyphony, DataType::AUDIO, 440.0f, _buffer_size);
- _ports->at(1) = _freq_port;
-
- _vel_port = new OutputPort(this, "velocity", 2, _polyphony, DataType::AUDIO, 0.0f, _buffer_size);
- _vel_port->set_variable("ingen:minimum", 0.0f);
- _vel_port->set_variable("ingen:maximum", 1.0f);
- _ports->at(2) = _vel_port;
-
- _gate_port = new OutputPort(this, "gate", 3, _polyphony, DataType::AUDIO, 0.0f, _buffer_size);
- _gate_port->set_variable("ingen:toggled", true);
- _ports->at(3) = _gate_port;
-
- _trig_port = new OutputPort(this, "trigger", 4, _polyphony, DataType::AUDIO, 0.0f, _buffer_size);
- _trig_port->set_variable("ingen:toggled", true);
- _ports->at(4) = _trig_port;
-}
-
-
-MidiNoteNode::~MidiNoteNode()
-{
- delete _voices;
-}
-
-
-bool
-MidiNoteNode::prepare_poly(uint32_t poly)
-{
- if (!_polyphonic)
- return true;
-
- NodeBase::prepare_poly(poly);
-
- if (_prepared_voices && poly <= _prepared_voices->size())
- return true;
-
- _prepared_voices = new Raul::Array<Voice>(poly, *_voices);
-
- return true;
-}
-
-
-bool
-MidiNoteNode::apply_poly(Raul::Maid& maid, uint32_t poly)
-{
- if (!_polyphonic)
- return true;
-
- NodeBase::apply_poly(maid, poly);
-
- if (_prepared_voices) {
- assert(poly <= _prepared_voices->size());
- maid.push(_voices);
- _voices = _prepared_voices;
- _prepared_voices = NULL;
- }
-
- _polyphony = poly;
- assert(_voices->size() >= _polyphony);
-
- return true;
-}
-
-
-void
-MidiNoteNode::process(ProcessContext& context)
-{
- NodeBase::pre_process(context);
-
- uint32_t frames = 0;
- uint32_t subframes = 0;
- uint16_t type = 0;
- uint16_t size = 0;
- unsigned char* buf = NULL;
-
- EventBuffer* const midi_in = (EventBuffer*)_midi_in_port->buffer(0);
- assert(midi_in->this_nframes() == context.nframes());
-
- //cerr << path() << " # input events: " << midi_in->event_count() << endl;
-
- if (midi_in->event_count() > 0)
- while (midi_in->get_event(&frames, &subframes, &type, &size, &buf)) {
-
- /*cout << "EVENT TYPE " << type << " @ " << frames << "." << subframes << ": ";
- for (uint16_t i = 0; i < size; ++i)
- cout << (int)((char)buf[i]) << " ";
- cout << endl;*/
-
- const FrameTime time = context.start() + (FrameTime)frames;
-
- if (size >= 3) {
- switch (buf[0] & 0xF0) {
- case MIDI_CMD_NOTE_ON:
- if (buf[2] == 0)
- note_off(context, buf[1], time);
- else
- note_on(context, buf[1], buf[2], time);
- break;
- case MIDI_CMD_NOTE_OFF:
- note_off(context, buf[1], time);
- break;
- case MIDI_CMD_CONTROL:
- switch (buf[1]) {
- case MIDI_CTL_ALL_NOTES_OFF:
- case MIDI_CTL_ALL_SOUNDS_OFF:
- all_notes_off(context, time);
- break;
- case MIDI_CTL_SUSTAIN:
- if (buf[2] > 63)
- sustain_on(context, time);
- else
- sustain_off(context, time);
- break;
- case MIDI_CMD_BENDER:
- // ?
- break;
- default:
- //cerr << "Ignored controller " << buf[1] << endl;
- break;
- }
- break;
- default:
- //fprintf(stderr, "Unknown (size %d) MIDI event %X\n", size, buf[0]);
- break;
- }
- } else {
- //fprintf(stderr, "Unknown (size %d) MIDI event %X\n", size, buf[0]);
- }
-
- if (midi_in->increment() == midi_in->this_nframes())
- break;
- }
-
- NodeBase::post_process(context);
-}
-
-
-void
-MidiNoteNode::note_on(ProcessContext& context, uchar note_num, uchar velocity, FrameTime time)
-{
- assert(time >= context.start() && time <= context.end());
- assert(time - context.start() < _buffer_size);
- assert(note_num <= 127);
-
- Key* key = &_keys[note_num];
- Voice* voice = NULL;
- uint32_t voice_num = 0;
-
- if (key->state != Key::OFF) {
- //cerr << "[MidiNoteNode] Double midi note received" << endl;
- return;
- }
-
- // Look for free voices
- for (uint32_t i=0; i < _polyphony; ++i) {
- if ((*_voices)[i].state == Voice::Voice::FREE) {
- voice = &(*_voices)[i];
- voice_num = i;
- break;
- }
- }
-
- // If we didn't find a free one, steal the oldest
- if (voice == NULL) {
- voice_num = 0;
- voice = &(*_voices)[0];
- jack_nframes_t oldest_time = (*_voices)[0].time;
- for (uint32_t i=1; i < _polyphony; ++i) {
- if ((*_voices)[i].time < oldest_time) {
- voice = &(*_voices)[i];
- voice_num = i;
- oldest_time = voice->time;
- }
- }
- }
- assert(voice != NULL);
- assert(voice == &(*_voices)[voice_num]);
-
- /*cerr << "[MidiNoteNode] Note " << (int)note_num << " on @ " << time
- << ". Voice " << voice_num << " / " << _polyphony << endl;*/
-
- // Update stolen key, if applicable
- if (voice->state == Voice::Voice::ACTIVE) {
- assert(_keys[voice->note].state == Key::ON_ASSIGNED);
- assert(_keys[voice->note].voice == voice_num);
- _keys[voice->note].state = Key::Key::ON_UNASSIGNED;
- //cerr << "[MidiNoteNode] Stole voice " << voice_num << endl;
- }
-
- // Store key information for later reallocation on note off
- key->state = Key::Key::ON_ASSIGNED;
- key->voice = voice_num;
- key->time = time;
-
- // Trigger voice
- voice->state = Voice::Voice::ACTIVE;
- voice->note = note_num;
- voice->time = time;
-
- assert(_keys[voice->note].state == Key::Key::ON_ASSIGNED);
- assert(_keys[voice->note].voice == voice_num);
-
- ((AudioBuffer*)_freq_port->buffer(voice_num))->set_value(note_to_freq(note_num), context.start(), time);
- ((AudioBuffer*)_vel_port->buffer(voice_num))->set_value(velocity/127.0, context.start(), time);
- ((AudioBuffer*)_gate_port->buffer(voice_num))->set_value(1.0f, context.start(), time);
-
- // trigger (one sample)
- ((AudioBuffer*)_trig_port->buffer(voice_num))->set_value(1.0f, context.start(), time);
- ((AudioBuffer*)_trig_port->buffer(voice_num))->set_value(0.0f, context.start(), time + 1);
-
- assert(key->state == Key::Key::ON_ASSIGNED);
- assert(voice->state == Voice::Voice::ACTIVE);
- assert(key->voice == voice_num);
- assert((*_voices)[key->voice].note == note_num);
-}
-
-
-void
-MidiNoteNode::note_off(ProcessContext& context, uchar note_num, FrameTime time)
-{
- assert(time >= context.start() && time <= context.end());
- assert(time - context.start() < _buffer_size);
-
- Key* key = &_keys[note_num];
-
- //cerr << "[MidiNoteNode] Note " << (int)note_num << " off @ " << time << endl;
-
- if (key->state == Key::ON_ASSIGNED) {
- // Assigned key, turn off voice and key
- if ((*_voices)[key->voice].state == Voice::ACTIVE) {
- assert((*_voices)[key->voice].note == note_num);
-
- if ( ! _sustain) {
- //cerr << "... free voice " << key->voice << endl;
- free_voice(context, key->voice, time);
- } else {
- //cerr << "... hold voice " << key->voice << endl;
- (*_voices)[key->voice].state = Voice::HOLDING;
- }
-
- } else {
-#ifndef NDEBUG
- cerr << "WARNING: Assigned key, but voice not active" << endl;
-#endif
- }
- }
-
- key->state = Key::OFF;
-}
-
-
-void
-MidiNoteNode::free_voice(ProcessContext& context, uint32_t voice, FrameTime time)
-{
- assert(time >= context.start() && time <= context.end());
- assert(time - context.start() < _buffer_size);
-
- // Find a key to reassign to the freed voice (the newest, if there is one)
- Key* replace_key = NULL;
- uchar replace_key_num = 0;
-
- for (uchar i = 0; i <= 127; ++i) {
- if (_keys[i].state == Key::ON_UNASSIGNED) {
- if (replace_key == NULL || _keys[i].time > replace_key->time) {
- replace_key = &_keys[i];
- replace_key_num = i;
- }
- }
- }
-
- if (replace_key != NULL) { // Found a key to assign to freed voice
- assert(&_keys[replace_key_num] == replace_key);
- assert(replace_key->state == Key::ON_UNASSIGNED);
-
- // Change the freq but leave the gate high and don't retrigger
- ((AudioBuffer*)_freq_port->buffer(voice))->set_value(note_to_freq(replace_key_num), context.start(), time);
-
- replace_key->state = Key::ON_ASSIGNED;
- replace_key->voice = voice;
- _keys[(*_voices)[voice].note].state = Key::ON_UNASSIGNED;
- (*_voices)[voice].note = replace_key_num;
- (*_voices)[voice].state = Voice::ACTIVE;
- } else {
- // No new note for voice, deactivate (set gate low)
- //cerr << "[MidiNoteNode] Note off. Key " << (int)note_num << ", Voice " << voice << " Killed" << endl;
- ((AudioBuffer*)_gate_port->buffer(voice))->set_value(0.0f, context.start(), time);
- (*_voices)[voice].state = Voice::FREE;
- }
-}
-
-
-void
-MidiNoteNode::all_notes_off(ProcessContext& context, FrameTime time)
-{
- assert(time >= context.start() && time <= context.end());
- assert(time - context.start() < _buffer_size);
-
- //cerr << "All notes off @ " << offset << endl;
-
- // FIXME: set all keys to Key::OFF?
-
- for (uint32_t i = 0; i < _polyphony; ++i) {
- ((AudioBuffer*)_gate_port->buffer(i))->set_value(0.0f, context.start(), time);
- (*_voices)[i].state = Voice::FREE;
- }
-}
-
-
-float
-MidiNoteNode::note_to_freq(int num)
-{
- static const float A4 = 440.0f;
- if (num >= 0 && num <= 119)
- return A4 * powf(2.0f, (float)(num - 57.0f) / 12.0f);
- return 1.0f; // Some LADSPA plugins don't like freq=0
-}
-
-
-void
-MidiNoteNode::sustain_on(ProcessContext& context, FrameTime time)
-{
- _sustain = true;
-}
-
-
-void
-MidiNoteNode::sustain_off(ProcessContext& context, FrameTime time)
-{
- assert(time >= context.start() && time <= context.end());
- assert(time - context.start() < _buffer_size);
-
- _sustain = false;
-
- for (uint32_t i=0; i < _polyphony; ++i)
- if ((*_voices)[i].state == Voice::HOLDING)
- free_voice(context, i, time);
-}
-
-
-} // namespace Ingen
-
diff --git a/src/libs/engine/MidiNoteNode.hpp b/src/libs/engine/MidiNoteNode.hpp
deleted file mode 100644
index eebcbda6..00000000
--- a/src/libs/engine/MidiNoteNode.hpp
+++ /dev/null
@@ -1,88 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef MIDINOTENODE_H
-#define MIDINOTENODE_H
-
-#include <string>
-#include "types.hpp"
-#include "NodeBase.hpp"
-
-namespace Ingen {
-
-class InputPort;
-class OutputPort;
-
-
-/** MIDI note input node.
- *
- * For pitched instruments like keyboard, etc.
- *
- * \ingroup engine
- */
-class MidiNoteNode : public NodeBase
-{
-public:
- MidiNoteNode(const std::string& path, bool polyphonic, PatchImpl* parent, SampleRate srate, size_t buffer_size);
- ~MidiNoteNode();
-
- bool prepare_poly(uint32_t poly);
- bool apply_poly(Raul::Maid& maid, uint32_t poly);
-
- void process(ProcessContext& context);
-
- void note_on(ProcessContext& context, uchar note_num, uchar velocity, FrameTime time);
- void note_off(ProcessContext& context, uchar note_num, FrameTime time);
- void all_notes_off(ProcessContext& context, FrameTime time);
-
- void sustain_on(ProcessContext& context, FrameTime time);
- void sustain_off(ProcessContext& context, FrameTime time);
-
-private:
- /** Key, one for each key on the keyboard */
- struct Key {
- enum State { OFF, ON_ASSIGNED, ON_UNASSIGNED };
- Key() : state(OFF), voice(0), time(0) {}
- State state; uint32_t voice; SampleCount time;
- };
-
- /** Voice, one of these always exists for each voice */
- struct Voice {
- enum State { FREE, ACTIVE, HOLDING };
- Voice() : state(FREE), note(0) {}
- State state; uchar note; SampleCount time;
- };
-
- float note_to_freq(int num);
- void free_voice(ProcessContext& context, uint32_t voice, FrameTime time);
-
- Raul::Array<Voice>* _voices;
- Raul::Array<Voice>* _prepared_voices;
- Key _keys[128];
- bool _sustain; ///< Whether or not hold pedal is depressed
-
- InputPort* _midi_in_port;
- OutputPort* _freq_port;
- OutputPort* _vel_port;
- OutputPort* _gate_port;
- OutputPort* _trig_port;
-};
-
-
-} // namespace Ingen
-
-#endif // MIDINOTENODE_H
diff --git a/src/libs/engine/MidiTriggerNode.cpp b/src/libs/engine/MidiTriggerNode.cpp
deleted file mode 100644
index aa2c272f..00000000
--- a/src/libs/engine/MidiTriggerNode.cpp
+++ /dev/null
@@ -1,135 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <cmath>
-#include <raul/midi_events.h>
-#include "MidiTriggerNode.hpp"
-#include "AudioBuffer.hpp"
-#include "InputPort.hpp"
-#include "OutputPort.hpp"
-#include "InternalPlugin.hpp"
-#include "ProcessContext.hpp"
-#include "EventBuffer.hpp"
-#include "util.hpp"
-
-using namespace std;
-
-namespace Ingen {
-
-
-MidiTriggerNode::MidiTriggerNode(const string& path, bool polyphonic, PatchImpl* parent, SampleRate srate, size_t buffer_size)
- : NodeBase(new InternalPlugin(NS_INGEN "trigger_node", "trigger", "MIDI Trigger"),
- path, false, parent, srate, buffer_size)
-{
- _ports = new Raul::Array<PortImpl*>(5);
-
- _midi_in_port = new InputPort(this, "input", 0, 1, DataType::EVENT, Atom(), _buffer_size);
- _ports->at(0) = _midi_in_port;
-
- _note_port = new InputPort(this, "note", 1, 1, DataType::CONTROL, 60.0f, 1);
- _note_port->set_variable("ingen:minimum", 0.0f);
- _note_port->set_variable("ingen:maximum", 127.0f);
- _note_port->set_variable("ingen:integer", true);
- _ports->at(1) = _note_port;
-
- _gate_port = new OutputPort(this, "gate", 2, 1, DataType::AUDIO, 0.0f, _buffer_size);
- _ports->at(2) = _gate_port;
-
- _trig_port = new OutputPort(this, "trigger", 3, 1, DataType::AUDIO, 0.0f, _buffer_size);
- _ports->at(3) = _trig_port;
-
- _vel_port = new OutputPort(this, "velocity", 4, 1, DataType::AUDIO, 0.0f, _buffer_size);
- _ports->at(4) = _vel_port;
-}
-
-
-void
-MidiTriggerNode::process(ProcessContext& context)
-{
- NodeBase::pre_process(context);
-
- uint32_t frames = 0;
- uint32_t subframes = 0;
- uint16_t type = 0;
- uint16_t size = 0;
- uint8_t* buf = NULL;
-
- EventBuffer* const midi_in = (EventBuffer*)_midi_in_port->buffer(0);
- assert(midi_in->this_nframes() == context.nframes());
-
- while (midi_in->get_event(&frames, &subframes, &type, &size, &buf)) {
- const FrameTime time = context.start() + (FrameTime)frames;
-
- if (size >= 3) {
- switch (buf[0] & 0xF0) {
- case MIDI_CMD_NOTE_ON:
- if (buf[2] == 0)
- note_off(context, buf[1], time);
- else
- note_on(context, buf[1], buf[2], time);
- break;
- case MIDI_CMD_NOTE_OFF:
- note_off(context, buf[1], time);
- break;
- case MIDI_CMD_CONTROL:
- if (buf[1] == MIDI_CTL_ALL_NOTES_OFF
- || buf[1] == MIDI_CTL_ALL_SOUNDS_OFF)
- ((AudioBuffer*)_gate_port->buffer(0))->set_value(0.0f, context.start(), time);
- default:
- break;
- }
- }
-
- midi_in->increment();
- }
-
- NodeBase::post_process(context);
-}
-
-
-void
-MidiTriggerNode::note_on(ProcessContext& context, uchar note_num, uchar velocity, FrameTime time)
-{
- assert(time >= context.start() && time <= context.end());
- assert(time - context.start() < _buffer_size);
-
- /*cerr << "[MidiTriggerNode] " << path() << " Note " << (int)note_num << " on @ " << time << endl;*/
-
- Sample filter_note = ((AudioBuffer*)_note_port->buffer(0))->value_at(0);
- if (filter_note >= 0.0 && filter_note < 127.0 && (note_num == (uchar)filter_note)) {
- ((AudioBuffer*)_gate_port->buffer(0))->set_value(1.0f, context.start(), time);
- ((AudioBuffer*)_trig_port->buffer(0))->set_value(1.0f, context.start(), time);
- ((AudioBuffer*)_trig_port->buffer(0))->set_value(0.0f, context.start(), time + 1);
- ((AudioBuffer*)_vel_port->buffer(0))->set_value(velocity / 127.0f, context.start(), time);
- assert(((AudioBuffer*)_trig_port->buffer(0))->data()[time - context.start()] == 1.0f);
- }
-}
-
-
-void
-MidiTriggerNode::note_off(ProcessContext& context, uchar note_num, FrameTime time)
-{
- assert(time >= context.start() && time <= context.end());
- assert(time - context.start() < _buffer_size);
-
- if (note_num == lrintf(((AudioBuffer*)_note_port->buffer(0))->value_at(0)))
- ((AudioBuffer*)_gate_port->buffer(0))->set_value(0.0f, context.start(), time);
-}
-
-
-} // namespace Ingen
-
diff --git a/src/libs/engine/MidiTriggerNode.hpp b/src/libs/engine/MidiTriggerNode.hpp
deleted file mode 100644
index ba96589b..00000000
--- a/src/libs/engine/MidiTriggerNode.hpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef MIDITRIGGERNODE_H
-#define MIDITRIGGERNODE_H
-
-#include <string>
-#include "NodeBase.hpp"
-
-namespace Ingen {
-
-class InputPort;
-class OutputPort;
-
-
-/** MIDI trigger input node.
- *
- * Just has a gate, for drums etc. A control port is used to select
- * which note number is responded to.
- *
- * Note that this node is always monophonic, the poly parameter is ignored.
- * (Should that change?)
- *
- * \ingroup engine
- */
-class MidiTriggerNode : public NodeBase
-{
-public:
- MidiTriggerNode(const std::string& path, bool polyphonic, PatchImpl* parent, SampleRate srate, size_t buffer_size);
-
- void process(ProcessContext& context);
-
- void note_on(ProcessContext& context, uchar note_num, uchar velocity, FrameTime time);
- void note_off(ProcessContext& context, uchar note_num, FrameTime time);
-
-private:
- InputPort* _midi_in_port;
- InputPort* _note_port;
- OutputPort* _gate_port;
- OutputPort* _trig_port;
- OutputPort* _vel_port;
-};
-
-
-} // namespace Ingen
-
-#endif // MIDITRIGGERNODE_H
diff --git a/src/libs/engine/NodeBase.cpp b/src/libs/engine/NodeBase.cpp
deleted file mode 100644
index bb4f0e5c..00000000
--- a/src/libs/engine/NodeBase.cpp
+++ /dev/null
@@ -1,230 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "NodeBase.hpp"
-#include <cassert>
-#include <iostream>
-#include <stdint.h>
-#include <raul/List.hpp>
-#include <raul/Array.hpp>
-#include "util.hpp"
-#include "PluginImpl.hpp"
-#include "ClientBroadcaster.hpp"
-#include "PortImpl.hpp"
-#include "PatchImpl.hpp"
-#include "EngineStore.hpp"
-#include "ThreadManager.hpp"
-
-using namespace std;
-
-namespace Ingen {
-
-
-NodeBase::NodeBase(PluginImpl* plugin, const string& name, bool polyphonic, PatchImpl* parent, SampleRate srate, size_t buffer_size)
- : NodeImpl(parent, name, polyphonic)
- , _plugin(plugin)
- , _polyphony((polyphonic && parent) ? parent->internal_polyphony() : 1)
- , _srate(srate)
- , _buffer_size(buffer_size)
- , _activated(false)
- , _traversed(false)
- , _input_ready(1)
- , _process_lock(0)
- , _n_inputs_ready(0)
- , _ports(NULL)
- , _providers(new Raul::List<NodeImpl*>())
- , _dependants(new Raul::List<NodeImpl*>())
-{
- assert(_plugin);
- assert(_polyphony > 0);
- assert(_parent == NULL || (_polyphony == parent->internal_polyphony() || _polyphony == 1));
-}
-
-
-NodeBase::~NodeBase()
-{
- if (_activated)
- deactivate();
-
- delete _providers;
- delete _dependants;
-}
-
-
-Port*
-NodeBase::port(uint32_t index) const
-{
- return (*_ports)[index];
-}
-
-
-const Plugin*
-NodeBase::plugin() const
-{
- return _plugin;
-}
-
-
-void
-NodeBase::activate()
-{
- assert(ThreadManager::current_thread_id() == THREAD_PRE_PROCESS);
- assert(!_activated);
- _activated = true;
-}
-
-
-void
-NodeBase::deactivate()
-{
- // FIXME: Not true witn monolithic GUI/engine
- //assert(ThreadManager::current_thread_id() == THREAD_POST_PROCESS);
- assert(_activated);
- _activated = false;
-}
-
-
-bool
-NodeBase::prepare_poly(uint32_t poly)
-{
- assert(ThreadManager::current_thread_id() == THREAD_PRE_PROCESS);
-
- if (!_polyphonic)
- return true;
-
- if (_ports)
- for (size_t i=0; i < _ports->size(); ++i)
- _ports->at(i)->prepare_poly(poly);
-
- return true;
-}
-
-
-bool
-NodeBase::apply_poly(Raul::Maid& maid, uint32_t poly)
-{
- assert(ThreadManager::current_thread_id() == THREAD_PROCESS);
-
- if (!_polyphonic)
- return true;
-
- for (size_t i=0; i < num_ports(); ++i) {
- _ports->at(i)->apply_poly(maid, poly);
- assert(_ports->at(i)->poly() == poly);
- }
-
- for (uint32_t i=0; i < num_ports(); ++i)
- for (uint32_t j=0; j < _polyphony; ++j)
- set_port_buffer(j, i, _ports->at(i)->buffer(j));
-
- return true;
-}
-
-
-void
-NodeBase::set_buffer_size(size_t size)
-{
- assert(ThreadManager::current_thread_id() == THREAD_PROCESS);
-
- _buffer_size = size;
-
- if (_ports)
- for (size_t i=0; i < _ports->size(); ++i)
- _ports->at(i)->set_buffer_size(size);
-}
-
-
-void
-NodeBase::reset_input_ready()
-{
- //cout << path() << " RESET" << endl;
- _n_inputs_ready = 0;
- _process_lock = 0;
- _input_ready.reset(0);
-}
-
-
-bool
-NodeBase::process_lock()
-{
- return _process_lock.compare_and_exchange(0, 1);
-}
-
-
-void
-NodeBase::process_unlock()
-{
- _process_lock = 0;
-}
-
-
-void
-NodeBase::wait_for_input(size_t num_providers)
-{
- assert(ThreadManager::current_thread_id() == THREAD_PROCESS);
- assert(_process_lock.get() == 1);
-
- while ((unsigned)_n_inputs_ready.get() < num_providers) {
- //cout << path() << " WAITING " << _n_inputs_ready.get() << endl;
- _input_ready.wait();
- //cout << path() << " CAUGHT SIGNAL" << endl;
- //++_n_inputs_ready;
- }
-
- //cout << path() << " READY" << endl;
-}
-
-
-void
-NodeBase::signal_input_ready()
-{
- assert(ThreadManager::current_thread_id() == THREAD_PROCESS);
- //cout << path() << " SIGNAL" << endl;
- ++_n_inputs_ready;
- _input_ready.post();
-}
-
-
-/** Prepare to run a cycle (in the audio thread)
- */
-void
-NodeBase::pre_process(ProcessContext& context)
-{
- assert(ThreadManager::current_thread_id() == THREAD_PROCESS);
-
- // Mix down any ports with multiple inputs
- for (size_t i=0; i < num_ports(); ++i)
- _ports->at(i)->pre_process(context);
-}
-
-
-/** Prepare to run a cycle (in the audio thread)
- */
-void
-NodeBase::post_process(ProcessContext& context)
-{
- assert(ThreadManager::current_thread_id() == THREAD_PROCESS);
-
- /* Write output ports */
- if (_ports)
- for (size_t i=0; i < _ports->size(); ++i)
- _ports->at(i)->post_process(context);
-}
-
-
-} // namespace Ingen
-
diff --git a/src/libs/engine/NodeBase.hpp b/src/libs/engine/NodeBase.hpp
deleted file mode 100644
index e3710aa9..00000000
--- a/src/libs/engine/NodeBase.hpp
+++ /dev/null
@@ -1,132 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef NODEBASE_H
-#define NODEBASE_H
-
-#include "types.hpp"
-#include <string>
-#include <cstdlib>
-#include <raul/Semaphore.hpp>
-#include <raul/AtomicInt.hpp>
-#include "interface/Port.hpp"
-#include "NodeImpl.hpp"
-
-using std::string;
-
-namespace Ingen {
-
-class PluginImpl;
-class PatchImpl;
-class EngineStore;
-
-namespace Shared {
- class ClientInterface;
-} using Shared::ClientInterface;
-
-
-/** Common implementation stuff for Node.
- *
- * Pretty much just attributes and getters/setters are here.
- *
- * \ingroup engine
- */
-class NodeBase : public NodeImpl
-{
-public:
- NodeBase(PluginImpl* plugin,
- const string& name,
- bool poly,
- PatchImpl* parent,
- SampleRate rate,
- size_t buffer_size);
-
- virtual ~NodeBase();
-
- virtual void activate();
- virtual void deactivate();
- bool activated() { return _activated; }
-
- virtual bool prepare_poly(uint32_t poly);
- virtual bool apply_poly(Raul::Maid& maid, uint32_t poly);
-
- virtual void reset_input_ready();
- virtual bool process_lock();
- virtual void process_unlock();
- virtual void wait_for_input(size_t num_providers);
- virtual unsigned n_inputs_ready() const { return _n_inputs_ready.get(); }
-
- virtual void message_process(MessageContext& context, uint32_t* output) {}
-
- virtual void pre_process(ProcessContext& context);
- virtual void process(ProcessContext& context) = 0;
- virtual void post_process(ProcessContext& context);
-
- virtual void set_port_buffer(uint32_t voice, uint32_t port_num, Buffer* buf) {}
-
- virtual void set_buffer_size(size_t size);
-
- SampleRate sample_rate() const { return _srate; }
- size_t buffer_size() const { return _buffer_size; }
- uint32_t num_ports() const { return _ports ? _ports->size() : 0; }
- uint32_t polyphony() const { return _polyphony; }
- bool traversed() const { return _traversed; }
- void traversed(bool b) { _traversed = b; }
-
- virtual Port* port(uint32_t index) const;
- virtual PortImpl* port_impl(uint32_t index) const { return (*_ports)[index]; }
-
- /* These are NOT to be used in the audio thread!
- * The providers and dependants in CompiledNode are for that
- */
-
- Raul::List<NodeImpl*>* providers() { return _providers; }
- void providers(Raul::List<NodeImpl*>* l) { _providers = l; }
-
- Raul::List<NodeImpl*>* dependants() { return _dependants; }
- void dependants(Raul::List<NodeImpl*>* l) { _dependants = l; }
-
- virtual const Plugin* plugin() const;
- virtual PluginImpl* plugin_impl() const { return _plugin; }
- virtual void plugin(PluginImpl* pi) { _plugin = pi; }
-
- /** A node's parent is always a patch, so static cast should be safe */
- inline PatchImpl* parent_patch() const { return (PatchImpl*)_parent; }
-
-protected:
- virtual void signal_input_ready();
-
- PluginImpl* _plugin;
-
- uint32_t _polyphony;
- SampleRate _srate;
- size_t _buffer_size;
- bool _activated;
-
- bool _traversed; ///< Flag for process order algorithm
- Raul::Semaphore _input_ready; ///< Parallelism: input ready signal
- Raul::AtomicInt _process_lock; ///< Parallelism: Waiting on inputs 'lock'
- Raul::AtomicInt _n_inputs_ready; ///< Parallelism: # input ready signals this cycle
- Raul::Array<PortImpl*>* _ports; ///< Access in audio thread only
- Raul::List<NodeImpl*>* _providers; ///< Nodes connected to this one's input ports
- Raul::List<NodeImpl*>* _dependants; ///< Nodes this one's output ports are connected to
-};
-
-
-} // namespace Ingen
-
-#endif // NODEBASE_H
diff --git a/src/libs/engine/NodeFactory.cpp b/src/libs/engine/NodeFactory.cpp
deleted file mode 100644
index c868d067..00000000
--- a/src/libs/engine/NodeFactory.cpp
+++ /dev/null
@@ -1,285 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include CONFIG_H_PATH
-#include <cstdlib>
-#include <pthread.h>
-#include <dirent.h>
-#include <float.h>
-#include <cmath>
-#include <redlandmm/World.hpp>
-#include "module/World.hpp"
-#include "NodeFactory.hpp"
-#include "ThreadManager.hpp"
-#include "MidiNoteNode.hpp"
-#include "MidiTriggerNode.hpp"
-#include "MidiControlNode.hpp"
-#include "TransportNode.hpp"
-#include "PatchImpl.hpp"
-#include "InternalPlugin.hpp"
-#ifdef HAVE_LADSPA
-#include "LADSPANode.hpp"
-#include "LADSPAPlugin.hpp"
-#endif
-#ifdef HAVE_SLV2
-#include <slv2/slv2.h>
-#include "LV2Plugin.hpp"
-#include "LV2Node.hpp"
-#endif
-
-using namespace std;
-
-namespace Ingen {
-
-
-NodeFactory::NodeFactory(Ingen::Shared::World* world)
- : _world(world)
- , _has_loaded(false)
-#ifdef HAVE_SLV2
- , _lv2_info(new LV2Info(world))
-#endif
-{
-}
-
-
-NodeFactory::~NodeFactory()
-{
- for (Plugins::iterator i = _plugins.begin(); i != _plugins.end(); ++i)
- if (i->second->type() != Plugin::Internal)
- delete i->second;
-
- _plugins.clear();
-}
-
-
-PluginImpl*
-NodeFactory::plugin(const string& uri)
-{
- const Plugins::const_iterator i = _plugins.find(uri);
- return ((i != _plugins.end()) ? i->second : NULL);
-}
-
-
-/** DEPRECATED: Find a plugin by type, lib, label.
- *
- * Slow. Evil. Do not use.
- */
-PluginImpl*
-NodeFactory::plugin(const string& type, const string& lib, const string& label)
-{
- if (type != "LADSPA" || lib == "" || label == "")
- return NULL;
-
-#ifdef HAVE_LADSPA
- for (Plugins::const_iterator i = _plugins.begin(); i != _plugins.end(); ++i) {
- LADSPAPlugin* lp = dynamic_cast<LADSPAPlugin*>(i->second);
- if (lp && lp->type_string() == type
- && lp->library_name() == lib
- && lp->label() == label)
- return lp;
- }
-#endif
-
- cerr << "ERROR: Failed to find " << type << " plugin " << lib << " / " << label << endl;
-
- return NULL;
-}
-
-
-void
-NodeFactory::load_plugins()
-{
- assert(ThreadManager::current_thread_id() == THREAD_PRE_PROCESS);
-
- _world->rdf_world->mutex().lock();
-
- // Only load if we havn't already, so every client connecting doesn't cause
- // this (expensive!) stuff to happen. Not the best solution - would be nice
- // if clients could refresh plugins list for whatever reason :/
- if (!_has_loaded) {
- _plugins.clear(); // FIXME: assert empty?
-
- load_internal_plugins();
-
-#ifdef HAVE_SLV2
- load_lv2_plugins();
-#endif
-
-#ifdef HAVE_LADSPA
- load_ladspa_plugins();
-#endif
-
- _has_loaded = true;
- }
-
- _world->rdf_world->mutex().unlock();
-
- //cerr << "[NodeFactory] # Plugins: " << _plugins.size() << endl;
-}
-
-
-void
-NodeFactory::load_internal_plugins()
-{
- // This is a touch gross...
-
- PatchImpl* parent = new PatchImpl(*_world->local_engine, "dummy", 1, NULL, 1, 1, 1);
-
- NodeImpl* n = NULL;
- n = new MidiNoteNode("foo", 1, parent, 1, 1);
- _plugins.insert(make_pair(n->plugin_impl()->uri(), n->plugin_impl()));
- delete n;
- n = new MidiTriggerNode("foo", 1, parent, 1, 1);
- _plugins.insert(make_pair(n->plugin_impl()->uri(), n->plugin_impl()));
- delete n;
- n = new MidiControlNode("foo", 1, parent, 1, 1);
- _plugins.insert(make_pair(n->plugin_impl()->uri(), n->plugin_impl()));
- delete n;
- n = new TransportNode("foo", 1, parent, 1, 1);
- _plugins.insert(make_pair(n->plugin_impl()->uri(), n->plugin_impl()));
- delete n;
-
- delete parent;
-}
-
-
-#ifdef HAVE_SLV2
-/** Loads information about all LV2 plugins into internal plugin database.
- */
-void
-NodeFactory::load_lv2_plugins()
-{
- SLV2Plugins plugins = slv2_world_get_all_plugins(_world->slv2_world);
-
- //cerr << "[NodeFactory] Found " << slv2_plugins_size(plugins) << " LV2 plugins:" << endl;
-
- for (unsigned i=0; i < slv2_plugins_size(plugins); ++i) {
-
- SLV2Plugin lv2_plug = slv2_plugins_get_at(plugins, i);
-
- const string uri(slv2_value_as_uri(slv2_plugin_get_uri(lv2_plug)));
-
-#ifndef NDEBUG
- assert(_plugins.find(uri) == _plugins.end());
-#endif
-
- LV2Plugin* const plugin = new LV2Plugin(_lv2_info, uri);
-
- plugin->slv2_plugin(lv2_plug);
- plugin->library_path(slv2_uri_to_path(slv2_value_as_uri(
- slv2_plugin_get_library_uri(lv2_plug))));
- _plugins.insert(make_pair(uri, plugin));
- }
-
- slv2_plugins_free(_world->slv2_world, plugins);
-}
-#endif // HAVE_SLV2
-
-
-#ifdef HAVE_LADSPA
-/** Loads information about all LADSPA plugins into internal plugin database.
- */
-void
-NodeFactory::load_ladspa_plugins()
-{
- char* env_ladspa_path = getenv("LADSPA_PATH");
- string ladspa_path;
- if (!env_ladspa_path) {
- cerr << "[NodeFactory] LADSPA_PATH is empty. Assuming /usr/lib/ladspa:/usr/local/lib/ladspa:~/.ladspa" << endl;
- ladspa_path = string("/usr/lib/ladspa:/usr/local/lib/ladspa:").append(
- getenv("HOME")).append("/.ladspa");
- } else {
- ladspa_path = env_ladspa_path;
- }
-
- // Yep, this should use an sstream alright..
- while (ladspa_path != "") {
- const string dir = ladspa_path.substr(0, ladspa_path.find(':'));
- if (ladspa_path.find(':') != string::npos)
- ladspa_path = ladspa_path.substr(ladspa_path.find(':')+1);
- else
- ladspa_path = "";
-
- DIR* pdir = opendir(dir.c_str());
- if (pdir == NULL) {
- //cerr << "[NodeFactory] Unreadable directory in LADSPA_PATH: " << dir.c_str() << endl;
- continue;
- }
-
- struct dirent* pfile;
- while ((pfile = readdir(pdir))) {
-
- LADSPA_Descriptor_Function df = NULL;
- LADSPA_Descriptor* descriptor = NULL;
-
- if (!strcmp(pfile->d_name, ".") || !strcmp(pfile->d_name, ".."))
- continue;
-
- const string lib_path = dir +"/"+ pfile->d_name;
-
- // Ignore stupid libtool files. Kludge alert.
- if (lib_path.substr(lib_path.length()-3) == ".la") {
- //cerr << "WARNING: Skipping stupid libtool file " << pfile->d_name << endl;
- continue;
- }
-
- Glib::Module* plugin_library = new Glib::Module(lib_path, Glib::MODULE_BIND_LOCAL);
- if (!plugin_library || !(*plugin_library)) {
- cerr << "WARNING: Failed to load LADSPA library " << lib_path << endl;
- continue;
- }
-
- bool found = plugin_library->get_symbol("ladspa_descriptor", (void*&)df);
- if (!found || !df) {
- cerr << "WARNING: Non-LADSPA library found in LADSPA path: " <<
- lib_path << endl;
- // Not a LADSPA plugin library
- delete plugin_library;
- continue;
- }
-
- for (unsigned long i=0; (descriptor = (LADSPA_Descriptor*)df(i)) != NULL; ++i) {
- char id_str[11];
- snprintf(id_str, 11, "%lu", descriptor->UniqueID);
- const string uri = string("ladspa:").append(id_str);
-
- const Plugins::const_iterator i = _plugins.find(uri);
-
- if (i == _plugins.end()) {
- LADSPAPlugin* plugin = new LADSPAPlugin(lib_path, uri,
- descriptor->UniqueID,
- descriptor->Label,
- descriptor->Name);
-
- _plugins.insert(make_pair(uri, plugin));
-
- } else {
- cerr << "Warning: Duplicate " << uri
- << " - Using " << i->second->library_path()
- << " over " << lib_path << endl;
- }
- }
-
- delete plugin_library;
- }
- closedir(pdir);
- }
-}
-#endif // HAVE_LADSPA
-
-
-} // namespace Ingen
diff --git a/src/libs/engine/NodeFactory.hpp b/src/libs/engine/NodeFactory.hpp
deleted file mode 100644
index 95194350..00000000
--- a/src/libs/engine/NodeFactory.hpp
+++ /dev/null
@@ -1,92 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef NODEFACTORY_H
-#define NODEFACTORY_H
-
-#include CONFIG_H_PATH
-#include "module/global.hpp"
-
-#include <list>
-#include <map>
-#include <string>
-#include <pthread.h>
-#include <glibmm/module.h>
-#ifdef HAVE_SLV2
-#include <slv2/slv2.h>
-#include "LV2Info.hpp"
-#endif
-#include "types.hpp"
-
-using std::string;
-
-namespace Ingen {
-
-class NodeImpl;
-class PatchImpl;
-class PluginImpl;
-
-
-/** Loads plugins and creates Nodes from them.
- *
- * NodeFactory's responsibility is to get enough information to allow the
- * loading of a plugin possible (ie finding/opening shared libraries etc)
- *
- * The constructor of various Node types (ie LADSPANode) are responsible
- * for actually creating a Node instance of the plugin.
- *
- * \ingroup engine
- */
-class NodeFactory
-{
-public:
- NodeFactory(Ingen::Shared::World* world);
- ~NodeFactory();
-
- void load_plugins();
-
- typedef std::map<std::string,PluginImpl*> Plugins;
- const Plugins& plugins() const { return _plugins; }
-
- PluginImpl* plugin(const string& uri);
-
- /** DEPRECATED */
- PluginImpl* plugin(const string& type, const string& lib, const string& label);
-
-private:
-#ifdef HAVE_LADSPA
- void load_ladspa_plugins();
-#endif
-
-#ifdef HAVE_SLV2
- void load_lv2_plugins();
-#endif
-
- void load_internal_plugins();
-
- Plugins _plugins;
- Ingen::Shared::World* _world;
- bool _has_loaded;
-#ifdef HAVE_SLV2
- SharedPtr<LV2Info> _lv2_info;
-#endif
-};
-
-
-} // namespace Ingen
-
-#endif // NODEFACTORY_H
diff --git a/src/libs/engine/NodeImpl.hpp b/src/libs/engine/NodeImpl.hpp
deleted file mode 100644
index ac125c13..00000000
--- a/src/libs/engine/NodeImpl.hpp
+++ /dev/null
@@ -1,170 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef NODEIMPL_H
-#define NODEIMPL_H
-
-#include <string>
-#include <raul/Array.hpp>
-#include "interface/Node.hpp"
-#include "types.hpp"
-#include "GraphObjectImpl.hpp"
-
-namespace Raul { template <typename T> class List; class Maid; }
-
-namespace Ingen {
-
-namespace Shared { class Plugin; class Node; class Port; }
-
-using namespace Shared;
-
-class Buffer;
-class PluginImpl;
-class PatchImpl;
-class PortImpl;
-class MessageContext;
-
-
-/** A Node (or "module") in a Patch (which is also a Node).
- *
- * A Node is a unit with input/output ports, a process() method, and some other
- * things.
- *
- * This is a pure abstract base class for any Node, it contains no
- * implementation details/data whatsoever. This is the interface you need to
- * implement to add a new Node type.
- *
- * \ingroup engine
- */
-class NodeImpl : public GraphObjectImpl, virtual public Ingen::Shared::Node
-{
-public:
- NodeImpl(GraphObjectImpl* parent, const std::string& name, bool poly)
- : GraphObjectImpl(parent, name, poly)
- {}
-
- /** Activate this Node.
- *
- * This function will be called in a non-realtime thread before it is
- * inserted in to a patch. Any non-realtime actions that need to be
- * done before the Node is ready for use should be done here.
- */
- virtual void activate() = 0;
- virtual void deactivate() = 0;
- virtual bool activated() = 0;
-
- /** Prepare for a new (external) polyphony value.
- *
- * Preprocessor thread, poly is actually applied by apply_poly.
- * \return true on success.
- */
- virtual bool prepare_poly(uint32_t poly) = 0;
-
- /** Apply a new (external) polyphony value.
- *
- * Audio thread.
- *
- * \param poly Must be < the most recent value passed to prepare_poly.
- * \param maid Any objects no longer needed will be pushed to this
- */
- virtual bool apply_poly(Raul::Maid& maid, uint32_t poly) = 0;
-
- /** Parallelism: Reset flags for start of a new cycle.
- */
- virtual void reset_input_ready() = 0;
-
- /** Parallelism: Claim this node (to wait on its input).
- * Only one thread will ever take this lock on a particular Node.
- * \return true if lock was aquired, false otherwise
- */
- virtual bool process_lock() = 0;
-
- /** Parallelism: Unclaim this node (let someone else wait on its input).
- * Only a thread which successfully called process_lock may call this.
- */
- virtual void process_unlock() = 0;
-
- /** Parallelism: Wait for signal that input is ready.
- * Only a thread which successfully called process_lock may call this.
- */
- virtual void wait_for_input(size_t num_providers) = 0;
-
- /** Parallelism: Signal that input is ready. Realtime safe.
- * Calling this will wake up the thread which blocked on wait_for_input
- * if there is one, and otherwise cause it to return true the next call.
- * \return true if lock was aquired and input is ready, false otherwise
- */
- virtual void signal_input_ready() = 0;
-
- /** Parallelism: Return the number of providers that have signalled.
- */
- virtual unsigned n_inputs_ready() const = 0;
-
- /** Run the node for one instant in the message thread.
- */
- virtual void message_process(MessageContext& context, uint32_t* output) = 0;
-
- /** Run the node for @a nframes input/output.
- *
- * @a start and @a end are transport times: end is not redundant in the case
- * of varispeed, where end-start != nframes.
- */
- virtual void process(ProcessContext& context) = 0;
-
- virtual void set_port_buffer(uint32_t voice, uint32_t port_num, Buffer* buf) = 0;
-
- virtual uint32_t num_ports() const = 0;
-
- virtual Port* port(uint32_t index) const = 0;
- virtual PortImpl* port_impl(uint32_t index) const = 0;
-
- /** Used by the process order finding algorithm (ie during connections) */
- virtual bool traversed() const = 0;
- virtual void traversed(bool b) = 0;
-
- /** Nodes that are connected to this Node's inputs.
- * (This Node depends on them)
- */
- virtual Raul::List<NodeImpl*>* providers() = 0;
- virtual void providers(Raul::List<NodeImpl*>* l) = 0;
-
- /** Nodes are are connected to this Node's outputs.
- * (They depend on this Node)
- */
- virtual Raul::List<NodeImpl*>* dependants() = 0;
- virtual void dependants(Raul::List<NodeImpl*>* l) = 0;
-
- /** The Patch this Node belongs to. */
- virtual PatchImpl* parent_patch() const = 0;
-
- /** Information about the Plugin this Node is an instance of.
- * Not the best name - not all nodes come from plugins (ie Patch)
- */
- virtual PluginImpl* plugin_impl() const = 0;
-
- /** Information about the Plugin this Node is an instance of.
- * Not the best name - not all nodes come from plugins (ie Patch)
- */
- virtual const Shared::Plugin* plugin() const = 0;
-
- virtual void set_buffer_size(size_t size) = 0;
-};
-
-
-} // namespace Ingen
-
-#endif // NODEIMPL_H
diff --git a/src/libs/engine/OSCClientSender.cpp b/src/libs/engine/OSCClientSender.cpp
deleted file mode 100644
index dca2e0ed..00000000
--- a/src/libs/engine/OSCClientSender.cpp
+++ /dev/null
@@ -1,358 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "OSCClientSender.hpp"
-#include <cassert>
-#include <iostream>
-#include <unistd.h>
-#include <raul/AtomLiblo.hpp>
-#include "EngineStore.hpp"
-#include "NodeFactory.hpp"
-#include "util.hpp"
-#include "PatchImpl.hpp"
-#include "NodeImpl.hpp"
-#include "PluginImpl.hpp"
-#include "PortImpl.hpp"
-#include "ConnectionImpl.hpp"
-#include "AudioDriver.hpp"
-#include "interface/ClientInterface.hpp"
-
-using namespace std;
-
-namespace Ingen {
-
-
-/*! \page client_osc_namespace Client OSC Namespace Documentation
- *
- * <p>NOTE: this comment doesn't really apply any longer.. sort of.
- * but maybe it still should.. maybe. so it remains...</p>
- *
- * <p>These are all the messages sent from the engine to the client.
- * Communication takes place over two distinct bands: control band and
- * notification band.</p>
- * <p>The control band is where clients send commands, and receive a simple
- * response, either OK or an error.</p>
- * <p>All notifications of engine state (ie new nodes) are sent over the
- * notification band <em>which is seperate from the control band</em>. The
- * reasoning behind this is that many clients may be connected at the same
- * time - a client may receive notifications that are not a direct consequence
- * of some message it sent.</p>
- * <p>The notification band can be thought of as a stream of events representing
- * the changing engine state. For example, It is possible for a client to send
- * commands and receive aknowledgements, and not listen to the notification band
- * at all; or (in the near future anyway) for a client to use UDP for the control
- * band (for speed), and TCP for the notification band (for reliability and
- * order guarantees).</p>
- * \n\n
- */
-
-
-/** \page client_osc_namespace
- * \n
- * <h2>Control Band</h2>
- */
-
-/** \page client_osc_namespace
- * <p> \b /ingen/ok - Respond to a successful user command
- * \arg \b response-id (int) - Request ID this is a response to
- * </p> \n \n
- */
-void
-OSCClientSender::response_ok(int32_t id)
-{
- if (!_enabled)
- return;
-
- if (lo_send(_address, "/ingen/ok", "i", id) < 0) {
- cerr << "Unable to send ok " << id << "! ("
- << lo_address_errstr(_address) << ")" << endl;
- }
-}
-
-
-/** \page client_osc_namespace
- * <p> \b /ingen/response - Respond to a user command
- * \arg \b response-id (int) - Request ID this is a response to
- * \arg \b message (string) - Error message (natural language text)
- * </p> \n \n
- */
-void
-OSCClientSender::response_error(int32_t id, const std::string& msg)
-{
- if (!_enabled)
- return;
-
- if (lo_send(_address, "/ingen/error", "is", id, msg.c_str()) < 0) {
- cerr << "Unable to send error " << id << "! ("
- << lo_address_errstr(_address) << ")" << endl;
- }
-}
-
-
-/** \page client_osc_namespace
- * \n
- * <h2>Notification Band</h2>
- */
-
-
-/** \page client_osc_namespace
- * <p> \b /ingen/error - Notification that an error has occurred
- * \arg \b message (string) - Error message (natural language text) \n\n
- * \li This is for notification of errors that aren't a direct response to a
- * user command, ie "unexpected" errors.</p> \n \n
- */
-void
-OSCClientSender::error(const std::string& msg)
-{
- send("/ingen/error", "s", msg.c_str(), LO_ARGS_END);
-}
-
-
-/** \page client_osc_namespace
- * <p> \b /ingen/new_node - Notification of a new node's creation.
- * \arg \b plug-uri (string) - URI of the plugin new node is an instance of
- * \arg \b path (string) - Path of the new node
- * \arg \b polyphonic (boolean) - Node is polyphonic\n\n
- * \li New nodes are sent as a bundle. The first message in the bundle will be
- * this one (/ingen/new_node), followed by a series of /ingen/new_port commands,
- * followed by /ingen/new_node_end. </p> \n \n
- */
-void OSCClientSender::new_node(const std::string& node_path,
- const std::string& plugin_uri)
-{
- send("/ingen/new_node", "ss", node_path.c_str(), plugin_uri.c_str(), LO_ARGS_END);
-}
-
-
-
-/** \page client_osc_namespace
- * <p> \b /ingen/new_port - Notification of a new port's creation.
- * \arg \b path (string) - Path of new port
- * \arg \b index (integer) - Index (or sort key) of port on parent
- * \arg \b data-type (string) - Type of port (ingen:AudioPort, ingen:ControlPort, ingen:MIDIPort, or ingen:OSCPort)
- * \arg \b direction ("is-output") (integer) - Direction of data flow (Input = 0, Output = 1)
- *
- * \li Note that in the event of loading a patch, this message could be
- * followed immediately by a control change, meaning the default-value is
- * not actually the current value of the port.
- * \li The minimum and maximum values are suggestions only, they are not
- * enforced in any way, and going outside them is perfectly fine. Also note
- * that the port ranges in om_gtk are not these ones! Those ranges are set
- * as variable.</p> \n \n
- */
-void
-OSCClientSender::new_port(const std::string& path,
- uint32_t index,
- const std::string& data_type,
- bool is_output)
-{
- send("/ingen/new_port", "sisi", path.c_str(), index, data_type.c_str(), is_output, LO_ARGS_END);
-}
-
-
-/** \page client_osc_namespace
- * <p> \b /ingen/destroyed - Notification an object has been destroyed
- * \arg \b path (string) - Path of object (which no longer exists) </p> \n \n
- */
-void
-OSCClientSender::destroy(const std::string& path)
-{
- assert(path != "/");
-
- send("/ingen/destroyed", "s", path.c_str(), LO_ARGS_END);
-}
-
-
-/** \page client_osc_namespace
- * <p> \b /ingen/patch_cleared - Notification a patch has been cleared (all children destroyed)
- * \arg \b path (string) - Path of patch (which is now empty)</p> \n \n
- */
-void
-OSCClientSender::patch_cleared(const std::string& patch_path)
-{
- send("/ingen/patch_cleared", "s", patch_path.c_str(), LO_ARGS_END);
-}
-
-
-/** \page client_osc_namespace
- * <p> \b /ingen/new_connection - Notification a new connection has been made.
- * \arg \b src-path (string) - Path of the source port
- * \arg \b dst-path (string) - Path of the destination port</p> \n \n
- */
-void
-OSCClientSender::connect(const std::string& src_port_path, const std::string& dst_port_path)
-{
- send("/ingen/new_connection", "ss", src_port_path.c_str(), dst_port_path.c_str(), LO_ARGS_END);
-}
-
-
-/** \page client_osc_namespace
- * <p> \b /ingen/disconnection - Notification a connection has been unmade.
- * \arg \b src-path (string) - Path of the source port
- * \arg \b dst-path (string) - Path of the destination port</p> \n \n
- */
-void
-OSCClientSender::disconnect(const std::string& src_port_path, const std::string& dst_port_path)
-{
- send("/ingen/disconnection", "ss", src_port_path.c_str(), dst_port_path.c_str(), LO_ARGS_END);
-}
-
-
-/** \page client_osc_namespace
- * <p> \b /ingen/set_variable - Notification of a variable.
- * \arg \b path (string) - Path of the object associated with variable (node, patch, or port)
- * \arg \b key (string)
- * \arg \b value (string)</p> \n \n
- */
-void
-OSCClientSender::set_variable(const std::string& path, const std::string& key, const Atom& value)
-{
- lo_message m = lo_message_new();
- lo_message_add_string(m, path.c_str());
- lo_message_add_string(m, key.c_str());
- Raul::AtomLiblo::lo_message_add_atom(m, value);
- send_message("/ingen/set_variable", m);
-}
-
-
-/** \page client_osc_namespace
- * <p> \b /ingen/set_property - Notification of a property.
- * \arg \b path (string) - Path of the object associated with property (node, patch, or port)
- * \arg \b key (string)
- * \arg \b value (string)</p> \n \n
- */
-void
-OSCClientSender::set_property(const std::string& path, const std::string& key, const Atom& value)
-{
- lo_message m = lo_message_new();
- lo_message_add_string(m, path.c_str());
- lo_message_add_string(m, key.c_str());
- Raul::AtomLiblo::lo_message_add_atom(m, value);
- send_message("/ingen/set_property", m);
-}
-
-
-/** \page client_osc_namespace
- * <p> \b /ingen/set_port_value - Notification the value of a port has changed
- * \arg \b path (string) - Path of port
- * \arg \b value (any) - New value of port </p> \n \n
- */
-void
-OSCClientSender::set_port_value(const std::string& port_path, const Raul::Atom& value)
-{
- lo_message m = lo_message_new();
- lo_message_add_string(m, port_path.c_str());
- Raul::AtomLiblo::lo_message_add_atom(m, value);
- send_message("/ingen/set_port_value", m);
-}
-
-
-/** \page client_osc_namespace
- * <p> \b /ingen/set_port_value - Notification the value of a port has changed
- * \arg \b path (string) - Path of port
- * \arg \b voice (int) - Voice which is set to this value
- * \arg \b value (any) - New value of port </p> \n \n
- */
-void
-OSCClientSender::set_voice_value(const std::string& port_path, uint32_t voice, const Raul::Atom& value)
-{
- lo_message m = lo_message_new();
- lo_message_add_string(m, port_path.c_str());
- Raul::AtomLiblo::lo_message_add_atom(m, value);
- send_message("/ingen/set_port_value", m);
-}
-
-
-/** \page client_osc_namespace
- * <p> \b /ingen/port_activity - Notification of activity for a port (e.g. MIDI messages)
- * \arg \b path (string) - Path of port </p> \n \n
- */
-void
-OSCClientSender::port_activity(const std::string& port_path)
-{
- if (!_enabled)
- return;
-
- lo_send(_address, "/ingen/port_activity", "s", port_path.c_str(), LO_ARGS_END);
-}
-
-
-/** \page client_osc_namespace
- * <p> \b /ingen/plugin - Notification of the existance of a plugin
- * \arg \b uri (string) - URI of plugin (e.g. http://example.org/filtermatic)
- * \arg \b type (string) - Type of plugin (e.g. "ingen:LV2Plugin")
- * \arg \b symbol (string) - Valid symbol for plugin (default symbol for nodes) (e.g. "adsr")
- * \arg \b name (string) - Descriptive human-readable name of plugin (e.g. "ADSR Envelope")
- */
-void
-OSCClientSender::new_plugin(const std::string& uri,
- const std::string& type_uri,
- const std::string& symbol,
- const std::string& name)
-{
- lo_message m = lo_message_new();
- lo_message_add_string(m, uri.c_str());
- lo_message_add_string(m, type_uri.c_str());
- lo_message_add_string(m, symbol.c_str());
- lo_message_add_string(m, name.c_str());
- send_message("/ingen/plugin", m);
-}
-
-
-/** \page client_osc_namespace
- * <p> \b /ingen/new_patch - Notification of a new patch
- * \arg \b path (string) - Path of new patch
- * \arg \b poly (int) - Polyphony of new patch (\em not a boolean like new_node) </p> \n \n
- */
-void
-OSCClientSender::new_patch(const std::string& path, uint32_t poly)
-{
- send("/ingen/new_patch", "si", path.c_str(), poly, LO_ARGS_END);
-}
-
-
-/** \page client_osc_namespace
- * <p> \b /ingen/object_renamed - Notification of an object's renaming
- * \arg \b old-path (string) - Old path of object
- * \arg \b new-path (string) - New path of object </p> \n \n
- */
-void
-OSCClientSender::object_renamed(const std::string& old_path, const std::string& new_path)
-{
- send("/ingen/object_renamed", "ss", old_path.c_str(), new_path.c_str(), LO_ARGS_END);
-}
-
-
-/** Sends information about a program associated with a node.
- */
-void
-OSCClientSender::program_add(const std::string& node_path, uint32_t bank, uint32_t program, const std::string& name)
-{
- send("/ingen/program_add", "siis",
- node_path.c_str(), bank, program, name.c_str(), LO_ARGS_END);
-}
-
-
-void
-OSCClientSender::program_remove(const std::string& node_path, uint32_t bank, uint32_t program)
-{
- send("/ingen/program_remove", "sii",
- node_path.c_str(), bank, program, LO_ARGS_END);
-}
-
-
-} // namespace Ingen
diff --git a/src/libs/engine/OSCClientSender.hpp b/src/libs/engine/OSCClientSender.hpp
deleted file mode 100644
index c8c8418f..00000000
--- a/src/libs/engine/OSCClientSender.hpp
+++ /dev/null
@@ -1,136 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef OSCCLIENTSENDER_H
-#define OSCCLIENTSENDER_H
-
-#include <cassert>
-#include <string>
-#include <iostream>
-#include <lo/lo.h>
-#include <pthread.h>
-#include "types.hpp"
-#include "interface/ClientInterface.hpp"
-#include "shared/OSCSender.hpp"
-
-namespace Ingen {
-
-namespace Shared { class EngineInterface; }
-
-
-/** Implements ClientInterface for OSC clients (sends OSC messages).
- *
- * \ingroup engine
- */
-class OSCClientSender : public Shared::ClientInterface, public Shared::OSCSender
-{
-public:
- OSCClientSender(const std::string& url)
- : _url(url)
- {
- _address = lo_address_new_from_url(url.c_str());
- }
-
- virtual ~OSCClientSender()
- { lo_address_free(_address); }
-
- bool enabled() const { return _enabled; }
-
- void enable() { _enabled = true; }
- void disable() { _enabled = false; }
-
- void bundle_begin() { OSCSender::bundle_begin(); }
- void bundle_end() { OSCSender::bundle_end(); }
- void transfer_begin() { OSCSender::transfer_begin(); }
- void transfer_end() { OSCSender::transfer_end(); }
-
- std::string uri() const { return lo_address_get_url(_address); }
-
- void subscribe(Shared::EngineInterface* engine) { }
-
- /* *** ClientInterface Implementation Below *** */
-
- //void client_registration(const std::string& url, int client_id);
-
- void response_ok(int32_t id);
- void response_error(int32_t id, const std::string& msg);
-
- void error(const std::string& msg);
-
- virtual void new_plugin(const std::string& uri,
- const std::string& type_uri,
- const std::string& symbol,
- const std::string& name);
-
- virtual void new_patch(const std::string& path, uint32_t poly);
-
- virtual void new_node(const std::string& path,
- const std::string& plugin_uri);
-
- virtual void new_port(const std::string& path,
- uint32_t index,
- const std::string& data_type,
- bool is_output);
-
- virtual void patch_cleared(const std::string& path);
-
- virtual void destroy(const std::string& path);
-
- virtual void object_renamed(const std::string& old_path,
- const std::string& new_path);
-
- virtual void connect(const std::string& src_port_path,
- const std::string& dst_port_path);
-
- virtual void disconnect(const std::string& src_port_path,
- const std::string& dst_port_path);
-
- virtual void set_variable(const std::string& subject_path,
- const std::string& predicate,
- const Raul::Atom& value);
-
- virtual void set_property(const std::string& subject_path,
- const std::string& predicate,
- const Raul::Atom& value);
-
- virtual void set_port_value(const std::string& port_path,
- const Raul::Atom& value);
-
- virtual void set_voice_value(const std::string& port_path,
- uint32_t voice,
- const Raul::Atom& value);
-
- virtual void port_activity(const std::string& port_path);
-
- virtual void program_add(const std::string& node_path,
- uint32_t bank,
- uint32_t program,
- const std::string& program_name);
-
- virtual void program_remove(const std::string& node_path,
- uint32_t bank,
- uint32_t program);
-
-private:
- std::string _url;
-};
-
-
-} // namespace Ingen
-
-#endif // OSCCLIENTSENDER_H
-
diff --git a/src/libs/engine/OSCDriver.hpp b/src/libs/engine/OSCDriver.hpp
deleted file mode 100644
index 06125217..00000000
--- a/src/libs/engine/OSCDriver.hpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef OSCDRIVER_H
-#define OSCDRIVER_H
-
-#include "types.hpp"
-#include "Driver.hpp"
-#include <iostream>
-
-namespace Ingen {
-
-
-/** OSC driver abstract base class.
- *
- * \ingroup engine
- */
-class OSCDriver : public Driver
-{
-public:
- OSCDriver() : Driver(DataType::EVENT) {}
-
- /** Prepare events (however neccessary) for the specified block (realtime safe) */
- virtual void prepare_block(const SampleCount block_start, const SampleCount block_end) = 0;
-};
-
-
-
-/** Dummy OSCDriver.
- *
- * Not abstract, all functions are dummies. One of these will be allocated and
- * "used" if no working OSC driver is loaded. (Doing it this way as opposed to
- * just making OSCDriver have dummy functions makes sure any existing OSCDriver
- * derived class actually implements the required functions).
- *
- * \ingroup engine
- */
-class DummyOSCDriver : public OSCDriver
-{
-public:
- DummyOSCDriver() {
- std::cout << "[DummyOSCDriver] Started Dummy OSC driver." << std::endl;
- }
-
- ~DummyOSCDriver() {}
-
- void activate() {}
- void deactivate() {}
-
- bool is_activated() const { return false; }
- bool is_enabled() const { return false; }
-
- void enable() {}
- void disable() {}
-
- DriverPort* create_port(DuplexPort* patch_port) { return NULL; }
-
- void add_port(DriverPort* port) {}
- DriverPort* remove_port(const Raul::Path& path) { return NULL; }
-
- void prepare_block(const SampleCount block_start, const SampleCount block_end) {}
-};
-
-
-
-} // namespace Ingen
-
-#endif // OSCDRIVER_H
diff --git a/src/libs/engine/OSCEngineReceiver.cpp b/src/libs/engine/OSCEngineReceiver.cpp
deleted file mode 100644
index e4e2fec1..00000000
--- a/src/libs/engine/OSCEngineReceiver.cpp
+++ /dev/null
@@ -1,884 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <iostream>
-#include <cstdlib>
-#include <string>
-//#define ENABLE_AVAHI 1
-#include <lo/lo.h>
-#include "types.hpp"
-#include <raul/SharedPtr.hpp>
-#include <raul/AtomLiblo.hpp>
-#include "interface/ClientInterface.hpp"
-#include "engine/ThreadManager.hpp"
-#include "OSCEngineReceiver.hpp"
-#include "QueuedEventSource.hpp"
-#include "OSCClientSender.hpp"
-#include "ClientBroadcaster.hpp"
-
-using namespace std;
-
-namespace Ingen {
-
-
-/*! \page engine_osc_namespace Engine OSC Namespace Documentation
- *
- * <p>These are the commands the engine recognizes. A client can control every
- * aspect of the engine entirely with these commands.</p>
- *
- * <p>All commands on this page are in the "control band". If a client needs to
- * know about the state of the engine, it must listen to the "notification band".
- * See the "Client OSC Namespace Documentation" for details.</p>\n\n
- */
-
-
-OSCEngineReceiver::OSCEngineReceiver(Engine& engine, size_t queue_size, uint16_t port)
- : QueuedEngineInterface(engine, queue_size, queue_size) // FIXME
- , _server(NULL)
-{
- _receive_thread = new ReceiveThread(*this);
-
- char port_str[6];
- snprintf(port_str, 6, "%u", port);
-
- _server = lo_server_new(port_str, error_cb);
-#ifdef ENABLE_AVAHI
- lo_server_avahi_init(_server, "ingen");
-#endif
-
- if (_server == NULL) {
- cerr << "[OSC] Could not start OSC server. Aborting." << endl;
- exit(EXIT_FAILURE);
- } else {
- char* lo_url = lo_server_get_url(_server);
- cout << "[OSC] Started OSC server at " << lo_url << endl;
- free(lo_url);
- }
-
- // For debugging, print all incoming OSC messages
- //lo_server_add_method(_server, NULL, NULL, generic_cb, NULL);
-
- // Set response address for this message.
- // It's important this is first and returns nonzero.
- lo_server_add_method(_server, NULL, NULL, set_response_address_cb, this);
-
- // Commands
- lo_server_add_method(_server, "/ingen/ping", "i", ping_cb, this);
- lo_server_add_method(_server, "/ingen/ping_queued", "i", ping_slow_cb, this);
- lo_server_add_method(_server, "/ingen/quit", "i", quit_cb, this);
- //lo_server_add_method(_server, "/ingen/register_client", "is", register_client_cb, this);
- lo_server_add_method(_server, "/ingen/register_client", "i", register_client_cb, this);
- lo_server_add_method(_server, "/ingen/unregister_client", "i", unregister_client_cb, this);
- lo_server_add_method(_server, "/ingen/load_plugins", "i", load_plugins_cb, this);
- lo_server_add_method(_server, "/ingen/activate", "i", engine_activate_cb, this);
- lo_server_add_method(_server, "/ingen/deactivate", "i", engine_deactivate_cb, this);
- lo_server_add_method(_server, "/ingen/new_patch", "isi", new_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/new_port", "issi", new_port_cb, this);
- lo_server_add_method(_server, "/ingen/new_node", "issss", new_node_cb, this);
- lo_server_add_method(_server, "/ingen/new_node", "issss", new_node_cb, this);
- lo_server_add_method(_server, "/ingen/new_node", "iss", new_node_by_uri_cb, this);
- lo_server_add_method(_server, "/ingen/new_node", "iss", new_node_by_uri_cb, this);
- lo_server_add_method(_server, "/ingen/destroy", "is", destroy_cb, this);
- lo_server_add_method(_server, "/ingen/rename", "iss", rename_cb, this);
- lo_server_add_method(_server, "/ingen/connect", "iss", connect_cb, this);
- lo_server_add_method(_server, "/ingen/disconnect", "iss", disconnect_cb, this);
- lo_server_add_method(_server, "/ingen/disconnect_all", "iss", disconnect_all_cb, this);
- lo_server_add_method(_server, "/ingen/set_port_value", NULL, set_port_value_cb, this);
- lo_server_add_method(_server, "/ingen/note_on", "isii", note_on_cb, this);
- lo_server_add_method(_server, "/ingen/note_off", "isi", note_off_cb, this);
- lo_server_add_method(_server, "/ingen/all_notes_off", "isi", all_notes_off_cb, this);
- lo_server_add_method(_server, "/ingen/midi_learn", "is", midi_learn_cb, this);
- lo_server_add_method(_server, "/ingen/set_variable", NULL, variable_set_cb, this);
- lo_server_add_method(_server, "/ingen/set_property", NULL, property_set_cb, this);
-
- // Queries
- lo_server_add_method(_server, "/ingen/request_variable", "iss", variable_get_cb, this);
- lo_server_add_method(_server, "/ingen/request_plugin", "is", request_plugin_cb, this);
- lo_server_add_method(_server, "/ingen/request_object", "is", request_object_cb, this);
- lo_server_add_method(_server, "/ingen/request_port_value", "is", request_port_value_cb, this);
- lo_server_add_method(_server, "/ingen/request_plugins", "i", request_plugins_cb, this);
- lo_server_add_method(_server, "/ingen/request_all_objects", "i", request_all_objects_cb, this);
-
- lo_server_add_method(_server, NULL, NULL, unknown_cb, NULL);
-
- Thread::set_name("OSC Pre-Processor");
-}
-
-
-OSCEngineReceiver::~OSCEngineReceiver()
-{
- deactivate();
- stop();
- _receive_thread->stop();
- delete _receive_thread;
-
- if (_server != NULL) {
-#ifdef ENABLE_AVAHI
- lo_server_avahi_free(_server);
-#endif
- lo_server_free(_server);
- _server = NULL;
- }
-}
-
-
-void
-OSCEngineReceiver::activate()
-{
- QueuedEventSource::activate();
- _receive_thread->set_name("OSC Receiver");
- _receive_thread->start();
- _receive_thread->set_scheduling(SCHED_FIFO, 5); // Jack default appears to be 10
-}
-
-
-void
-OSCEngineReceiver::deactivate()
-{
- cout << "[OSCEngineReceiver] Stopped OSC listening thread" << endl;
- _receive_thread->stop();
- QueuedEventSource::deactivate();
-}
-
-
-/** Override the semaphore driven _run method of QueuedEngineInterface
- * to wait on OSC messages and prepare them right away in the same thread.
- */
-void
-OSCEngineReceiver::ReceiveThread::_run()
-{
- Thread::get().set_context(THREAD_PRE_PROCESS);
-
- /* get a timestamp here and stamp all the events with the same time so
- * they all get executed in the same cycle */
-
- while (true) {
- assert(_receiver._server);
- /*if ( ! _server) {
- cout << "[OSCEngineReceiver] Server is NULL, exiting" << endl;
- break;
- }*/
-
- // Wait on a message and enqueue it
- lo_server_recv(_receiver._server);
-
- // Enqueue every other message that is here "now"
- // (would this provide truly atomic bundles?)
- while (lo_server_recv_noblock(_receiver._server, 0) > 0)
- if (_receiver.unprepared_events())
- _receiver.whip();
-
- // No more unprepared events
- }
-}
-
-
-/** Create a new responder for this message, if necessary.
- *
- * This is based on the fact that the current responder is stored in a ref
- * counted pointer, and events just take a reference to that. Thus, events
- * may delete their responder if we've since switched to a new one, or the
- * same one can stay around and serve a series of events.
- * Hooray for reference counting.
- *
- * If this message came from the same source as the last message, no allocation
- * of responders or lo_addresses or any of it needs to be done. Unfortunately
- * the only way to check is by comparing URLs, because liblo addresses suck.
- * Lack of a fast liblo address comparison really sucks here, in any case.
- */
-int
-OSCEngineReceiver::set_response_address_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg, void* user_data)
-{
- OSCEngineReceiver* const me = reinterpret_cast<OSCEngineReceiver*>(user_data);
-
- if (argc < 1 || types[0] != 'i') // Not a valid Ingen message
- return 0; // Save liblo the trouble
-
- const int32_t id = argv[0]->i;
-
- const lo_address addr = lo_message_get_source(msg);
- char* const url = lo_address_get_url(addr);
-
- const SharedPtr<Responder> r = me->_responder;
-
- /* Different address than last time, have to do a lookup */
- if (!r || !r->client() || strcmp(url, r->client()->uri().c_str())) {
- ClientInterface* client = me->_engine.broadcaster()->client(url);
- if (client)
- me->_responder = SharedPtr<Responder>(new Responder(client, id));
- else
- me->_responder = SharedPtr<Responder>(new Responder());
- }
-
- if (id != -1) {
- me->set_next_response_id(id);
- } else {
- me->disable_responses();
- }
-
- // If this returns 0 no OSC commands will work
- return 1;
-}
-
-
-void
-OSCEngineReceiver::error_cb(int num, const char* msg, const char* path)
-{
- cerr << "liblo server error " << num << " in path \"" << "\" - " << msg << endl;
-}
-
-
-/** \page engine_osc_namespace
- * <p> \b /ingen/ping - Immediately sends a successful response to the given response id.
- * \arg \b response-id (integer) </p> \n \n
- */
-int
-OSCEngineReceiver::_ping_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- const lo_address addr = lo_message_get_source(msg);
- if (lo_send(addr, "/ingen/ok", "i", argv[0]->i) < 0)
- cerr << "WARNING: Unable to send response: " << lo_address_errstr(addr) << endl;
- return 0;
-}
-
-
-/** \page engine_osc_namespace
- * <p> \b /ingen/ping_queued - Sends response after going through the event queue.
- * \arg \b response-id (integer)
- *
- * \li See the documentation for /ingen/set_port_value_queued for an explanation of how
- * this differs from /ingen/ping. This is useful to send after sending a large cluster of
- * events as a sentinel and wait on it's response, to know when the events are all
- * finished processing.</p> \n \n
- */
-int
-OSCEngineReceiver::_ping_slow_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- ping();
- return 0;
-}
-
-
-/** \page engine_osc_namespace
- * <p> \b /ingen/quit - Terminates the engine.
- * \arg \b response-id (integer)
- *
- * \li Note that there is NO order guarantees with this command at all. You could
- * send 10 messages then quit, and the quit reply could come immediately and the
- * 10 messages would never get executed. </p> \n \n
- */
-int
-OSCEngineReceiver::_quit_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- quit();
- return 0;
-}
-
-/** \page engine_osc_namespace
- * <p> \b /ingen/register_client - Registers a new client with the engine
- * \arg \b response-id (integer) \n\n
- * \li The incoming address will be used for the new registered client. If you
- * want to register a different specific address, use the URL version. </p> \n \n
- */
-int
-OSCEngineReceiver::_register_client_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- lo_address addr = lo_message_get_source(msg);
-
- char* const url = lo_address_get_url(addr);
- ClientInterface* client = new OSCClientSender((const char*)url);
- register_client(client);
- free(url);
-
- return 0;
-}
-
-
-/** \page engine_osc_namespace
- * <p> \b /ingen/unregister_client - Unregisters a client
- * \arg \b response-id (integer) </p> \n \n
- */
-int
-OSCEngineReceiver::_unregister_client_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- lo_address addr = lo_message_get_source(msg);
-
- char* url = lo_address_get_url(addr);
- unregister_client(url);
- free(url);
-
- return 0;
-}
-
-
-/** \page engine_osc_namespace
- * <p> \b /ingen/load_plugins - Locates all available plugins, making them available for use.
- * \arg \b response-id (integer) </p> \n \n
- */
-int
-OSCEngineReceiver::_load_plugins_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- load_plugins();
- return 0;
-}
-
-
-/** \page engine_osc_namespace
- * <p> \b /ingen/activate - Activate the engine (MIDI, audio, everything)
- * \arg \b response-id (integer) </p>
- *
- * \li Note that you <b>must</b> send this message first if you want the engine to do
- * anything at all - <em>including respond to your messages!</em> \n \n
- */
-int
-OSCEngineReceiver::_engine_activate_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- QueuedEngineInterface::activate();
- return 0;
-}
-
-
-/** \page engine_osc_namespace
- * <p> \b /ingen/deactivate - Deactivate the engine completely.
- * \arg \b response-id (integer) </p> \n \n
- */
-int
-OSCEngineReceiver::_engine_deactivate_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- QueuedEngineInterface::deactivate();
- return 0;
-}
-
-
-/** \page engine_osc_namespace
- * <p> \b /ingen/new_patch - Creates a new, empty, toplevel patch.
- * \arg \b response-id (integer)
- * \arg \b patch-path (string) - Patch path (complete, ie /master/parent/new_patch)
- * \arg \b poly (integer) - Patch's (internal) polyphony </p> \n \n
- */
-int
-OSCEngineReceiver::_new_patch_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- const char* patch_path = &argv[1]->s;
- const int32_t poly = argv[2]->i;
-
- new_patch(patch_path, poly);
- return 0;
-}
-
-
-/** \page engine_osc_namespace
- * <p> \b /ingen/rename - Rename an Object (only Nodes, for now)
- * \arg \b response-id (integer)
- * \arg \b path - Object's path
- * \arg \b name - New name for object </p> \n \n
- */
-int
-OSCEngineReceiver::_rename_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- const char* object_path = &argv[1]->s;
- const char* name = &argv[2]->s;
-
- rename(object_path, name);
- return 0;
-}
-
-
-/** \page engine_osc_namespace
- * <p> \b /ingen/clear_patch - Remove all nodes from a patch
- * \arg \b response-id (integer)
- * \arg \b patch-path - Patch's path </p> \n \n
- */
-int
-OSCEngineReceiver::_clear_patch_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- const char* patch_path = &argv[1]->s;
-
- clear_patch(patch_path);
- return 0;
-}
-
-
-/** \page engine_osc_namespace
- * <p> \b /ingen/set_polyphony - Set the polyphony of a patch
- * \arg \b response-id (integer)
- * \arg \b patch-path - Patch's path
- * \arg \b poly (integer) </p> \n \n
- */
-int
-OSCEngineReceiver::_set_polyphony_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- const char* patch_path = &argv[1]->s;
- const uint32_t poly = argv[2]->i;
-
- set_polyphony(patch_path, poly);
- return 0;
-}
-
-
-/** \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;
-}
-
-
-// FIXME: add index
-/** \page engine_osc_namespace
- * <p> \b /ingen/new_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)
- * \arg \b data-type (string) - Type of port (ingen:AudioPort, ingen:ControlPort, ingen:MIDIPort, or ingen:OSCPort)
- * \arg \b direction ("is-output") (integer) - Direction of data flow (Input = 0, Output = 1) </p> \n \n
- */
-int
-OSCEngineReceiver::_new_port_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- const char* port_path = &argv[1]->s;
- const char* data_type = &argv[2]->s;
- const int32_t direction = argv[3]->i;
-
- new_port(port_path, 0, data_type, (direction == 1));
- return 0;
-}
-
-/** \page engine_osc_namespace
- * <p> \b /ingen/new_node - Add a node into a given patch (load a plugin by URI)
- * \arg \b response-id (integer)
- * \arg \b node-path (string) - Full path of the new node (ie. /patch2/subpatch/newnode)
- * \arg \b plug-uri (string) - URI of the plugin to load \n \n
- */
-int
-OSCEngineReceiver::_new_node_by_uri_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- const char* node_path = &argv[1]->s;
- const char* plug_uri = &argv[2]->s;
-
- new_node(node_path, plug_uri);
- return 0;
-}
-
-
-/** \page engine_osc_namespace
- * <p> \b /ingen/new_node - Add a node into a given patch (load a plugin by libname, label) \b DEPRECATED
- * \arg \b response-id (integer)
- * \arg \b node-path (string) - Full path of the new node (ie. /patch2/subpatch/newnode)
- * \arg \b type (string) - Plugin type ("LADSPA" or "Internal")
- * \arg \b lib-name (string) - Name of library where plugin resides (eg "cmt.so")
- * \arg \b plug-label (string) - Label (ID) of plugin (eg "sine_fcaa") \n \n
- *
- * \li This is only here to provide backwards compatibility for old patches that store LADSPA plugin
- * references as libname, label. It is to be removed ASAP, don't use it.
- * </p> \n \n
- */
-int
-OSCEngineReceiver::_new_node_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- const char* node_path = &argv[1]->s;
- const char* type = &argv[2]->s;
- const char* lib_name = &argv[3]->s;
- const char* plug_label = &argv[4]->s;
-
- new_node_deprecated(node_path, type, lib_name, plug_label);
- return 0;
-}
-
-
-/** \page engine_osc_namespace
- * <p> \b /ingen/destroy - Removes (destroys) a Patch or a Node
- * \arg \b response-id (integer)
- * \arg \b node-path (string) - Full path of the object </p> \n \n
- */
-int
-OSCEngineReceiver::_destroy_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- const char* node_path = &argv[1]->s;
-
- destroy(node_path);
- return 0;
-}
-
-
-/** \page engine_osc_namespace
- * <p> \b /ingen/connect - Connects two ports (must be in the same patch)
- * \arg \b response-id (integer)
- * \arg \b src-port-path (string) - Full path of source port
- * \arg \b dst-port-path (string) - Full path of destination port </p> \n \n
- */
-int
-OSCEngineReceiver::_connect_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- const char* src_port_path = &argv[1]->s;
- const char* dst_port_path = &argv[2]->s;
-
- connect(src_port_path, dst_port_path);
- return 0;
-}
-
-
-/** \page engine_osc_namespace
- * <p> \b /ingen/disconnect - Disconnects two ports.
- * \arg \b response-id (integer)
- * \arg \b src-port-path (string) - Full path of source port
- * \arg \b dst-port-path (string) - Full path of destination port </p> \n \n
- */
-int
-OSCEngineReceiver::_disconnect_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- const char* src_port_path = &argv[1]->s;
- const char* dst_port_path = &argv[2]->s;
-
- disconnect(src_port_path, dst_port_path);
- return 0;
-}
-
-
-/** \page engine_osc_namespace
- * <p> \b /ingen/disconnect_all - Disconnect all connections to/from a node/port.
- * \arg \b response-id (integer)
- * \arg \b patch-path (string) - The (parent) patch in which to disconnect object. </p> \n \n
- * \arg \b node-path (string) - Full path of object. </p> \n \n
- */
-int
-OSCEngineReceiver::_disconnect_all_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- const char* patch_path = &argv[1]->s;
- const char* object_path = &argv[2]->s;
-
- disconnect_all(patch_path, object_path);
- return 0;
-}
-
-
-/** \page engine_osc_namespace
- * <p> \b /ingen/set_port_value - Sets the value of a port for all voices (as a QueuedEvent)
- * \arg \b response-id (integer)
- * \arg \b port-path (string) - Name of port
- * \arg \b value (float) - Value to set port to.</p> \n \n
- */
-int
-OSCEngineReceiver::_set_port_value_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- if (argc < 3 || argc > 5 || strncmp(types, "is", 2))
- return 1;
-
- const char* port_path = &argv[1]->s;
-
- using Raul::Atom;
-
- if (!strcmp(types, "isf")) { // float, all voices
- const float value = argv[2]->f;
- set_port_value(port_path, Atom(value));
- } else if (!strcmp(types, "isif")) { // float, specific voice
- const float value = argv[3]->f;
- set_voice_value(port_path, argv[2]->i, Atom(value));
- } else if (!strcmp(types, "issb")) { // blob (event), all voices
- const char* type = &argv[2]->s;
- lo_blob b = argv[3];
- size_t data_size = lo_blob_datasize(b);
- void* data = lo_blob_dataptr(b);
- set_port_value(port_path, Atom(type, data_size, data));
- } else if (!strcmp(types, "isisb")) { // blob (event), specific voice
- const char* type = &argv[3]->s;
- lo_blob b = argv[4];
- size_t data_size = lo_blob_datasize(b);
- void* data = lo_blob_dataptr(b);
- set_voice_value(port_path, argv[2]->i, Atom(type, data_size, data));
- } else if (!strcmp(types, "issN")) { // empty event (type only), all voices
- const char* type = &argv[2]->s;
- set_port_value(port_path, Atom(type, 0, NULL));
- } else if (!strcmp(types, "isisN")) { // empty event (type only), specific voice
- const char* type = &argv[3]->s;
- set_voice_value(port_path, argv[2]->i, Atom(type, 0, NULL));
- } else {
- return 1;
- }
-
- return 0;
-}
-
-
-/** \page engine_osc_namespace
- * <p> \b /ingen/note_on - Triggers a note-on, just as if it came from MIDI
- * \arg \b response-id (integer)
- * \arg \b node-path (string) - Patch of Node to trigger (must be a trigger or note node)
- * \arg \b note-num (int) - MIDI style note number (0-127)
- * \arg \b velocity (int) - MIDI style velocity (0-127)</p> \n \n
- */
-int
-OSCEngineReceiver::_note_on_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- /*
-
- const char* node_path = &argv[1]->s;
- const uchar note_num = argv[2]->i;
- const uchar velocity = argv[3]->i;
- */
- cerr << "FIXME: OSC note on\n";
- //note_on(node_path, note_num, velocity);
- return 0;
-}
-
-
-/** \page engine_osc_namespace
- * <p> \b /ingen/note_off - Triggers a note-off, just as if it came from MIDI
- * \arg \b response-id (integer)
- * \arg \b node-path (string) - Patch of Node to trigger (must be a trigger or note node)
- * \arg \b note-num (int) - MIDI style note number (0-127)</p> \n \n
- */
-int
-OSCEngineReceiver::_note_off_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- /*
-
- const char* patch_path = &argv[1]->s;
- const uchar note_num = argv[2]->i;
- */
- cerr << "FIXME: OSC note off\n";
- //note_off(patch_path, note_num);
- return 0;
-}
-
-
-/** \page engine_osc_namespace
- * <p> \b /ingen/all_notes_off - Triggers a note-off for all voices, just as if it came from MIDI
- * \arg \b response-id (integer)
- * \arg \b patch-path (string) - Patch of patch to send event to </p> \n \n
- */
-int
-OSCEngineReceiver::_all_notes_off_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- /*
-
- const char* patch_path = &argv[1]->s;
- */
- cerr << "FIXME: OSC all notes off\n";
- //all_notes_off(patch_path);
- return 0;
-}
-
-
-/** \page engine_osc_namespace
- * <p> \b /ingen/midi_learn - Initiate MIDI learn for a given (MIDI Control) Node
- * \arg \b response-id (integer)
- * \arg \b node-path (string) - Patch of the Node that should learn the next MIDI event.
- *
- * \li This of course will only do anything for MIDI control nodes. The node will learn the next MIDI
- * event that arrives at it's MIDI input port - no behind the scenes voodoo happens here. It is planned
- * that a plugin specification supporting arbitrary OSC commands for plugins will exist one day, and this
- * method will go away completely. </p> \n \n
- */
-int
-OSCEngineReceiver::_midi_learn_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- const char* patch_path = &argv[1]->s;
-
- midi_learn(patch_path);
- return 0;
-}
-
-
-/** \page engine_osc_namespace
- * <p> \b /ingen/set_variable - Set a variable, associated with a synth-space object (node, etc)
- * \arg \b response-id (integer)
- * \arg \b object-path (string) - Full path of object to associate variable with
- * \arg \b key (string) - Key (index/predicate/ID) for new variable
- * \arg \b value (string) - Value of new variable </p> \n \n
- */
-int
-OSCEngineReceiver::_variable_set_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- if (argc != 4 || types[0] != 'i' || types[1] != 's' || types[2] != 's')
- return 1;
-
- const char* object_path = &argv[1]->s;
- const char* key = &argv[2]->s;
-
- Raul::Atom value = Raul::AtomLiblo::lo_arg_to_atom(types[3], argv[3]);
-
- set_variable(object_path, key, value);
- return 0;
-}
-
-
-/** \page engine_osc_namespace
- * <p> \b /ingen/set_property - Set an (RDF) property, associated with a synth-space object (node, etc)
- * \arg \b response-id (integer)
- * \arg \b object-path (string) - Full path of object to associate variable with
- * \arg \b key (string) - URI/QName for predicate of this property (e.g. "ingen:enabled")
- * \arg \b value (string) - Value of property </p> \n \n
- */
-int
-OSCEngineReceiver::_property_set_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- if (argc != 4 || types[0] != 'i' || types[1] != 's' || types[2] != 's')
- return 1;
-
- const char* object_path = &argv[1]->s;
- const char* key = &argv[2]->s;
-
- Raul::Atom value = Raul::AtomLiblo::lo_arg_to_atom(types[3], argv[3]);
-
- set_property(object_path, key, value);
- return 0;
-}
-
-
-/** \page engine_osc_namespace
- * <p> \b /ingen/request_variable - Requests the engine send a piece of variable, associated with a synth-space object (node, etc)
- * \arg \b response-id (integer)
- * \arg \b object-path (string) - Full path of object variable is associated with
- * \arg \b key (string) - Key (index) for piece of variable
- *
- * \li Reply will be sent to client registered with the source address of this message.</p> \n \n
- */
-int
-OSCEngineReceiver::_variable_get_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- const char* object_path = &argv[1]->s;
- const char* key = &argv[2]->s;
-
- request_variable(object_path, key);
- return 0;
-}
-
-
-/** \page engine_osc_namespace
- * <p> \b /ingen/request_plugin - Requests the engine send the value of a port.
- * \arg \b response-id (integer)
- * \arg \b port-path (string) - Full path of port to send the value of \n\n
- * \li Reply will be sent to client registered with the source address of this message.</p>\n\n
- */
-int
-OSCEngineReceiver::_request_plugin_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- const char* uri = &argv[1]->s;
-
- request_plugin(uri);
- return 0;
-}
-
-
-/** \page engine_osc_namespace
- * <p> \b /ingen/request_object - Requests the engine send the value of a port.
- * \arg \b response-id (integer)
- * \arg \b port-path (string) - Full path of port to send the value of \n\n
- * \li Reply will be sent to client registered with the source address of this message.</p>\n\n
- */
-int
-OSCEngineReceiver::_request_object_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- const char* object_path = &argv[1]->s;
-
- request_object(object_path);
- return 0;
-}
-
-
-/** \page engine_osc_namespace
- * <p> \b /ingen/request_port_value - Requests the engine send the value of a port.
- * \arg \b response-id (integer)
- * \arg \b port-path (string) - Full path of port to send the value of \n\n
- * \li Reply will be sent to client registered with the source address of this message.</p>\n\n
- */
-int
-OSCEngineReceiver::_request_port_value_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- const char* port_path = &argv[1]->s;
-
- request_port_value(port_path);
- return 0;
-}
-
-
-/** \page engine_osc_namespace
- * <p> \b /ingen/request_plugins - Requests the engine send a list of all known plugins.
- * \arg \b response-id (integer) \n\n
- * \li Reply will be sent to client registered with the source address of this message.</p>\n\n
- */
-int
-OSCEngineReceiver::_request_plugins_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- request_plugins();
- return 0;
-}
-
-
-/** \page engine_osc_namespace
- * <p> \b /ingen/request_all_objects - Requests the engine send information about \em all objects (patches, nodes, etc)
- * \arg \b response-id (integer)\n\n
- * \li Reply will be sent to client registered with the source address of this message.</p> \n \n
- */
-int
-OSCEngineReceiver::_request_all_objects_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- request_all_objects();
- return 0;
-}
-
-
-// Static Callbacks //
-
-
-// Display incoming OSC messages (for debugging purposes)
-int
-OSCEngineReceiver::generic_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg, void* user_data)
-{
- printf("[OSCMsg] %s (%s)\t", path, types);
-
- for (int i=0; i < argc; ++i) {
- lo_arg_pp(lo_type(types[i]), argv[i]);
- printf("\t");
- }
- printf("\n");
-
- return 1; // not handled
-}
-
-
-int
-OSCEngineReceiver::unknown_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg, void* user_data)
-{
- const lo_address addr = lo_message_get_source(msg);
- char* const url = lo_address_get_url(addr);
-
- cerr << "Unknown command " << path << " (" << types << "), sending error.\n";
-
- string error_msg = "Unknown command: ";
- error_msg.append(path).append(" ").append(types);
-
- OSCClientSender(url).error(error_msg);
-
- return 0;
-}
-
-
-} // namespace Ingen
diff --git a/src/libs/engine/OSCEngineReceiver.hpp b/src/libs/engine/OSCEngineReceiver.hpp
deleted file mode 100644
index c6e0bf59..00000000
--- a/src/libs/engine/OSCEngineReceiver.hpp
+++ /dev/null
@@ -1,129 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef OSCENGINERECEIVER_H
-#define OSCENGINERECEIVER_H
-
-#include CONFIG_H_PATH
-#include <string>
-#include <stdint.h>
-#include <lo/lo.h>
-#include <raul/SharedPtr.hpp>
-#include "QueuedEngineInterface.hpp"
-#include "Responder.hpp"
-using std::string;
-
-namespace Ingen {
-
-class JackDriver;
-class NodeFactory;
-class PatchImpl;
-
-
-/* Some boilerplate killing macros... */
-#define LO_HANDLER_ARGS const char* path, const char* types, lo_arg** argv, int argc, lo_message msg
-
-/* Defines a static handler to be passed to lo_add_method, which is a trivial
- * wrapper around a non-static method that does the real work. Makes a whoole
- * lot of ugly boiler plate go away */
-#define LO_HANDLER(name) \
-int _##name##_cb (LO_HANDLER_ARGS);\
-inline static int name##_cb(LO_HANDLER_ARGS, void* myself)\
-{ return ((OSCEngineReceiver*)myself)->_##name##_cb(path, types, argv, argc, msg); }
-
-
-/* FIXME: Make this receive and preprocess in the same thread? */
-
-
-/** Receives OSC messages from liblo.
- *
- * This inherits from QueuedEngineInterface and calls it's own functions
- * via OSC. It's not actually a directly callable EngineInterface (it's
- * callable via OSC...) so it should be implemented-as-a (privately inherit)
- * QueuedEngineInterface, but it needs to be public so it's an EventSource
- * the Driver can use. This probably should be fixed somehow..
- *
- * \ingroup engine
- */
-class OSCEngineReceiver : public QueuedEngineInterface
-{
-public:
- OSCEngineReceiver(Engine& engine, size_t queue_size, uint16_t port);
- ~OSCEngineReceiver();
-
- void activate();
- void deactivate();
-
-private:
- struct ReceiveThread : public Raul::Thread {
- ReceiveThread(OSCEngineReceiver& receiver) : _receiver(receiver) {}
- virtual void _run();
- private:
- OSCEngineReceiver& _receiver;
- };
-
- friend class ReceiveThread;
-
- ReceiveThread* _receive_thread;
-
- static void error_cb(int num, const char* msg, const char* path);
- static int set_response_address_cb(LO_HANDLER_ARGS, void* myself);
- static int generic_cb(LO_HANDLER_ARGS, void* myself);
- static int unknown_cb(LO_HANDLER_ARGS, void* myself);
-
- LO_HANDLER(quit);
- LO_HANDLER(ping);
- LO_HANDLER(ping_slow);
- LO_HANDLER(register_client);
- LO_HANDLER(unregister_client);
- LO_HANDLER(load_plugins);
- LO_HANDLER(engine_activate);
- LO_HANDLER(engine_deactivate);
- LO_HANDLER(new_patch);
- LO_HANDLER(rename);
- LO_HANDLER(new_port);
- LO_HANDLER(new_node);
- LO_HANDLER(new_node_by_uri);
- LO_HANDLER(clear_patch);
- LO_HANDLER(set_polyphony);
- LO_HANDLER(set_polyphonic);
- LO_HANDLER(destroy);
- LO_HANDLER(connect);
- LO_HANDLER(disconnect);
- LO_HANDLER(disconnect_all);
- LO_HANDLER(set_port_value);
- LO_HANDLER(note_on);
- LO_HANDLER(note_off);
- LO_HANDLER(all_notes_off);
- LO_HANDLER(midi_learn);
- LO_HANDLER(variable_get);
- LO_HANDLER(variable_set);
- LO_HANDLER(property_set);
- LO_HANDLER(request_plugin);
- LO_HANDLER(request_object);
- LO_HANDLER(request_port_value);
- LO_HANDLER(request_variable);
- LO_HANDLER(request_plugins);
- LO_HANDLER(request_all_objects);
-
- lo_server _server;
-};
-
-
-} // namespace Ingen
-
-#endif // OSCENGINERECEIVER_H
diff --git a/src/libs/engine/ObjectSender.cpp b/src/libs/engine/ObjectSender.cpp
deleted file mode 100644
index 688cea8e..00000000
--- a/src/libs/engine/ObjectSender.cpp
+++ /dev/null
@@ -1,150 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "ObjectSender.hpp"
-#include "interface/ClientInterface.hpp"
-#include "EngineStore.hpp"
-#include "PatchImpl.hpp"
-#include "NodeImpl.hpp"
-#include "PortImpl.hpp"
-#include "PortImpl.hpp"
-#include "ConnectionImpl.hpp"
-#include "NodeFactory.hpp"
-#include "interface/DataType.hpp"
-#include "AudioBuffer.hpp"
-
-namespace Ingen {
-
-
-void
-ObjectSender::send_patch(ClientInterface* client, const PatchImpl* patch, bool recursive)
-{
- client->bundle_begin();
-
- client->new_patch(patch->path(), patch->internal_polyphony());
- client->set_property(patch->path(), "ingen:polyphonic", patch->polyphonic());
-
- // Send variable
- const GraphObjectImpl::Variables& data = patch->variables();
- for (GraphObjectImpl::Variables::const_iterator j = data.begin(); j != data.end(); ++j)
- client->set_variable(patch->path(), (*j).first, (*j).second);
-
- client->set_property(patch->path(), "ingen:enabled", (bool)patch->enabled());
-
- client->bundle_end();
-
- if (recursive) {
-
- // Send nodes
- for (List<NodeImpl*>::const_iterator j = patch->nodes().begin();
- j != patch->nodes().end(); ++j) {
- const NodeImpl* const node = (*j);
- send_node(client, node, true);
- }
-
- // Send ports
- for (uint32_t i=0; i < patch->num_ports(); ++i) {
- PortImpl* const port = patch->port_impl(i);
- send_port(client, port);
- }
-
- // Send connections
- client->transfer_begin();
- for (PatchImpl::Connections::const_iterator j = patch->connections().begin();
- j != patch->connections().end(); ++j)
- client->connect((*j)->src_port_path(), (*j)->dst_port_path());
- client->transfer_end();
- }
-}
-
-
-/** Sends a node or a patch */
-void
-ObjectSender::send_node(ClientInterface* client, const NodeImpl* node, bool recursive)
-{
- PluginImpl* const plugin = node->plugin_impl();
-
- assert(node->path().length() > 0);
-
- if (plugin->type() == Plugin::Patch) {
- send_patch(client, (PatchImpl*)node, recursive);
- return;
- }
-
- if (plugin->uri().length() == 0) {
- cerr << "Node " << node->path() << " plugin has no URI! Not sending." << endl;
- return;
- }
-
- client->bundle_begin();
-
- client->new_node(node->path(), node->plugin()->uri());
- client->set_property(node->path(), "ingen:polyphonic", node->polyphonic());
-
- // Send variables
- const GraphObjectImpl::Variables& data = node->variables();
- for (GraphObjectImpl::Variables::const_iterator j = data.begin(); j != data.end(); ++j)
- client->set_variable(node->path(), (*j).first, (*j).second);
-
- // Send properties
- const GraphObjectImpl::Properties& prop = node->properties();
- for (GraphObjectImpl::Properties::const_iterator j = prop.begin(); j != prop.end(); ++j)
- client->set_property(node->path(), (*j).first, (*j).second);
-
- client->bundle_end();
-
- if (recursive) {
- // Send ports
- for (size_t j=0; j < node->num_ports(); ++j)
- send_port(client, node->port_impl(j));
- }
-}
-
-
-void
-ObjectSender::send_port(ClientInterface* client, const PortImpl* port)
-{
- assert(port);
-
- client->bundle_begin();
-
- client->new_port(port->path(), port->index(), port->type().uri(), port->is_output());
- client->set_property(port->path(), "ingen:polyphonic", port->polyphonic());
-
- // Send variable
- const GraphObjectImpl::Variables& data = port->variables();
- for (GraphObjectImpl::Variables::const_iterator j = data.begin(); j != data.end(); ++j)
- client->set_variable(port->path(), (*j).first, (*j).second);
-
- // Send properties
- const GraphObjectImpl::Properties& prop = port->properties();
- for (GraphObjectImpl::Properties::const_iterator j = prop.begin(); j != prop.end(); ++j)
- client->set_property(port->path(), (*j).first, (*j).second);
-
- // Send control value
- if (port->type() == DataType::CONTROL) {
- const Sample value = dynamic_cast<const AudioBuffer*>(port->buffer(0))->value_at(0);
- //cerr << port->path() << " sending default value " << default_value << endl;
- client->set_port_value(port->path(), value);
- }
-
- client->bundle_end();
-}
-
-
-} // namespace Ingen
-
diff --git a/src/libs/engine/ObjectSender.hpp b/src/libs/engine/ObjectSender.hpp
deleted file mode 100644
index 9b6eb000..00000000
--- a/src/libs/engine/ObjectSender.hpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef OBJECTSENDER_H
-#define OBJECTSENDER_H
-
-#include <list>
-
-namespace Ingen {
-
-namespace Shared {
- class ClientInterface;
-} using Shared::ClientInterface;
-
-class PatchImpl;
-class NodeImpl;
-class PortImpl;
-class PluginImpl;
-
-
-/** Utility class for sending GraphObjects to clients through ClientInterface.
- *
- * While ClientInterface is the direct low level message-based interface
- * (protocol), this is used from the engine to easily send proper Objects
- * with these messages (which is done in a few different parts of the code).
- *
- * Basically a serialiser, except to calls on ClientInterface rather than
- * eg a byte stream.
- */
-class ObjectSender {
-public:
-
- // FIXME: Make all object parameters const
-
- static void send_patch(ClientInterface* client, const PatchImpl* patch, bool recursive);
- static void send_node(ClientInterface* client, const NodeImpl* node, bool recursive);
- static void send_port(ClientInterface* client, const PortImpl* port);
-};
-
-} // namespace Ingen
-
-#endif // OBJECTSENDER_H
-
diff --git a/src/libs/engine/OmInProcess.cpp b/src/libs/engine/OmInProcess.cpp
deleted file mode 100644
index 6a65cf38..00000000
--- a/src/libs/engine/OmInProcess.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/* This file is part of Ingen. Copyright (C) 2006 Mario Lang.
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <pthread.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <memory.h>
-#include <jack/jack.h>
-#include "Engine.hpp"
-#include "OSCReceiver.hpp"
-#include "JackAudioDriver.hpp"
-
-extern "C"
-{
- int jack_initialize(jack_client_t* client, const char* load_init);
- void jack_finish(void* arg);
-}
-
-
-void*
-run_main(void* arg)
-{
- Engine::instance().main();
-
- // FIXME: cleanup
-
- return 0;
-}
-
-
-pthread_t main_thread;
-
-
-int
-jack_initialize(jack_client_t* client, const char* load_init)
-{
- if ((Ingen::om = new Engine(load_init, new Ingen::JackAudioDriver(client))) != NULL) {
- pthread_create(&main_thread, NULL, run_main, NULL);
- return 0; // Success
- } else {
- return 1;
- }
-}
-
-
-void
-jack_finish(void* arg)
-{
- void* ret;
- Engine::instance().quit();
- pthread_join(main_thread, &ret);
-}
-
diff --git a/src/libs/engine/OutputPort.cpp b/src/libs/engine/OutputPort.cpp
deleted file mode 100644
index 116d9a3e..00000000
--- a/src/libs/engine/OutputPort.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <iostream>
-#include "OutputPort.hpp"
-#include "Buffer.hpp"
-#include "ProcessContext.hpp"
-
-using namespace std;
-
-namespace Ingen {
-
-
-OutputPort::OutputPort(NodeImpl* parent,
- const string& name,
- uint32_t index,
- uint32_t poly,
- DataType type,
- const Atom& value,
- size_t buffer_size)
- : PortImpl(parent, name, index, poly, type, value, buffer_size)
-{
- if (type == DataType::CONTROL)
- _broadcast = true;
-}
-
-
-void
-OutputPort::pre_process(ProcessContext& context)
-{
- for (uint32_t i=0; i < _poly; ++i)
- buffer(i)->prepare_write(context.start(), context.nframes());
-}
-
-
-void
-OutputPort::post_process(ProcessContext& context)
-{
- for (uint32_t i=0; i < _poly; ++i)
- buffer(i)->prepare_read(context.start(), context.nframes());
-
- //cerr << path() << " output post: buffer: " << buffer(0) << endl;
-
- broadcast(context);
-}
-
-
-} // namespace Ingen
diff --git a/src/libs/engine/OutputPort.hpp b/src/libs/engine/OutputPort.hpp
deleted file mode 100644
index 8d441b5c..00000000
--- a/src/libs/engine/OutputPort.hpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef OUTPUTPORT_H
-#define OUTPUTPORT_H
-
-#include <string>
-#include <cstdlib>
-#include "PortImpl.hpp"
-#include "types.hpp"
-
-namespace Ingen {
-
-
-/** An output port.
- *
- * Output ports always have a locally allocated buffer, and buffer() will
- * always return that buffer. (This is very different from InputPort)
- *
- * This class actually adds no functionality to Port whatsoever right now,
- * it will in the future when more advanced port types exist, and it makes
- * things clearer throughout the engine.
- *
- * \ingroup engine
- */
-class OutputPort : virtual public PortImpl
-{
-public:
- OutputPort(NodeImpl* parent,
- const std::string& name,
- uint32_t index,
- uint32_t poly,
- DataType type,
- const Atom& value,
- size_t buffer_size);
-
- void pre_process(ProcessContext& context);
- void post_process(ProcessContext& context);
-
- virtual ~OutputPort() {}
-
- bool is_input() const { return false; }
- bool is_output() const { return true; }
-};
-
-
-} // namespace Ingen
-
-#endif // OUTPUTPORT_H
diff --git a/src/libs/engine/PatchImpl.cpp b/src/libs/engine/PatchImpl.cpp
deleted file mode 100644
index 9f0ae701..00000000
--- a/src/libs/engine/PatchImpl.cpp
+++ /dev/null
@@ -1,481 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <cassert>
-#include <cmath>
-#include <iostream>
-#include "ThreadManager.hpp"
-#include "NodeImpl.hpp"
-#include "PatchImpl.hpp"
-#include "PatchPlugin.hpp"
-#include "PortImpl.hpp"
-#include "ConnectionImpl.hpp"
-#include "DuplexPort.hpp"
-#include "Engine.hpp"
-#include "ProcessSlave.hpp"
-
-using namespace std;
-
-namespace Ingen {
-
-
-PatchImpl::PatchImpl(Engine& engine, const string& path, uint32_t poly, PatchImpl* parent, SampleRate srate, size_t buffer_size, uint32_t internal_poly)
- : NodeBase(new PatchPlugin("http://example.org/FIXME", "patch", "Ingen Patch"),
- path, poly, parent, srate, buffer_size)
- , _engine(engine)
- , _internal_poly(internal_poly)
- , _compiled_patch(NULL)
- , _process(false)
-{
- assert(internal_poly >= 1);
-}
-
-
-PatchImpl::~PatchImpl()
-{
- assert(!_activated);
-
- delete _compiled_patch;
-}
-
-
-void
-PatchImpl::activate()
-{
- NodeBase::activate();
-
- for (List<NodeImpl*>::iterator i = _nodes.begin(); i != _nodes.end(); ++i)
- (*i)->activate();
-
- assert(_activated);
-}
-
-
-void
-PatchImpl::deactivate()
-{
- if (_activated) {
-
- NodeBase::deactivate();
-
- for (List<NodeImpl*>::iterator i = _nodes.begin(); i != _nodes.end(); ++i) {
- if ((*i)->activated())
- (*i)->deactivate();
- assert(!(*i)->activated());
- }
- }
- assert(!_activated);
-}
-
-
-void
-PatchImpl::disable()
-{
- assert(ThreadManager::current_thread_id() == THREAD_PROCESS);
-
- _process = false;
-
- for (List<PortImpl*>::iterator i = _output_ports.begin(); i != _output_ports.end(); ++i)
- (*i)->clear_buffers();
-}
-
-
-bool
-PatchImpl::prepare_internal_poly(uint32_t poly)
-{
- assert(ThreadManager::current_thread_id() == THREAD_PRE_PROCESS);
-
- /* TODO: ports? internal/external poly? */
-
- for (List<NodeImpl*>::iterator i = _nodes.begin(); i != _nodes.end(); ++i)
- (*i)->prepare_poly(poly);
-
- for (Connections::iterator i = _connections.begin(); i != _connections.end(); ++i)
- ((ConnectionImpl*)i->get())->prepare_poly(poly);
-
- /* FIXME: Deal with failure */
-
- return true;
-}
-
-
-bool
-PatchImpl::apply_internal_poly(Raul::Maid& maid, uint32_t poly)
-{
- assert(ThreadManager::current_thread_id() == THREAD_PROCESS);
-
- /* TODO: ports? internal/external poly? */
-
- for (List<NodeImpl*>::iterator i = _nodes.begin(); i != _nodes.end(); ++i)
- (*i)->apply_poly(maid, poly);
-
- _internal_poly = poly;
-
- return true;
-}
-
-
-/** Run the patch for the specified number of frames.
- *
- * Calls all Nodes in (roughly, if parallel) the order _compiled_patch specifies.
- */
-void
-PatchImpl::process(ProcessContext& context)
-{
- if (!_process)
- return;
-
- NodeBase::pre_process(context);
-
- /*if (_ports)
- for (size_t i=0; i < _ports->size(); ++i)
- if (_ports->at(i)->is_input() && _ports->at(i)->type() == DataType::MIDI)
- cerr << _ports->at(i)->path() << " "
- << _ports->at(i)->buffer(0) << " # events: "
- << ((MidiBuffer*)_ports->at(i)->buffer(0))->event_count() << endl;*/
-
- /* Run */
- if (_compiled_patch && _compiled_patch->size() > 0) {
- if (_engine.process_slaves().size() > 0)
- process_parallel(context);
- else
- process_single(context);
- }
-
- NodeBase::post_process(context);
-}
-
-
-void
-PatchImpl::process_parallel(ProcessContext& context)
-{
- size_t n_slaves = _engine.process_slaves().size();
-
- CompiledPatch* const cp = _compiled_patch;
-
- /* Start p-1 slaves */
-
- if (n_slaves >= cp->size())
- n_slaves = cp->size()-1;
-
- if (n_slaves > 0) {
- for (size_t i=0; i < cp->size(); ++i)
- (*cp)[i].node()->reset_input_ready();
-
- for (size_t i=0; i < n_slaves; ++i)
- _engine.process_slaves()[i]->whip(cp, i+1, context);
- }
-
-
- /* Process ourself until everything is done
- * This is analogous to ProcessSlave::_whipped(), but this is the master
- * (i.e. what the main Jack process thread calls). Where ProcessSlave
- * waits on input, this just skips the node and tries the next, to avoid
- * waiting in the Jack thread which pisses Jack off.
- */
-
- size_t index = 0;
- size_t num_finished = 0; // Number of consecutive finished nodes hit
-
- while (num_finished < cp->size()) {
-
- CompiledNode& n = (*cp)[index];
-
- if (n.node()->process_lock()) {
- if (n.node()->n_inputs_ready() == n.n_providers()) {
- n.node()->process(context);
-
- /* Signal dependants their input is ready */
- for (size_t i=0; i < n.dependants().size(); ++i)
- n.dependants()[i]->signal_input_ready();
-
- ++num_finished;
- } else {
- n.node()->process_unlock();
- num_finished = 0;
- }
- } else {
- if (n.node()->n_inputs_ready() == n.n_providers())
- ++num_finished;
- else
- num_finished = 0;
- }
-
- index = (index + 1) % cp->size();
- }
-
- /* Tell slaves we're done in case we beat them, and pray they're
- * really done by the start of next cycle.
- * FIXME: This probably breaks (race) at extremely small nframes where
- * ingen is the majority of the DSP load.
- */
- for (size_t i=0; i < n_slaves; ++i)
- _engine.process_slaves()[i]->finish();
-}
-
-
-void
-PatchImpl::process_single(ProcessContext& context)
-{
- CompiledPatch* const cp = _compiled_patch;
-
- for (size_t i=0; i < cp->size(); ++i)
- (*cp)[i].node()->process(context);
-}
-
-
-void
-PatchImpl::set_buffer_size(size_t size)
-{
- NodeBase::set_buffer_size(size);
- assert(_buffer_size == size);
-
- CompiledPatch* const cp = _compiled_patch;
-
- for (size_t i=0; i < cp->size(); ++i)
- (*cp)[i].node()->set_buffer_size(size);
-}
-
-
-// Patch specific stuff
-
-
-/** Add a node.
- * Preprocessing thread only.
- */
-void
-PatchImpl::add_node(List<NodeImpl*>::Node* ln)
-{
- assert(ThreadManager::current_thread_id() == THREAD_PRE_PROCESS);
- assert(ln != NULL);
- assert(ln->elem() != NULL);
- assert(ln->elem()->parent_patch() == this);
- //assert(ln->elem()->polyphony() == _internal_poly);
-
- _nodes.push_back(ln);
-}
-
-
-/** Remove a node.
- * Preprocessing thread only.
- */
-PatchImpl::Nodes::Node*
-PatchImpl::remove_node(const string& symbol)
-{
- assert(ThreadManager::current_thread_id() == THREAD_PRE_PROCESS);
- for (List<NodeImpl*>::iterator i = _nodes.begin(); i != _nodes.end(); ++i)
- if ((*i)->symbol() == symbol)
- return _nodes.erase(i);
-
- return NULL;
-}
-
-
-/** Remove a connection.
- * Preprocessing thread only.
- */
-PatchImpl::Connections::Node*
-PatchImpl::remove_connection(const PortImpl* src_port, const PortImpl* dst_port)
-{
- assert(ThreadManager::current_thread_id() == THREAD_PRE_PROCESS);
- bool found = false;
- Connections::Node* connection = NULL;
- for (Connections::iterator i = _connections.begin(); i != _connections.end(); ++i) {
- ConnectionImpl* const c = (ConnectionImpl*)i->get();
- if (c->src_port() == src_port && c->dst_port() == dst_port) {
- connection = _connections.erase(i);
- found = true;
- break;
- }
- }
-
- if ( ! found)
- cerr << "WARNING: [PatchImpl::remove_connection] Connection not found !" << endl;
-
- return connection;
-}
-
-
-bool
-PatchImpl::has_connection(const PortImpl* src_port, const PortImpl* dst_port) const
-{
- // FIXME: Doesn't scale
- for (Connections::const_iterator i = _connections.begin(); i != _connections.end(); ++i) {
- ConnectionImpl* const c = (ConnectionImpl*)i->get();
- if (c->src_port() == src_port && c->dst_port() == dst_port)
- return true;
- }
-
- return false;
-}
-
-
-uint32_t
-PatchImpl::num_ports() const
-{
- ThreadID context = ThreadManager::current_thread_id();
-
- if (context == THREAD_PROCESS)
- return NodeBase::num_ports();
- else
- return _input_ports.size() + _output_ports.size();
-}
-
-
-/** Create a port. Not realtime safe.
- */
-PortImpl*
-PatchImpl::create_port(const string& name, DataType type, size_t buffer_size, bool is_output)
-{
- if (type == DataType::UNKNOWN) {
- cerr << "[PatchImpl::create_port] Unknown port type " << type.uri() << endl;
- return NULL;
- }
-
- assert( !(type == DataType::UNKNOWN) );
-
- return new DuplexPort(this, name, num_ports(), _polyphony, type, Atom(), buffer_size, is_output);
-}
-
-
-/** Remove port from ports list used in pre-processing thread.
- *
- * Port is not removed from ports array for process thread (which could be
- * simultaneously running).
- *
- * Realtime safe. Preprocessing thread only.
- */
-List<PortImpl*>::Node*
-PatchImpl::remove_port(const string& symbol)
-{
- assert(ThreadManager::current_thread_id() == THREAD_PRE_PROCESS);
-
-