Add gain variable to accumulate_channel.
authorCarl Hetherington <cth@carlh.net>
Mon, 6 Jan 2014 16:43:52 +0000 (16:43 +0000)
committerCarl Hetherington <cth@carlh.net>
Mon, 6 Jan 2014 16:43:52 +0000 (16:43 +0000)
src/lib/audio_buffers.cc
src/lib/audio_buffers.h

index e80142b8e518ad2efe66f5f1c1ee4b90f6dcafa6..a1c9b81ac099259bbe86e2f9f8dcea1340bbb9ae 100644 (file)
@@ -210,9 +210,11 @@ AudioBuffers::move (int from, int to, int frames)
        }
 }
 
-/** Add data from from `from', `from_channel' to our channel `to_channel' */
+/** Add data from from `from', `from_channel' to our channel `to_channel'.
+ *  @param gain Linear gain to apply to the data before it is added.
+ */
 void
-AudioBuffers::accumulate_channel (AudioBuffers const * from, int from_channel, int to_channel)
+AudioBuffers::accumulate_channel (AudioBuffers const * from, int from_channel, int to_channel, float gain)
 {
        int const N = frames ();
        assert (from->frames() == N);
@@ -222,7 +224,7 @@ AudioBuffers::accumulate_channel (AudioBuffers const * from, int from_channel, i
        float* d = _data[to_channel];
 
        for (int i = 0; i < N; ++i) {
-               *d++ += *s++;
+               *d++ += (*s++) * gain;
        }
 }
 
index 75bc686f83086df201ecd200510c04cbeb6b59e1..c9030dbfa9e84af247dd760f276c3ee33eaa5969 100644 (file)
@@ -61,7 +61,7 @@ public:
 
        void copy_from (AudioBuffers const * from, int frames_to_copy, int read_offset, int write_offset);
        void move (int from, int to, int frames);
-       void accumulate_channel (AudioBuffers const *, int, int);
+       void accumulate_channel (AudioBuffers const *, int, int, float gain = 1);
        void accumulate_frames (AudioBuffers const *, int read_offset, int write_offset, int frames);
 
 private: