summaryrefslogtreecommitdiff
path: root/libs/ardour/ardour
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
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')
-rw-r--r--libs/ardour/ardour/audio_port.h10
-rw-r--r--libs/ardour/ardour/buffer.h24
-rw-r--r--libs/ardour/ardour/buffer_set.h5
-rw-r--r--libs/ardour/ardour/midi_port.h5
-rw-r--r--libs/ardour/ardour/port.h11
5 files changed, 21 insertions, 34 deletions
diff --git a/libs/ardour/ardour/audio_port.h b/libs/ardour/ardour/audio_port.h
index 45949dc59e..07dc8da442 100644
--- a/libs/ardour/ardour/audio_port.h
+++ b/libs/ardour/ardour/audio_port.h
@@ -75,16 +75,6 @@ class AudioPort : public Port {
static void set_short_over_length (jack_nframes_t);
static void set_long_over_length (jack_nframes_t);
- /** Assumes that the port is an audio output port */
- void silence (jack_nframes_t nframes, jack_nframes_t offset) {
- if (!_silent) {
- _buffer.silence(nframes, offset);
- if (offset == 0 && nframes == _buffer.capacity()) {
- _silent = true;
- }
- }
- }
-
protected:
friend class AudioEngine;
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
diff --git a/libs/ardour/ardour/buffer_set.h b/libs/ardour/ardour/buffer_set.h
index 43df729e05..03b0b193d4 100644
--- a/libs/ardour/ardour/buffer_set.h
+++ b/libs/ardour/ardour/buffer_set.h
@@ -84,10 +84,7 @@ public:
return (MidiBuffer&)get(DataType::MIDI, i);
}
- void read_from(BufferSet& in, jack_nframes_t nframes, jack_nframes_t offset=0)
- {
- throw; // FIXME: implement this with spiffy DataType iterator etc.
- }
+ void read_from(BufferSet& in, jack_nframes_t nframes, jack_nframes_t offset=0);
// ITERATORS
diff --git a/libs/ardour/ardour/midi_port.h b/libs/ardour/ardour/midi_port.h
index f6eafe11bd..1abfd80932 100644
--- a/libs/ardour/ardour/midi_port.h
+++ b/libs/ardour/ardour/midi_port.h
@@ -52,11 +52,6 @@ class MidiPort : public Port {
size_t capacity() { return _buffer.capacity(); }
size_t size() { return _buffer.size(); }
-
- /** Assumes that the port is an output port */
- void silence (jack_nframes_t nframes, jack_nframes_t offset) {
- _buffer.silence(nframes, offset);
- }
protected:
friend class AudioEngine;
diff --git a/libs/ardour/ardour/port.h b/libs/ardour/ardour/port.h
index a436722cb0..2a99bdcc16 100644
--- a/libs/ardour/ardour/port.h
+++ b/libs/ardour/ardour/port.h
@@ -47,10 +47,6 @@ class Port : public sigc::trackable {
virtual Buffer& get_buffer() = 0;
- /** Silence/Empty the port, output ports only */
- virtual void silence (jack_nframes_t nframes, jack_nframes_t offset) = 0;
-
-
std::string name() const {
return _name;
}
@@ -128,12 +124,6 @@ class Port : public sigc::trackable {
jack_port_set_latency (_port, nframes);
}
- bool is_silent() const { return _silent; }
-
- void mark_silence (bool yn) {
- _silent = yn;
- }
-
sigc::signal<void,bool> MonitorInputChanged;
sigc::signal<void,bool> ClockSyncChanged;
@@ -156,7 +146,6 @@ class Port : public sigc::trackable {
unsigned short _metering;
bool _last_monitor : 1;
- bool _silent : 1;
};
} // namespace ARDOUR