From e96c36c1a7abb062e36efc0ac95c35fedcef922e Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 8 Apr 2007 06:04:32 +0000 Subject: De-template-ification of port types (req. for LV2 MIDI, but nice code size reduction). LV2 MIDI patching support (LV2 style MIDI throughout, inc. internal plugins). git-svn-id: http://svn.drobilla.net/lad/ingen@415 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/engine/Connection.h | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'src/libs/engine/Connection.h') diff --git a/src/libs/engine/Connection.h b/src/libs/engine/Connection.h index a7a2b3fa..7d109d88 100644 --- a/src/libs/engine/Connection.h +++ b/src/libs/engine/Connection.h @@ -21,11 +21,14 @@ #include #include #include +#include "DataType.h" +#include "Port.h" #include "types.h" namespace Ingen { class Port; +class Buffer; /** Represents a single inbound connection for an InputPort. @@ -41,7 +44,8 @@ class Port; class Connection : public Raul::Deletable { public: - virtual ~Connection() {} + Connection(Port* src_port, Port* dst_port); + virtual ~Connection(); Port* src_port() const { return _src_port; } Port* dst_port() const { return _dst_port; } @@ -50,17 +54,41 @@ public: bool pending_disconnection() { return _pending_disconnection; } void pending_disconnection(bool b) { _pending_disconnection = b; } - virtual void set_buffer_size(size_t size) {} + void process(SampleCount nframes, FrameTime start, FrameTime end); -protected: - Connection(Port* const src_port, Port* const dst_port); + /** Get the buffer for a particular voice. + * A Connection is smart - it knows the destination port requesting the + * buffer, and will return accordingly (ie the same buffer for every voice + * in a mono->poly connection). + */ + inline Buffer* buffer(size_t voice) const; + void set_buffer_size(size_t size); + + DataType type() const { return _src_port->type(); } + +protected: Port* const _src_port; Port* const _dst_port; + Buffer* _local_buffer; + size_t _buffer_size; + bool _must_mix; bool _pending_disconnection; }; +inline Buffer* +Connection::buffer(size_t voice) const +{ + if (_must_mix) + return _local_buffer; + else if (_src_port->poly() == 1) + return _src_port->buffer(0); + else + return _src_port->buffer(voice); +} + + } // namespace Ingen #endif // CONNECTION_H -- cgit v1.2.1