diff options
Diffstat (limited to 'libs/ardour/delayline.cc')
-rw-r--r-- | libs/ardour/delayline.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/libs/ardour/delayline.cc b/libs/ardour/delayline.cc index d0a691c5ff..72ea208126 100644 --- a/libs/ardour/delayline.cc +++ b/libs/ardour/delayline.cc @@ -69,6 +69,8 @@ DelayLine::run (BufferSet& bufs, samplepos_t /* start_sample */, samplepos_t /* const bool pending_flush = _pending_flush; _pending_flush = false; + // TODO handle pending_flush. + /* Audio buffers */ if (_buf.size () == bufs.count ().n_audio () && _buf.size () > 0) { @@ -155,6 +157,26 @@ DelayLine::run (BufferSet& bufs, samplepos_t /* start_sample */, samplepos_t /* /* set new delay */ _delay = pending_delay; + if (pending_flush) { + /* fade out data after read-pointer, clear buffer until write-pointer */ + const samplecnt_t fade_out_len = std::min (_delay, (samplecnt_t)FADE_LEN); + + for (AudioDlyBuf::iterator i = _buf.begin(); i != _buf.end (); ++i) { + Sample* rb = (*i).get (); + uint32_t s = 0; + for (; s < fade_out_len; ++s) { + sampleoffset_t off = (_roff + s) % _bsiz; + rb[off] *= 1. - (s / (float) fade_out_len); + } + for (; s < _delay; ++s) { + sampleoffset_t off = (_roff + s) % _bsiz; + rb[off] = 0; + } + assert (_woff == ((_roff + s) % _bsiz)); + } + // TODO consider adding a fade-in to bufs + } + /* delay audio buffers */ assert (_delay == ((_woff - _roff + _bsiz) % _bsiz)); AudioDlyBuf::iterator bi = _buf.begin (); |