diff options
Diffstat (limited to 'src/libs/engine/InputPort.cpp')
-rw-r--r-- | src/libs/engine/InputPort.cpp | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/src/libs/engine/InputPort.cpp b/src/libs/engine/InputPort.cpp index 1adb53a0..4f2147c4 100644 --- a/src/libs/engine/InputPort.cpp +++ b/src/libs/engine/InputPort.cpp @@ -23,17 +23,30 @@ #include "Connection.hpp" #include "OutputPort.hpp" #include "Node.hpp" +#include "ProcessContext.hpp" #include "util.hpp" -using std::cerr; using std::cout; using std::endl; - +using namespace std; namespace Ingen { InputPort::InputPort(Node* parent, const string& name, uint32_t index, uint32_t poly, DataType type, size_t buffer_size) -: Port(parent, name, index, poly, type, buffer_size) + : Port(parent, name, index, poly, type, buffer_size) + , _last_reported_value(0.0f) // default? +{ +} + + +void +InputPort::set_buffer_size(size_t size) { + Port::set_buffer_size(size); + assert(_buffer_size = size); + + for (Raul::List<Connection*>::iterator c = _connections.begin(); c != _connections.end(); ++c) + (*c)->set_buffer_size(size); + } @@ -64,6 +77,10 @@ InputPort::add_connection(Raul::ListNode<Connection*>* const c) } Port::connect_buffers(); } + + // Automatically monitor connected control inputs + if (_type == DataType::FLOAT && _buffer_size == 1) + _monitor = true; } @@ -104,6 +121,10 @@ InputPort::remove_connection(const OutputPort* src_port) if (modify_buffers) Port::connect_buffers(); + + // Turn off monitoring if we're not connected any more (FIXME: not quite right..) + if (_type == DataType::FLOAT && _buffer_size == 1 && _connections.size() == 0) + _monitor = false; return connection; } @@ -195,16 +216,18 @@ InputPort::pre_process(SampleCount nframes, FrameTime start, FrameTime end) void -InputPort::set_buffer_size(size_t size) +InputPort::process(ProcessContext& context, SampleCount nframes, FrameTime start, FrameTime end) { - Port::set_buffer_size(size); - assert(_buffer_size = size); - - for (Raul::List<Connection*>::iterator c = _connections.begin(); c != _connections.end(); ++c) - (*c)->set_buffer_size(size); - + if (_monitor && _type == DataType::FLOAT && _buffer_size == 1) { + const Sample value = ((AudioBuffer*)(*_buffers)[0])->value_at(0); + if (value != _last_reported_value) { + context.event_sink().control_change(this, ((AudioBuffer*)(*_buffers)[0])->value_at(0)); + _last_reported_value = value; + } + } } + void InputPort::post_process(SampleCount nframes, FrameTime start, FrameTime end) { |