mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-11 00:56:33 +01:00
add some utility functions to Buffers and BufferSets to allow some kinds of debugging easily
This commit is contained in:
parent
ac47688023
commit
86c3b70c54
6 changed files with 33 additions and 0 deletions
|
|
@ -42,6 +42,8 @@ public:
|
||||||
*/
|
*/
|
||||||
void silence (samplecnt_t len, samplecnt_t offset = 0);
|
void silence (samplecnt_t len, samplecnt_t offset = 0);
|
||||||
|
|
||||||
|
bool silent_data() const;
|
||||||
|
|
||||||
/** Copy samples from src array starting at src_offset into self starting at dst_offset
|
/** Copy samples from src array starting at src_offset into self starting at dst_offset
|
||||||
* @param src array to read from
|
* @param src array to read from
|
||||||
* @param len number of samples to copy
|
* @param len number of samples to copy
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,9 @@ public:
|
||||||
/** Clear (eg zero, or empty) buffer */
|
/** Clear (eg zero, or empty) buffer */
|
||||||
virtual void silence (samplecnt_t len, samplecnt_t offset = 0) = 0;
|
virtual void silence (samplecnt_t len, samplecnt_t offset = 0) = 0;
|
||||||
|
|
||||||
|
/* return true if all data is silent (or for MIDI-like, non-existent */
|
||||||
|
virtual bool silent_data () const = 0;
|
||||||
|
|
||||||
/** Clear the entire buffer */
|
/** Clear the entire buffer */
|
||||||
virtual void clear() { silence(_capacity, 0); }
|
virtual void clear() { silence(_capacity, 0); }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,9 @@ public:
|
||||||
void ensure_buffers(DataType type, size_t num_buffers, size_t buffer_capacity);
|
void ensure_buffers(DataType type, size_t num_buffers, size_t buffer_capacity);
|
||||||
void ensure_buffers(const ChanCount& chns, size_t buffer_capacity);
|
void ensure_buffers(const ChanCount& chns, size_t buffer_capacity);
|
||||||
|
|
||||||
|
/* Returns true if Buffer::silent_data() is true for all buffers */
|
||||||
|
bool silent_data() const;
|
||||||
|
|
||||||
const ChanCount& available() const { return _available; }
|
const ChanCount& available() const { return _available; }
|
||||||
ChanCount& available() { return _available; }
|
ChanCount& available() { return _available; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ public:
|
||||||
void resize(size_t);
|
void resize(size_t);
|
||||||
size_t size() const { return _size; }
|
size_t size() const { return _size; }
|
||||||
bool empty() const { return _size == 0; }
|
bool empty() const { return _size == 0; }
|
||||||
|
bool silent_data () const { return _size == 0; }
|
||||||
|
|
||||||
bool insert_event(const Evoral::Event<TimeType>& event);
|
bool insert_event(const Evoral::Event<TimeType>& event);
|
||||||
bool merge_in_place(const MidiBuffer &other);
|
bool merge_in_place(const MidiBuffer &other);
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,17 @@ AudioBuffer::check_silence (pframes_t nframes, pframes_t& n) const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
AudioBuffer::silent_data () const
|
||||||
|
{
|
||||||
|
for (pframes_t n = 0; n < _capacity; ++n) {
|
||||||
|
if (_data[n]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AudioBuffer::silence (samplecnt_t len, samplecnt_t offset) {
|
AudioBuffer::silence (samplecnt_t len, samplecnt_t offset) {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -229,6 +229,19 @@ BufferSet::ensure_buffers(const ChanCount& chns, size_t buffer_capacity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
BufferSet::silent_data () const
|
||||||
|
{
|
||||||
|
for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
|
||||||
|
for (BufferSet::const_iterator i = begin (*t); i != end (*t); ++i) {
|
||||||
|
if (!i->silent_data ()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/** Get the capacity (size) of the available buffers of the given type.
|
/** Get the capacity (size) of the available buffers of the given type.
|
||||||
*
|
*
|
||||||
* All buffers of a certain type always have the same capacity.
|
* All buffers of a certain type always have the same capacity.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue