summaryrefslogtreecommitdiffstats
path: root/src/server
diff options
context:
space:
mode:
Diffstat (limited to 'src/server')
-rw-r--r--src/server/BlockImpl.cpp34
-rw-r--r--src/server/BlockImpl.hpp11
-rw-r--r--src/server/PortType.hpp4
-rw-r--r--src/server/events/Delta.cpp22
4 files changed, 62 insertions, 9 deletions
diff --git a/src/server/BlockImpl.cpp b/src/server/BlockImpl.cpp
index 069ecdfa..3d684e6c 100644
--- a/src/server/BlockImpl.cpp
+++ b/src/server/BlockImpl.cpp
@@ -45,6 +45,7 @@ BlockImpl::BlockImpl(PluginImpl* plugin,
, _polyphony((polyphonic && parent) ? parent->internal_poly() : 1)
, _polyphonic(polyphonic)
, _activated(false)
+ , _enabled(true)
, _traversed(false)
{
assert(_plugin);
@@ -144,6 +145,21 @@ BlockImpl::set_buffer_size(Context& context,
}
}
+PortImpl*
+BlockImpl::nth_port_by_type(uint32_t n, bool input, PortType type)
+{
+ uint32_t count = 0;
+ for (uint32_t i = 0; _ports && i < _ports->size(); ++i) {
+ PortImpl* const port = _ports->at(i);
+ if (port->is_input() == input && port->type() == type) {
+ if (count++ == n) {
+ return port;
+ }
+ }
+ }
+ return NULL;
+}
+
void
BlockImpl::pre_process(ProcessContext& context)
{
@@ -160,6 +176,24 @@ BlockImpl::process(ProcessContext& context)
{
pre_process(context);
+ if (!_enabled) {
+ for (PortType t : { PortType::AUDIO, PortType::CV, PortType::ATOM }) {
+ for (uint32_t i = 0;; ++i) {
+ PortImpl* in = nth_port_by_type(i, true, t);
+ PortImpl* out;
+ if (in && (out = nth_port_by_type(i, false, t))) {
+ for (uint32_t v = 0; v < _polyphony; ++v) {
+ out->buffer(v)->copy(context, in->buffer(v).get());
+ }
+ } else {
+ break;
+ }
+ }
+ }
+ post_process(context);
+ return;
+ }
+
ProcessContext subcontext(context);
for (SampleCount offset = 0; offset < context.nframes();) {
// Find earliest offset of a value change
diff --git a/src/server/BlockImpl.hpp b/src/server/BlockImpl.hpp
index 58ced1fe..845cd7df 100644
--- a/src/server/BlockImpl.hpp
+++ b/src/server/BlockImpl.hpp
@@ -84,7 +84,13 @@ public:
virtual void deactivate();
/** Return true iff this block is activated */
- bool activated() { return _activated; }
+ bool activated() const { return _activated; }
+
+ /** Return true iff this block is enabled (not bypassed). */
+ bool enabled() const { return _enabled; }
+
+ /** Enable or disable (bypass) this block. */
+ void set_enabled(bool e) { _enabled = e; }
/** Learn the next incoming MIDI event (for internals) */
virtual void learn() {}
@@ -157,6 +163,8 @@ public:
void traversed(bool b) { _traversed = b; }
protected:
+ PortImpl* nth_port_by_type(uint32_t n, bool input, PortType type);
+
PluginImpl* _plugin;
Raul::Array<PortImpl*>* _ports; ///< Access in audio thread only
Context::ID _context; ///< Context this block runs in
@@ -165,6 +173,7 @@ protected:
std::list<BlockImpl*> _dependants; ///< Blocks this one's output ports are connected to
bool _polyphonic;
bool _activated;
+ bool _enabled;
bool _traversed; ///< Flag for process order algorithm
};
diff --git a/src/server/PortType.hpp b/src/server/PortType.hpp
index b1719e3b..8371bd2c 100644
--- a/src/server/PortType.hpp
+++ b/src/server/PortType.hpp
@@ -58,8 +58,8 @@ public:
PortType(ID id) : _id(id) {}
- inline const Raul::URI& uri() const { return type_uri(_id); }
- inline ID id() const { return _id; }
+ inline const Raul::URI& uri() const { return type_uri(_id); }
+ inline ID id() const { return _id; }
inline bool operator==(const ID& id) const { return (_id == id); }
inline bool operator!=(const ID& id) const { return (_id != id); }
diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp
index c3d4e458..f1acbdc2 100644
--- a/src/server/events/Delta.cpp
+++ b/src/server/events/Delta.cpp
@@ -209,6 +209,12 @@ Delta::pre_process()
} else if ((block = dynamic_cast<BlockImpl*>(_object))) {
if (key == uris.midi_binding && value == uris.patch_wildcard) {
op = SpecialType::CONTROL_BINDING; // Internal block learn
+ } else if (key == uris.ingen_enabled) {
+ if (value.type() == uris.forge.Bool) {
+ op = SpecialType::ENABLE;
+ } else {
+ _status = Status::BAD_VALUE_TYPE;
+ }
}
}
@@ -316,13 +322,17 @@ Delta::execute(ProcessContext& context)
}
break;
case SpecialType::ENABLE:
- if (value.get<int32_t>()) {
- if (_compiled_graph) {
- _graph->set_compiled_graph(_compiled_graph);
+ if (_graph) {
+ if (value.get<int32_t>()) {
+ if (_compiled_graph) {
+ _graph->set_compiled_graph(_compiled_graph);
+ }
+ _graph->enable();
+ } else {
+ _graph->disable(context);
}
- _graph->enable();
- } else {
- _graph->disable(context);
+ } else if (block) {
+ block->set_enabled(value.get<int32_t>());
}
break;
case SpecialType::POLYPHONIC: {