diff options
author | David Robillard <d@drobilla.net> | 2007-04-08 06:04:32 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-04-08 06:04:32 +0000 |
commit | e96c36c1a7abb062e36efc0ac95c35fedcef922e (patch) | |
tree | 826d5caa0392201472d12c02a1c3df4cf7b275be /src/libs/engine/Buffer.h | |
parent | 7d69e89f22304e37fa325ce4f39a374a02072a69 (diff) | |
download | ingen-e96c36c1a7abb062e36efc0ac95c35fedcef922e.tar.gz ingen-e96c36c1a7abb062e36efc0ac95c35fedcef922e.tar.bz2 ingen-e96c36c1a7abb062e36efc0ac95c35fedcef922e.zip |
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
Diffstat (limited to 'src/libs/engine/Buffer.h')
-rw-r--r-- | src/libs/engine/Buffer.h | 56 |
1 files changed, 20 insertions, 36 deletions
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 <cstddef> #include <cassert> +#include <boost/utility.hpp> #include "types.h" +#include "DataType.h" namespace Ingen { -template <typename T> -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<T>* src, size_t start_sample, size_t end_sample); - void accumulate(const Buffer<T>* 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<T>* _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; }; |