summaryrefslogtreecommitdiffstats
path: root/src/libs
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-07-29 04:39:59 +0000
committerDavid Robillard <d@drobilla.net>2008-07-29 04:39:59 +0000
commitde58b508b28a42b072fb26d2633aa0af37ee7c0e (patch)
treede1ea38fe51dabe98b21f8533885ec3c1030069b /src/libs
parent99aacf95b16b828ca5f50d7dab34487240d07eff (diff)
downloadingen-de58b508b28a42b072fb26d2633aa0af37ee7c0e.tar.gz
ingen-de58b508b28a42b072fb26d2633aa0af37ee7c0e.tar.bz2
ingen-de58b508b28a42b072fb26d2633aa0af37ee7c0e.zip
Bump Ingen librdf dependency to 1.0.8.
Several serialization fixes. Include Smack 808 Om patches converted to Ingen files. git-svn-id: http://svn.drobilla.net/lad/ingen@1301 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/client/DeprecatedLoader.cpp7
-rw-r--r--src/libs/engine/MidiControlNode.cpp4
-rw-r--r--src/libs/engine/MidiNoteNode.cpp8
-rw-r--r--src/libs/engine/MidiTriggerNode.cpp13
-rw-r--r--src/libs/engine/events/ConnectionEvent.cpp42
-rw-r--r--src/libs/serialisation/Loader.cpp8
-rw-r--r--src/libs/serialisation/Serialiser.cpp34
7 files changed, 75 insertions, 41 deletions
diff --git a/src/libs/client/DeprecatedLoader.cpp b/src/libs/client/DeprecatedLoader.cpp
index fa1dc7b9..e5179fa0 100644
--- a/src/libs/client/DeprecatedLoader.cpp
+++ b/src/libs/client/DeprecatedLoader.cpp
@@ -72,9 +72,9 @@ DeprecatedLoader::translate_load_path(const string& path)
// (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")
+ 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")
+ 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";
@@ -284,7 +284,8 @@ DeprecatedLoader::load_patch(const Glib::ustring& filename,
list<ControlModel>::const_iterator i = pm->controls().begin();
for ( ; i != pm->controls().end(); ++i) {
const float value = i->value();
- _engine->set_port_value(i->port_path(), "ingen:Float", sizeof(float), &value);
+ _engine->set_port_value(translate_load_path(i->port_path()),
+ "ingen:Float", sizeof(float), &value);
}
} else {
cerr << "WARNING: Unknown preset: \"" << pm->name() << endl;
diff --git a/src/libs/engine/MidiControlNode.cpp b/src/libs/engine/MidiControlNode.cpp
index d9c426e3..afd588ea 100644
--- a/src/libs/engine/MidiControlNode.cpp
+++ b/src/libs/engine/MidiControlNode.cpp
@@ -48,11 +48,11 @@ MidiControlNode::MidiControlNode(const string& path,
_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", 1);
+ _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", 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);
diff --git a/src/libs/engine/MidiNoteNode.cpp b/src/libs/engine/MidiNoteNode.cpp
index 729cf2c3..3c4f0e56 100644
--- a/src/libs/engine/MidiNoteNode.cpp
+++ b/src/libs/engine/MidiNoteNode.cpp
@@ -57,11 +57,11 @@ MidiNoteNode::MidiNoteNode(const string& path, bool polyphonic, PatchImpl* paren
_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", 1);
+ _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", 1);
+ _trig_port->set_variable("ingen:toggled", true);
_ports->at(4) = _trig_port;
}
@@ -225,8 +225,8 @@ MidiNoteNode::note_on(uchar note_num, uchar velocity, FrameTime time, ProcessCon
assert(voice != NULL);
assert(voice == &(*_voices)[voice_num]);
- //cerr << "[MidiNoteNode] Note " << (int)note_num << " on @ " << time
- // << ". Voice " << voice_num << " / " << _polyphony << endl;
+ cerr << "[MidiNoteNode] Note " << (int)note_num << " on @ " << time
+ << ". Voice " << voice_num << " / " << _polyphony << endl;
// Update stolen key, if applicable
if (voice->state == Voice::Voice::ACTIVE) {
diff --git a/src/libs/engine/MidiTriggerNode.cpp b/src/libs/engine/MidiTriggerNode.cpp
index 0ae67c27..5fa1cd4b 100644
--- a/src/libs/engine/MidiTriggerNode.cpp
+++ b/src/libs/engine/MidiTriggerNode.cpp
@@ -26,6 +26,8 @@
#include "EventBuffer.hpp"
#include "util.hpp"
+using namespace std;
+
namespace Ingen {
@@ -41,7 +43,7 @@ MidiTriggerNode::MidiTriggerNode(const string& path, bool polyphonic, PatchImpl*
_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", 1);
+ _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);
@@ -105,11 +107,14 @@ MidiTriggerNode::note_on(uchar note_num, uchar velocity, FrameTime time, Process
assert(time >= context.start() && time <= context.end());
assert(time - context.start() < _buffer_size);
- //std::cerr << "Note on starting at sample " << offset << std::endl;
+ cerr << "[MidiTriggerNode] " << path() << " Note " << (int)note_num << " on @ " << time << endl;
- const 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)){
+ Sample filter_note = ((AudioBuffer*)_note_port->buffer(0))->value_at(0);
+ cerr << "note: " << (int)note_num << ", filter: " << filter_note << endl;
+ if (filter_note >= 0.0 && filter_note < 127.0 && (note_num == (uchar)filter_note)) {
+ cerr << "!\n";
+
// FIXME FIXME FIXME
SampleCount offset = time - context.start();
diff --git a/src/libs/engine/events/ConnectionEvent.cpp b/src/libs/engine/events/ConnectionEvent.cpp
index 4c8e7f72..893dc9cb 100644
--- a/src/libs/engine/events/ConnectionEvent.cpp
+++ b/src/libs/engine/events/ConnectionEvent.cpp
@@ -15,20 +15,22 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "ConnectionEvent.hpp"
+
#include <string>
+#include <boost/format.hpp>
#include <raul/Maid.hpp>
#include <raul/Path.hpp>
-#include "Responder.hpp"
-#include "types.hpp"
-#include "Engine.hpp"
+#include "ClientBroadcaster.hpp"
+#include "ConnectionEvent.hpp"
#include "ConnectionImpl.hpp"
+#include "Engine.hpp"
#include "InputPort.hpp"
+#include "ObjectStore.hpp"
#include "OutputPort.hpp"
#include "PatchImpl.hpp"
-#include "ClientBroadcaster.hpp"
#include "PortImpl.hpp"
-#include "ObjectStore.hpp"
+#include "Responder.hpp"
+#include "types.hpp"
using std::string;
namespace Ingen {
@@ -164,15 +166,33 @@ ConnectionEvent::execute(ProcessContext& context)
void
ConnectionEvent::post_process()
{
+ std::ostringstream ss;
if (_error == NO_ERROR) {
_responder->respond_ok();
_engine.broadcaster()->send_connection(_connection);
- } else {
- // FIXME: better error messages
- string msg = "Unable to make connection ";
- msg.append(_src_port_path + " -> " + _dst_port_path);
- _responder->respond_error(msg);
+ return;
+ }
+
+ ss << boost::format("Unable to make connection %1% -> %2% (") % _src_port_path % _dst_port_path;
+
+ switch (_error) {
+ case PARENT_PATCH_DIFFERENT:
+ ss << "Ports have mismatched parents"; break;
+ case PORT_NOT_FOUND:
+ ss << "Port not found"; break;
+ case TYPE_MISMATCH:
+ ss << "Type mismatch"; break;
+ case DIRECTION_MISMATCH:
+ ss << "Direction mismatch"; break;
+ case ALREADY_CONNECTED:
+ ss << "Already connected"; break;
+ case PARENTS_NOT_FOUND:
+ ss << "Parents not found"; break;
+ default:
+ ss << "Unknown error";
}
+ ss << ")";
+ _responder->respond_error(ss.str());
}
diff --git a/src/libs/serialisation/Loader.cpp b/src/libs/serialisation/Loader.cpp
index da2e6507..6708a0e3 100644
--- a/src/libs/serialisation/Loader.cpp
+++ b/src/libs/serialisation/Loader.cpp
@@ -212,8 +212,9 @@ Loader::load(Ingen::Shared::World* world,
const string port_name = (*i)["portname"].to_string();
const float val = (*i)["portval"].to_float();
- const Path port_path = patch_path.base() + Path::nameify(node_name)
- +"/"+ Path::nameify(port_name);
+ assert(Path::is_valid_name(node_name));
+ assert(Path::is_valid_name(port_name));
+ const Path port_path = patch_path.base() + node_name + "/" + port_name;
world->engine->set_port_value(port_path, "ingen:Float", sizeof(float), &val);
}
@@ -243,7 +244,8 @@ Loader::load(Ingen::Shared::World* world,
const string type = world->rdf_world->qualify((*i)["type"].to_string());
const string datatype = world->rdf_world->qualify((*i)["datatype"].to_string());
- const Path port_path = patch_path.base() + (string)name;
+ assert(Path::is_valid_name(name));
+ const Path port_path = patch_path.base() + name;
if (created.find(port_path) == created.end()) {
bool is_output = (type == "ingen:OutputPort"); // FIXME: check validity
diff --git a/src/libs/serialisation/Serialiser.cpp b/src/libs/serialisation/Serialiser.cpp
index a81c76f6..710a538c 100644
--- a/src/libs/serialisation/Serialiser.cpp
+++ b/src/libs/serialisation/Serialiser.cpp
@@ -100,9 +100,15 @@ Serialiser::start_to_filename(const string& filename)
{
setlocale(LC_NUMERIC, "C");
- _base_uri = "file://" + filename;
+ cout << "STARTING SERIALIZATION TO FILENAME: " << filename << endl;
+
+ assert(filename.find(":") == string::npos || filename.substr(0, 5) == "file:");
+ if (filename.find(":") == string::npos)
+ _base_uri = "file://" + filename;
+ else
+ _base_uri = filename;
_model = new Redland::Model(_world);
- _model->set_base_uri(string("file://" + filename));
+ _model->set_base_uri(_base_uri);
_mode = TO_FILE;
}
@@ -429,19 +435,19 @@ void
Serialiser::serialise_variables(Redland::Node subject, const GraphObject::Variables& variables)
{
for (GraphObject::Variables::const_iterator v = variables.begin(); v != variables.end(); ++v) {
- if (v->first.find(":") != string::npos) {
+ if (v->first.find(":") != string::npos && v->first != "ingen:document") {
if (v->second.is_valid()) {
- const Redland::Node var_id = _world.blank_id();
- const Redland::Node key(_model->world(), Redland::Node::RESOURCE, v->first);
- const Redland::Node value = AtomRDF::atom_to_node(_model->world(), v->second);
- if (value) {
- _model->add_statement(subject, "ingen:variable", var_id);
- _model->add_statement(var_id, "ingen:key", key);
- _model->add_statement(var_id, "ingen:value", value);
- } else {
- cerr << "Warning: can not serialise value: key '" << v->first << "', type "
- << (int)v->second.type() << endl;
- }
+ const Redland::Node var_id = _world.blank_id();
+ const Redland::Node key(_model->world(), Redland::Node::RESOURCE, v->first);
+ const Redland::Node value = AtomRDF::atom_to_node(_model->world(), v->second);
+ if (value) {
+ _model->add_statement(subject, "ingen:variable", var_id);
+ _model->add_statement(var_id, "ingen:key", key);
+ _model->add_statement(var_id, "ingen:value", value);
+ } else {
+ cerr << "Warning: can not serialise value: key '" << v->first << "', type "
+ << (int)v->second.type() << endl;
+ }
} else {
cerr << "Warning: variable with no value: key '" << v->first << "'" << endl;
}