}
}
-/** 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);
float* d = _data[to_channel];
for (int i = 0; i < N; ++i) {
- *d++ += *s++;
+ *d++ += (*s++) * gain;
}
}
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: