- float const linear = pow (10, dB / 20);
-
- for (int i = 0; i < _channels; ++i) {
- for (int j = 0; j < _frames; ++j) {
- _data[i][j] *= linear;
- }
- }
+ DCPOMATIC_ASSERT (from->frames() == frames());
+ memcpy (data(to_channel), from->data(from_channel), frames() * sizeof (float));
+}
+
+
+/** Make a copy of these AudioBuffers */
+shared_ptr<AudioBuffers>
+AudioBuffers::clone () const
+{
+ auto b = make_shared<AudioBuffers>(channels(), frames());
+ b->copy_from (this, frames(), 0, 0);
+ return b;
+}
+
+
+/** Extend these buffers with the data from another. The AudioBuffers must have the same number of channels. */
+void
+AudioBuffers::append (shared_ptr<const AudioBuffers> other)
+{
+ DCPOMATIC_ASSERT (channels() == other->channels());
+ auto old_frames = frames();
+ set_frames(old_frames + other->frames());
+ copy_from (other.get(), other->frames(), 0, old_frames);