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/Buffer.h | 56 +++++++++++++++++------------------------------- 1 file changed, 20 insertions(+), 36 deletions(-) (limited to 'src/libs/engine/Buffer.h') diff --git a/src/libs/engine/Buffer.h b/src/libs/engine/Buffer.h index 3491b799..ee94b786 100644 --- a/src/libs/engine/Buffer.h +++ b/src/libs/engine/Buffer.h @@ -20,55 +20,39 @@ #include #include +#include #include "types.h" +#include "DataType.h" namespace Ingen { -template -class Buffer +class Buffer : public boost::noncopyable { public: - Buffer(size_t size); + Buffer(DataType type, size_t size) + : _type(type) + , _size(size) + {} - void clear(); - void set(T val, size_t start_sample); - void set(T val, size_t start_sample, size_t end_sample); - void scale(T val, size_t start_sample, size_t end_sample); - void copy(const Buffer* src, size_t start_sample, size_t end_sample); - void accumulate(const Buffer* src, size_t start_sample, size_t end_sample); + virtual ~Buffer() {} - void join(Buffer* buf); - void unjoin(); + virtual void clear() = 0; + virtual void prepare(SampleCount nframes) = 0; - /** For driver use only!! */ - void set_data(T* data); - - inline T& value_at(size_t offset) { assert(offset < _size); return data()[offset]; } - - void prepare(SampleCount nframes); - - 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; } - inline T* data() const { return ((_joined_buf != NULL) ? _joined_buf->data() : _data); } - - void resize(size_t size); + 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; -private: - enum BufferState { OK, HALF_SET_CYCLE_1, HALF_SET_CYCLE_2 }; + virtual void resize(size_t size) { _size = size; } - void allocate(); - void deallocate(); + DataType type() const { return _type; } + size_t size() const { return _size; } - T* _data; ///< Used data pointer (probably same as _local_data) - T* _local_data; ///< Locally allocated buffer (possibly unused if joined or set_data used) - Buffer* _joined_buf; ///< Buffer to mirror, if joined - size_t _size; ///< Allocated buffer size - size_t _filled_size; ///< Usable buffer size (for MIDI ports etc) - BufferState _state; ///< State of buffer for setting values next cycle - T _set_value; ///< Value set by @ref set (may need to be set next cycle) +protected: + DataType _type; + size_t _size; }; -- cgit v1.2.1