summaryrefslogtreecommitdiffstats
path: root/src/engine/AudioBuffer.hpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-02-26 01:39:16 +0000
committerDavid Robillard <d@drobilla.net>2010-02-26 01:39:16 +0000
commit52e49500bb78974d43bdfd30b2ec9b2a4522dd25 (patch)
tree44a5a46e946c6b43b657ca5733a165943dd947ae /src/engine/AudioBuffer.hpp
parent3d6b047cd19baf9bf5a81b4fe16e1e9e53ed8fef (diff)
downloadingen-52e49500bb78974d43bdfd30b2ec9b2a4522dd25.tar.gz
ingen-52e49500bb78974d43bdfd30b2ec9b2a4522dd25.tar.bz2
ingen-52e49500bb78974d43bdfd30b2ec9b2a4522dd25.zip
Perform all mixing for an audio input in a single mix operation (instead of a two step polyphony mixdown (by connections) and connections mixdown (by ports)).
Speed up and inline AudioBuffer::accumulate, to speed up mix(). Remove local buffer from Connection (always mix into destination InputPort's buffers). git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2494 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine/AudioBuffer.hpp')
-rw-r--r--src/engine/AudioBuffer.hpp32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/engine/AudioBuffer.hpp b/src/engine/AudioBuffer.hpp
index cfac3d59..7edfdef3 100644
--- a/src/engine/AudioBuffer.hpp
+++ b/src/engine/AudioBuffer.hpp
@@ -23,6 +23,7 @@
#include <boost/utility.hpp>
#include "types.hpp"
#include "ObjectBuffer.hpp"
+#include "Context.hpp"
using namespace std;
@@ -42,7 +43,7 @@ public:
void copy(Context& context, const Buffer* src);
void accumulate(Context& context, const AudioBuffer* src);
- bool is_control() const { return _type.symbol() == Shared::PortType::CONTROL; }
+ inline bool is_control() const { return _type.symbol() == Shared::PortType::CONTROL; }
inline Sample* data() const {
return (is_control())
@@ -75,6 +76,35 @@ private:
};
+/** Accumulate a block of @a src into buffer.
+ */
+inline void
+AudioBuffer::accumulate(Context& context, const AudioBuffer* const src)
+{
+ Sample* const buf = data();
+ const Sample* const src_buf = src->data();
+
+ if (is_control()) {
+ if (src->is_control()) { // control => control
+ buf[0] += src_buf[0];
+ } else { // audio => control
+ buf[0] += src_buf[context.offset()];
+ }
+ } else {
+ const SampleCount end = context.offset() + context.nframes();
+ if (src->is_control()) { // control => audio
+ for (SampleCount i = context.offset(); i < end; ++i) {
+ buf[i] += src_buf[0];
+ }
+ } else { // audio => audio
+ for (SampleCount i = context.offset(); i < end; ++i) {
+ buf[i] += src_buf[i];
+ }
+ }
+ }
+}
+
+
} // namespace Ingen
#endif // INGEN_ENGINE_AUDIOBUFFER_HPP