summaryrefslogtreecommitdiffstats
path: root/src/engine/events
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/events')
-rw-r--r--src/engine/events/EnablePatchEvent.cpp86
-rw-r--r--src/engine/events/EnablePatchEvent.hpp63
-rw-r--r--src/engine/events/SetMetadataEvent.cpp93
-rw-r--r--src/engine/events/SetMetadataEvent.hpp15
-rw-r--r--src/engine/events/SetPolyphonicEvent.cpp82
-rw-r--r--src/engine/events/SetPolyphonicEvent.hpp56
-rw-r--r--src/engine/events/SetPolyphonyEvent.cpp79
-rw-r--r--src/engine/events/SetPolyphonyEvent.hpp56
8 files changed, 94 insertions, 436 deletions
diff --git a/src/engine/events/EnablePatchEvent.cpp b/src/engine/events/EnablePatchEvent.cpp
deleted file mode 100644
index 04759cea..00000000
--- a/src/engine/events/EnablePatchEvent.cpp
+++ /dev/null
@@ -1,86 +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 "EnablePatchEvent.hpp"
-#include "Responder.hpp"
-#include "Engine.hpp"
-#include "PatchImpl.hpp"
-#include "util.hpp"
-#include "ClientBroadcaster.hpp"
-#include "EngineStore.hpp"
-
-namespace Ingen {
-
-
-EnablePatchEvent::EnablePatchEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, const string& patch_path, bool enable)
-: QueuedEvent(engine, responder, timestamp),
- _patch_path(patch_path),
- _patch(NULL),
- _compiled_patch(NULL),
- _enable(enable)
-{
-}
-
-
-void
-EnablePatchEvent::pre_process()
-{
- _patch = _engine.engine_store()->find_patch(_patch_path);
-
- if (_enable && _patch) {
- /* Any event that requires a new process order will set the patch's
- * compiled_patch to NULL if it is executed when the patch is not
- * active. So, if the CP is NULL, calculate it here */
- if (_patch->compiled_patch() == NULL)
- _compiled_patch = _patch->compile();
- }
-
- QueuedEvent::pre_process();
-}
-
-
-void
-EnablePatchEvent::execute(ProcessContext& context)
-{
- QueuedEvent::execute(context);
-
- if (_patch != NULL) {
- if (_enable)
- _patch->enable();
- else
- _patch->disable();
-
- if (_enable && _patch->compiled_patch() == NULL)
- _patch->compiled_patch(_compiled_patch);
- }
-}
-
-
-void
-EnablePatchEvent::post_process()
-{
- if (_patch != NULL) {
- _responder->respond_ok();
- _engine.broadcaster()->send_property_change(_patch_path, "ingen:enabled", (bool)_enable);
- } else {
- _responder->respond_error(string("Patch ") + _patch_path + " not found");
- }
-}
-
-
-} // namespace Ingen
-
diff --git a/src/engine/events/EnablePatchEvent.hpp b/src/engine/events/EnablePatchEvent.hpp
deleted file mode 100644
index dad1803a..00000000
--- a/src/engine/events/EnablePatchEvent.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 ENABLEPATCHEVENT_H
-#define ENABLEPATCHEVENT_H
-
-#include <string>
-#include "QueuedEvent.hpp"
-
-using std::string;
-
-namespace Raul { template <typename T> class Array; }
-
-namespace Ingen {
-
-class PatchImpl;
-class NodeImpl;
-class CompiledPatch;
-
-
-/** Enables a patch's DSP processing.
- *
- * \ingroup engine
- */
-class EnablePatchEvent : public QueuedEvent
-{
-public:
- EnablePatchEvent(Engine& engine,
- SharedPtr<Responder> responder,
- SampleCount timestamp,
- const string& patch_path,
- bool enable);
-
- void pre_process();
- void execute(ProcessContext& context);
- void post_process();
-
-private:
- string _patch_path;
- PatchImpl* _patch;
- CompiledPatch* _compiled_patch; // Patch's new process order
- bool _enable;
-};
-
-
-} // namespace Ingen
-
-
-#endif // ENABLEPATCHEVENT_H
diff --git a/src/engine/events/SetMetadataEvent.cpp b/src/engine/events/SetMetadataEvent.cpp
index 8caede6e..e0b51f2b 100644
--- a/src/engine/events/SetMetadataEvent.cpp
+++ b/src/engine/events/SetMetadataEvent.cpp
@@ -23,6 +23,7 @@
#include "PortImpl.hpp"
#include "ClientBroadcaster.hpp"
#include "GraphObjectImpl.hpp"
+#include "PatchImpl.hpp"
#include "EngineStore.hpp"
using std::string;
@@ -46,6 +47,8 @@ SetMetadataEvent::SetMetadataEvent(
, _key(key)
, _value(value)
, _object(NULL)
+ , _patch(NULL)
+ , _compiled_patch(NULL)
{
}
@@ -61,17 +64,47 @@ SetMetadataEvent::pre_process()
_object = _engine.engine_store()->find_object(_path);
if (_object == NULL) {
+ _error = NOT_FOUND;
QueuedEvent::pre_process();
return;
}
+ /*cerr << "SET " << _object->path() << (_property ? " PROP " : " VAR ")
+ << _key << " :: " << _value.type() << endl;*/
+
if (_property)
_object->set_property(_key, _value);
else
_object->set_variable(_key, _value);
- if (_key == "ingen:broadcast")
+ _patch = dynamic_cast<PatchImpl*>(_object);
+
+ if (_key == "ingen:broadcast") {
_special_type = ENABLE_BROADCAST;
+ } else if (_patch) {
+ if (!_property && _key == "ingen:enabled") {
+ if (_value.type() == Atom::BOOL) {
+ _special_type = ENABLE;
+ if (_value.get_bool() && !_patch->compiled_patch())
+ _compiled_patch = _patch->compile();
+ } else {
+ _error = BAD_TYPE;
+ }
+ } else if (!_property && _key == "ingen:polyphonic") {
+ if (_value.type() == Atom::BOOL) {
+ _special_type = POLYPHONIC;
+ } else {
+ _error = BAD_TYPE;
+ }
+ } else if (_property && _key == "ingen:polyphony") {
+ if (_value.type() == Atom::INT) {
+ _special_type = POLYPHONY;
+ _patch->prepare_internal_poly(_value.get_int32());
+ } else {
+ _error = BAD_TYPE;
+ }
+ }
+ }
QueuedEvent::pre_process();
}
@@ -80,33 +113,69 @@ SetMetadataEvent::pre_process()
void
SetMetadataEvent::execute(ProcessContext& context)
{
- if (_special_type == ENABLE_BROADCAST) {
- PortImpl* port = dynamic_cast<PortImpl*>(_object);
- if (port)
+ if (_error != NO_ERROR)
+ return;
+
+ PortImpl* port = 0;
+ switch (_special_type) {
+ case ENABLE_BROADCAST:
+ if ((port = dynamic_cast<PortImpl*>(_object)))
port->broadcast(_value.get_bool());
- }
+ break;
+ case ENABLE:
+ if (_value.get_bool()) {
+ if (!_patch->compiled_patch())
+ _patch->compiled_patch(_compiled_patch);
+ _patch->enable();
+ } else {
+ _patch->disable();
+ }
+ break;
+ case POLYPHONIC:
+ if (!_object->set_polyphonic(*_engine.maid(), _value.get_bool()))
+ _error = INTERNAL;
+ break;
+ case POLYPHONY:
+ if (!_patch->apply_internal_poly(*_engine.maid(), _value.get_int32()))
+ _error = INTERNAL;
+ break;
+ default:
+ _success = true;
+ }
QueuedEvent::execute(context);
- // Do nothing
}
void
SetMetadataEvent::post_process()
{
- if (_error == INVALID_PATH) {
- _responder->respond_error((boost::format("Invalid path '%1%' setting '%2%'") % _path % _key).str());
- } else if (_object == NULL) {
- string msg = (boost::format("Unable to find object '%1%' to set '%2%'") % _path % _key).str();
- _responder->respond_error(msg);
- } else {
+ switch (_error) {
+ case NO_ERROR:
_responder->respond_ok();
if (_property)
_engine.broadcaster()->send_property_change(_path, _key, _value);
else
_engine.broadcaster()->send_variable_change(_path, _key, _value);
+ break;
+ case NOT_FOUND:
+ _responder->respond_error((boost::format(
+ "Unable to find object '%1%' to set '%2%'")
+ % _path % _key).str());
+ case INTERNAL:
+ _responder->respond_error("Internal error");
+ break;
+ case INVALID_PATH:
+ _responder->respond_error((boost::format(
+ "Invalid path '%1%' setting '%2%'")
+ % _path % _key).str());
+ break;
+ case BAD_TYPE:
+ _responder->respond_error((boost::format("Bad type for '%1%'") % _key).str());
+ break;
}
}
} // namespace Ingen
+
diff --git a/src/engine/events/SetMetadataEvent.hpp b/src/engine/events/SetMetadataEvent.hpp
index ef1538b7..09774fe9 100644
--- a/src/engine/events/SetMetadataEvent.hpp
+++ b/src/engine/events/SetMetadataEvent.hpp
@@ -27,6 +27,8 @@ using std::string;
namespace Ingen {
class GraphObjectImpl;
+class PatchImpl;
+class CompiledPatch;
/** An event to set a piece of variable for an GraphObjectImpl.
@@ -49,14 +51,23 @@ public:
void post_process();
private:
- enum { NO_ERROR, INVALID_PATH } _error;
- enum { NONE, ENABLE_BROADCAST } _special_type;
+ enum { NO_ERROR, NOT_FOUND, INTERNAL, INVALID_PATH, BAD_TYPE } _error;
+ enum {
+ NONE,
+ ENABLE,
+ ENABLE_BROADCAST,
+ POLYPHONY,
+ POLYPHONIC
+ } _special_type;
bool _property;
+ bool _success;
string _path;
string _key;
Raul::Atom _value;
GraphObjectImpl* _object;
+ PatchImpl* _patch;
+ CompiledPatch* _compiled_patch;
};
diff --git a/src/engine/events/SetPolyphonicEvent.cpp b/src/engine/events/SetPolyphonicEvent.cpp
deleted file mode 100644
index 87e03d9e..00000000
--- a/src/engine/events/SetPolyphonicEvent.cpp
+++ /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
- */
-
-#include "raul/Maid.hpp"
-#include "SetPolyphonicEvent.hpp"
-#include "Responder.hpp"
-#include "Engine.hpp"
-#include "PatchImpl.hpp"
-#include "ClientBroadcaster.hpp"
-#include "util.hpp"
-#include "EngineStore.hpp"
-#include "PortImpl.hpp"
-#include "NodeImpl.hpp"
-#include "ConnectionImpl.hpp"
-#include "QueuedEventSource.hpp"
-
-namespace Ingen {
-
-
-SetPolyphonicEvent::SetPolyphonicEvent(Engine& engine, SharedPtr<Responder> responder, FrameTime time, QueuedEventSource* source, const string& path, bool poly)
-: QueuedEvent(engine, responder, time, true, source),
- _path(path),
- _object(NULL),
- _poly(poly),
- _success(false)
-{
-}
-
-
-void
-SetPolyphonicEvent::pre_process()
-{
- _object = _engine.engine_store()->find_object(_path);
-
- QueuedEvent::pre_process();
-}
-
-
-void
-SetPolyphonicEvent::execute(ProcessContext& context)
-{
- QueuedEvent::execute(context);
-
- if (_object)
- _success = _object->set_polyphonic(*_engine.maid(), _poly);
-
- _source->unblock();
-}
-
-
-void
-SetPolyphonicEvent::post_process()
-{
- if (_object) {
- if (_success) {
- _responder->respond_ok();
- _engine.broadcaster()->send_property_change(_path, "ingen:polyphonic", _poly);
- } else {
- _responder->respond_error("Unable to set object as polyphonic");
- }
- } else {
- _responder->respond_error("Unable to find object to set polyphonic");
- }
-}
-
-
-} // namespace Ingen
-
diff --git a/src/engine/events/SetPolyphonicEvent.hpp b/src/engine/events/SetPolyphonicEvent.hpp
deleted file mode 100644
index 93505cba..00000000
--- a/src/engine/events/SetPolyphonicEvent.hpp
+++ /dev/null
@@ -1,56 +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 SETPOLYPHONICEVENT_H
-#define SETPOLYPHONICEVENT_H
-
-#include <string>
-#include "raul/Array.hpp"
-#include "QueuedEvent.hpp"
-
-using std::string;
-
-namespace Ingen {
-
-class GraphObjectImpl;
-
-
-/** Delete all nodes from a patch.
- *
- * \ingroup engine
- */
-class SetPolyphonicEvent : public QueuedEvent
-{
-public:
- SetPolyphonicEvent(Engine& engine, SharedPtr<Responder> responder, FrameTime time, QueuedEventSource* source, const string& path, bool poly);
-
- void pre_process();
- void execute(ProcessContext& context);
- void post_process();
-
-private:
- const string _path;
- GraphObjectImpl* _object;
- bool _poly;
- bool _success;
-};
-
-
-} // namespace Ingen
-
-
-#endif // SETPOLYPHONICEVENT_H
diff --git a/src/engine/events/SetPolyphonyEvent.cpp b/src/engine/events/SetPolyphonyEvent.cpp
deleted file mode 100644
index 8f48fc41..00000000
--- a/src/engine/events/SetPolyphonyEvent.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 "raul/Maid.hpp"
-#include "SetPolyphonyEvent.hpp"
-#include "Responder.hpp"
-#include "Engine.hpp"
-#include "PatchImpl.hpp"
-#include "ClientBroadcaster.hpp"
-#include "util.hpp"
-#include "EngineStore.hpp"
-#include "PortImpl.hpp"
-#include "NodeImpl.hpp"
-#include "ConnectionImpl.hpp"
-#include "QueuedEventSource.hpp"
-
-namespace Ingen {
-
-
-SetPolyphonyEvent::SetPolyphonyEvent(Engine& engine, SharedPtr<Responder> responder, FrameTime time, QueuedEventSource* source, const string& patch_path, uint32_t poly)
-: QueuedEvent(engine, responder, time, true, source),
- _patch_path(patch_path),
- _patch(NULL),
- _poly(poly)
-{
-}
-
-
-void
-SetPolyphonyEvent::pre_process()
-{
- _patch = _engine.engine_store()->find_patch(_patch_path);
- if (_patch && _poly > _patch->internal_polyphony())
- _patch->prepare_internal_poly(_poly);
-
- QueuedEvent::pre_process();
-}
-
-
-void
-SetPolyphonyEvent::execute(ProcessContext& context)
-{
- QueuedEvent::execute(context);
-
- if (_patch)
- _patch->apply_internal_poly(*_engine.maid(), _poly);
-
- _source->unblock();
-}
-
-
-void
-SetPolyphonyEvent::post_process()
-{
- if (_patch) {
- _responder->respond_ok();
- _engine.broadcaster()->send_property_change(_patch_path, "ingen:polyphony", (int32_t)_poly);
- } else {
- _responder->respond_error("Unable to find patch");
- }
-}
-
-
-} // namespace Ingen
-
diff --git a/src/engine/events/SetPolyphonyEvent.hpp b/src/engine/events/SetPolyphonyEvent.hpp
deleted file mode 100644
index f9c5b4f9..00000000
--- a/src/engine/events/SetPolyphonyEvent.hpp
+++ /dev/null
@@ -1,56 +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 SETPOLYPHONYEVENT_H
-#define SETPOLYPHONYEVENT_H
-
-#include <string>
-#include "raul/Array.hpp"
-#include "QueuedEvent.hpp"
-
-using std::string;
-
-namespace Ingen {
-
-class PatchImpl;
-
-
-/** Delete all nodes from a patch.
- *
- * \ingroup engine
- */
-class SetPolyphonyEvent : public QueuedEvent
-{
-public:
- SetPolyphonyEvent(Engine& engine, SharedPtr<Responder> responder, FrameTime time, QueuedEventSource* source, const string& patch_path, uint32_t poly);
-
- void pre_process();
- void execute(ProcessContext& context);
- void post_process();
-
-private:
- const string _patch_path;
- PatchImpl* _patch;
- const uint32_t _poly;
-
-};
-
-
-} // namespace Ingen
-
-
-#endif // SETPOLYPHONYEVENT_H