summaryrefslogtreecommitdiff
path: root/libs/ardour/ardour/buffer.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2006-09-01 07:38:55 +0000
committerDavid Robillard <d@drobilla.net>2006-09-01 07:38:55 +0000
commitbd1220a46db9fe909d09c08139cfb61ba98ec9f3 (patch)
tree5662e862dba8408601c0495e1aa8dabba72c688a /libs/ardour/ardour/buffer.h
parent017e16c530bb1a9f186aa81893089dc79b4ddc24 (diff)
Fixes for IO port adding/removing
Working audio sends/port inserts Send gain, panning MIDI sends working (maybe port inserts too?) Buffer/Port fixes (related to silence) Metering bug fixes git-svn-id: svn://localhost/ardour2/branches/midi@883 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/ardour/buffer.h')
-rw-r--r--libs/ardour/ardour/buffer.h24
1 files changed, 20 insertions, 4 deletions
diff --git a/libs/ardour/ardour/buffer.h b/libs/ardour/ardour/buffer.h
index 896d6e7616..828eac4d64 100644
--- a/libs/ardour/ardour/buffer.h
+++ b/libs/ardour/ardour/buffer.h
@@ -56,6 +56,8 @@ public:
* Based on this you can static cast a Buffer* to the desired type. */
DataType type() const { return _type; }
+ bool silent() const { return _silent; }
+
/** Clear (eg zero, or empty) buffer starting at TIME @a offset */
virtual void silence(jack_nframes_t len, jack_nframes_t offset=0) = 0;
@@ -66,12 +68,13 @@ public:
protected:
Buffer(DataType type, size_t capacity)
- : _type(type), _capacity(capacity), _size(0)
+ : _type(type), _capacity(capacity), _size(0), _silent(true)
{}
DataType _type;
size_t _capacity;
size_t _size;
+ bool _silent;
private:
// Prevent copies (undefined)
@@ -93,9 +96,14 @@ public:
void silence(jack_nframes_t len, jack_nframes_t offset=0)
{
- assert(_capacity > 0);
- assert(offset + len <= _capacity);
- memset(_data + offset, 0, sizeof (Sample) * len);
+ if (!_silent) {
+ assert(_capacity > 0);
+ assert(offset + len <= _capacity);
+ memset(_data + offset, 0, sizeof (Sample) * len);
+ if (offset == 0 && len == _capacity) {
+ _silent = true;
+ }
+ }
}
/** Read @a len frames FROM THE START OF @a src into self at @a offset */
@@ -105,6 +113,7 @@ public:
assert(src.type() == _type == DataType::AUDIO);
assert(offset + len <= _capacity);
memcpy(_data + offset, ((AudioBuffer&)src).data(len), sizeof(Sample) * len);
+ _silent = src.silent();
}
/** Accumulate (add)@a len frames FROM THE START OF @a src into self at @a offset */
@@ -119,6 +128,8 @@ public:
for (jack_nframes_t n = 0; n < len; ++n) {
dst_raw[n] += src_raw[n];
}
+
+ _silent = (src.silent() && _silent);
}
/** Accumulate (add) @a len frames FROM THE START OF @a src into self at @a offset
@@ -134,6 +145,8 @@ public:
for (jack_nframes_t n = 0; n < len; ++n) {
dst_raw[n] += src_raw[n] * gain_coeff;
}
+
+ _silent = ( (src.silent() && _silent) || (_silent && gain_coeff == 0) );
}
void apply_gain(gain_t gain, jack_nframes_t len, jack_nframes_t offset=0) {
@@ -142,6 +155,8 @@ public:
for (jack_nframes_t n = 0; n < len; ++n) {
buf[n] *= gain;
}
+
+ _silent = (_silent || gain == 0);
}
/** Set the data contained by this buffer manually (for setting directly to jack buffer).
@@ -154,6 +169,7 @@ public:
_capacity = size;
_size = size;
_data = data;
+ _silent = false;
}
const Sample* data(jack_nframes_t nframes, jack_nframes_t offset=0) const