summaryrefslogtreecommitdiffstats
path: root/src/libs/engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/engine')
-rw-r--r--src/libs/engine/AudioBuffer.cpp2
-rw-r--r--src/libs/engine/AudioBuffer.h9
-rw-r--r--src/libs/engine/Buffer.h9
-rw-r--r--src/libs/engine/DSSINode.cpp4
-rw-r--r--src/libs/engine/DuplexPort.cpp26
-rw-r--r--src/libs/engine/DuplexPort.h7
-rw-r--r--src/libs/engine/Engine.cpp5
-rw-r--r--src/libs/engine/InputPort.cpp11
-rw-r--r--src/libs/engine/InputPort.h2
-rw-r--r--src/libs/engine/InternalNode.h3
-rw-r--r--src/libs/engine/JackMidiDriver.cpp3
-rw-r--r--src/libs/engine/LADSPANode.cpp5
-rw-r--r--src/libs/engine/LV2Node.cpp5
-rw-r--r--src/libs/engine/Makefile.am1
-rw-r--r--src/libs/engine/MidiBuffer.cpp26
-rw-r--r--src/libs/engine/MidiBuffer.h17
-rw-r--r--src/libs/engine/MidiControlNode.cpp4
-rw-r--r--src/libs/engine/MidiNoteNode.cpp4
-rw-r--r--src/libs/engine/MidiTriggerNode.cpp4
-rw-r--r--src/libs/engine/NodeBase.cpp19
-rw-r--r--src/libs/engine/NodeBase.h4
-rw-r--r--src/libs/engine/OutputPort.cpp40
-rw-r--r--src/libs/engine/OutputPort.h3
-rw-r--r--src/libs/engine/Patch.cpp9
-rw-r--r--src/libs/engine/Patch.h20
-rw-r--r--src/libs/engine/Port.cpp8
-rw-r--r--src/libs/engine/Port.h4
-rw-r--r--src/libs/engine/TransportNode.cpp4
-rw-r--r--src/libs/engine/events/DisconnectionEvent.cpp6
29 files changed, 182 insertions, 82 deletions
diff --git a/src/libs/engine/AudioBuffer.cpp b/src/libs/engine/AudioBuffer.cpp
index 525f0b41..35987942 100644
--- a/src/libs/engine/AudioBuffer.cpp
+++ b/src/libs/engine/AudioBuffer.cpp
@@ -264,7 +264,7 @@ AudioBuffer::is_joined_to(Buffer* buf) const
void
-AudioBuffer::prepare(SampleCount nframes)
+AudioBuffer::prepare_read(SampleCount nframes)
{
// FIXME: nframes parameter doesn't actually work,
// writing starts from 0 every time
diff --git a/src/libs/engine/AudioBuffer.h b/src/libs/engine/AudioBuffer.h
index fa946108..eba25c83 100644
--- a/src/libs/engine/AudioBuffer.h
+++ b/src/libs/engine/AudioBuffer.h
@@ -52,14 +52,15 @@ public:
inline Sample& value_at(size_t offset) const
{ assert(offset < _size); return data()[offset]; }
- void prepare(SampleCount nframes);
+ void prepare_read(SampleCount nframes);
+ void prepare_write(SampleCount nframes) {}
+
+ void reset(SampleCount nframes) {}
+ void resize(size_t size);
void filled_size(size_t size) { _filled_size = size; }
size_t filled_size() const { return _filled_size; }
- bool is_joined() const { return (_joined_buf == NULL); }
size_t size() const { return _size; }
-
- void resize(size_t size);
private:
enum State { OK, HALF_SET_CYCLE_1, HALF_SET_CYCLE_2 };
diff --git a/src/libs/engine/Buffer.h b/src/libs/engine/Buffer.h
index ee94b786..b27c3a86 100644
--- a/src/libs/engine/Buffer.h
+++ b/src/libs/engine/Buffer.h
@@ -37,10 +37,15 @@ public:
virtual ~Buffer() {}
+ /** Clear contents and reset state */
virtual void clear() = 0;
- virtual void prepare(SampleCount nframes) = 0;
+
+ /** Reset state (ie reset read ptr), but leave contents */
+ virtual void reset(SampleCount nframes) = 0;
+
+ virtual void prepare_read(SampleCount nframes) = 0;
+ virtual void prepare_write(SampleCount nframes) = 0;
- virtual bool is_joined() const = 0;
virtual bool is_joined_to(Buffer* buf) const = 0;
virtual bool join(Buffer* buf) = 0;
virtual void unjoin() = 0;
diff --git a/src/libs/engine/DSSINode.cpp b/src/libs/engine/DSSINode.cpp
index 5a23baba..58ff050d 100644
--- a/src/libs/engine/DSSINode.cpp
+++ b/src/libs/engine/DSSINode.cpp
@@ -165,7 +165,7 @@ DSSINode::has_midi_input() const
void
DSSINode::process(SampleCount nframes, FrameTime start, FrameTime end)
{
- NodeBase::process(nframes, start, end);
+ NodeBase::pre_process(nframes, start, end);
if (_dssi_descriptor->run_synth) {
convert_events();
@@ -181,6 +181,8 @@ DSSINode::process(SampleCount nframes, FrameTime start, FrameTime end)
} else {
LADSPANode::process(nframes, start, end);
}
+
+ NodeBase::post_process(nframes, start, end);
}
diff --git a/src/libs/engine/DuplexPort.cpp b/src/libs/engine/DuplexPort.cpp
index f4a71aae..c498c774 100644
--- a/src/libs/engine/DuplexPort.cpp
+++ b/src/libs/engine/DuplexPort.cpp
@@ -40,5 +40,31 @@ DuplexPort::DuplexPort(Node* parent, const string& name, size_t index, size_t po
}
+void
+DuplexPort::pre_process(SampleCount nframes, FrameTime start, FrameTime end)
+{
+ if (_is_output) {
+ for (size_t i=0; i < _poly; ++i)
+ _buffers.at(i)->prepare_write(nframes);
+ } else {
+ for (size_t i=0; i < _poly; ++i)
+ _buffers.at(i)->prepare_read(nframes);
+ }
+}
+
+
+void
+DuplexPort::post_process(SampleCount nframes, FrameTime start, FrameTime end)
+{
+ if (_is_output) {
+ for (size_t i=0; i < _poly; ++i)
+ _buffers.at(i)->prepare_read(nframes);
+ } else {
+ for (size_t i=0; i < _poly; ++i)
+ _buffers.at(i)->prepare_write(nframes);
+ }
+}
+
+
} // namespace Ingen
diff --git a/src/libs/engine/DuplexPort.h b/src/libs/engine/DuplexPort.h
index 10c305b4..986c1862 100644
--- a/src/libs/engine/DuplexPort.h
+++ b/src/libs/engine/DuplexPort.h
@@ -45,10 +45,11 @@ public:
DuplexPort(Node* parent, const string& name, size_t index, size_t poly, DataType type, size_t buffer_size, bool is_output);
virtual ~DuplexPort() {}
- virtual void prepare_buffers(size_t nframes) {}
+ void pre_process(SampleCount nframes, FrameTime start, FrameTime end);
+ void post_process(SampleCount nframes, FrameTime start, FrameTime end);
- virtual bool is_input() const { return !_is_output; }
- virtual bool is_output() const { return _is_output; }
+ bool is_input() const { return !_is_output; }
+ bool is_output() const { return _is_output; }
protected:
bool _is_output;
diff --git a/src/libs/engine/Engine.cpp b/src/libs/engine/Engine.cpp
index 053528ff..ddb9ea81 100644
--- a/src/libs/engine/Engine.cpp
+++ b/src/libs/engine/Engine.cpp
@@ -190,9 +190,6 @@ Engine::deactivate()
{
if (!_activated)
return;
-
- _audio_driver->root_patch()->disable();
- _audio_driver->root_patch()->deactivate();
/*for (Tree<GraphObject*>::iterator i = _object_store->objects().begin();
i != _object_store->objects().end(); ++i)
@@ -204,6 +201,8 @@ Engine::deactivate()
_audio_driver->deactivate();
+ _audio_driver->root_patch()->deactivate();
+
// Finalize any lingering events (unlikely)
_post_processor->whip();
_post_processor->stop();
diff --git a/src/libs/engine/InputPort.cpp b/src/libs/engine/InputPort.cpp
index 9326afd6..0e149abe 100644
--- a/src/libs/engine/InputPort.cpp
+++ b/src/libs/engine/InputPort.cpp
@@ -102,7 +102,7 @@ InputPort::remove_connection(const OutputPort* src_port)
if (_connections.size() == 0) {
for (size_t i=0; i < _poly; ++i) {
// Use a local buffer
- if (modify_buffers && _buffers.at(i)->is_joined())
+ if (modify_buffers)
_buffers.at(i)->unjoin();
_buffers.at(i)->clear(); // Write silence
//if (_is_tied)
@@ -145,10 +145,8 @@ InputPort::is_connected_to(const OutputPort* port) const
* FIXME: nframes parameter not used,
*/
void
-InputPort::process(SampleCount nframes, FrameTime start, FrameTime end)
+InputPort::pre_process(SampleCount nframes, FrameTime start, FrameTime end)
{
- Port::process(nframes, start, end);
-
//assert(!_is_tied || _tied_port != NULL);
bool do_mixdown = true;
@@ -167,7 +165,6 @@ InputPort::process(SampleCount nframes, FrameTime start, FrameTime end)
do_mixdown = true;
} else {
// zero-copy
- //assert(_buffers.at(0)->is_joined());
_buffers.at(0)->join((*_connections.begin())->buffer(0));
do_mixdown = false;
}
@@ -179,6 +176,9 @@ InputPort::process(SampleCount nframes, FrameTime start, FrameTime end)
//cerr << path() << " mixing: " << do_mixdown << endl;
+ for (size_t i=0; i < _poly; ++i)
+ _buffers.at(i)->prepare_read(nframes);
+
if (!do_mixdown) {
assert(_buffers.at(0)->is_joined_to((*_connections.begin())->buffer(0)));
return;
@@ -188,6 +188,7 @@ InputPort::process(SampleCount nframes, FrameTime start, FrameTime end)
assert(!_is_tied || _buffers.at(0)->data() == _tied_port->buffer(0)->data());*/
for (size_t voice=0; voice < _poly; ++voice) {
+ assert(_type == DataType::FLOAT);
// Copy first connection
((AudioBuffer*)_buffers.at(voice))->copy(
((AudioBuffer*)(*_connections.begin())->buffer(voice)), 0, _buffer_size-1);
diff --git a/src/libs/engine/InputPort.h b/src/libs/engine/InputPort.h
index 284f976f..25777ecf 100644
--- a/src/libs/engine/InputPort.h
+++ b/src/libs/engine/InputPort.h
@@ -56,7 +56,7 @@ public:
typedef Raul::List<Connection*> Connections;
const Connections& connections() { return _connections; }
- void process(SampleCount nframes, FrameTime start, FrameTime end);
+ void pre_process(SampleCount nframes, FrameTime start, FrameTime end);
bool is_connected() const { return (_connections.size() > 0); }
bool is_connected_to(const OutputPort* port) const;
diff --git a/src/libs/engine/InternalNode.h b/src/libs/engine/InternalNode.h
index b3ad00a3..7f7d54fe 100644
--- a/src/libs/engine/InternalNode.h
+++ b/src/libs/engine/InternalNode.h
@@ -42,9 +42,6 @@ public:
virtual ~InternalNode() {}
- virtual void process(SampleCount nframes, FrameTime start, FrameTime end)
- { NodeBase::process(nframes, start, end); }
-
protected:
Plugin* plugin() const { return const_cast<Plugin*>(_plugin); }
};
diff --git a/src/libs/engine/JackMidiDriver.cpp b/src/libs/engine/JackMidiDriver.cpp
index ada9a439..44c44725 100644
--- a/src/libs/engine/JackMidiDriver.cpp
+++ b/src/libs/engine/JackMidiDriver.cpp
@@ -80,8 +80,7 @@ JackMidiPort::prepare_block(const SampleCount block_start, const SampleCount blo
MidiBuffer* patch_buf = dynamic_cast<MidiBuffer*>(_patch_port->buffer(0));
assert(patch_buf);
- patch_buf->clear();
- patch_buf->reset_state(nframes);
+ patch_buf->prepare_write(nframes);
// Copy events from Jack port buffer into patch port buffer
for (jack_nframes_t i=0; i < event_count; ++i) {
diff --git a/src/libs/engine/LADSPANode.cpp b/src/libs/engine/LADSPANode.cpp
index 3ad197a4..b347afa6 100644
--- a/src/libs/engine/LADSPANode.cpp
+++ b/src/libs/engine/LADSPANode.cpp
@@ -176,9 +176,12 @@ LADSPANode::deactivate()
void
LADSPANode::process(SampleCount nframes, FrameTime start, FrameTime end)
{
- NodeBase::process(nframes, start, end); // mixes down input ports
+ NodeBase::pre_process(nframes, start, end);
+
for (size_t i=0; i < _poly; ++i)
_descriptor->run(_instances[i], nframes);
+
+ NodeBase::post_process(nframes, start, end);
}
diff --git a/src/libs/engine/LV2Node.cpp b/src/libs/engine/LV2Node.cpp
index 0baf41ef..f05a477b 100644
--- a/src/libs/engine/LV2Node.cpp
+++ b/src/libs/engine/LV2Node.cpp
@@ -170,9 +170,12 @@ LV2Node::deactivate()
void
LV2Node::process(SampleCount nframes, FrameTime start, FrameTime end)
{
- NodeBase::process(nframes, start, end); // mixes down input ports
+ NodeBase::pre_process(nframes, start, end);
+
for (size_t i=0; i < _poly; ++i)
slv2_instance_run(_instances[i], nframes);
+
+ NodeBase::post_process(nframes, start, end);
}
diff --git a/src/libs/engine/Makefile.am b/src/libs/engine/Makefile.am
index 29b601a9..2516b24a 100644
--- a/src/libs/engine/Makefile.am
+++ b/src/libs/engine/Makefile.am
@@ -48,6 +48,7 @@ libingen_la_SOURCES = \
InputPort.h \
InputPort.cpp \
OutputPort.h \
+ OutputPort.cpp \
DuplexPort.h \
DuplexPort.cpp \
MidiMessage.h \
diff --git a/src/libs/engine/MidiBuffer.cpp b/src/libs/engine/MidiBuffer.cpp
index 7dfe72e6..35bda0a0 100644
--- a/src/libs/engine/MidiBuffer.cpp
+++ b/src/libs/engine/MidiBuffer.cpp
@@ -15,8 +15,11 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+//#include <iostream>
#include "MidiBuffer.h"
+using namespace std;
+
namespace Ingen {
@@ -48,6 +51,8 @@ MidiBuffer::unjoin()
_joined_buf = NULL;
_buf = _local_buf;
_state = &_local_state;
+ clear();
+ reset(_this_nframes);
}
@@ -63,14 +68,23 @@ MidiBuffer::is_joined_to(Buffer* buf) const
void
-MidiBuffer::prepare(SampleCount nframes)
+MidiBuffer::prepare_read(SampleCount nframes)
+{
+ assert(!_joined_buf || data() == _joined_buf->data());
+ assert(!_joined_buf || state() == _joined_buf->state());
+
+ reset(nframes);
+}
+
+
+void
+MidiBuffer::prepare_write(SampleCount nframes)
{
- if (_joined_buf)
- _local_state = *_joined_buf->state();
- else
- reset_state(nframes);
+ clear();
+ reset(nframes);
- _this_nframes = nframes;
+ assert(!_joined_buf || data() == _joined_buf->data());
+ assert(!_joined_buf || state() == _joined_buf->state());
}
diff --git a/src/libs/engine/MidiBuffer.h b/src/libs/engine/MidiBuffer.h
index 459c1209..5a810bc3 100644
--- a/src/libs/engine/MidiBuffer.h
+++ b/src/libs/engine/MidiBuffer.h
@@ -31,20 +31,19 @@ public:
MidiBuffer(size_t capacity)
: Buffer(DataType(DataType::MIDI), capacity)
, _state(&_local_state)
- , _buf(lv2midi_new((uint32_t)capacity))
- , _local_buf(NULL)
+ , _local_buf(lv2midi_new((uint32_t)capacity))
+ , _buf(_local_buf)
, _joined_buf(NULL)
{
clear();
- reset_state(0);
}
~MidiBuffer() { lv2midi_free(_buf); }
- void prepare(SampleCount nframes);
+ void prepare_read(SampleCount nframes);
+ void prepare_write(SampleCount nframes);
bool is_joined_to(Buffer* buf) const;
- bool is_joined() const { return (_joined_buf == NULL); }
bool join(Buffer* buf);
void unjoin();
@@ -57,9 +56,9 @@ public:
{ return ((_joined_buf != NULL) ? _joined_buf->state() : _state); }
inline void clear()
- { lv2midi_reset_buffer(_buf); }
+ { lv2midi_reset_buffer(_buf); _state->position = 0; }
- inline void reset_state(uint32_t nframes)
+ inline void reset(SampleCount nframes)
{ lv2midi_reset_state(_state, _buf, nframes); _this_nframes = nframes; }
inline double increment()
@@ -72,10 +71,10 @@ public:
{ return lv2midi_put_event(_state, timestamp, size, data); }
private:
- LV2_MIDIState* _state;
LV2_MIDIState _local_state;
- LV2_MIDI* _buf;
+ LV2_MIDIState* _state;
LV2_MIDI* _local_buf;
+ LV2_MIDI* _buf;
MidiBuffer* _joined_buf; ///< Buffer to mirror, if joined
diff --git a/src/libs/engine/MidiControlNode.cpp b/src/libs/engine/MidiControlNode.cpp
index 81df8e6c..abe930c8 100644
--- a/src/libs/engine/MidiControlNode.cpp
+++ b/src/libs/engine/MidiControlNode.cpp
@@ -65,7 +65,7 @@ MidiControlNode::MidiControlNode(const string& path, size_t poly, Patch* parent,
void
MidiControlNode::process(SampleCount nframes, FrameTime start, FrameTime end)
{
- InternalNode::process(nframes, start, end);
+ NodeBase::pre_process(nframes, start, end);
double timestamp = 0;
uint32_t size = 0;
@@ -81,6 +81,8 @@ MidiControlNode::process(SampleCount nframes, FrameTime start, FrameTime end)
if (size >= 3 && (buffer[0] & 0xF0) == MIDI_CMD_CONTROL)
control(buffer[1], buffer[2], time);
}
+
+ NodeBase::post_process(nframes, start, end);
}
diff --git a/src/libs/engine/MidiNoteNode.cpp b/src/libs/engine/MidiNoteNode.cpp
index 6a6b698c..aac195ef 100644
--- a/src/libs/engine/MidiNoteNode.cpp
+++ b/src/libs/engine/MidiNoteNode.cpp
@@ -75,7 +75,7 @@ MidiNoteNode::~MidiNoteNode()
void
MidiNoteNode::process(SampleCount nframes, FrameTime start, FrameTime end)
{
- InternalNode::process(nframes, start, end);
+ NodeBase::pre_process(nframes, start, end);
double timestamp = 0;
uint32_t size = 0;
@@ -122,6 +122,8 @@ MidiNoteNode::process(SampleCount nframes, FrameTime start, FrameTime end)
midi_in->increment();
}
+
+ NodeBase::post_process(nframes, start, end);
}
diff --git a/src/libs/engine/MidiTriggerNode.cpp b/src/libs/engine/MidiTriggerNode.cpp
index 9d78f7b8..d45cfe85 100644
--- a/src/libs/engine/MidiTriggerNode.cpp
+++ b/src/libs/engine/MidiTriggerNode.cpp
@@ -60,7 +60,7 @@ MidiTriggerNode::MidiTriggerNode(const string& path, size_t poly, Patch* parent,
void
MidiTriggerNode::process(SampleCount nframes, FrameTime start, FrameTime end)
{
- InternalNode::process(nframes, start, end);
+ NodeBase::pre_process(nframes, start, end);
double timestamp = 0;
uint32_t size = 0;
@@ -93,6 +93,8 @@ MidiTriggerNode::process(SampleCount nframes, FrameTime start, FrameTime end)
}
}
}
+
+ NodeBase::post_process(nframes, start, end);
}
diff --git a/src/libs/engine/NodeBase.cpp b/src/libs/engine/NodeBase.cpp
index 7f9fe23b..ffd509c4 100644
--- a/src/libs/engine/NodeBase.cpp
+++ b/src/libs/engine/NodeBase.cpp
@@ -123,18 +123,31 @@ NodeBase::set_buffer_size(size_t size)
}
-/** Runs the Node for the specified number of frames (block size)
+/** Prepare to run a cycle (in the audio thread)
*/
void
-NodeBase::process(SampleCount nframes, FrameTime start, FrameTime end)
+NodeBase::pre_process(SampleCount nframes, FrameTime start, FrameTime end)
{
assert(_activated);
// Mix down any ports with multiple inputs
for (size_t i=0; i < _ports->size(); ++i)
- _ports->at(i)->process(nframes, start, end);
+ _ports->at(i)->pre_process(nframes, start, end);
}
+/** Prepare to run a cycle (in the audio thread)
+ */
+void
+NodeBase::post_process(SampleCount nframes, FrameTime start, FrameTime end)
+{
+ assert(_activated);
+ // Prepare any output ports for reading (MIDI)
+ for (size_t i=0; i < _ports->size(); ++i)
+ _ports->at(i)->post_process(nframes, start, end);
+}
+
+
+
/** Rename this Node.
*
* This is responsible for updating the ObjectStore so the Node can be
diff --git a/src/libs/engine/NodeBase.h b/src/libs/engine/NodeBase.h
index 8fed6196..6ae890f3 100644
--- a/src/libs/engine/NodeBase.h
+++ b/src/libs/engine/NodeBase.h
@@ -53,7 +53,9 @@ public:
virtual void deactivate();
bool activated() { return _activated; }
- virtual void process(SampleCount nframes, FrameTime start, FrameTime end);
+ virtual void post_process(SampleCount nframes, FrameTime start, FrameTime end);
+ virtual void process(SampleCount nframes, FrameTime start, FrameTime end) = 0;
+ virtual void pre_process(SampleCount nframes, FrameTime start, FrameTime end);
virtual void set_port_buffer(size_t voice, size_t port_num, Buffer* buf) {}
diff --git a/src/libs/engine/OutputPort.cpp b/src/libs/engine/OutputPort.cpp
new file mode 100644
index 00000000..ea723963
--- /dev/null
+++ b/src/libs/engine/OutputPort.cpp
@@ -0,0 +1,40 @@
+/* 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 "OutputPort.h"
+#include "Buffer.h"
+
+namespace Ingen {
+
+
+void
+OutputPort::pre_process(SampleCount nframes, FrameTime start, FrameTime end)
+{
+ for (size_t i=0; i < _poly; ++i)
+ _buffers.at(i)->prepare_write(nframes);
+}
+
+
+void
+OutputPort::post_process(SampleCount nframes, FrameTime start, FrameTime end)
+{
+ for (size_t i=0; i < _poly; ++i)
+ _buffers.at(i)->prepare_read(nframes);
+}
+
+
+} // namespace Ingen
diff --git a/src/libs/engine/OutputPort.h b/src/libs/engine/OutputPort.h
index 10118076..0e94be9f 100644
--- a/src/libs/engine/OutputPort.h
+++ b/src/libs/engine/OutputPort.h
@@ -49,6 +49,9 @@ public:
: Port(parent, name, index, poly, type, buffer_size)
{}
+ void pre_process(SampleCount nframes, FrameTime start, FrameTime end);
+ void post_process(SampleCount nframes, FrameTime start, FrameTime end);
+
virtual ~OutputPort() {}
bool is_input() const { return false; }
diff --git a/src/libs/engine/Patch.cpp b/src/libs/engine/Patch.cpp
index a2b5a85f..ad414642 100644
--- a/src/libs/engine/Patch.cpp
+++ b/src/libs/engine/Patch.cpp
@@ -98,15 +98,10 @@ Patch::deactivate()
void
Patch::disable()
{
- // Write output buffers to 0
- /*for (Raul::List<InternalNode*>::iterator i = _bridge_nodes.begin(); i != _bridge_nodes.end(); ++i) {
- assert((*i)->as_port() != NULL);
- if ((*i)->as_port()->port_info()->is_output())
- (*i)->as_port()->clear_buffers();*/
+ _process = false;
+
for (Raul::List<Port*>::iterator i = _output_ports.begin(); i != _output_ports.end(); ++i)
(*i)->clear_buffers();
-
- _process = false;
}
diff --git a/src/libs/engine/Patch.h b/src/libs/engine/Patch.h
index 55a2be83..76290c8f 100644
--- a/src/libs/engine/Patch.h
+++ b/src/libs/engine/Patch.h
@@ -98,21 +98,21 @@ public:
/** Whether to run this patch's DSP bits in the audio thread */
bool enabled() const { return _process; }
- void enable() { _process = true; }
+ void enable() { _process = true; }
void disable();
size_t internal_poly() const { return _internal_poly; }
private:
- inline void build_process_order_recursive(Node* n, Raul::Array<Node*>* order) const;
-
- size_t _internal_poly;
- Raul::Array<Node*>* _process_order; ///< Accessed in audio thread only
- Raul::List<Connection*> _connections; ///< Accessed in audio thread only
- Raul::List<Port*> _input_ports; ///< Accessed in preprocessing thread only
- Raul::List<Port*> _output_ports; ///< Accessed in preprocessing thread only
- Raul::List<Node*> _nodes; ///< Accessed in preprocessing thread only
- bool _process;
+ inline void build_process_order_recursive(Node* n, Raul::Array<Node*>* order) const;
+
+ size_t _internal_poly;
+ Raul::Array<Node*>* _process_order; ///< Accessed in audio thread only
+ Raul::List<Connection*> _connections; ///< Accessed in audio thread only
+ Raul::List<Port*> _input_ports; ///< Accessed in preprocessing thread only
+ Raul::List<Port*> _output_ports; ///< Accessed in preprocessing thread only
+ Raul::List<Node*> _nodes; ///< Accessed in preprocessing thread only
+ bool _process;
};
diff --git a/src/libs/engine/Port.cpp b/src/libs/engine/Port.cpp
index 4b9a014b..bfb09a35 100644
--- a/src/libs/engine/Port.cpp
+++ b/src/libs/engine/Port.cpp
@@ -91,12 +91,4 @@ Port::clear_buffers()
}
-void
-Port::process(SampleCount nframes, FrameTime start, FrameTime end)
-{
- for (size_t i=0; i < _poly; ++i)
- _buffers.at(i)->prepare(nframes);
-}
-
-
} // namespace Ingen
diff --git a/src/libs/engine/Port.h b/src/libs/engine/Port.h
index b42231fe..6b3c20e8 100644
--- a/src/libs/engine/Port.h
+++ b/src/libs/engine/Port.h
@@ -52,7 +52,9 @@ public:
Buffer* buffer(size_t voice) const { return _buffers.at(voice); }
/** Called once per process cycle */
- virtual void process(SampleCount nframes, FrameTime start, FrameTime end);
+ virtual void pre_process(SampleCount nframes, FrameTime start, FrameTime end) = 0;
+ virtual void process(SampleCount nframes, FrameTime start, FrameTime end) {}
+ virtual void post_process(SampleCount nframes, FrameTime start, FrameTime end) {};
/** Empty buffer contents completely (ie silence) */
virtual void clear_buffers();
diff --git a/src/libs/engine/TransportNode.cpp b/src/libs/engine/TransportNode.cpp
index 028fd45e..d8895d72 100644
--- a/src/libs/engine/TransportNode.cpp
+++ b/src/libs/engine/TransportNode.cpp
@@ -83,7 +83,7 @@ TransportNode::TransportNode(const string& path, size_t poly, Patch* parent, Sam
void
TransportNode::process(SampleCount nframes, FrameTime start, FrameTime end)
{
- NodeBase::process(nframes, start, end);
+ NodeBase::pre_process(nframes, start, end);
#if 0
// FIXME: this will die horribly with any driver other than jack (in theory)
@@ -147,6 +147,8 @@ TransportNode::process(SampleCount nframes, FrameTime start, FrameTime end)
}
}
#endif
+
+ NodeBase::post_process(nframes, start, end);
}
diff --git a/src/libs/engine/events/DisconnectionEvent.cpp b/src/libs/engine/events/DisconnectionEvent.cpp
index aef271f4..7ac7e236 100644
--- a/src/libs/engine/events/DisconnectionEvent.cpp
+++ b/src/libs/engine/events/DisconnectionEvent.cpp
@@ -92,12 +92,6 @@ DisconnectionEvent::pre_process()
return;
}
- if (_src_port->type() != _dst_port->type() || _src_port->buffer_size() != _dst_port->buffer_size()) {
- _error = TYPE_MISMATCH;
- QueuedEvent::pre_process();
- return;
- }
-
_dst_input_port = dynamic_cast<InputPort*>(_dst_port);
_src_output_port = dynamic_cast<OutputPort*>(_src_port);
assert(_src_output_port);