summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/server/BlockImpl.cpp61
-rw-r--r--src/server/BlockImpl.hpp3
2 files changed, 39 insertions, 25 deletions
diff --git a/src/server/BlockImpl.cpp b/src/server/BlockImpl.cpp
index bdcf1500..3b051fd4 100644
--- a/src/server/BlockImpl.cpp
+++ b/src/server/BlockImpl.cpp
@@ -185,37 +185,48 @@ BlockImpl::pre_process(RunContext& context)
}
void
-BlockImpl::process(RunContext& context)
+BlockImpl::bypass(RunContext& context)
{
- pre_process(context);
+ if (!_ports) {
+ return;
+ }
- if (!_enabled) {
- // Prepare port buffers for reading, converting/mixing if necessary
- for (uint32_t i = 0; _ports && i < _ports->size(); ++i) {
- _ports->at(i)->connect_buffers();
- _ports->at(i)->pre_run(context);
- }
+ // Prepare port buffers for reading, converting/mixing if necessary
+ for (uint32_t i = 0; i < _ports->size(); ++i) {
+ _ports->at(i)->connect_buffers();
+ _ports->at(i)->pre_run(context);
+ }
- // Dumb bypass
- 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 = nth_port_by_type(i, false, t);
- if (!out) {
- break; // Finished writing all outputs
- } else if (in) {
- // Copy corresponding input to output
- for (uint32_t v = 0; v < _polyphony; ++v) {
- out->buffer(v)->copy(context, in->buffer(v).get());
- }
- } else {
- // Output but no corresponding input, clear
- for (uint32_t v = 0; v < _polyphony; ++v) {
- out->buffer(v)->clear();
- }
+ // Dumb bypass
+ 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 = nth_port_by_type(i, false, t);
+ if (!out) {
+ break; // Finished writing all outputs
+ } else if (in) {
+ // Copy corresponding input to output
+ for (uint32_t v = 0; v < _polyphony; ++v) {
+ out->buffer(v)->copy(context, in->buffer(v).get());
+ }
+ } else {
+ // Output but no corresponding input, clear
+ for (uint32_t v = 0; v < _polyphony; ++v) {
+ out->buffer(v)->clear();
}
}
}
+ }
+ post_process(context);
+}
+
+void
+BlockImpl::process(RunContext& context)
+{
+ pre_process(context);
+
+ if (!_enabled) {
+ bypass(context);
post_process(context);
return;
}
diff --git a/src/server/BlockImpl.hpp b/src/server/BlockImpl.hpp
index 2e3e5fcd..701e2188 100644
--- a/src/server/BlockImpl.hpp
+++ b/src/server/BlockImpl.hpp
@@ -121,6 +121,9 @@ public:
/** Run block for an entire process cycle (calls run()). */
virtual void process(RunContext& context);
+ /** Bypass block for an entire process cycle (called from process()). */
+ virtual void bypass(RunContext& context);
+
/** Run block for a portion of process cycle (called from process()). */
virtual void run(RunContext& context) = 0;