- void silence (framecnt_t len, framecnt_t offset = 0) {
- if (!_silent) {
- assert(_capacity > 0);
- assert(offset + len <= _capacity);
- memset(_data + offset, 0, sizeof (Sample) * len);
- if (len == _capacity) {
- _silent = true;
- }
+ /** silence buffer
+ * @param len number of samples to clear
+ * @laram offset start offset
+ */
+ void silence (samplecnt_t len, samplecnt_t offset = 0);
+
+ /** Copy samples from src array starting at src_offset into self starting at dst_offset
+ * @param src array to read from
+ * @param len number of samples to copy
+ * @param dst_offset offset in destination buffer
+ * @param src_offset start offset in src buffer
+ */
+ void read_from (const Sample* src, samplecnt_t len, sampleoffset_t dst_offset = 0, sampleoffset_t src_offset = 0) {
+ assert(src != 0);
+ assert(_capacity > 0);
+ assert(len <= _capacity);
+ memcpy(_data + dst_offset, src + src_offset, sizeof(Sample) * len);
+ _silent = false;
+ _written = true;
+ }
+
+ void read_from_with_gain (const Sample* src, samplecnt_t len, gain_t gain, sampleoffset_t dst_offset = 0, sampleoffset_t src_offset = 0) {
+ assert(src != 0);
+ assert(_capacity > 0);
+ assert(len <= _capacity);
+ src += src_offset;
+ for (samplecnt_t n = 0; n < len; ++n) {
+ _data[dst_offset+n] = src[n] * gain;